From: Thomas Debesse Date: Tue, 21 Jun 2022 02:43:16 +0000 (+0200) Subject: Merge commit 'e984b9f54a0c733aab34a8ec19724dc4114ade28' into master-merge X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=484defd6cf1148d020be9d3e548870ab85181b37;p=xonotic%2Fnetradiant.git Merge commit 'e984b9f54a0c733aab34a8ec19724dc4114ade28' into master-merge --- 484defd6cf1148d020be9d3e548870ab85181b37 diff --cc libs/gtkutil/paned.h index 951a72d7,7bb5dc1b..1a19d9c5 --- a/libs/gtkutil/paned.h +++ b/libs/gtkutil/paned.h @@@ -22,20 -22,8 +22,19 @@@ #if !defined( INCLUDED_GTKUTIL_PANED_H ) #define INCLUDED_GTKUTIL_PANED_H ++#include + #include + -ui::Widget create_split_views( ui::Widget topleft, ui::Widget botleft, ui::Widget topright, ui::Widget botright, ui::Widget& vsplit1, ui::Widget& vsplit2 ); +class PanedState +{ +public: +float position; +int size; +}; + +gboolean hpaned_allocate( ui::Widget widget, GtkAllocation* allocation, PanedState* paned ); +gboolean vpaned_allocate( ui::Widget widget, GtkAllocation* allocation, PanedState* paned ); +gboolean paned_position( ui::Widget widget, gpointer dummy, PanedState* paned ); - ui::HPaned create_split_views( ui::Widget topleft, ui::Widget topright, ui::Widget botleft, ui::Widget botright ); - ++ui::Widget create_split_views( ui::Widget topleft, ui::Widget botleft, ui::Widget topright, ui::Widget botright, ui::Widget& vsplit1, ui::Widget& vsplit2 ); #endif diff --cc radiant/mainframe.cpp index dd18db71,86bddbe7..46960e22 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@@ -3252,13 -3172,20 +3253,17 @@@ void MainFrame::Create() { auto frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) ); g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() ); - -#ifndef GARUX_GTK_WORKAROUND - /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ - g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() ); -#endif + WORKAROUND_GOBJECT_SET_GLWIDGET( GroupDialog_getWindow(), TextureBrowser_getGLWidget() ); } + // FIXME: find a way to do it with newer syntax + // m_vSplit = 0; + // m_hSplit = 0; + // m_vSplit2 = 0; + GroupDialog_show(); } - else // 4 way + else if ( CurrentStyle() == eSplit ) { m_pCamWnd = NewCamWnd(); GlobalCamera_setCamWnd( *m_pCamWnd ); @@@ -3287,60 -3214,12 +3292,70 @@@ { auto frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) ); g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() ); -#ifndef GARUX_GTK_WORKAROUND - /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ - g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() ); -#endif + + WORKAROUND_GOBJECT_SET_GLWIDGET( window, TextureBrowser_getGLWidget() ); } } + else // single window + { + m_pCamWnd = NewCamWnd(); + GlobalCamera_setCamWnd( *m_pCamWnd ); + CamWnd_setParent( *m_pCamWnd, window ); + + ui::Widget camera = CamWnd_getWidget( *m_pCamWnd ); + + m_pYZWnd = new XYWnd(); + m_pYZWnd->SetViewType( YZ ); + + ui::Widget yz = m_pYZWnd->GetWidget(); + + m_pXYWnd = new XYWnd(); + m_pXYWnd->SetViewType( XY ); + + ui::Widget xy = m_pXYWnd->GetWidget(); + + m_pXZWnd = new XYWnd(); + m_pXZWnd->SetViewType( XZ ); + + ui::Widget xz = m_pXZWnd->GetWidget(); + + ui::Widget hsplit = ui::HPaned(ui::New); + vbox.pack_start( hsplit, TRUE, TRUE, 0 ); + hsplit.show(); + - ui::Widget split = create_split_views( camera, yz, xy, xz ); ++ /* Before merging NetRadiantCustom: ++ ui::Widget split = create_split_views( camera, yz, xy, xz ); */ ++ m_hSplit = create_split_views( camera, yz, xy, xz, m_vSplit, m_vSplit2 ); + + ui::Widget vsplit = ui::VPaned(ui::New); + vsplit.show(); + + // textures + ui::Widget texture_window = create_framed_widget( TextureBrowser_constructWindow( window ) ); + + // console + ui::Widget console_window = create_framed_widget( Console_constructWindow( window ) ); + - gtk_paned_add1( GTK_PANED( hsplit ), split ); ++ /* Before merging NetRadiantCustom: ++ gtk_paned_add1( GTK_PANED( hsplit ), m_hSplit ); + gtk_paned_add2( GTK_PANED( hsplit ), vsplit ); + + gtk_paned_add1( GTK_PANED( vsplit ), texture_window ); + gtk_paned_add2( GTK_PANED( vsplit ), console_window ); ++ */ ++ ++ gtk_paned_pack1( GTK_PANED( hsplit ), m_hSplit, TRUE, TRUE ); ++ gtk_paned_pack2( GTK_PANED( hsplit ), vsplit, TRUE, TRUE); ++ ++ gtk_paned_pack1( GTK_PANED( vsplit ), texture_window, TRUE, TRUE ); ++ gtk_paned_pack2( GTK_PANED( vsplit ), console_window, TRUE, TRUE ); + + hsplit.connect( "size_allocate", G_CALLBACK( hpaned_allocate ), &g_single_hpaned ); + hsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_single_hpaned ); + + vsplit.connect( "size_allocate", G_CALLBACK( vpaned_allocate ), &g_single_vpaned ); + vsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_single_vpaned ); + } EntityList_constructWindow( window ); PreferencesDialog_constructWindow( window ); @@@ -3582,9 -3461,76 +3597,76 @@@ void MainFrame_toggleFullscreen() } } + class MaximizeView + { + public: + MaximizeView(): m_maximized( false ){ + } + void toggle(){ + return m_maximized ? restore() : maximize(); + } + private: + bool m_maximized; + int m_vSplitPos; + int m_vSplit2Pos; + int m_hSplitPos; + + void restore(){ + m_maximized = false; + gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), m_vSplitPos ); + gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), m_vSplit2Pos ); + gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), m_hSplitPos ); + } + + void maximize(){ + m_maximized = true; + m_vSplitPos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_vSplit ) ); + m_vSplit2Pos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_vSplit2 ) ); + m_hSplitPos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_hSplit ) ); + + int vSplitX, vSplitY, vSplit2X, vSplit2Y, hSplitX, hSplitY; + gdk_window_get_origin( GTK_WIDGET( g_pParentWnd->m_vSplit )->window, &vSplitX, &vSplitY ); + gdk_window_get_origin( GTK_WIDGET( g_pParentWnd->m_vSplit2 )->window, &vSplit2X, &vSplit2Y ); + gdk_window_get_origin( GTK_WIDGET( g_pParentWnd->m_hSplit )->window, &hSplitX, &hSplitY ); + + vSplitY += m_vSplitPos; + vSplit2Y += m_vSplit2Pos; + hSplitX += m_hSplitPos; + + int cur_x, cur_y; + Sys_GetCursorPos( MainFrame_getWindow(), &cur_x, &cur_y ); + + if( cur_x > hSplitX ){ + gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), 0 ); + } + else{ + gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), 9999 ); + } + if( cur_y > vSplitY ){ + gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), 0 ); + } + else{ + gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), 9999 ); + } + if( cur_y > vSplit2Y ){ + gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), 0 ); + } + else{ + gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), 9999 ); + } + } + }; + + MaximizeView g_maximizeview; + + void Maximize_View(){ + if( g_pParentWnd != 0 && g_pParentWnd->m_vSplit != 0 && g_pParentWnd->m_vSplit2 != 0 && g_pParentWnd->m_hSplit != 0 ) + g_maximizeview.toggle(); + } + - #include "preferencesystem.h" #include "stringio.h" +#include "transformpath/transformpath.h" void MainFrame_Construct(){ GlobalCommands_insert( "OpenManual", makeCallbackF(OpenHelpURL), Accelerator( GDK_KEY_F1 ) ); @@@ -3666,7 -3612,6 +3748,7 @@@ GlobalCommands_insert( "ColorSchemeQER", makeCallbackF(ColorScheme_QER) ); GlobalCommands_insert( "ColorSchemeBlackAndGreen", makeCallbackF(ColorScheme_Black) ); GlobalCommands_insert( "ColorSchemeYdnar", makeCallbackF(ColorScheme_Ydnar) ); - GlobalCommands_insert("ColorSchemeAdwaitaDark", makeCallbackF(ColorScheme_AdwaitaDark)); ++ GlobalCommands_insert( "ColorSchemeAdwaitaDark", makeCallbackF(ColorScheme_AdwaitaDark)); GlobalCommands_insert( "ChooseTextureBackgroundColor", makeCallback( g_ColoursMenu.m_textureback ) ); GlobalCommands_insert( "ChooseGridBackgroundColor", makeCallback( g_ColoursMenu.m_xyback ) ); GlobalCommands_insert( "ChooseGridMajorColor", makeCallback( g_ColoursMenu.m_gridmajor ) );