]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge commit '71ef2336cbab4cca1d1b228cdb89601f6569c107' into master-merge
authorThomas Debesse <dev@illwieckz.net>
Mon, 20 Jun 2022 02:48:59 +0000 (04:48 +0200)
committerThomas Debesse <dev@illwieckz.net>
Mon, 20 Jun 2022 02:48:59 +0000 (04:48 +0200)
14 files changed:
libs/gtkutil/toolbar.cpp
libs/gtkutil/toolbar.h
libs/gtkutil/widget.h
libs/gtkutil/window.cpp
radiant/groupdialog.cpp
radiant/gtkmisc.cpp
radiant/gtkmisc.h
radiant/mainframe.cpp
radiant/texwindow.cpp
setup/data/tools-src/texbro_tags.xcf [new file with mode: 0644]
setup/data/tools/bitmaps/texbro_gtk-find-and-replace.png [new file with mode: 0644]
setup/data/tools/bitmaps/texbro_refresh.png [new file with mode: 0644]
setup/data/tools/bitmaps/texbro_tags.png [new file with mode: 0644]
setup/data/tools/bitmaps/texbro_view.png [new file with mode: 0644]

index 049d05ec1fc62fd4684ecb79661fb54077a70551..8df8802d27d1b250d8c16d2c1ed8909b63d3ec41 100644 (file)
@@ -37,6 +37,12 @@ void toolbar_append( ui::Toolbar toolbar, ui::ToolItem button, const char* descr
        toolbar.add(button);
 }
 
+ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon ){
+       auto button = ui::ToolButton::from(gtk_tool_button_new(new_local_image(icon), nullptr));
+       toolbar_append(toolbar, button, description);
+       return button;
+}
+
 ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback<void()>& callback ){
        auto button = ui::ToolButton::from(gtk_tool_button_new(new_local_image(icon), nullptr));
        button_connect_callback(button, callback);
index f3481783028943c680be1f49d4522905f802f7fd..c995e1be4a3879dfe5d013ffe73d9f2f66034cb2 100644 (file)
@@ -28,6 +28,7 @@
 class Command;
 class Toggle;
 
+ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon );
 ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback<void()>& callback );
 ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Command& command );
 ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback<void()>& callback );
index 28395b3516da90470c318b408d330fb85e498810..ff93211dc632e46e85983530be09c7f13b4d98ba 100644 (file)
 #include "debugging/debugging.h"
 #include "property.h"
 
+#define GARUX_GTK_WORKAROUND
+#ifndef GARUX_GTK_WORKAROUND
+inline bool widget_is_visible( GtkWidget* widget ){
+       return GTK_WIDGET_VISIBLE( widget ) != FALSE;
+}
+
+inline void widget_set_visible( GtkWidget* widget, bool show ){
+       if ( show ) {
+               /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+               GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( widget ), "glwidget" ) );
+               if ( glwidget ){
+                       //if ( widget_is_visible( glwidget ) )
+                               //globalOutputStream() << "glwidget have been already visible :0\n"; /* is not hidden aswell, according to this */
+                       gtk_widget_hide( glwidget );
+                       gtk_widget_show( glwidget );
+               }
+               gtk_widget_show( widget );
+       }
+       else
+       {
+               gtk_widget_hide( widget );
+       }
+}
+#endif
+
 class ToggleItem {
     Callback<void(const Callback<void(bool)> &)> m_exportCallback;
     typedef std::list<Callback<void(bool)>> ImportCallbacks;
index 80b79738892daabe2590316fc95c1cfa999fa3ba..c8671a2fbcf0ab25976c5658d26a02d6abf87e44 100644 (file)
@@ -39,6 +39,15 @@ inline void CHECK_RESTORE( ui::Widget w ){
 #endif // WORKAROUND_WINDOWS_GTK2_GLWIDGET
 
                w.show();
+#define GARUX_GTK_WORKAROUND
+#ifndef GARUX_GTK_WORKAROUND
+               /* workaround for gtk 2.24 issue: not displayed glwidget after min/restore */
+               GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( w ), "glwidget" ) );
+               if ( glwidget ){
+                       gtk_widget_hide( glwidget );
+                       gtk_widget_show( glwidget );
+               }
+#endif
        }
 }
 
