X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fpatchdialog.cpp;h=6fbbe3e7305e2654b35a1024504f2ccc84bb2309;hb=refs%2Fheads%2Fdevelop;hp=464bc06fabcf8e76a4d42682823c5fa3d9457c7e;hpb=2951e448a7f008f2438be4bd5feba2e4f4400eef;p=xonotic%2Fnetradiant.git diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index 464bc06f..6fbbe3e7 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -137,20 +137,11 @@ void Scene_PatchGetFixedSubdivisions( PatchFixedSubdivisions& subdivisions ){ #endif } -class PatchSetFixedSubdivisions -{ -const PatchFixedSubdivisions& m_subdivisions; -public: -PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions ) : m_subdivisions( subdivisions ){ -} -void operator()( Patch& patch ) const { - Patch_setFixedSubdivisions( patch, m_subdivisions ); -} -}; - void Scene_PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions ){ UndoableCommand command( "patchSetFixedSubdivisions" ); - Scene_forEachVisibleSelectedPatch( PatchSetFixedSubdivisions( subdivisions ) ); + Scene_forEachVisibleSelectedPatch([&](Patch &patch) { + Patch_setFixedSubdivisions(patch, subdivisions); + }); } @@ -171,21 +162,21 @@ void update(){ if ( subdivisions.m_enabled ) { entry_set_int( m_horizontal, static_cast( subdivisions.m_x ) ); entry_set_int( m_vertical, static_cast( subdivisions.m_y ) ); - gtk_widget_set_sensitive( GTK_WIDGET( m_horizontal ), TRUE ); - gtk_widget_set_sensitive( GTK_WIDGET( m_vertical ), TRUE ); + gtk_widget_set_sensitive( m_horizontal , TRUE ); + gtk_widget_set_sensitive( m_vertical , TRUE ); } else { m_horizontal.text(""); m_vertical.text(""); - gtk_widget_set_sensitive( GTK_WIDGET( m_horizontal ), FALSE ); - gtk_widget_set_sensitive( GTK_WIDGET( m_vertical ), FALSE ); + gtk_widget_set_sensitive( m_horizontal , FALSE ); + gtk_widget_set_sensitive( m_vertical , FALSE ); } } void cancel(){ update(); } -typedef MemberCaller CancelCaller; +typedef MemberCaller CancelCaller; void apply(){ Scene_PatchSetFixedSubdivisions( PatchFixedSubdivisions( @@ -195,8 +186,8 @@ void apply(){ ) ); } -typedef MemberCaller ApplyCaller; -static void applyGtk( GtkToggleButton* toggle, Subdivisions* self ){ +typedef MemberCaller ApplyCaller; +static void applyGtk( ui::ToggleButton toggle, Subdivisions* self ){ self->apply(); } }; @@ -239,7 +230,7 @@ bool m_bListenChanged; PatchInspector() : m_horizontalSubdivisionsEntry( Subdivisions::ApplyCaller( m_subdivisions ), Subdivisions::CancelCaller( m_subdivisions ) ), m_verticalSubdivisionsEntry( Subdivisions::ApplyCaller( m_subdivisions ), Subdivisions::CancelCaller( m_subdivisions ) ), - m_idleDraw( MemberCaller( *this ) ){ + m_idleDraw( MemberCaller( *this ) ){ m_fS = 0.0f; m_fT = 0.0f; m_fX = 0.0f; @@ -350,19 +341,10 @@ static void OnSelchangeComboColRow( ui::Widget widget, gpointer data ){ g_PatchInspector.importData(); } -class PatchSetTextureRepeat -{ -float m_s, m_t; -public: -PatchSetTextureRepeat( float s, float t ) : m_s( s ), m_t( t ){ -} -void operator()( Patch& patch ) const { - patch.SetTextureRepeat( m_s, m_t ); -} -}; - void Scene_PatchTileTexture_Selected( scene::Graph& graph, float s, float t ){ - Scene_forEachVisibleSelectedPatch( PatchSetTextureRepeat( s, t ) ); + Scene_forEachVisibleSelectedPatch([&](Patch &patch) { + patch.SetTextureRepeat(s, t); + }); SceneChangeNotify(); } @@ -390,32 +372,12 @@ static void OnBtnPatchFlipY( ui::Widget widget, gpointer data ){ Patch_FlipTextureY(); } -struct PatchRotateTexture -{ - float m_angle; -public: - PatchRotateTexture( float angle ) : m_angle( angle ){ - } - void operator()( Patch& patch ) const { - patch.RotateTexture( m_angle ); - } -}; - void Scene_PatchRotateTexture_Selected( scene::Graph& graph, float angle ){ - Scene_forEachVisibleSelectedPatch( PatchRotateTexture( angle ) ); + Scene_forEachVisibleSelectedPatch([&](Patch &patch) { + patch.RotateTexture(angle); + }); } -class PatchScaleTexture -{ -float m_s, m_t; -public: -PatchScaleTexture( float s, float t ) : m_s( s ), m_t( t ){ -} -void operator()( Patch& patch ) const { - patch.ScaleTexture( m_s, m_t ); -} -}; - float Patch_convertScale( float scale ){ if ( scale > 0 ) { return scale; @@ -427,23 +389,17 @@ float Patch_convertScale( float scale ){ } void Scene_PatchScaleTexture_Selected( scene::Graph& graph, float s, float t ){ - Scene_forEachVisibleSelectedPatch( PatchScaleTexture( Patch_convertScale( s ), Patch_convertScale( t ) ) ); + s = Patch_convertScale(s); + t = Patch_convertScale(t); + Scene_forEachVisibleSelectedPatch([&](Patch &patch) { + patch.ScaleTexture(s, t); + }); } -class PatchTranslateTexture -{ -float m_s, m_t; -public: -PatchTranslateTexture( float s, float t ) - : m_s( s ), m_t( t ){ -} -void operator()( Patch& patch ) const { - patch.TranslateTexture( m_s, m_t ); -} -}; - void Scene_PatchTranslateTexture_Selected( scene::Graph& graph, float s, float t ){ - Scene_forEachVisibleSelectedPatch( PatchTranslateTexture( s, t ) ); + Scene_forEachVisibleSelectedPatch([&](Patch &patch) { + patch.TranslateTexture(s, t); + }); } static void OnBtnPatchAutoCap( ui::Widget widget, gpointer data ){ @@ -595,40 +551,32 @@ ui::Window PatchInspector::BuildDialog(){ { auto label = ui::Label( "Row:" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {0, 1, 0, 1}, {(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0)}, {0, 0}); } { auto label = ui::Label( "Column:" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {1, 2, 0, 1}, {(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0)}, {0, 0}); } { auto combo = ui::ComboBoxText(ui::New); combo.connect( "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); - AddDialogData( *GTK_COMBO_BOX(combo), m_nRow ); + AddDialogData( combo, m_nRow ); combo.show(); - gtk_table_attach( table, GTK_WIDGET( combo ), 0, 1, 1, 2, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( combo ), 60, -1 ); + table.attach(combo, {0, 1, 1, 2}, {(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0)}, {0, 0}); + combo.dimensions(60, -1); m_pRowCombo = combo; } { auto combo = ui::ComboBoxText(ui::New); combo.connect( "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); - AddDialogData( *GTK_COMBO_BOX(combo), m_nCol ); + AddDialogData( combo, m_nCol ); combo.show(); - gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 1, 2, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( combo ), 60, -1 ); + table.attach(combo, {1, 2, 1, 2}, {(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0)}, {0, 0}); + combo.dimensions(60, -1); m_pColCombo = combo; } } @@ -640,85 +588,65 @@ ui::Window PatchInspector::BuildDialog(){ { auto label = ui::Label( "X:" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); } { auto label = ui::Label( "Y:" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {0, 1, 1, 2}, {GTK_EXPAND | GTK_FILL, 0}); } { auto label = ui::Label( "Z:" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {0, 1, 2, 3}, {GTK_EXPAND | GTK_FILL, 0}); } { auto label = ui::Label( "S:" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 3, 4, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {0, 1, 3, 4}, {GTK_EXPAND | GTK_FILL, 0}); } { auto label = ui::Label( "T:" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 4, 5, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {0, 1, 4, 5}, {GTK_EXPAND | GTK_FILL, 0}); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - AddDialogData( *GTK_ENTRY(entry), m_fX ); + table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); + AddDialogData( entry, m_fX ); entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - AddDialogData( *GTK_ENTRY(entry), m_fY ); + table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0}); + AddDialogData( entry, m_fY ); entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - AddDialogData( *GTK_ENTRY(entry), m_fZ ); + table.attach(entry, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, 0}); + AddDialogData( entry, m_fZ ); entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 3, 4, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - AddDialogData( *GTK_ENTRY(entry), m_fS ); + table.attach(entry, {1, 2, 3, 4}, {GTK_EXPAND | GTK_FILL, 0}); + AddDialogData( entry, m_fS ); entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 4, 5, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - AddDialogData( *GTK_ENTRY(entry), m_fT ); + table.attach(entry, {1, 2, 4, 5}, {GTK_EXPAND | GTK_FILL, 0}); + AddDialogData( entry, m_fT ); entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } @@ -742,16 +670,12 @@ ui::Window PatchInspector::BuildDialog(){ { auto label = ui::Label( "Fixed" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); } { auto check = ui::CheckButton(GTK_CHECK_BUTTON( gtk_check_button_new() )); check.show(); - gtk_table_attach( table, GTK_WIDGET( check ), 1, 2, 0, 1, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(check, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); m_subdivisions.m_enabled = check; guint handler_id = check.connect( "toggled", G_CALLBACK( &Subdivisions::applyGtk ), &m_subdivisions ); g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) ); @@ -759,32 +683,24 @@ ui::Window PatchInspector::BuildDialog(){ { auto label = ui::Label( "Horizontal" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {0, 1, 1, 2}, {GTK_EXPAND | GTK_FILL, 0}); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0}); m_subdivisions.m_horizontal = entry; m_horizontalSubdivisionsEntry.connect( entry ); } { auto label = ui::Label( "Vertical" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {0, 1, 2, 3}, {GTK_EXPAND | GTK_FILL, 0}); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3, - (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(entry, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, 0}); m_subdivisions.m_vertical = entry; m_verticalSubdivisionsEntry.connect( entry ); } @@ -813,7 +729,7 @@ ui::Window PatchInspector::BuildDialog(){ // gtk_editable_set_editable (GTK_ENTRY (entry), false); entry.show(); vbox2.pack_start( entry, TRUE, TRUE, 0 ); - AddDialogData( *GTK_ENTRY(entry), m_strName ); + AddDialogData( entry, m_strName ); entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } @@ -826,68 +742,52 @@ ui::Window PatchInspector::BuildDialog(){ { auto label = ui::Label( "Horizontal Shift Step" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 0, 1, - (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {2, 4, 0, 1}, {GTK_FILL | GTK_EXPAND, 0}); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { auto label = ui::Label( "Vertical Shift Step" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 1, 2, - (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {2, 4, 1, 2}, {GTK_FILL | GTK_EXPAND, 0}); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { auto label = ui::Label( "Horizontal Stretch Step" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 2, 3, - (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {2, 3, 2, 3}, {GTK_FILL | GTK_EXPAND, 0}); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { auto button = ui::Button( "Flip" ); button.show(); - gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 2, 3, - (GtkAttachOptions)( GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(button, {3, 4, 2, 3}, {GTK_FILL, 0}); button.connect( "clicked", G_CALLBACK( OnBtnPatchFlipX ), 0 ); - gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); + button.dimensions(60, -1); } { auto label = ui::Label( "Vertical Stretch Step" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 3, 4, - (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {2, 3, 3, 4}, {GTK_FILL | GTK_EXPAND, 0}); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { auto button = ui::Button( "Flip" ); button.show(); - gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 3, 4, - (GtkAttachOptions)( GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(button, {3, 4, 3, 4}, {GTK_FILL, 0}); button.connect( "clicked", G_CALLBACK( OnBtnPatchFlipY ), 0 ); - gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); + button.dimensions(60, -1); } { auto label = ui::Label( "Rotate Step" ); label.show(); - gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 4, 5, - (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), - (GtkAttachOptions)( 0 ), 0, 0 ); + table.attach(label, {2, 4, 4, 5}, {GTK_FILL | GTK_EXPAND, 0}); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 0, 1, - (GtkAttachOptions)( GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); + table.attach(entry, {0, 1, 0, 1}, {GTK_FILL, 0}); + entry.dimensions(50, -1); g_object_set_data( G_OBJECT( window ), "hshift_entry", (void *) entry ); // we fill in this data, if no patch is selected the widgets are unmodified when the inspector is raised // so we need to have at least one initialisation somewhere @@ -899,19 +799,15 @@ ui::Window PatchInspector::BuildDialog(){ auto spin = ui::SpinButton( adj, 1, 0 ); spin.show(); - gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1, - (GtkAttachOptions)( 0 ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + table.attach(spin, {1, 2, 0, 1}, {0, 0}); + spin.dimensions(10, -1); gtk_widget_set_can_focus( spin, false ); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 1, 2, - (GtkAttachOptions)( GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); + table.attach(entry, {0, 1, 1, 2}, {GTK_FILL, 0}); + entry.dimensions(50, -1); entry_set_float( entry, g_pi_globals.shift[1] ); auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 ); @@ -920,19 +816,15 @@ ui::Window PatchInspector::BuildDialog(){ auto spin = ui::SpinButton( adj, 1, 0 ); spin.show(); - gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2, - (GtkAttachOptions)( 0 ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + table.attach(spin, {1, 2, 1, 2}, {0, 0}); + spin.dimensions(10, -1); gtk_widget_set_can_focus( spin, false ); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 2, 3, - (GtkAttachOptions)( GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); + table.attach(entry, {0, 1, 2, 3}, {GTK_FILL, 0}); + entry.dimensions(50, -1); entry_set_float( entry, g_pi_globals.scale[0] ); auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); @@ -941,19 +833,15 @@ ui::Window PatchInspector::BuildDialog(){ auto spin = ui::SpinButton( adj, 1, 0 ); spin.show(); - gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3, - (GtkAttachOptions)( 0 ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + table.attach(spin, {1, 2, 2, 3}, {0, 0}); + spin.dimensions(10, -1); gtk_widget_set_can_focus( spin, false ); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 3, 4, - (GtkAttachOptions)( GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); + table.attach(entry, {0, 1, 3, 4}, {GTK_FILL, 0}); + entry.dimensions(50, -1); entry_set_float( entry, g_pi_globals.scale[1] ); auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); @@ -962,19 +850,15 @@ ui::Window PatchInspector::BuildDialog(){ auto spin = ui::SpinButton( adj, 1, 0 ); spin.show(); - gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 3, 4, - (GtkAttachOptions)( 0 ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + table.attach(spin, {1, 2, 3, 4}, {0, 0}); + spin.dimensions(10, -1); gtk_widget_set_can_focus( spin, false ); } { auto entry = ui::Entry(ui::New); entry.show(); - gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 4, 5, - (GtkAttachOptions)( GTK_FILL ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); + table.attach(entry, {0, 1, 4, 5}, {GTK_FILL, 0}); + entry.dimensions(50, -1); entry_set_float( entry, g_pi_globals.rotate ); auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); // NOTE: Arnout - this really should be 360 but can't change it anymore as it could break existing maps @@ -983,10 +867,8 @@ ui::Window PatchInspector::BuildDialog(){ auto spin = ui::SpinButton( adj, 1, 0 ); spin.show(); - gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 4, 5, - (GtkAttachOptions)( 0 ), - (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + table.attach(spin, {1, 2, 4, 5}, {0, 0}); + spin.dimensions(10, -1); gtk_widget_set_can_focus( spin, false ); } } @@ -998,35 +880,35 @@ ui::Window PatchInspector::BuildDialog(){ button.show(); hbox2.pack_end(button, TRUE, FALSE, 0); button.connect( "clicked", G_CALLBACK( OnBtnPatchAutoCap ), 0 ); - gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); + button.dimensions(60, -1); } { auto button = ui::Button( "CAP" ); button.show(); hbox2.pack_end(button, TRUE, FALSE, 0); button.connect( "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 ); - gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); + button.dimensions(60, -1); } { auto button = ui::Button( "Set..." ); button.show(); hbox2.pack_end(button, TRUE, FALSE, 0); button.connect( "clicked", G_CALLBACK( OnBtnPatchreset ), 0 ); - gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); + button.dimensions(60, -1); } { auto button = ui::Button( "Natural" ); button.show(); hbox2.pack_end(button, TRUE, FALSE, 0); button.connect( "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 ); - gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); + button.dimensions(60, -1); } { auto button = ui::Button( "Fit" ); button.show(); hbox2.pack_end(button, TRUE, FALSE, 0); button.connect( "clicked", G_CALLBACK( OnBtnPatchfit ), 0 ); - gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); + button.dimensions(60, -1); } } } @@ -1151,18 +1033,18 @@ void PatchInspector_SelectionChanged( const Selectable& selectable ){ void PatchInspector_Construct(){ - GlobalCommands_insert( "PatchInspector", FreeCaller(), Accelerator( 'S', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "PatchInspector", makeCallbackF(PatchInspector_toggleShown), Accelerator( 'S', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalPreferenceSystem().registerPreference( "PatchWnd", WindowPositionTrackerImportStringCaller( g_PatchInspector.m_position_tracker ), WindowPositionTrackerExportStringCaller( g_PatchInspector.m_position_tracker ) ); - GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale1", FloatImportStringCaller( g_pi_globals.scale[0] ), FloatExportStringCaller( g_pi_globals.scale[0] ) ); - GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale2", FloatImportStringCaller( g_pi_globals.scale[1] ), FloatExportStringCaller( g_pi_globals.scale[1] ) ); - GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift1", FloatImportStringCaller( g_pi_globals.shift[0] ), FloatExportStringCaller( g_pi_globals.shift[0] ) ); - GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift2", FloatImportStringCaller( g_pi_globals.shift[1] ), FloatExportStringCaller( g_pi_globals.shift[1] ) ); - GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Rotate", FloatImportStringCaller( g_pi_globals.rotate ), FloatExportStringCaller( g_pi_globals.rotate ) ); + GlobalPreferenceSystem().registerPreference( "PatchWnd", make_property( g_PatchInspector.m_position_tracker ) ); + GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale1", make_property_string( g_pi_globals.scale[0] ) ); + GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale2", make_property_string( g_pi_globals.scale[1] ) ); + GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift1", make_property_string( g_pi_globals.shift[0] ) ); + GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift2", make_property_string( g_pi_globals.shift[1] ) ); + GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Rotate", make_property_string( g_pi_globals.rotate ) ); - typedef FreeCaller1 PatchInspectorSelectionChangedCaller; + typedef FreeCaller PatchInspectorSelectionChangedCaller; GlobalSelectionSystem().addSelectionChangeCallback( PatchInspectorSelectionChangedCaller() ); - typedef FreeCaller PatchInspectorQueueDrawCaller; + typedef FreeCaller PatchInspectorQueueDrawCaller; Patch_addTextureChangedCallback( PatchInspectorQueueDrawCaller() ); } void PatchInspector_Destroy(){