From 8b6812e9b55416a0277b80012e781180c8315588 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Thu, 30 Sep 2021 01:37:09 +0200 Subject: [PATCH] radiant/layouts: add a single-window layout --- libs/gtkutil/paned.cpp | 12 ----- libs/gtkutil/paned.h | 12 +++++ radiant/mainframe.cpp | 68 ++++++++++++++++++++++++--- radiant/mainframe.h | 1 + setup/data/tools/bitmaps/window5.png | Bin 0 -> 207 bytes 5 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 setup/data/tools/bitmaps/window5.png diff --git a/libs/gtkutil/paned.cpp b/libs/gtkutil/paned.cpp index 4f724eef..e664aef4 100644 --- a/libs/gtkutil/paned.cpp +++ b/libs/gtkutil/paned.cpp @@ -20,20 +20,8 @@ */ #include "paned.h" - -#include -#include - #include "frame.h" - -class PanedState -{ -public: -float position; -int size; -}; - gboolean hpaned_allocate(ui::Widget widget, GtkAllocation* allocation, PanedState* paned ){ if ( paned->size != allocation->width ) { paned->size = allocation->width; diff --git a/libs/gtkutil/paned.h b/libs/gtkutil/paned.h index 842996ef..951a72d7 100644 --- a/libs/gtkutil/paned.h +++ b/libs/gtkutil/paned.h @@ -19,11 +19,23 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #if !defined( INCLUDED_GTKUTIL_PANED_H ) #define INCLUDED_GTKUTIL_PANED_H +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 ); #endif diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 17e53efc..3b691f3a 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -2943,6 +2943,9 @@ static gint mainframe_delete( ui::Widget widget, GdkEvent *event, gpointer data return TRUE; } +PanedState g_single_hpaned = { 0.75f, -1, }; +PanedState g_single_vpaned = { 0.75f, -1, }; + void MainFrame::Create(){ ui::Window window = ui::Window( ui::window_type::TOP ); @@ -3027,7 +3030,8 @@ void MainFrame::Create(){ window.show(); - if ( CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft ) { + if ( CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft ) + { { ui::Widget vsplit = ui::VPaned(ui::New); m_vSplit = vsplit; @@ -3064,7 +3068,6 @@ void MainFrame::Create(){ gtk_paned_add2( GTK_PANED( hsplit ), xy_window ); } - // camera m_pCamWnd = NewCamWnd(); GlobalCamera_setCamWnd( *m_pCamWnd ); @@ -3093,7 +3096,8 @@ void MainFrame::Create(){ gtk_paned_set_position( GTK_PANED( m_vSplit2 ), g_layout_globals.nCamHeight ); } - else if ( CurrentStyle() == eFloating ) { + else if ( CurrentStyle() == eFloating ) + { { ui::Window window = ui::Window(create_persistent_floating_window( "Camera", m_window )); global_accel_connect_window( window ); @@ -3187,7 +3191,7 @@ void MainFrame::Create(){ GroupDialog_show(); } - else // 4 way + else if ( CurrentStyle() == eSplit ) { m_pCamWnd = NewCamWnd(); GlobalCamera_setCamWnd( *m_pCamWnd ); @@ -3210,16 +3214,66 @@ void MainFrame::Create(){ ui::Widget xz = m_pXZWnd->GetWidget(); - auto split = create_split_views( camera, yz, xy, xz ); + auto split = create_split_views( camera, yz, xy, xz ); vbox.pack_start( split, TRUE, TRUE, 0 ); { - auto frame = create_framed_widget( TextureBrowser_constructWindow( window ) ); + auto frame = create_framed_widget( TextureBrowser_constructWindow( window ) ); g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() ); 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 ); + + 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 ); + gtk_paned_add2( GTK_PANED( hsplit ), vsplit ); + + gtk_paned_add1( GTK_PANED( vsplit ), texture_window ); + gtk_paned_add2( GTK_PANED( vsplit ), console_window ); + + 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 ); @@ -3384,7 +3438,7 @@ void GlobalGL_sharedContextDestroyed(){ void Layout_constructPreferences( PreferencesPage& page ){ { - const char* layouts[] = { "window1.png", "window2.png", "window3.png", "window4.png" }; + const char* layouts[] = { "window1.png", "window2.png", "window3.png", "window4.png", "window5.png" }; page.appendRadioIcons( "Window Layout", STRING_ARRAY_RANGE( layouts ), diff --git a/radiant/mainframe.h b/radiant/mainframe.h index ca0c4c97..ee7368b1 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -54,6 +54,7 @@ enum EViewStyle eFloating = 1, eSplit = 2, eRegularLeft = 3, + eSingle = 4, }; MainFrame(); diff --git a/setup/data/tools/bitmaps/window5.png b/setup/data/tools/bitmaps/window5.png new file mode 100644 index 0000000000000000000000000000000000000000..24335a50e4ed8fe911bcf6c8078c530d6c2e1ed3 GIT binary patch literal 207 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfv{s5m4R|bXyK<5Ad{|^8G1H*&b+Zb+11J9nY1X+_k666S}0(^q+Os2!@5 zYoEHCv4@rAZG#E3)&T?OI_G^xjSF@qCajxa#%HjC3z0Zb${-N?mc2@ z7qTC2?eP#;Xf%aEl)Y+B-GO&*&us2?H6Fgl{%4)j{LkBcw1CcF@O1TaS?83{1OSzr BN`3$U literal 0 HcmV?d00001 -- 2.39.2