X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fsurfacedialog.cpp;h=f4471578bf404487d5479b9b468f4ddcfbe2ae4c;hb=0f91bcf305ef8707b4a96a764c09aeb3cb6beba3;hp=73312a078fba5435b28649a9680e03ea31efe045;hpb=2d1587ebf86f3a9f8962260a79f815ce29d8cf77;p=xonotic%2Fnetradiant.git diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index 73312a07..f4471578 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -27,6 +27,8 @@ #include "surfacedialog.h" +#include + #include "debugging/debugging.h" #include "warnings.h" @@ -35,15 +37,7 @@ #include "iundo.h" #include "iselection.h" -#include -#include -#include -#include -#include -#include -#include #include -#include //Shamus: For Textool #include "signal/isignal.h" #include "generic/object.h" @@ -89,18 +83,18 @@ namespace TexTool { //Shamus: Textool function prototypes -gboolean size_allocate( GtkWidget *, GtkAllocation *, gpointer ); -gboolean expose( GtkWidget *, GdkEventExpose *, gpointer ); -gboolean button_press( GtkWidget *, GdkEventButton *, gpointer ); -gboolean button_release( GtkWidget *, GdkEventButton *, gpointer ); -gboolean motion( GtkWidget *, GdkEventMotion *, gpointer ); -void flipX( GtkToggleButton *, gpointer ); -void flipY( GtkToggleButton *, gpointer ); +gboolean size_allocate( ui::Widget, GtkAllocation *, gpointer ); +gboolean expose( ui::Widget, GdkEventExpose *, gpointer ); +gboolean button_press( ui::Widget, GdkEventButton *, gpointer ); +gboolean button_release( ui::Widget, GdkEventButton *, gpointer ); +gboolean motion( ui::Widget, GdkEventMotion *, gpointer ); +void flipX( ui::ToggleButton, gpointer ); +void flipY( ui::ToggleButton, gpointer ); //End Textool function prototypes //Shamus: Textool globals -GtkWidget * g_textoolWin; +ui::Widget g_textoolWin; //End Textool globals void queueDraw(){ @@ -111,9 +105,9 @@ void queueDraw(){ #endif -inline void spin_button_set_step( GtkSpinButton* spin, gfloat step ){ +inline void spin_button_set_step( ui::SpinButton spin, gfloat step ){ #if 1 - gtk_spin_button_get_adjustment( spin )->step_increment = step; + gtk_adjustment_set_step_increment(gtk_spin_button_get_adjustment( spin ), step); #else GValue gvalue = GValue_default(); g_value_init( &gvalue, G_TYPE_DOUBLE ); @@ -126,26 +120,26 @@ class Increment { float& m_f; public: -GtkSpinButton* m_spin; -GtkEntry* m_entry; -Increment( float& f ) : m_f( f ), m_spin( 0 ), m_entry( 0 ){ +ui::SpinButton m_spin; +ui::Entry m_entry; +Increment( float& f ) : m_f( f ), m_spin( ui::null ), m_entry( ui::null ){ } void cancel(){ entry_set_float( m_entry, m_f ); } -typedef MemberCaller CancelCaller; +typedef MemberCaller CancelCaller; void apply(){ m_f = static_cast( entry_get_float( m_entry ) ); spin_button_set_step( m_spin, m_f ); } -typedef MemberCaller ApplyCaller; +typedef MemberCaller ApplyCaller; }; void SurfaceInspector_GridChange(); class SurfaceInspector : public Dialog { -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); NonModalEntry m_textureEntry; NonModalSpinner m_hshiftSpinner; @@ -165,11 +159,9 @@ GtkCheckButton* m_surfaceFlags[32]; GtkCheckButton* m_contentFlags[32]; NonModalEntry m_valueEntry; -GtkEntry* m_valueEntryWidget; +ui::Entry m_valueEntryWidget{ui::null}; public: WindowPositionTracker m_positionTracker; -WindowPositionTrackerImportStringCaller m_importPosition; -WindowPositionTrackerExportStringCaller m_exportPosition; // Dialog Data float m_fitHorizontal; @@ -180,7 +172,7 @@ Increment m_vshiftIncrement; Increment m_hscaleIncrement; Increment m_vscaleIncrement; Increment m_rotateIncrement; -GtkEntry* m_texture; +ui::Entry m_texture{ui::null}; SurfaceInspector() : m_textureEntry( ApplyShaderCaller( *this ), UpdateCaller( *this ) ), @@ -196,8 +188,6 @@ SurfaceInspector() : m_rotateEntry( Increment::ApplyCaller( m_rotateIncrement ), Increment::CancelCaller( m_rotateIncrement ) ), m_idleDraw( UpdateCaller( *this ) ), m_valueEntry( ApplyFlagsCaller( *this ), UpdateCaller( *this ) ), - m_importPosition( m_positionTracker ), - m_exportPosition( m_positionTracker ), m_hshiftIncrement( g_si_globals.shift[0] ), m_vshiftIncrement( g_si_globals.shift[1] ), m_hscaleIncrement( g_si_globals.scale[0] ), @@ -208,16 +198,16 @@ SurfaceInspector() : m_positionTracker.setPosition( c_default_window_pos ); } -void constructWindow( GtkWindow* main_window ){ +void constructWindow( ui::Window main_window ){ m_parent = main_window; Create(); - AddGridChangeCallback( FreeCaller() ); + AddGridChangeCallback( FreeCaller() ); } void destroyWindow(){ Destroy(); } -bool visible() const { - return GTK_WIDGET_VISIBLE( const_cast( GetWidget() ) ); +bool visible() { + return GetWidget().visible(); } void queueDraw(){ if ( visible() ) { @@ -226,13 +216,13 @@ void queueDraw(){ } void Update(); -typedef MemberCaller UpdateCaller; +typedef MemberCaller UpdateCaller; void ApplyShader(); -typedef MemberCaller ApplyShaderCaller; +typedef MemberCaller ApplyShaderCaller; void ApplyTexdef(); -typedef MemberCaller ApplyTexdefCaller; +typedef MemberCaller ApplyTexdefCaller; void ApplyFlags(); -typedef MemberCaller ApplyFlagsCaller; +typedef MemberCaller ApplyFlagsCaller; }; namespace @@ -245,7 +235,7 @@ inline SurfaceInspector& getSurfaceInspector(){ } } -void SurfaceInspector_constructWindow( GtkWindow* main_window ){ +void SurfaceInspector_constructWindow( ui::Window main_window ){ getSurfaceInspector().constructWindow( main_window ); } void SurfaceInspector_destroyWindow(){ @@ -400,10 +390,10 @@ void SurfaceInspector_GridChange(){ // we move the textures in pixels, not world units. (i.e. increment values are in pixel) // depending on the texture scale it doesn't take the same amount of pixels to move of GetGridSize() // increment * scale = gridsize -static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){ +static void OnBtnMatchGrid( ui::Widget widget, gpointer data ){ float hscale, vscale; - hscale = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_hscaleIncrement.m_spin ) ); - vscale = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_vscaleIncrement.m_spin ) ); + hscale = static_cast( gtk_spin_button_get_value( getSurfaceInspector().m_hscaleIncrement.m_spin ) ); + vscale = static_cast( gtk_spin_button_get_value( getSurfaceInspector().m_vscaleIncrement.m_spin ) ); if ( hscale == 0.0f || vscale == 0.0f ) { globalOutputStream() << "ERROR: unexpected scale == 0.0f\n"; @@ -417,7 +407,7 @@ static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){ // or update it because something new has been selected // Shamus: It does get called when the SI is hidden, but not when you select something new. ;-) void DoSurface( void ){ - if ( getSurfaceInspector().GetWidget() == 0 ) { + if ( !getSurfaceInspector().GetWidget() ) { getSurfaceInspector().Create(); } @@ -441,23 +431,23 @@ void SurfaceInspector_FitTexture(){ Select_FitTexture( getSurfaceInspector().m_fitHorizontal, getSurfaceInspector().m_fitVertical ); } -static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){ Patch_CapTexture(); } -static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){ Patch_NaturalTexture(); } -static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchreset( ui::Widget widget, gpointer data ){ Patch_ResetTexture(); } -static void OnBtnPatchFit( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchFit( ui::Widget widget, gpointer data ){ Patch_FitTexture(); } -static void OnBtnAxial( GtkWidget *widget, gpointer data ){ +static void OnBtnAxial( ui::Widget widget, gpointer data ){ //globalOutputStream() << "--> [OnBtnAxial]...\n"; UndoableCommand undo( "textureDefault" ); TextureProjection projection; @@ -486,7 +476,7 @@ static void OnBtnAxial( GtkWidget *widget, gpointer data ){ Select_SetTexdef( projection ); } -static void OnBtnFaceFit( GtkWidget *widget, gpointer data ){ +static void OnBtnFaceFit( ui::Widget widget, gpointer data ){ getSurfaceInspector().exportData(); SurfaceInspector_FitTexture(); } @@ -583,12 +573,12 @@ const char* getContentFlagName( std::size_t bit ){ // ============================================================================= // SurfaceInspector class -guint togglebutton_connect_toggled( GtkToggleButton* button, const Callback& callback ){ +guint togglebutton_connect_toggled( ui::ToggleButton button, const Callback& callback ){ return g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); } -GtkWindow* SurfaceInspector::BuildDialog(){ - GtkWindow* window = create_floating_window( "Surface Inspector", m_parent ); +ui::Window SurfaceInspector::BuildDialog(){ + ui::Window window = ui::Window(create_floating_window( "Surface Inspector", m_parent )); m_positionTracker.connect( window ); @@ -599,25 +589,25 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { // replaced by only the vbox: - GtkWidget* vbox = gtk_vbox_new( FALSE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + auto vbox = ui::VBox( FALSE, 5 ); + vbox.show(); + window.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); { - GtkWidget* hbox2 = gtk_hbox_new( FALSE, 5 ); - gtk_widget_show( hbox2 ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 ); + auto hbox2 = ui::HBox( FALSE, 5 ); + hbox2.show(); + vbox.pack_start( hbox2, FALSE, FALSE, 0 ); { - GtkWidget* label = gtk_label_new( "Texture" ); - gtk_widget_show( label ); - gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); + ui::Widget label = ui::Label( "Texture" ); + label.show(); + hbox2.pack_start( label, FALSE, TRUE, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); - gtk_box_pack_start( GTK_BOX( hbox2 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); + auto entry = ui::Entry(ui::New); + entry.show(); + hbox2.pack_start( entry, TRUE, TRUE, 0 ); m_texture = entry; m_textureEntry.connect( entry ); GlobalTextureEntryCompletion::instance().connect( entry ); @@ -626,352 +616,284 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { - GtkWidget* table = gtk_table_new( 6, 4, FALSE ); - gtk_widget_show( table ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), FALSE, FALSE, 0 ); - gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); - gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); + auto table = ui::Table(6, 4, FALSE); + table.show(); + vbox.pack_start( table, FALSE, FALSE, 0 ); + gtk_table_set_row_spacings(table, 5); + gtk_table_set_col_spacings(table, 5); { - GtkWidget* label = gtk_label_new( "Horizontal shift" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Horizontal shift" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0}); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_hshiftIncrement.m_spin = spin; m_hshiftSpinner.connect( spin ); - gtk_widget_show( GTK_WIDGET( spin ) ); - gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 0, 1, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + spin.show(); + table.attach(spin, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); + spin.dimensions(60, -1); } { - GtkWidget* label = gtk_label_new( "Step" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Step" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + table.attach(label, {2, 3, 0, 1}, {GTK_FILL, 0}); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); - gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 0, 1, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + auto entry = ui::Entry(ui::New); + entry.show(); + table.attach(entry, {3, 4, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); + entry.dimensions(50, -1); m_hshiftIncrement.m_entry = entry; m_hshiftEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Vertical shift" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Vertical shift" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0}); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_vshiftIncrement.m_spin = spin; m_vshiftSpinner.connect( spin ); - gtk_widget_show( GTK_WIDGET( spin ) ); - gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 1, 2, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + spin.show(); + table.attach(spin, {1, 2, 1, 2}, {GTK_FILL, 0}); + spin.dimensions(60, -1); } { - GtkWidget* label = gtk_label_new( "Step" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Step" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + table.attach(label, {2, 3, 1, 2}, {GTK_FILL, 0}); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); - gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 1, 2, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + auto entry = ui::Entry(ui::New); + entry.show(); + table.attach(entry, {3, 4, 1, 2}, {GTK_FILL, 0}); + entry.dimensions(50, -1); m_vshiftIncrement.m_entry = entry; m_vshiftEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Horizontal stretch" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Horizontal stretch" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + table.attach(label, {0, 1, 2, 3}, {GTK_FILL, 0}); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 5 ) ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 ); m_hscaleIncrement.m_spin = spin; m_hscaleSpinner.connect( spin ); - gtk_widget_show( GTK_WIDGET( spin ) ); - gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 2, 3, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + spin.show(); + table.attach(spin, {1, 2, 2, 3}, {GTK_FILL, 0}); + spin.dimensions(60, -1); } { - GtkWidget* label = gtk_label_new( "Step" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Step" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 2, 3 ); + table.attach(label, {2, 3, 2, 3}, {GTK_FILL, 0}); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); - gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 2, 3, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 2, 3 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + auto entry = ui::Entry(ui::New); + entry.show(); + table.attach(entry, {3, 4, 2, 3}, {GTK_FILL, 0}); + entry.dimensions(50, -1); m_hscaleIncrement.m_entry = entry; m_hscaleEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Vertical stretch" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Vertical stretch" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 3, 4, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + table.attach(label, {0, 1, 3, 4}, {GTK_FILL, 0}); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 5 ) ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 ); m_vscaleIncrement.m_spin = spin; m_vscaleSpinner.connect( spin ); - gtk_widget_show( GTK_WIDGET( spin ) ); - gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 3, 4, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + spin.show(); + table.attach(spin, {1, 2, 3, 4}, {GTK_FILL, 0}); + spin.dimensions(60, -1); } { - GtkWidget* label = gtk_label_new( "Step" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Step" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 3, 4, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + table.attach(label, {2, 3, 3, 4}, {GTK_FILL, 0}); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); - gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 3, 4, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + auto entry = ui::Entry(ui::New); + entry.show(); + table.attach(entry, {3, 4, 3, 4}, {GTK_FILL, 0}); + entry.dimensions(50, -1); m_vscaleIncrement.m_entry = entry; m_vscaleEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Rotate" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Rotate" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 4, 5, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + table.attach(label, {0, 1, 4, 5}, {GTK_FILL, 0}); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_rotateIncrement.m_spin = spin; m_rotateSpinner.connect( spin ); - gtk_widget_show( GTK_WIDGET( spin ) ); - gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 4, 5, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + spin.show(); + table.attach(spin, {1, 2, 4, 5}, {GTK_FILL, 0}); + spin.dimensions(60, -1); gtk_spin_button_set_wrap( spin, TRUE ); } { - GtkWidget* label = gtk_label_new( "Step" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Step" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 4, 5, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + table.attach(label, {2, 3, 4, 5}, {GTK_FILL, 0}); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); - gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 4, 5, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + auto entry = ui::Entry(ui::New); + entry.show(); + table.attach(entry, {3, 4, 4, 5}, {GTK_FILL, 0}); + entry.dimensions(50, -1); m_rotateIncrement.m_entry = entry; m_rotateEntry.connect( entry ); } { // match grid button - GtkWidget* button = gtk_button_new_with_label( "Match Grid" ); - gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 2, 4, 5, 6, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnMatchGrid ), 0 ); + ui::Widget button = ui::Button( "Match Grid" ); + button.show(); + table.attach(button, {2, 4, 5, 6}, {GTK_EXPAND | GTK_FILL, 0}); + button.connect( "clicked", G_CALLBACK( OnBtnMatchGrid ), 0 ); } } { - GtkWidget* frame = gtk_frame_new( "Texturing" ); - gtk_widget_show( frame ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); + auto frame = ui::Frame( "Texturing" ); + frame.show(); + vbox.pack_start( frame, FALSE, FALSE, 0 ); { - GtkWidget* table = gtk_table_new( 4, 4, FALSE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); - gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); - gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); + auto table = ui::Table(4, 4, FALSE); + table.show(); + frame.add(table); + gtk_table_set_row_spacings(table, 5); + gtk_table_set_col_spacings(table, 5); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); { - GtkWidget* label = gtk_label_new( "Brush" ); - gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + ui::Widget label = ui::Label( "Brush" ); + label.show(); + table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0}); } { - GtkWidget* label = gtk_label_new( "Patch" ); - gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + ui::Widget label = ui::Label( "Patch" ); + label.show(); + table.attach(label, {0, 1, 2, 3}, {GTK_FILL, 0}); } { - GtkWidget* label = gtk_label_new( "Width" ); - gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + ui::Widget label = ui::Label( "Width" ); + label.show(); + table.attach(label, {2, 3, 0, 1}, {GTK_FILL, 0}); } { - GtkWidget* label = gtk_label_new( "Height" ); - gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + ui::Widget label = ui::Label( "Height" ); + label.show(); + table.attach(label, {3, 4, 0, 1}, {GTK_FILL, 0}); } { - GtkWidget* button = gtk_button_new_with_label( "Axial" ); - gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + ui::Widget button = ui::Button( "Axial" ); + button.show(); + table.attach(button, {0, 1, 1, 2}, {GTK_EXPAND | GTK_FILL, 0}); + button.connect( "clicked", G_CALLBACK( OnBtnAxial ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + button.dimensions(60, -1); } { - GtkWidget* button = gtk_button_new_with_label( "Fit" ); - gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + ui::Widget button = ui::Button( "Fit" ); + button.show(); + table.attach(button, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0}); + button.connect( "clicked", G_CALLBACK( OnBtnFaceFit ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + button.dimensions(60, -1); } { - GtkWidget* button = gtk_button_new_with_label( "CAP" ); - gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 3, 4, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + ui::Widget button = ui::Button( "CAP" ); + button.show(); + table.attach(button, {0, 1, 3, 4}, {GTK_EXPAND | GTK_FILL, 0}); + button.connect( "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + button.dimensions(60, -1); } { - GtkWidget* button = gtk_button_new_with_label( "Set..." ); - gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 3, 4, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + ui::Widget button = ui::Button( "Set..." ); + button.show(); + table.attach(button, {1, 2, 3, 4}, {GTK_EXPAND | GTK_FILL, 0}); + button.connect( "clicked", G_CALLBACK( OnBtnPatchreset ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + button.dimensions(60, -1); } { - GtkWidget* button = gtk_button_new_with_label( "Natural" ); - gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 3, 4, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + ui::Widget button = ui::Button( "Natural" ); + button.show(); + table.attach(button, {2, 3, 3, 4}, {GTK_EXPAND | GTK_FILL, 0}); + button.connect( "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + button.dimensions(60, -1); } { - GtkWidget* button = gtk_button_new_with_label( "Fit" ); - gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 3, 4, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + ui::Widget button = ui::Button( "Fit" ); + button.show(); + table.attach(button, {3, 4, 3, 4}, {GTK_EXPAND | GTK_FILL, 0}); + button.connect( "clicked", G_CALLBACK( OnBtnPatchFit ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + button.dimensions(60, -1); } { - GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 ); - gtk_widget_show( spin ); - gtk_table_attach( GTK_TABLE( table ), spin, 2, 3, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); - AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitHorizontal ); + auto spin = ui::SpinButton( ui::Adjustment( 1, 0, 1 << 16, 1, 10, 0 ), 0, 6 ); + spin.show(); + table.attach(spin, {2, 3, 1, 2}, {GTK_EXPAND | GTK_FILL, 0}); + spin.dimensions(60, -1); + AddDialogData( spin, m_fitHorizontal ); } { - GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 ); - gtk_widget_show( spin ); - gtk_table_attach( GTK_TABLE( table ), spin, 3, 4, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); - AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitVertical ); + auto spin = ui::SpinButton( ui::Adjustment( 1, 0, 1 << 16, 1, 10, 0 ), 0, 6 ); + spin.show(); + table.attach(spin, {3, 4, 1, 2}, {GTK_EXPAND | GTK_FILL, 0}); + spin.dimensions(60, -1); + AddDialogData( spin, m_fitVertical ); } } } if ( !string_empty( g_pGameDescription->getKeyValue( "si_flags" ) ) ) { { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Surface Flags" ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); + auto frame = ui::Frame( "Surface Flags" ); + frame.show(); + vbox.pack_start( frame, TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) ); + auto vbox3 = ui::VBox( FALSE, 4 ); //gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4); - gtk_widget_show( GTK_WIDGET( vbox3 ) ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + vbox3.show(); + frame.add(vbox3); { - GtkTable* table = GTK_TABLE( gtk_table_new( 8, 4, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); - gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); + auto table = ui::Table( 8, 4, FALSE ); + table.show(); + vbox3.pack_start( table, TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 0 ); gtk_table_set_col_spacings( table, 0 ); GtkCheckButton** p = m_surfaceFlags; - for ( int c = 0; c != 4; ++c ) + for (unsigned int c = 0; c != 4; ++c) { - for ( int r = 0; r != 8; ++r ) + for (unsigned int r = 0; r != 8; ++r) { - GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new_with_label( getSurfaceFlagName( c * 8 + r ) ) ); - gtk_widget_show( GTK_WIDGET( check ) ); - gtk_table_attach( table, GTK_WIDGET( check ), c, c + 1, r, r + 1, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + auto check = ui::CheckButton( getSurfaceFlagName( c * 8 + r ) ); + check.show(); + table.attach(check, {c, c + 1, r, r + 1}, {GTK_EXPAND | GTK_FILL, 0}); *p++ = check; - guint handler_id = togglebutton_connect_toggled( GTK_TOGGLE_BUTTON( check ), ApplyFlagsCaller( *this ) ); + guint handler_id = togglebutton_connect_toggled( check, ApplyFlagsCaller( *this ) ); g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) ); } } @@ -979,58 +901,56 @@ GtkWindow* SurfaceInspector::BuildDialog(){ } } { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Content Flags" ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); + auto frame = ui::Frame( "Content Flags" ); + frame.show(); + vbox.pack_start( frame, TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) ); + auto vbox3 = ui::VBox( FALSE, 4 ); //gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4); - gtk_widget_show( GTK_WIDGET( vbox3 ) ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + vbox3.show(); + frame.add(vbox3); { - GtkTable* table = GTK_TABLE( gtk_table_new( 8, 4, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); - gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); + auto table = ui::Table( 8, 4, FALSE ); + table.show(); + vbox3.pack_start( table, TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 0 ); gtk_table_set_col_spacings( table, 0 ); GtkCheckButton** p = m_contentFlags; - for ( int c = 0; c != 4; ++c ) + for (unsigned int c = 0; c != 4; ++c) { - for ( int r = 0; r != 8; ++r ) + for (unsigned int r = 0; r != 8; ++r) { - GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new_with_label( getContentFlagName( c * 8 + r ) ) ); - gtk_widget_show( GTK_WIDGET( check ) ); - gtk_table_attach( table, GTK_WIDGET( check ), c, c + 1, r, r + 1, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + auto check = ui::CheckButton( getContentFlagName( c * 8 + r ) ); + check.show(); + table.attach(check, {c, c + 1, r, r + 1}, {GTK_EXPAND | GTK_FILL, 0}); *p++ = check; - guint handler_id = togglebutton_connect_toggled( GTK_TOGGLE_BUTTON( check ), ApplyFlagsCaller( *this ) ); + guint handler_id = togglebutton_connect_toggled( check, ApplyFlagsCaller( *this ) ); g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) ); } } // not allowed to modify detail flag using Surface Inspector - gtk_widget_set_sensitive( GTK_WIDGET( m_contentFlags[BRUSH_DETAIL_FLAG] ), FALSE ); + gtk_widget_set_sensitive( ui::CheckButton::from(m_contentFlags[BRUSH_DETAIL_FLAG]), FALSE ); } } } { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Value" ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); + auto frame = ui::Frame( "Value" ); + frame.show(); + vbox.pack_start( frame, TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) ); + auto vbox3 = ui::VBox( FALSE, 4 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 4 ); - gtk_widget_show( GTK_WIDGET( vbox3 ) ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + vbox3.show(); + frame.add(vbox3); { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); - gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); + auto entry = ui::Entry(ui::New); + entry.show(); + vbox3.pack_start( entry, TRUE, TRUE, 0 ); m_valueEntryWidget = entry; m_valueEntry.connect( entry ); } @@ -1041,49 +961,49 @@ GtkWindow* SurfaceInspector::BuildDialog(){ #if TEXTOOL_ENABLED if ( g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_BRUSHPRIMITIVES ) { // Shamus: Textool goodies... - GtkWidget * frame = gtk_frame_new( "Textool" ); - gtk_widget_show( frame ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); + ui::Widget frame = ui::Frame( "Textool" ); + frame.show(); + vbox.pack_start( frame , FALSE, FALSE, 0 ); { //Prolly should make this a member or global var, so the SI can draw on it... TexTool::g_textoolWin = glwidget_new( FALSE ); // --> Dunno, but this stuff may be necessary... (Looks like it!) - gtk_widget_ref( TexTool::g_textoolWin ); + g_object_ref( TexTool::g_textoolWin ); gtk_widget_set_events( TexTool::g_textoolWin, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ); - GTK_WIDGET_SET_FLAGS( TexTool::g_textoolWin, GTK_CAN_FOCUS ); + gtk_widget_set_can_focus( TexTool::g_textoolWin, true ); // <-- end stuff... - gtk_widget_show( TexTool::g_textoolWin ); - gtk_widget_set_usize( TexTool::g_textoolWin, -1, 240 ); //Yeah! - gtk_container_add( GTK_CONTAINER( frame ), TexTool::g_textoolWin ); - - g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "size_allocate", G_CALLBACK( TexTool::size_allocate ), NULL ); - g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "expose_event", G_CALLBACK( TexTool::expose ), NULL ); - g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "button_press_event", G_CALLBACK( TexTool::button_press ), NULL ); - g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "button_release_event", G_CALLBACK( TexTool::button_release ), NULL ); - g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "motion_notify_event", G_CALLBACK( TexTool::motion ), NULL ); + TexTool::g_textoolWin.show(); + TexTool::g_textoolWin.dimensions( -1, 240 ); //Yeah! + frame.add(TexTool::g_textoolWin); + + TexTool::g_textoolWin.connect( "size_allocate", G_CALLBACK( TexTool::size_allocate ), NULL ); + TexTool::g_textoolWin.connect( "expose_event", G_CALLBACK( TexTool::expose ), NULL ); + TexTool::g_textoolWin.connect( "button_press_event", G_CALLBACK( TexTool::button_press ), NULL ); + TexTool::g_textoolWin.connect( "button_release_event", G_CALLBACK( TexTool::button_release ), NULL ); + TexTool::g_textoolWin.connect( "motion_notify_event", G_CALLBACK( TexTool::motion ), NULL ); } { - GtkWidget * hbox = gtk_hbox_new( FALSE, 5 ); - gtk_widget_show( hbox ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, FALSE, 0 ); + ui::Widget hbox = ui::HBox( FALSE, 5 ); + hbox.show(); + vbox.pack_start( hbox , FALSE, FALSE, 0 ); // Checkboxes go here... (Flip X/Y) - GtkWidget * flipX = gtk_check_button_new_with_label( "Flip X axis" ); - GtkWidget * flipY = gtk_check_button_new_with_label( "Flip Y axis" ); - gtk_widget_show( flipX ); - gtk_widget_show( flipY ); - gtk_box_pack_start( GTK_BOX( hbox ), flipX, FALSE, FALSE, 0 ); - gtk_box_pack_start( GTK_BOX( hbox ), flipY, FALSE, FALSE, 0 ); + ui::Widget flipX = ui::CheckButton( "Flip X axis" ); + ui::Widget flipY = ui::CheckButton( "Flip Y axis" ); + flipX.show(); + flipY.show(); + hbox.pack_start( flipX, FALSE, FALSE, 0 ); + hbox.pack_start( flipY, FALSE, FALSE, 0 ); //Instead of this, we probably need to create a vbox to put into the frame, then the //window, then the hbox. !!! FIX !!! -// gtk_container_add(GTK_CONTAINER(frame), hbox); +// frame.add(hbox); //Hmm. Do we really need g_object_set_data? Mebbe not... And we don't! :-) -// g_object_set_data(G_OBJECT(flipX), "handler", gint_to_pointer(g_signal_connect(G_OBJECT(flipX), "toggled", G_CALLBACK(TexTool::flipX), 0))); -// g_object_set_data(G_OBJECT(flipY), "handler", gint_to_pointer(g_signal_connect(G_OBJECT(flipY), "toggled", G_CALLBACK(TexTool::flipY), 0))); +// g_object_set_data(G_OBJECT(flipX), "handler", gint_to_pointer(flipX.connect("toggled", G_CALLBACK(TexTool::flipX), 0))); +// g_object_set_data(G_OBJECT(flipY), "handler", gint_to_pointer(flipY.connect("toggled", G_CALLBACK(TexTool::flipY), 0))); //Instead, just do: - g_signal_connect( G_OBJECT( flipX ), "toggled", G_CALLBACK( TexTool::flipX ), NULL ); - g_signal_connect( G_OBJECT( flipY ), "toggled", G_CALLBACK( TexTool::flipY ), NULL ); + flipX.connect( "toggled", G_CALLBACK( TexTool::flipX ), NULL ); + flipY.connect( "toggled", G_CALLBACK( TexTool::flipY ), NULL ); } } #endif @@ -1102,27 +1022,27 @@ GtkWindow* SurfaceInspector::BuildDialog(){ =============== */ -void spin_button_set_value_no_signal( GtkSpinButton* spin, gdouble value ){ +void spin_button_set_value_no_signal( ui::SpinButton spin, gdouble value ){ guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( spin ), "handler" ) ); g_signal_handler_block( G_OBJECT( gtk_spin_button_get_adjustment( spin ) ), handler_id ); gtk_spin_button_set_value( spin, value ); g_signal_handler_unblock( G_OBJECT( gtk_spin_button_get_adjustment( spin ) ), handler_id ); } -void spin_button_set_step_increment( GtkSpinButton* spin, gdouble value ){ - GtkAdjustment* adjust = gtk_spin_button_get_adjustment( spin ); - adjust->step_increment = value; +void spin_button_set_step_increment( ui::SpinButton spin, gdouble value ){ + auto adjust = gtk_spin_button_get_adjustment( spin ); + gtk_adjustment_set_step_increment(adjust, value); } void SurfaceInspector::Update(){ const char * name = SurfaceInspector_GetSelectedShader(); if ( shader_is_texture( name ) ) { - gtk_entry_set_text( m_texture, shader_get_textureName( name ) ); + m_texture.text(shader_get_textureName(name)); } else { - gtk_entry_set_text( m_texture, "" ); + m_texture.text(""); } texdef_t shiftScaleRotate; @@ -1178,12 +1098,12 @@ void SurfaceInspector::Update(){ for ( GtkCheckButton** p = m_surfaceFlags; p != m_surfaceFlags + 32; ++p ) { - toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) ); + toggle_button_set_active_no_signal( ui::CheckButton::from( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) ); } for ( GtkCheckButton** p = m_contentFlags; p != m_contentFlags + 32; ++p ) { - toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) ); + toggle_button_set_active_no_signal( ui::CheckButton::from( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) ); } } } @@ -1214,11 +1134,11 @@ void SurfaceInspector::ApplyShader(){ void SurfaceInspector::ApplyTexdef(){ texdef_t shiftScaleRotate; - shiftScaleRotate.shift[0] = static_cast( gtk_spin_button_get_value_as_float( m_hshiftIncrement.m_spin ) ); - shiftScaleRotate.shift[1] = static_cast( gtk_spin_button_get_value_as_float( m_vshiftIncrement.m_spin ) ); - shiftScaleRotate.scale[0] = static_cast( gtk_spin_button_get_value_as_float( m_hscaleIncrement.m_spin ) ); - shiftScaleRotate.scale[1] = static_cast( gtk_spin_button_get_value_as_float( m_vscaleIncrement.m_spin ) ); - shiftScaleRotate.rotate = static_cast( gtk_spin_button_get_value_as_float( m_rotateIncrement.m_spin ) ); + shiftScaleRotate.shift[0] = static_cast( gtk_spin_button_get_value( m_hshiftIncrement.m_spin ) ); + shiftScaleRotate.shift[1] = static_cast( gtk_spin_button_get_value( m_vshiftIncrement.m_spin ) ); + shiftScaleRotate.scale[0] = static_cast( gtk_spin_button_get_value( m_hscaleIncrement.m_spin ) ); + shiftScaleRotate.scale[1] = static_cast( gtk_spin_button_get_value( m_vscaleIncrement.m_spin ) ); + shiftScaleRotate.rotate = static_cast( gtk_spin_button_get_value( m_rotateIncrement.m_spin ) ); TextureProjection projection; //Shamus: This is the other place that screws up, it seems, since it doesn't seem to do the @@ -1259,14 +1179,14 @@ void Face_getTexture( Face& face, CopiedString& shader, TextureProjection& proje face.GetTexdef( projection ); flags = face.getShader().m_flags; } -typedef Function4 FaceGetTexture; +typedef Function FaceGetTexture; void Face_setTexture( Face& face, const char* shader, const TextureProjection& projection, const ContentsFlagsValue& flags ){ face.SetShader( shader ); face.SetTexdef( projection ); face.SetFlags( flags ); } -typedef Function4 FaceSetTexture; +typedef Function FaceSetTexture; void Patch_getTexture( Patch& patch, CopiedString& shader, TextureProjection& projection, ContentsFlagsValue& flags ){ @@ -1274,16 +1194,16 @@ void Patch_getTexture( Patch& patch, CopiedString& shader, TextureProjection& pr projection = TextureProjection( texdef_t(), brushprimit_texdef_t(), Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ) ); flags = ContentsFlagsValue( 0, 0, 0, false ); } -typedef Function4 PatchGetTexture; +typedef Function PatchGetTexture; void Patch_setTexture( Patch& patch, const char* shader, const TextureProjection& projection, const ContentsFlagsValue& flags ){ patch.SetShader( shader ); } -typedef Function4 PatchSetTexture; +typedef Function PatchSetTexture; -typedef Callback3 GetTextureCallback; -typedef Callback3 SetTextureCallback; +typedef Callback GetTextureCallback; +typedef Callback SetTextureCallback; struct Texturable { @@ -1298,8 +1218,8 @@ void Face_getClosest( Face& face, SelectionTest& test, SelectionIntersection& be if ( intersection.valid() && SelectionIntersection_closer( intersection, bestIntersection ) ) { bestIntersection = intersection; - texturable.setTexture = makeCallback3( FaceSetTexture(), face ); - texturable.getTexture = makeCallback3( FaceGetTexture(), face ); + texturable.setTexture = makeCallback( FaceSetTexture(), face ); + texturable.getTexture = makeCallback( FaceGetTexture(), face ); } } @@ -1353,8 +1273,8 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const { if ( occluded ) { Patch* patch = Node_getPatch( path.top() ); if ( patch != 0 ) { - m_texturable.setTexture = makeCallback3( PatchSetTexture(), *patch ); - m_texturable.getTexture = makeCallback3( PatchGetTexture(), *patch ); + m_texturable.setTexture = makeCallback( PatchSetTexture(), *patch ); + m_texturable.getTexture = makeCallback( PatchGetTexture(), *patch ); } else { @@ -1469,15 +1389,15 @@ void SurfaceInspector_constructPage( PreferenceGroup& group ){ SurfaceInspector_constructPreferences( page ); } void SurfaceInspector_registerPreferencesPage(){ - PreferencesDialog_addSettingsPage( FreeCaller1() ); + PreferencesDialog_addSettingsPage( makeCallbackF(SurfaceInspector_constructPage) ); } void SurfaceInspector_registerCommands(){ - GlobalCommands_insert( "FitTexture", FreeCaller(), Accelerator( 'B', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "SurfaceInspector", FreeCaller(), Accelerator( 'S' ) ); + GlobalCommands_insert( "FitTexture", makeCallbackF(SurfaceInspector_FitTexture), Accelerator( 'B', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "SurfaceInspector", makeCallbackF(SurfaceInspector_toggleShown), Accelerator( 'S' ) ); - GlobalCommands_insert( "FaceCopyTexture", FreeCaller() ); - GlobalCommands_insert( "FacePasteTexture", FreeCaller() ); + GlobalCommands_insert( "FaceCopyTexture", makeCallbackF(SelectedFaces_copyTexture) ); + GlobalCommands_insert( "FacePasteTexture", makeCallbackF(SelectedFaces_pasteTexture) ); } @@ -1491,17 +1411,17 @@ void SurfaceInspector_Construct(){ FaceTextureClipboard_setDefault(); - GlobalPreferenceSystem().registerPreference( "SurfaceWnd", getSurfaceInspector().m_importPosition, getSurfaceInspector().m_exportPosition ); - GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale1", FloatImportStringCaller( g_si_globals.scale[0] ), FloatExportStringCaller( g_si_globals.scale[0] ) ); - GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale2", FloatImportStringCaller( g_si_globals.scale[1] ), FloatExportStringCaller( g_si_globals.scale[1] ) ); - GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift1", FloatImportStringCaller( g_si_globals.shift[0] ), FloatExportStringCaller( g_si_globals.shift[0] ) ); - GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift2", FloatImportStringCaller( g_si_globals.shift[1] ), FloatExportStringCaller( g_si_globals.shift[1] ) ); - GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Rotate", FloatImportStringCaller( g_si_globals.rotate ), FloatExportStringCaller( g_si_globals.rotate ) ); - GlobalPreferenceSystem().registerPreference( "SnapTToGrid", BoolImportStringCaller( g_si_globals.m_bSnapTToGrid ), BoolExportStringCaller( g_si_globals.m_bSnapTToGrid ) ); + GlobalPreferenceSystem().registerPreference( "SurfaceWnd", make_property( getSurfaceInspector().m_positionTracker) ); + GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale1", make_property_string( g_si_globals.scale[0] ) ); + GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale2", make_property_string( g_si_globals.scale[1] ) ); + GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift1", make_property_string( g_si_globals.shift[0] ) ); + GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift2", make_property_string( g_si_globals.shift[1] ) ); + GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Rotate", make_property_string( g_si_globals.rotate ) ); + GlobalPreferenceSystem().registerPreference( "SnapTToGrid", make_property_string( g_si_globals.m_bSnapTToGrid ) ); - typedef FreeCaller1 SurfaceInspectorSelectionChangedCaller; + typedef FreeCaller SurfaceInspectorSelectionChangedCaller; GlobalSelectionSystem().addSelectionChangeCallback( SurfaceInspectorSelectionChangedCaller() ); - typedef FreeCaller SurfaceInspectorUpdateSelectionCaller; + typedef FreeCaller SurfaceInspectorUpdateSelectionCaller; Brush_addTextureChangedCallback( SurfaceInspectorUpdateSelectionCaller() ); Patch_addTextureChangedCallback( SurfaceInspectorUpdateSelectionCaller() ); @@ -1877,14 +1797,14 @@ void focus(){ // << extents.maxX << ", " << extents.minY << ", " << extents.maxY << "\n"; } -gboolean size_allocate( GtkWidget * win, GtkAllocation * a, gpointer ){ +gboolean size_allocate( ui::Widget win, GtkAllocation * a, gpointer ){ windowSize.x() = a->width; windowSize.y() = a->height; queueDraw(); return false; } -gboolean expose( GtkWidget * win, GdkEventExpose * e, gpointer ){ +gboolean expose( ui::Widget win, GdkEventExpose * e, gpointer ){ // globalOutputStream() << "--> Textool Window was exposed!\n"; // globalOutputStream() << " (window width/height: " << cc << "/" << e->area.height << ")\n"; @@ -1983,7 +1903,7 @@ Vector2 trans; Vector2 trans2; Vector2 dragPoint; // Defined in terms of window space (+x/-y) Vector2 oldTrans; -gboolean button_press( GtkWidget * win, GdkEventButton * e, gpointer ){ +gboolean button_press( ui::Widget win, GdkEventButton * e, gpointer ){ // globalOutputStream() << "--> Textool button press...\n"; if ( e->button == 1 ) { @@ -2045,7 +1965,7 @@ gboolean button_press( GtkWidget * win, GdkEventButton * e, gpointer ){ return false; } -gboolean button_release( GtkWidget * win, GdkEventButton * e, gpointer ){ +gboolean button_release( ui::Widget win, GdkEventButton * e, gpointer ){ // globalOutputStream() << "--> Textool button release...\n"; if ( e->button == 1 ) { @@ -2107,7 +2027,7 @@ gboolean button_release( GtkWidget * win, GdkEventButton * e, gpointer ){ c[1] = ((float)(y))/((float)(m_rect.bottom-m_rect.top))*(m_Maxs[1]-m_Mins[1])+m_Mins[1]; } */ -gboolean motion( GtkWidget * win, GdkEventMotion * e, gpointer ){ +gboolean motion( ui::Widget win, GdkEventMotion * e, gpointer ){ // globalOutputStream() << "--> Textool motion...\n"; if ( lButtonDown ) { @@ -2284,7 +2204,7 @@ gboolean motion( GtkWidget * win, GdkEventMotion * e, gpointer ){ //It seems the fake tex coords conversion is screwing this stuff up... !!! FIX !!! //This is still wrong... Prolly need to do something with the oldScaleX/Y stuff... -void flipX( GtkToggleButton *, gpointer ){ +void flipX( ui::ToggleButton, gpointer ){ // globalOutputStream() << "--> Flip X...\n"; //Shamus: // SurfaceInspector_GetSelectedBPTexdef(); // Refresh g_selectedBrushPrimitTexdef... @@ -2298,7 +2218,7 @@ void flipX( GtkToggleButton *, gpointer ){ UpdateControlPoints(); } -void flipY( GtkToggleButton *, gpointer ){ +void flipY( ui::ToggleButton, gpointer ){ // globalOutputStream() << "--> Flip Y...\n"; // tm.coords[0][1] = -tm.coords[0][1]; // tm.coords[1][1] = -tm.coords[1][1];