From 30be2ae5f84fef5b4e38a1692d42820f376e345b Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 4 Apr 2020 07:42:55 +0200 Subject: [PATCH] contrib/bobtoolz: center some dialog windows on main window also rename the Path Plotter window title correctly --- contrib/bobtoolz/bobToolz-GTK.cpp | 6 ++--- contrib/bobtoolz/dialogs/dialogs-gtk.cpp | 34 +++++++++++------------- contrib/bobtoolz/dialogs/dialogs-gtk.h | 4 +-- contrib/bobtoolz/funchandlers-GTK.cpp | 8 +++--- contrib/bobtoolz/funchandlers.h | 6 +++-- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/contrib/bobtoolz/bobToolz-GTK.cpp b/contrib/bobtoolz/bobToolz-GTK.cpp index ab78ffdc..04f7d89b 100644 --- a/contrib/bobtoolz/bobToolz-GTK.cpp +++ b/contrib/bobtoolz/bobToolz-GTK.cpp @@ -62,7 +62,7 @@ void BobToolz_destroy(){ static const char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge"; // globals -ui::Window g_pRadiantWnd{ui::null}; +static ui::Window g_pRadiantWnd{ui::null}; extern "C" const char* QERPlug_Init( void* hApp, void* pMainWidget ) { g_pRadiantWnd = ui::Window::from(pMainWidget); @@ -115,7 +115,7 @@ extern "C" void QERPlug_Dispatch( const char *p, vec3_t vMin, vec3_t vMax, bool DoFlipTerrain(); } else if ( string_equal_nocase( p, "reset textures..." ) ) { - DoResetTextures(); + DoResetTextures( main_window ); } else if ( string_equal_nocase( p, "pitomatic" ) ) { DoPitBuilder(); @@ -136,7 +136,7 @@ extern "C" void QERPlug_Dispatch( const char *p, vec3_t vMin, vec3_t vMax, bool DoMakeChain(); } else if ( string_equal_nocase( p, "path plotter..." ) ) { - DoPathPlotter(); + DoPathPlotter( main_window ); } else if ( string_equal_nocase( p, "about..." ) ) { static const char *label_text = diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index 9329f306..05376e3f 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -24,6 +24,7 @@ #include #include #include "gtkutil/pointer.h" +#include "gtkutil/dialog.h" #include "../lists.h" #include "../misc.h" @@ -90,7 +91,7 @@ static void dialog_button_callback( ui::Widget widget, gpointer data ){ *ret = (EMessageBoxReturn)gpointer_to_int( data ); } -static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){ +static gint custom_dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){ widget.hide(); int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop"); *loop = 0; @@ -210,7 +211,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess int loop = 1; auto window = ui::Window( ui::window_type::TOP ); - window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( window, lpCaption ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); @@ -312,7 +313,7 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ auto window = ui::Window( ui::window_type::TOP ); - window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( window, "Intersect" ); @@ -405,7 +406,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ auto window = ui::Window( ui::window_type::TOP ); - window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( window, "Polygon Builder" ); @@ -573,7 +574,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ auto window = ui::Window( ui::window_type::TOP ); - window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( window, "Stair Builder" ); @@ -823,7 +824,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ auto window = ui::Window( ui::window_type::TOP ); - window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( window, "Door Builder" ); @@ -1025,18 +1026,17 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ //-djbob } -EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ +EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs, ui::Window main_window ){ ui::Widget w{ui::null}; + ModalDialog dialog; EMessageBoxReturn ret; int loop = 1; - auto window = ui::Window( ui::window_type::TOP ); + auto window = main_window.create_dialog_window( "Path Plotter", G_CALLBACK( custom_dialog_delete_callback ), &dialog ); - window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( window, "Texture Reset" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -1204,7 +1204,7 @@ EMessageBoxReturn DoCTFColourChangeBox(){ auto window = ui::Window( ui::window_type::TOP ); - window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( window, "CTF Colour Changer" ); @@ -1265,20 +1265,19 @@ EMessageBoxReturn DoCTFColourChangeBox(){ return ret; } -EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ +EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs, ui::Window main_window ){ Str texSelected; ui::Widget w{ui::null}; + ModalDialog dialog; EMessageBoxReturn ret; int loop = 1; - auto window = ui::Window( ui::window_type::TOP ); + auto window = main_window.create_dialog_window( "Texture Reset", G_CALLBACK( custom_dialog_delete_callback ), &dialog ); - window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( window, "Texture Reset" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -1491,7 +1490,6 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- /vbox ---- - gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -1571,7 +1569,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ auto window = ui::Window( ui::window_type::TOP ); - window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( window, "Train Thing" ); @@ -1806,7 +1804,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ auto window = ui::Window( ui::window_type::TOP ); - window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( window, "Make Chain" ); diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.h b/contrib/bobtoolz/dialogs/dialogs-gtk.h index a8490459..f45a197b 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.h +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.h @@ -98,10 +98,10 @@ struct TwinWidget { EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ); EMessageBoxReturn DoIntersectBox( IntersectRS* rs ); EMessageBoxReturn DoPolygonBox( PolygonRS* rs ); -EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ); +EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs, ui::Window main_window ); EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ); EMessageBoxReturn DoDoorsBox( DoorRS* rs ); -EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ); +EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs, ui::Window main_window ); EMessageBoxReturn DoCTFColourChangeBox(); EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ); EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ); diff --git a/contrib/bobtoolz/funchandlers-GTK.cpp b/contrib/bobtoolz/funchandlers-GTK.cpp index b07bf328..decbf8ad 100644 --- a/contrib/bobtoolz/funchandlers-GTK.cpp +++ b/contrib/bobtoolz/funchandlers-GTK.cpp @@ -202,7 +202,7 @@ void DoFixBrushes(){ globalOutputStream() << "bobToolz FixBrushes: " << count << " invalid/duplicate planes removed.\n"; } -void DoResetTextures(){ +void DoResetTextures( ui::Window main_window ){ UndoableCommand undo( "bobToolz.resetTextures" ); static ResetTextureRS rs; @@ -217,7 +217,7 @@ void DoResetTextures(){ } EMessageBoxReturn ret; - if ( ( ret = DoResetTextureBox( &rs ) ) == eIDCANCEL ) { + if ( ( ret = DoResetTextureBox( &rs, main_window ) ) == eIDCANCEL ) { return; } @@ -362,10 +362,10 @@ void DoBuildDoors(){ } } -void DoPathPlotter(){ +void DoPathPlotter( ui::Window main_window ){ UndoableCommand undo( "bobToolz.pathPlotter" ); PathPlotterRS rs; - EMessageBoxReturn ret = DoPathPlotterBox( &rs ); + EMessageBoxReturn ret = DoPathPlotterBox( &rs, main_window ); if ( ret == eIDCANCEL ) { return; } diff --git a/contrib/bobtoolz/funchandlers.h b/contrib/bobtoolz/funchandlers.h index 6062ea6e..124f4725 100644 --- a/contrib/bobtoolz/funchandlers.h +++ b/contrib/bobtoolz/funchandlers.h @@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "uilib/uilib.h" + class DBobView; class DVisDrawer; class DTrainDrawer; @@ -54,10 +56,10 @@ void DoIntersect(); void DoPolygonsTB(); void DoPolygons(); void DoFixBrushes(); -void DoResetTextures(); +void DoResetTextures( ui::Window main_window ); void DoBuildStairs(); void DoBuildDoors(); -void DoPathPlotter(); +void DoPathPlotter( ui::Window main_window ); void DoPitBuilder(); void DoCTFColourChanger(); void DoMergePatches(); -- 2.39.2