]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/surfacedialog.cpp
Merge commit 'cac514541c3ae6f72c4c00c19c215ff62a023df4' into garux-merge
[xonotic/netradiant.git] / radiant / surfacedialog.cpp
index 57007112446f6ef73a2543bf51e11838e54da3e6..70d25f7599b885b2f26d6b4f29019eee5fda3b8d 100644 (file)
@@ -122,7 +122,7 @@ float& m_f;
 public:
 ui::SpinButton m_spin;
 ui::Entry m_entry;
-Increment( float& f ) : m_f( f ), m_spin( 0 ), m_entry( ui::null ){
+Increment( float& f ) : m_f( f ), m_spin( ui::null ), m_entry( ui::null ){
 }
 void cancel(){
        entry_set_float( m_entry, m_f );
@@ -162,8 +162,6 @@ NonModalEntry m_valueEntry;
 ui::Entry m_valueEntryWidget{ui::null};
 public:
 WindowPositionTracker m_positionTracker;
-WindowPositionTrackerImportStringCaller m_importPosition;
-WindowPositionTrackerExportStringCaller m_exportPosition;
 
 // Dialog Data
 float m_fitHorizontal;
@@ -190,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] ),
@@ -416,7 +412,7 @@ void DoSurface( void ){
 
        }
        getSurfaceInspector().Update();
-       getSurfaceInspector().importData();
+       //getSurfaceInspector().importData(); //happens in .ShowDlg() anyway
        getSurfaceInspector().ShowDlg();
 }
 
@@ -435,6 +431,16 @@ void SurfaceInspector_FitTexture(){
        Select_FitTexture( getSurfaceInspector().m_fitHorizontal, getSurfaceInspector().m_fitVertical );
 }
 
+void SurfaceInspector_FitTextureW(){
+       UndoableCommand undo( "textureAutoFitW" );
+       Select_FitTexture( getSurfaceInspector().m_fitHorizontal, 0 );
+}
+
+void SurfaceInspector_FitTextureH(){
+       UndoableCommand undo( "textureAutoFitH" );
+       Select_FitTexture( 0, getSurfaceInspector().m_fitVertical );
+}
+
 static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){
        Patch_CapTexture();
 }
@@ -485,6 +491,18 @@ static void OnBtnFaceFit( ui::Widget widget, gpointer data ){
        SurfaceInspector_FitTexture();
 }
 
+static void OnBtnFaceFitW( GtkWidget *widget, gpointer data ){
+       getSurfaceInspector().exportData();
+       SurfaceInspector_FitTextureW();
+}
+
+static void OnBtnFaceFitH( GtkWidget *widget, gpointer data ){
+       getSurfaceInspector().exportData();
+       SurfaceInspector_FitTextureH();
+}
+
+
+
 typedef const char* FlagName;
 
 const FlagName surfaceflagNamesDefault[32] = {
@@ -859,14 +877,14 @@ ui::Window SurfaceInspector::BuildDialog(){
                                        spin.show();
                                        table.attach(spin, {2, 3, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
                     spin.dimensions(60, -1);
-                                       AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitHorizontal );
+                                       AddDialogData( spin, m_fitHorizontal );
                                }
                                {
                                        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( *GTK_SPIN_BUTTON( spin ), m_fitVertical );
+                                       AddDialogData( spin, m_fitVertical );
                                }
                        }
                }
@@ -937,7 +955,7 @@ ui::Window SurfaceInspector::BuildDialog(){
                                                }
 
                                                // not allowed to modify detail flag using Surface Inspector
-                                               gtk_widget_set_sensitive( ui::CheckButton(m_contentFlags[BRUSH_DETAIL_FLAG]), FALSE );
+                                               gtk_widget_set_sensitive( ui::CheckButton::from(m_contentFlags[BRUSH_DETAIL_FLAG]), FALSE );
                                        }
                                }
                        }
@@ -1102,12 +1120,12 @@ void SurfaceInspector::Update(){
 
                for ( GtkCheckButton** p = m_surfaceFlags; p != m_surfaceFlags + 32; ++p )
                {
-                       toggle_button_set_active_no_signal( ui::CheckButton( *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( ui::CheckButton( *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 ) ) );
                }
        }
 }
@@ -1288,6 +1306,9 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
                        }
                }
        }
+       else{
+               return false;
+       }
        return true;
 }
 };
@@ -1415,13 +1436,13 @@ 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<WindowPositionTracker_String>( 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 FreeCaller<void(const Selectable&), SurfaceInspector_SelectionChanged> SurfaceInspectorSelectionChangedCaller;
        GlobalSelectionSystem().addSelectionChangeCallback( SurfaceInspectorSelectionChangedCaller() );