]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/patchdialog.cpp
Dialog: wrap GTK widgets in data binding
[xonotic/netradiant.git] / radiant / patchdialog.cpp
index 0b85ea2d1f0a1c6ae46328dd1b0db91f1a18c9df..6fbbe3e7305e2654b35a1024504f2ccc84bb2309 100644 (file)
@@ -176,7 +176,7 @@ void update(){
 void cancel(){
        update();
 }
-typedef MemberCaller<Subdivisions, &Subdivisions::cancel> CancelCaller;
+typedef MemberCaller<Subdivisions, void(), &Subdivisions::cancel> CancelCaller;
 void apply(){
        Scene_PatchSetFixedSubdivisions(
                PatchFixedSubdivisions(
@@ -186,7 +186,7 @@ void apply(){
                        )
                );
 }
-typedef MemberCaller<Subdivisions, &Subdivisions::apply> ApplyCaller;
+typedef MemberCaller<Subdivisions, void(), &Subdivisions::apply> ApplyCaller;
 static void applyGtk( ui::ToggleButton toggle, Subdivisions* self ){
        self->apply();
 }
@@ -230,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<PatchInspector, &PatchInspector::GetPatchInfo>( *this ) ){
+       m_idleDraw( MemberCaller<PatchInspector, void(), &PatchInspector::GetPatchInfo>( *this ) ){
        m_fS = 0.0f;
        m_fT = 0.0f;
        m_fX = 0.0f;
@@ -561,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});
@@ -572,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});
@@ -614,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 );
                                                }
@@ -622,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 );
                                                }
@@ -630,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 );
                                                }
@@ -638,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 );
                                                }
@@ -646,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 );
                                                }
@@ -729,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 );
                                        }
@@ -1033,18 +1033,18 @@ void PatchInspector_SelectionChanged( const Selectable& selectable ){
 
 
 void PatchInspector_Construct(){
-       GlobalCommands_insert( "PatchInspector", FreeCaller<PatchInspector_toggleShown>(), 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<WindowPositionTracker_String>( 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<const Selectable&, PatchInspector_SelectionChanged> PatchInspectorSelectionChangedCaller;
+       typedef FreeCaller<void(const Selectable&), PatchInspector_SelectionChanged> PatchInspectorSelectionChangedCaller;
        GlobalSelectionSystem().addSelectionChangeCallback( PatchInspectorSelectionChangedCaller() );
-       typedef FreeCaller<PatchInspector_queueDraw> PatchInspectorQueueDrawCaller;
+       typedef FreeCaller<void(), PatchInspector_queueDraw> PatchInspectorQueueDrawCaller;
        Patch_addTextureChangedCallback( PatchInspectorQueueDrawCaller() );
 }
 void PatchInspector_Destroy(){