@@ -119,6 +128,23 @@ ui::Window create_floating_window( const char* title, ui::Window parent ){
                connect_floating_window_destroy_present( window, parent );
                g_object_set_data( G_OBJECT( window ), "floating_handler", gint_to_pointer( connect_floating( parent, window ) ) );
                window.connect( "destroy", G_CALLBACK( destroy_disconnect_floating ), parent );
+/*
+               //gtk_window_set_type_hint (window,GDK_WINDOW_TYPE_HINT_UTILITY);
+               //gtk_window_set_type_hint (window,GDK_WINDOW_TYPE_HINT_DIALOG);
+               gtk_window_set_keep_above ( window, TRUE );
+               GtkWidget* widget = GTK_WIDGET( window );
+               gtk_widget_realize ( widget );
+               GdkWindow* gdk_window = gtk_widget_get_window( widget );
+               //gdk_window_set_decorations ( gdk_window, (GdkWMDecoration)(GDK_DECOR_BORDER|GDK_DECOR_RESIZEH|GDK_DECOR_TITLE|GDK_DECOR_MENU|GDK_DECOR_MINIMIZE|GDK_DECOR_MAXIMIZE) );
+               //gdk_window_set_functions ( gdk_window, (GdkWMFunction)( GDK_FUNC_RESIZE|GDK_FUNC_MOVE|GDK_FUNC_MINIMIZE|GDK_FUNC_MAXIMIZE|GDK_FUNC_CLOSE ) );
+               //gdk_window_set_decorations ( gdk_window, (GdkWMDecoration)( GDK_DECOR_ALL ) );
+               //gdk_window_set_functions ( gdk_window, (GdkWMFunction)( GDK_FUNC_ALL ) );
+               //gdk_window_set_type_hint ( gdk_window, GDK_WINDOW_TYPE_HINT_DIALOG );
+               //gdk_window_set_type_hint ( gdk_window, GDK_WINDOW_TYPE_HINT_UTILITY );
+               //gdk_window_set_type_hint ( gdk_window, GDK_WINDOW_TYPE_HINT_NORMAL );
+               gdk_window_set_skip_taskbar_hint ( gdk_window, TRUE );
+               gdk_window_set_skip_pager_hint ( gdk_window, TRUE );
+*/
        }
 
        return window;
