X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=radiant%2Fselect.cpp;h=eb2cacbd8129ea80a5d76decef17c5a6aabf248a;hb=1730832afea74a75aeed212d19d2a1bce354c7ec;hp=f88cf1aad979d19cf12f3d17c42005193195d9ca;hpb=225950494a606af9aac2bc2f06ece70cb2146481;p=xonotic%2Fnetradiant.git diff --git a/radiant/select.cpp b/radiant/select.cpp index f88cf1aa..eb2cacbd 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -21,6 +21,8 @@ #include "select.h" +#include + #include "debugging/debugging.h" #include "ientity.h" @@ -355,7 +357,7 @@ void Selection_UpdateWorkzone(){ Select_GetBounds( g_select_workzone.d_work_min, g_select_workzone.d_work_max ); } } -typedef FreeCaller SelectionUpdateWorkzoneCaller; +typedef FreeCaller SelectionUpdateWorkzoneCaller; IdleDraw g_idleWorkzone = IdleDraw( SelectionUpdateWorkzoneCaller() ); } @@ -692,6 +694,24 @@ void Select_FitTexture( float horizontal, float vertical ){ SceneChangeNotify(); } +void Select_FitTextureW( float horizontal, float vertical ){ + if ( GlobalSelectionSystem().Mode() != SelectionSystem::eComponent ) { + Scene_BrushFitTexture_SelectedW( GlobalSceneGraph(), horizontal, vertical ); + } + Scene_BrushFitTexture_Component_SelectedW( GlobalSceneGraph(), horizontal, vertical ); + + SceneChangeNotify(); +} + +void Select_FitTextureH( float horizontal, float vertical ){ + if ( GlobalSelectionSystem().Mode() != SelectionSystem::eComponent ) { + Scene_BrushFitTexture_SelectedH( GlobalSceneGraph(), horizontal, vertical ); + } + Scene_BrushFitTexture_Component_SelectedH( GlobalSceneGraph(), horizontal, vertical ); + + SceneChangeNotify(); +} + inline void hide_node( scene::Node& node, bool hide ){ hide ? node.enable( scene::Node::eHidden ) @@ -816,11 +836,11 @@ void SceneSelectionChange( const Selectable& selectable ){ SignalHandlerId Selection_boundsChanged; void Selection_construct(){ - typedef FreeCaller1 SceneSelectionChangeCaller; + typedef FreeCaller SceneSelectionChangeCaller; GlobalSelectionSystem().addSelectionChangeCallback( SceneSelectionChangeCaller() ); - typedef FreeCaller1 UpdateWorkzoneForSelectionChangedCaller; + typedef FreeCaller UpdateWorkzoneForSelectionChangedCaller; GlobalSelectionSystem().addSelectionChangeCallback( UpdateWorkzoneForSelectionChangedCaller() ); - typedef FreeCaller UpdateWorkzoneForSelectionCaller; + typedef FreeCaller UpdateWorkzoneForSelectionCaller; Selection_boundsChanged = GlobalSceneGraph().addBoundsChangedCallback( UpdateWorkzoneForSelectionCaller() ); } @@ -863,15 +883,18 @@ inline Quaternion quaternion_for_euler_xyz_degrees( const Vector3& eulerXYZ ){ struct RotateDialog { - GtkSpinButton* x; - GtkSpinButton* y; - GtkSpinButton* z; - ui::Window window; + 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( gtk_spin_button_get_value( rotateDialog->x ) ); eulerXYZ[1] = static_cast( gtk_spin_button_get_value( rotateDialog->y ) ); eulerXYZ[2] = static_cast( gtk_spin_button_get_value( rotateDialog->z ) ); @@ -885,7 +908,7 @@ static gboolean rotatedlg_apply( ui::Widget widget, RotateDialog* rotateDialog ) } static gboolean rotatedlg_cancel( ui::Widget widget, RotateDialog* rotateDialog ){ - gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) ); + rotateDialog->window.hide(); gtk_spin_button_set_value( rotateDialog->x, 0.0f ); // reset to 0 on close gtk_spin_button_set_value( rotateDialog->y, 0.0f ); @@ -896,7 +919,8 @@ static gboolean rotatedlg_cancel( ui::Widget widget, RotateDialog* rotateDialog static gboolean rotatedlg_ok( ui::Widget widget, RotateDialog* rotateDialog ){ rotatedlg_apply( widget, rotateDialog ); - gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) ); +// rotatedlg_cancel( widget, rotateDialog ); + rotateDialog->window.hide(); return TRUE; } @@ -910,47 +934,39 @@ void DoRotateDlg(){ if ( !g_rotate_dialog.window ) { g_rotate_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary rotation", G_CALLBACK(rotatedlg_delete ), &g_rotate_dialog ); - auto accel = ui::AccelGroup(); + auto accel = ui::AccelGroup(ui::New); g_rotate_dialog.window.add_accel_group( accel ); { auto hbox = create_dialog_hbox( 4, 4 ); g_rotate_dialog.window.add(hbox); { - GtkTable* table = create_dialog_table( 3, 2, 4, 4 ); - gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); + auto table = create_dialog_table( 3, 2, 4, 4 ); + hbox.pack_start( table, TRUE, TRUE, 0 ); { 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, GTK_WIDGET( spin ), 1, 2, 0, 1, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( 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( GTK_WIDGET( spin ) ); + gtk_widget_grab_focus( spin ); g_rotate_dialog.x = spin; } @@ -958,10 +974,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, GTK_WIDGET( spin ), 1, 2, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( 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; @@ -970,32 +984,30 @@ 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, GTK_WIDGET( spin ), 1, 2, 2, 3, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( GTK_WIDGET( 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; } } { - GtkVBox* vbox = create_dialog_vbox( 4 ); - gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); + auto vbox = create_dialog_vbox( 4 ); + hbox.pack_start( vbox, TRUE, TRUE, 0 ); { auto button = create_dialog_button( "OK", G_CALLBACK( rotatedlg_ok ), &g_rotate_dialog ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); + vbox.pack_start( button, FALSE, FALSE, 0 ); widget_make_default( button ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { - GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( rotatedlg_cancel ), &g_rotate_dialog ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + auto button = create_dialog_button( "Cancel", G_CALLBACK( rotatedlg_cancel ), &g_rotate_dialog ); + vbox.pack_start( button, FALSE, FALSE, 0 ); + gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); } { - GtkButton* button = create_dialog_button( "Apply", G_CALLBACK( rotatedlg_apply ), &g_rotate_dialog ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); + auto button = create_dialog_button( "Apply", G_CALLBACK( rotatedlg_apply ), &g_rotate_dialog ); + vbox.pack_start( button, FALSE, FALSE, 0 ); } } } @@ -1014,10 +1026,10 @@ void DoRotateDlg(){ struct ScaleDialog { - ui::Widget x; - ui::Widget y; - ui::Widget z; - ui::Window window; + ui::Entry x{ui::null}; + ui::Entry y{ui::null}; + ui::Entry z{ui::null}; + ui::Window window{ui::null}; }; static gboolean scaledlg_apply( ui::Widget widget, ScaleDialog* scaleDialog ){ @@ -1037,18 +1049,19 @@ static gboolean scaledlg_apply( ui::Widget widget, ScaleDialog* scaleDialog ){ } static gboolean scaledlg_cancel( ui::Widget widget, ScaleDialog* scaleDialog ){ - gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) ); + scaleDialog->window.hide(); - gtk_entry_set_text( GTK_ENTRY( scaleDialog->x ), "1.0" ); - gtk_entry_set_text( GTK_ENTRY( scaleDialog->y ), "1.0" ); - gtk_entry_set_text( GTK_ENTRY( scaleDialog->z ), "1.0" ); + scaleDialog->x.text("1.0"); + scaleDialog->y.text("1.0"); + scaleDialog->z.text("1.0"); return TRUE; } static gboolean scaledlg_ok( ui::Widget widget, ScaleDialog* scaleDialog ){ scaledlg_apply( widget, scaleDialog ); - gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) ); + //scaledlg_cancel( widget, scaleDialog ); + scaleDialog->window.hide(); return TRUE; } @@ -1063,84 +1076,72 @@ void DoScaleDlg(){ if ( !g_scale_dialog.window ) { g_scale_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary scale", G_CALLBACK(scaledlg_delete ), &g_scale_dialog ); - auto accel = ui::AccelGroup(); + auto accel = ui::AccelGroup(ui::New); g_scale_dialog.window.add_accel_group( accel ); { auto hbox = create_dialog_hbox( 4, 4 ); g_scale_dialog.window.add(hbox); { - GtkTable* table = create_dialog_table( 3, 2, 4, 4 ); - gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); + auto table = create_dialog_table( 3, 2, 4, 4 ); + hbox.pack_start( table, TRUE, TRUE, 0 ); { 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}); } { - ui::Widget entry = ui::Entry(); - gtk_entry_set_text( GTK_ENTRY( entry ), "1.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; } { - ui::Widget entry = ui::Entry(); - gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" ); + 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; } { - ui::Widget entry = ui::Entry(); - gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" ); + 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; } } { - GtkVBox* vbox = create_dialog_vbox( 4 ); - gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); + auto vbox = create_dialog_vbox( 4 ); + hbox.pack_start( vbox, TRUE, TRUE, 0 ); { auto button = create_dialog_button( "OK", G_CALLBACK( scaledlg_ok ), &g_scale_dialog ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); + vbox.pack_start( button, FALSE, FALSE, 0 ); widget_make_default( button ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { - GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( scaledlg_cancel ), &g_scale_dialog ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + auto button = create_dialog_button( "Cancel", G_CALLBACK( scaledlg_cancel ), &g_scale_dialog ); + vbox.pack_start( button, FALSE, FALSE, 0 ); + gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); } { - GtkButton* button = create_dialog_button( "Apply", G_CALLBACK( scaledlg_apply ), &g_scale_dialog ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); + auto button = create_dialog_button( "Apply", G_CALLBACK( scaledlg_apply ), &g_scale_dialog ); + vbox.pack_start( button, FALSE, FALSE, 0 ); } } }