]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/select.cpp
Merge commit 'b25e4389ba4d089fc94cc3860774c8510b843042' into master-merge
[xonotic/netradiant.git] / radiant / select.cpp
index 265474276ec6444561979e116ae4c9f05570e572..f92706b5bdb9ecc5156ce8f09bc0e7a63e772806 100644 (file)
@@ -112,27 +112,33 @@ SelectByBounds( AABB* aabbs, Unsigned count )
 }
 
 bool pre( const scene::Path& path, scene::Instance& instance ) const {
-       Selectable* selectable = Instance_getSelectable( instance );
+       if( path.top().get().visible() ){
+               Selectable* selectable = Instance_getSelectable( instance );
 
-       // ignore worldspawn
-       Entity* entity = Node_getEntity( path.top() );
-       if ( entity ) {
-               if ( string_equal( entity->getKeyValue( "classname" ), "worldspawn" ) ) {
-                       return true;
+               // ignore worldspawn
+               Entity* entity = Node_getEntity( path.top() );
+               if ( entity ) {
+                       if ( string_equal( entity->getKeyValue( "classname" ), "worldspawn" ) ) {
+                               return true;
+                       }
                }
-       }
 
-       if ( ( path.size() > 1 ) &&
-                ( !path.top().get().isRoot() ) &&
-                ( selectable != 0 )
-                ) {
-               for ( Unsigned i = 0; i < m_count; ++i )
-               {
-                       if ( policy.Evaluate( m_aabbs[i], instance ) ) {
-                               selectable->setSelected( true );
+               if ( ( path.size() > 1 ) &&
+                       ( !path.top().get().isRoot() ) &&
+                       ( selectable != 0 ) &&
+                       ( !node_is_group( path.top() ) )
+                       ) {
+                       for ( Unsigned i = 0; i < m_count; ++i )
+                       {
+                               if ( policy.Evaluate( m_aabbs[i], instance ) ) {
+                                       selectable->setSelected( true );
+                               }
                        }
                }
        }
+       else{
+               return false;
+       }
 
        return true;
 }
@@ -277,6 +283,10 @@ InvertSelectionWalker( SelectionSystem::EMode mode )
        : m_mode( mode ), m_selectable( 0 ){
 }
 bool pre( const scene::Path& path, scene::Instance& instance ) const {
+       if( !path.top().get().visible() ){
+               m_selectable = 0;
+               return false;
+       }
        Selectable* selectable = Instance_getSelectable( instance );
        if ( selectable ) {
                switch ( m_mode )
@@ -357,7 +367,7 @@ void Selection_UpdateWorkzone(){
                Select_GetBounds( g_select_workzone.d_work_min, g_select_workzone.d_work_max );
        }
 }
-typedef FreeCaller<Selection_UpdateWorkzone> SelectionUpdateWorkzoneCaller;
+typedef FreeCaller<void(), Selection_UpdateWorkzone> SelectionUpdateWorkzoneCaller;
 
 IdleDraw g_idleWorkzone = IdleDraw( SelectionUpdateWorkzoneCaller() );
 }
@@ -610,6 +620,9 @@ EntityFindByPropertyValueWalker( const char *prop, const PropertyValues& propert
        : m_propertyvalues( propertyvalues ), m_prop( prop ){
 }
 bool pre( const scene::Path& path, scene::Instance& instance ) const {
+       if( !path.top().get().visible() ){
+               return false;
+       }
        Entity* entity = Node_getEntity( path.top() );
        if ( entity != 0
                 && propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
@@ -818,11 +831,11 @@ void SceneSelectionChange( const Selectable& selectable ){
 SignalHandlerId Selection_boundsChanged;
 
 void Selection_construct(){
-       typedef FreeCaller1<const Selectable&, SceneSelectionChange> SceneSelectionChangeCaller;
+       typedef FreeCaller<void(const Selectable&), SceneSelectionChange> SceneSelectionChangeCaller;
        GlobalSelectionSystem().addSelectionChangeCallback( SceneSelectionChangeCaller() );
-       typedef FreeCaller1<const Selectable&, UpdateWorkzone_ForSelectionChanged> UpdateWorkzoneForSelectionChangedCaller;
+       typedef FreeCaller<void(const Selectable&), UpdateWorkzone_ForSelectionChanged> UpdateWorkzoneForSelectionChangedCaller;
        GlobalSelectionSystem().addSelectionChangeCallback( UpdateWorkzoneForSelectionChangedCaller() );
-       typedef FreeCaller<UpdateWorkzone_ForSelection> UpdateWorkzoneForSelectionCaller;
+       typedef FreeCaller<void(), UpdateWorkzone_ForSelection> UpdateWorkzoneForSelectionCaller;
        Selection_boundsChanged = GlobalSceneGraph().addBoundsChangedCallback( UpdateWorkzoneForSelectionCaller() );
 }
 
@@ -865,15 +878,18 @@ inline Quaternion quaternion_for_euler_xyz_degrees( const Vector3& eulerXYZ ){
 
 struct RotateDialog
 {
-       GtkSpinButton* x;
-       GtkSpinButton* y;
-       GtkSpinButton* z;
+       ui::SpinButton x{ui::null};
+       ui::SpinButton y{ui::null};
+       ui::SpinButton z{ui::null};
        ui::Window window{ui::null};
 };
 
 static gboolean rotatedlg_apply( ui::Widget widget, RotateDialog* rotateDialog ){
        Vector3 eulerXYZ;
 
+       gtk_spin_button_update ( rotateDialog->x );
+       gtk_spin_button_update ( rotateDialog->y );
+       gtk_spin_button_update ( rotateDialog->z );
        eulerXYZ[0] = static_cast<float>( gtk_spin_button_get_value( rotateDialog->x ) );
        eulerXYZ[1] = static_cast<float>( gtk_spin_button_get_value( rotateDialog->y ) );
        eulerXYZ[2] = static_cast<float>( gtk_spin_button_get_value( rotateDialog->z ) );
@@ -898,6 +914,7 @@ static gboolean rotatedlg_cancel( ui::Widget widget, RotateDialog* rotateDialog
 
 static gboolean rotatedlg_ok( ui::Widget widget, RotateDialog* rotateDialog ){
        rotatedlg_apply( widget, rotateDialog );
+//     rotatedlg_cancel( widget, rotateDialog );
        rotateDialog->window.hide();
        return TRUE;
 }
@@ -924,32 +941,24 @@ void DoRotateDlg(){
                                {
                                        ui::Widget label = ui::Label( "  X  " );
                                        label.show();
-                                       gtk_table_attach( table, label, 0, 1, 0, 1,
-                                                                         (GtkAttachOptions) ( 0 ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 0, 1}, {0, 0});
                                }
                                {
                                        ui::Widget label = ui::Label( "  Y  " );
                                        label.show();
-                                       gtk_table_attach( table, label, 0, 1, 1, 2,
-                                                                         (GtkAttachOptions) ( 0 ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 1, 2}, {0, 0});
                                }
                                {
                                        ui::Widget label = ui::Label( "  Z  " );
                                        label.show();
-                                       gtk_table_attach( table, label, 0, 1, 2, 3,
-                                                                         (GtkAttachOptions) ( 0 ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 2, 3}, {0, 0});
                                }
                                {
                                        auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
                                        auto spin = ui::SpinButton( adj, 1, 0 );
                                        spin.show();
-                                       gtk_table_attach( table, spin , 1, 2, 0, 1,
-                                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       gtk_widget_set_size_request( spin , 64, -1 );
+                    table.attach(spin, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+                    spin.dimensions(64, -1);
                                        gtk_spin_button_set_wrap( spin, TRUE );
 
                                        gtk_widget_grab_focus( spin  );
@@ -960,10 +969,8 @@ void DoRotateDlg(){
                                        auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
                                        auto spin = ui::SpinButton( adj, 1, 0 );
                                        spin.show();
-                                       gtk_table_attach( table, spin , 1, 2, 1, 2,
-                                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       gtk_widget_set_size_request( spin , 64, -1 );
+                    table.attach(spin, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+                    spin.dimensions(64, -1);
                                        gtk_spin_button_set_wrap( spin, TRUE );
 
                                        g_rotate_dialog.y = spin;
@@ -972,10 +979,8 @@ void DoRotateDlg(){
                                        auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
                                        auto spin = ui::SpinButton( adj, 1, 0 );
                                        spin.show();
-                                       gtk_table_attach( table, spin , 1, 2, 2, 3,
-                                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       gtk_widget_set_size_request( spin , 64, -1 );
+                    table.attach(spin, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, 0});
+                    spin.dimensions(64, -1);
                                        gtk_spin_button_set_wrap( spin, TRUE );
 
                                        g_rotate_dialog.z = spin;
@@ -1050,6 +1055,7 @@ static gboolean scaledlg_cancel( ui::Widget widget, ScaleDialog* scaleDialog ){
 
 static gboolean scaledlg_ok( ui::Widget widget, ScaleDialog* scaleDialog ){
        scaledlg_apply( widget, scaleDialog );
+       //scaledlg_cancel( widget, scaleDialog );
        scaleDialog->window.hide();
        return TRUE;
 }
@@ -1077,31 +1083,23 @@ void DoScaleDlg(){
                                {
                                        ui::Widget label = ui::Label( "  X  " );
                                        label.show();
-                                       gtk_table_attach( table, label, 0, 1, 0, 1,
-                                                                         (GtkAttachOptions) ( 0 ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 0, 1}, {0, 0});
                                }
                                {
                                        ui::Widget label = ui::Label( "  Y  " );
                                        label.show();
-                                       gtk_table_attach( table, label, 0, 1, 1, 2,
-                                                                         (GtkAttachOptions) ( 0 ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 1, 2}, {0, 0});
                                }
                                {
                                        ui::Widget label = ui::Label( "  Z  " );
                                        label.show();
-                                       gtk_table_attach( table, label, 0, 1, 2, 3,
-                                                                         (GtkAttachOptions) ( 0 ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 2, 3}, {0, 0});
                                }
                                {
                                        auto entry = ui::Entry(ui::New);
                                        entry.text("1.0");
                                        entry.show();
-                                       gtk_table_attach( table, entry, 1, 2, 0, 1,
-                                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
 
                                        g_scale_dialog.x = entry;
                                }
@@ -1109,9 +1107,7 @@ void DoScaleDlg(){
                                        auto entry = ui::Entry(ui::New);
                                        entry.text("1.0");
                                        entry.show();
-                                       gtk_table_attach( table, 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});
 
                                        g_scale_dialog.y = entry;
                                }
@@ -1119,9 +1115,7 @@ void DoScaleDlg(){
                                        auto entry = ui::Entry(ui::New);
                                        entry.text("1.0");
                                        entry.show();
-                                       gtk_table_attach( table, 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});
 
                                        g_scale_dialog.z = entry;
                                }