X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fpatchdialog.cpp;h=6a29298d592f8de1a599863a37669c572c66af22;hb=5ebff88302017e024f6c8cc0d1b8d518d6c2070a;hp=4a358a5ed2f9dce2884f94c3b362d9402aaee487;hpb=51fa1a72ab2099fab13b429097300ed464c25a9d;p=xonotic%2Fnetradiant.git diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index 4a358a5e..6a29298d 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); + }); } @@ -160,7 +151,7 @@ public: ui::CheckButton m_enabled; ui::Entry m_horizontal; ui::Entry m_vertical; -Subdivisions() : m_enabled( (GtkCheckButton *) 0 ), m_horizontal( ui::null ), m_vertical( ui::null ){ +Subdivisions() : m_enabled( ui::null ), m_horizontal( ui::null ), m_vertical( ui::null ){ } void update(){ PatchFixedSubdivisions subdivisions; @@ -185,7 +176,7 @@ void update(){ void cancel(){ update(); } -typedef MemberCaller CancelCaller; +typedef MemberCaller CancelCaller; void apply(){ Scene_PatchSetFixedSubdivisions( PatchFixedSubdivisions( @@ -195,7 +186,7 @@ void apply(){ ) ); } -typedef MemberCaller ApplyCaller; +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,30 +389,24 @@ 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 ){ Patch_AutoCapTexture(); } -static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ +static void OnSpinChanged(ui::Adjustment adj, gpointer data ){ texdef_t td; td.rotate = 0; @@ -535,7 +491,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ } // update the point-by-point view - OnSelchangeComboColRow( ui::root ,0 ); + OnSelchangeComboColRow( ui::root, 0 ); } static gint OnDialogKey( ui::Widget widget, GdkEventKey* event, gpointer data ){ @@ -605,7 +561,7 @@ ui::Window PatchInspector::BuildDialog(){ { 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(); table.attach(combo, {0, 1, 1, 2}, {(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0)}, {0, 0}); @@ -616,7 +572,7 @@ ui::Window PatchInspector::BuildDialog(){ { 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(); table.attach(combo, {1, 2, 1, 2}, {(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0)}, {0, 0}); @@ -658,7 +614,7 @@ ui::Window PatchInspector::BuildDialog(){ auto entry = ui::Entry(ui::New); entry.show(); table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); - AddDialogData( *GTK_ENTRY(entry), m_fX ); + AddDialogData( entry, m_fX ); entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } @@ -666,7 +622,7 @@ ui::Window PatchInspector::BuildDialog(){ auto entry = ui::Entry(ui::New); entry.show(); table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0}); - AddDialogData( *GTK_ENTRY(entry), m_fY ); + AddDialogData( entry, m_fY ); entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } @@ -674,7 +630,7 @@ ui::Window PatchInspector::BuildDialog(){ auto entry = ui::Entry(ui::New); entry.show(); table.attach(entry, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, 0}); - AddDialogData( *GTK_ENTRY(entry), m_fZ ); + AddDialogData( entry, m_fZ ); entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } @@ -682,7 +638,7 @@ ui::Window PatchInspector::BuildDialog(){ auto entry = ui::Entry(ui::New); entry.show(); table.attach(entry, {1, 2, 3, 4}, {GTK_EXPAND | GTK_FILL, 0}); - AddDialogData( *GTK_ENTRY(entry), m_fS ); + AddDialogData( entry, m_fS ); entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } @@ -690,7 +646,7 @@ ui::Window PatchInspector::BuildDialog(){ auto entry = ui::Entry(ui::New); entry.show(); table.attach(entry, {1, 2, 4, 5}, {GTK_EXPAND | GTK_FILL, 0}); - AddDialogData( *GTK_ENTRY(entry), m_fT ); + AddDialogData( entry, m_fT ); entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } @@ -717,7 +673,7 @@ ui::Window PatchInspector::BuildDialog(){ table.attach(label, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); } { - auto check = ui::CheckButton(GTK_CHECK_BUTTON( gtk_check_button_new() )); + auto check = ui::CheckButton::from( gtk_check_button_new() ); check.show(); table.attach(check, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0}); m_subdivisions.m_enabled = check; @@ -773,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 ); } @@ -1077,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(){