index d96bc7c271bea3be9beae9c5f8974eb08d7bd0d0..b7054e2b54a53e7bb56d4f917ebfafeab3da9f4f 100644 (file)
@@ -59,6 +59,17 @@ void Create( ui::Window parent );
 void Show(){
        // workaround for strange gtk behaviour - modifying the contents of a window while it is not visible causes the window position to change without sending a configure_event
        m_position_tracker.sync( m_window );
+#define GARUX_GTK_WORKAROUND
+#ifndef GARUX_GTK_WORKAROUND
+       /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+       GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( m_window ), "glwidget" ) );
+       if ( glwidget ){
+               //if ( widget_is_visible( glwidget ) )
+                       //globalOutputStream() << "glwidget have been already visible :0\n"; /* is not hidden aswell, according to this */
+               gtk_widget_hide( glwidget );
+               gtk_widget_show( glwidget );
+       }
+#endif
        m_window.show();
 }
 void Hide(){
index 85554502c3e1d4d4eef18ea229a4f665e3b5feb2..702f6ac4e38a339b2c7743bfccf60608495d7400 100644 (file)
@@ -43,7 +43,6 @@
 #include "gtkutil/dialog.h"
 #include "gtkutil/filechooser.h"
 #include "gtkutil/menu.h"
-#include "gtkutil/toolbar.h"
 #include "commands.h"
 
 
index e867d6a213b6611a38836666e246758725cb7231..2019452b90720b85b39922c1567ffdf63c3e16dd 100644 (file)
@@ -32,6 +32,7 @@
 #define INCLUDED_GTKMISC_H
 
 #include <uilib/uilib.h>
+#include "gtkutil/toolbar.h"
 
 void command_connect_accelerator( const char* commandName );
 void command_disconnect_accelerator( const char* commandName );
index df57ccb7d3a2da2ea77fce1901ee5fb82b05110b..c413708181aa6dc9a0306064202a9827619b01cb 100644 (file)
@@ -3076,16 +3076,20 @@ void MainFrame::Create(){
        {
                {
                        ui::Widget hsplit = ui::HPaned(ui::New);
-                       m_vSplit = hsplit;
+                       m_hSplit = hsplit;
+
                        vbox.pack_start( hsplit, TRUE, TRUE, 0 );
                        hsplit.show();
+
                        {
                                ui::Widget vsplit = ui::VPaned(ui::New);
                                vsplit.show();
                                m_vSplit = vsplit;
+
                                ui::Widget vsplit2 = ui::VPaned(ui::New);
                                vsplit2.show();
-                               m_vSplit = vsplit2;
+                               m_vSplit2 = vsplit2;
+
                                if ( CurrentStyle() == eRegular ){
                                        gtk_paned_add1( GTK_PANED( hsplit ), vsplit );
                                        gtk_paned_add2( GTK_PANED( hsplit ), vsplit2 );
@@ -3103,8 +3107,8 @@ void MainFrame::Create(){
                                m_pXYWnd = new XYWnd();
                                m_pXYWnd->SetViewType( XY );
                                ui::Widget xy_window = ui::Widget(create_framed_widget( m_pXYWnd->GetWidget( ) ));
-
                                gtk_paned_add1( GTK_PANED( vsplit ), xy_window );
+
                                {
                                        // camera
                                        m_pCamWnd = NewCamWnd();
index 81d1edc08bdefe15412af379515cd96a3dbb38d0..32c4a8137b11db24039989795297b717b2326f8d 100644 (file)
@@ -726,7 +726,7 @@ public:
 void realise(){
        m_realiseCallbacks();
        /* texturebrowser tree update on vfs restart */
-       TextureBrowser_constructTreeStore();
+//     TextureBrowser_constructTreeStore();
 }
 
 void unrealise(){
@@ -1353,24 +1353,24 @@ void Texture_Draw( TextureBrowser& textureBrowser ){
                                glEnable( GL_TEXTURE_2D );
                                glLineWidth( 1 );
                        }
-                               // highlight in-use textures
+                       // highlight in-use textures
                        else if ( !textureBrowser.m_hideUnused && shader->IsInUse() ) {
                        //1px with float
                                float xf = (float)x;
                                float yf = (float)( y - TextureBrowser_fontHeight( textureBrowser ) );
-                                       glColor3f( 0.5,1,0.5 );
-                                       glDisable( GL_TEXTURE_2D );
-                                       glBegin( GL_LINE_LOOP );
+                               glColor3f( 0.5,1,0.5 );
+                               glDisable( GL_TEXTURE_2D );
+                               glBegin( GL_LINE_LOOP );
                                glVertex2f( xf - 3.5,yf + 3.5 );
                                glVertex2f( xf - 3.5,yf - nHeight - 3.5 );
                                glVertex2f( xf + 3.5 + nWidth,yf - nHeight - 3.5 );
                                glVertex2f( xf + 3.5 + nWidth,yf + 3.5 );
-                                       glEnd();
-                                       glEnable( GL_TEXTURE_2D );
-                               }
+                               glEnd();
+                               glEnable( GL_TEXTURE_2D );
+                       }
 
                        // draw checkerboard for transparent textures
-                       if ( g_TextureBrowser_enableAlpha )
+                       if ( g_TextureBrowser_enableAlpha )
                        {
                                glDisable( GL_TEXTURE_2D );
                                glBegin( GL_QUADS );
@@ -1945,6 +1945,10 @@ ui::MenuItem TextureBrowser_constructViewMenu( ui::Menu menu ){
        return textures_menu_item;
 }
 
+void Popup_View_Menu( GtkWidget *widget, GtkMenu *menu ){
+       gtk_menu_popup( menu, NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time() );
+}
+
 ui::MenuItem TextureBrowser_constructToolsMenu( ui::Menu menu ){
        ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_Tools" ));
 
@@ -2290,22 +2294,44 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
        table.attach(vbox, {0, 1, 1, 3}, {GTK_FILL, GTK_FILL});
        vbox.show();
 
-       ui::Widget menu_bar{ui::null};
+       // ui::Widget menu_bar{ui::null};
+       auto toolbar = ui::Toolbar::from( gtk_toolbar_new() );
 
        { // menu bar
-               menu_bar = ui::Widget::from(gtk_menu_bar_new());
+               // menu_bar = ui::Widget::from(gtk_menu_bar_new());
                auto menu_view = ui::Menu(ui::New);
-               auto view_item = TextureBrowser_constructViewMenu( menu_view );
-               gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view );
-               gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), view_item );
+               // auto view_item = TextureBrowser_constructViewMenu( menu_view );
+               TextureBrowser_constructViewMenu( menu_view );
+               // gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view );
+               // gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), view_item );
+
+               //gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( toolbar ), 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0 );
+               gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( toolbar ), FALSE, FALSE, 0 );
+
+               //view menu button
+               {
+                       auto button = toolbar_append_button( toolbar, "View", "texbro_view.png" );
+                       button.dimensions( 22, 22 );
+                       button.connect( "clicked", G_CALLBACK( Popup_View_Menu ), menu_view );
+               }
+               {
+                       auto button = toolbar_append_button( toolbar, "Find / Replace...", "texbro_gtk-find-and-replace.png", "FindReplaceTextures" );
+                       button.dimensions( 22, 22 );
+               }
+               {
+                       auto button = toolbar_append_button( toolbar, "Flush & Reload Shaders", "texbro_refresh.png", "RefreshShaders" );
+                       button.dimensions( 22, 22 );
+               }
+               toolbar.show();
 
+/*
                auto menu_tools = ui::Menu(ui::New);
                auto tools_item = TextureBrowser_constructToolsMenu( menu_tools );
                gtk_menu_item_set_submenu( GTK_MENU_ITEM( tools_item ), menu_tools );
                gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tools_item );
-
-               table.attach(menu_bar, {0, 3, 0, 1}, {GTK_FILL, GTK_SHRINK});
-               menu_bar.show();
+*/
+               // table.attach(menu_bar, {0, 3, 0, 1}, {GTK_FILL, GTK_SHRINK});
+               // menu_bar.show();
        }
        { // Texture TreeView
                textureBrowser.m_scr_win_tree = ui::ScrolledWindow(ui::New);
@@ -2371,9 +2397,14 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
                }
                { // tag menu bar
                        auto menu_tags = ui::Menu(ui::New);
-                       auto tags_item = TextureBrowser_constructTagsMenu( menu_tags );
-                       gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags );
-                       gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tags_item );
+                       // auto tags_item = TextureBrowser_constructTagsMenu( menu_tags );
+                       TextureBrowser_constructTagsMenu( menu_tags );
+                       // gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags );
+                       // gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tags_item );
+
+                       auto button = toolbar_append_button( toolbar, "Tags", "texbro_tags.png" );
+                       button.dimensions( 22, 22 );
+                       button.connect( "clicked", G_CALLBACK( Popup_View_Menu ), menu_tags );
                }
                { // Tag TreeView
                        textureBrowser.m_scr_win_tags = ui::ScrolledWindow(ui::New);
@@ -2785,6 +2816,8 @@ void TextureBrowser_RefreshShaders(){
 
                ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" );
                GlobalShaderSystem().refresh();
+               /* texturebrowser tree update on vfs restart */
+               TextureBrowser_constructTreeStore();
                UpdateAllWindows();
 
                TextureBrowser_ShowDirectory( GlobalTextureBrowser(), dirName );
@@ -2794,6 +2827,8 @@ void TextureBrowser_RefreshShaders(){
        else{
                ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" );
                GlobalShaderSystem().refresh();
+               /* texturebrowser tree update on vfs restart */
+               TextureBrowser_constructTreeStore();
                UpdateAllWindows();
        }
 }
@@ -3059,6 +3094,10 @@ void TextureBrowser_Destroy(){
        Textures_setModeChangedNotify( Callback<void()>() );
 }
 
+ui::Widget TextureBrowser_getGLWidget(){
+       return GlobalTextureBrowser().m_gl_widget;
+}
+
 #if WORKAROUND_WINDOWS_GTK2_GLWIDGET
 ui::GLArea TextureBrowser_getGLWidget(){
        return GlobalTextureBrowser().m_gl_widget;
diff --git a/setup/data/tools-src/texbro_tags.xcf b/setup/data/tools-src/texbro_tags.xcf
new file mode 100644 (file)
index 0000000..2719ad5
Binary files /dev/null and b/setup/data/tools-src/texbro_tags.xcf differ
diff --git a/setup/data/tools/bitmaps/texbro_gtk-find-and-replace.png b/setup/data/tools/bitmaps/texbro_gtk-find-and-replace.png
new file mode 100644 (file)
index 0000000..fca34f5
Binary files /dev/null and b/setup/data/tools/bitmaps/texbro_gtk-find-and-replace.png differ
diff --git a/setup/data/tools/bitmaps/texbro_refresh.png b/setup/data/tools/bitmaps/texbro_refresh.png
new file mode 100644 (file)
index 0000000..ed2419a
Binary files /dev/null and b/setup/data/tools/bitmaps/texbro_refresh.png differ
diff --git a/setup/data/tools/bitmaps/texbro_tags.png b/setup/data/tools/bitmaps/texbro_tags.png
new file mode 100644 (file)
index 0000000..8b0da1e
Binary files /dev/null and b/setup/data/tools/bitmaps/texbro_tags.png differ
diff --git a/setup/data/tools/bitmaps/texbro_view.png b/setup/data/tools/bitmaps/texbro_view.png
new file mode 100644 (file)
index 0000000..cf2f4ac
Binary files /dev/null and b/setup/data/tools/bitmaps/texbro_view.png differ