]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
contrib/prtview: center config window on main window
authorThomas Debesse <dev@illwieckz.net>
Sat, 4 Apr 2020 04:23:10 +0000 (06:23 +0200)
committerThomas Debesse <dev@illwieckz.net>
Sat, 4 Apr 2020 07:54:55 +0000 (09:54 +0200)
also center color picker on config window

contrib/prtview/ConfigDialog.cpp
contrib/prtview/ConfigDialog.h
contrib/prtview/prtview.cpp

index 1d7f2743499b4a31460baa1b26376d230d39bb14..688a66b18f20223bf611af831e12dee113208642 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <gtk/gtk.h>
 #include <uilib/uilib.h>
+#include "gtkutil/dialog.h"
 #include "gtkutil/pointer.h"
 
 #include "iscenegraph.h"
@@ -28,6 +29,8 @@
 #include "prtview.h"
 #include "portals.h"
 
+ui::Window config_dialog{ui::null};
+
 static void dialog_button_callback( ui::Widget widget, gpointer data ){
        int *loop, *ret;
 
@@ -39,7 +42,7 @@ static void dialog_button_callback( ui::Widget widget, gpointer data ){
        *ret = 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;
@@ -58,6 +61,7 @@ static int DoColor( PackedColour *c ){
        clr.green = (guint16) (GetBValue(*c) * (65535 / 255));
 
        auto dlg = ui::Widget::from(gtk_color_selection_dialog_new( "Choose Color" ));
+       gtk_window_set_transient_for( GTK_WINDOW( dlg ), config_dialog );
        gtk_color_selection_set_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(dlg)) ), &clr );
        dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
        dlg.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
@@ -233,17 +237,16 @@ static void OnClip(ui::Widget widget, gpointer data ){
        SceneChangeNotify();
 }
 
-void DoConfigDialog(){
+void DoConfigDialog( ui::Window main_window ){
        int loop = 1, ret = IDCANCEL;
+       ModalDialog dialog;
 
-       auto dlg = ui::Window( ui::window_type::TOP );
-       gtk_window_set_title( dlg, "Portal Viewer Configuration" );
-       dlg.connect( "delete_event",
-                                               G_CALLBACK( dialog_delete_callback ), NULL );
-       dlg.connect( "destroy",
-                                               G_CALLBACK( gtk_widget_destroy ), NULL );
+       auto dlg = main_window.create_dialog_window( "Portal Viewer Configuration", G_CALLBACK( custom_dialog_delete_callback ), &dialog );
+       
+       dlg.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
        g_object_set_data( G_OBJECT( dlg ), "loop", &loop );
        g_object_set_data( G_OBJECT( dlg ), "ret", &ret );
+       config_dialog = dlg;
 
        auto vbox = ui::VBox( FALSE, 5 );
        vbox.show();
index a9725847e6294506947494317ed5f5fd0f2505ad..e17e41267790cd0f44bbb7136cdf2e6d6284427e 100644 (file)
@@ -20,6 +20,8 @@
 #if !defined( INCLUDED_CONFIGDIALOG_H )
 #define INCLUDED_CONFIGDIALOG_H
 
-void DoConfigDialog();
+#include <uilib/uilib.h>
+
+void DoConfigDialog( ui::Window main_window );
 
 #endif
index 62aa2a9f4456f9b3456caae758fd205d4ae17225..14aeec1325bb80feec981cda000f8170d6c21bb0 100644 (file)
@@ -65,7 +65,7 @@ const char *TRANS_3D = "Transparency";
 const char *CLIP_RANGE = "ClipRange";
 const char *CLIP = "Clip";
 
-ui::Window main_window{ui::null};
+static ui::Window main_window{ui::null};
 
 void PrtView_construct(){
        StringOutputStream tmp( 64 );
@@ -282,7 +282,7 @@ void QERPlug_Dispatch( const char* p, float* vMin, float* vMax, bool bSingleBrus
                }
        }
        else if ( !strcmp( p,Q3R_CMD_OPTIONS ) ) {
-               DoConfigDialog();
+               DoConfigDialog( main_window );
                SaveConfig();
 
                SceneChangeNotify();