]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge commit '2de8ee725b2a6e54e21d5e217ae453ee115b913a' into garux-merge
authorThomas Debesse <dev@illwieckz.net>
Sat, 23 Feb 2019 21:40:57 +0000 (22:40 +0100)
committerThomas Debesse <dev@illwieckz.net>
Sun, 24 Feb 2019 00:30:40 +0000 (01:30 +0100)
13 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
radiant/texwindow.h
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_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..d001fd702588d5c1fd94b509a7274ab9c366cb82 100644 (file)
 #include "debugging/debugging.h"
 #include "property.h"
 
+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 );
+       }
+}
+
 class ToggleItem {
     Callback<void(const Callback<void(bool)> &)> m_exportCallback;
     typedef std::list<Callback<void(bool)>> ImportCallbacks;
index 11b6efeb21cd043373859011100ac7a7d676efd0..eee5b58202519fb0147a8877881d24566e6a120e 100644 (file)
 inline void CHECK_RESTORE( ui::Widget w ){
        if ( gpointer_to_int( g_object_get_data( G_OBJECT( w ), "was_mapped" ) ) != 0 ) {
                w.show();
+               /* 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 );
+               }
        }
 }
 
@@ -90,6 +96,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 1be74bf7caf67d3aec9ff561eca2f7c3252b8648..22c6150ae848933b2fa08319ef44a8122b4e43e3 100644 (file)
@@ -57,6 +57,14 @@ 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 );
+       /* 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 );
+       }
        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 208d8043b79a416b15cb1fa3dba8f78bd7d582c5..c8078621f3a97f79e889d45c0e82f699c623c3aa 100644 (file)
@@ -3061,6 +3061,8 @@ void MainFrame::Create(){
                                window.add(frame);
                        }
                        CamWnd_setParent( *m_pCamWnd, window );
+                       /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+                       g_object_set_data( G_OBJECT( window ), "glwidget", CamWnd_getWidget( *m_pCamWnd ) );
 
                        g_floating_windows.push_back( window );
                }
@@ -3080,6 +3082,8 @@ void MainFrame::Create(){
                                window.add(frame);
                        }
                        XY_Top_Shown_Construct( window );
+                       /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+                       g_object_set_data( G_OBJECT( window ), "glwidget", m_pXYWnd->GetWidget() );
 
                        g_floating_windows.push_back( window );
                }
@@ -3099,6 +3103,8 @@ void MainFrame::Create(){
                        }
 
                        XZ_Front_Shown_Construct( window );
+                       /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+                       g_object_set_data( G_OBJECT( window ), "glwidget", m_pXZWnd->GetWidget() );
 
                        g_floating_windows.push_back( window );
                }
@@ -3118,6 +3124,8 @@ void MainFrame::Create(){
                        }
 
                        YZ_Side_Shown_Construct( window );
+                       /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+                       g_object_set_data( G_OBJECT( window ), "glwidget", m_pYZWnd->GetWidget() );
 
                        g_floating_windows.push_back( window );
                }
@@ -3125,6 +3133,9 @@ void MainFrame::Create(){
                {
                        auto frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
                        g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() );
+                       /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+                       g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() );
+
                }
 
                GroupDialog_show();
@@ -3158,6 +3169,8 @@ void MainFrame::Create(){
                {
             auto frame = create_framed_widget( TextureBrowser_constructWindow( window ) );
                        g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() );
+                       /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+                       g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() );
                }
        }
 
index 1d766aea237eb16877f37e8fdc43af63df1cb009..7a24d67fd18592acbbc7d7ea0a1c97ffe33dbebb 100644 (file)
@@ -715,7 +715,7 @@ public:
 void realise(){
        m_realiseCallbacks();
        /* texturebrowser tree update on vfs restart */
-       TextureBrowser_constructTreeStore();
+//     TextureBrowser_constructTreeStore();
 }
 
 void unrealise(){
@@ -1869,6 +1869,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" ));
 
@@ -2174,22 +2178,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
                g_TextureBrowser.m_scr_win_tree = ui::ScrolledWindow(ui::New);
@@ -2247,9 +2273,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
                        g_TextureBrowser.m_scr_win_tags = ui::ScrolledWindow(ui::New);
@@ -2597,6 +2628,8 @@ void TextureBrowser_RefreshShaders(){
 
                ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" );
                GlobalShaderSystem().refresh();
+               /* texturebrowser tree update on vfs restart */
+               TextureBrowser_constructTreeStore();
                UpdateAllWindows();
 
                TextureBrowser_ShowDirectory( GlobalTextureBrowser(), dirName );
@@ -2606,6 +2639,8 @@ void TextureBrowser_RefreshShaders(){
        else{
                ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" );
                GlobalShaderSystem().refresh();
+               /* texturebrowser tree update on vfs restart */
+               TextureBrowser_constructTreeStore();
                UpdateAllWindows();
        }
 }
@@ -2867,3 +2902,7 @@ void TextureBrowser_Destroy(){
 
        Textures_setModeChangedNotify( Callback<void()>() );
 }
+
+ui::Widget TextureBrowser_getGLWidget(){
+       return GlobalTextureBrowser().m_gl_widget;
+}
index 2d5125e4b0ac59755ca9ad3a9164ef8660fc09eb..d354c9dfd00f4dbfc26c67fd240b2fba813e5fb9 100644 (file)
@@ -56,4 +56,6 @@ void TextureBrowser_addShadersRealiseCallback( const SignalHandler& handler );
 
 void TextureBrowser_RefreshShaders();
 
+ui::Widget TextureBrowser_getGLWidget();
+
 #endif
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_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