Skip to content

Commit

Permalink
AUI panels now take up the entire window
Browse files Browse the repository at this point in the history
Use a nasty hack to workaround AUI's inability to take into account BestSize()
when initially adding a docked pane. The panes are all added with a minimum
size of approximately half the window, then those minimum sizes are reset to a
much smaller value after the first Update(). This results in panels which take
up the entire window to begin with, but can still be shrunk by the user if
required.
  • Loading branch information
Matthew Mott committed Feb 19, 2021
1 parent 275e8a8 commit 29d4cb0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
37 changes: 29 additions & 8 deletions radiant/ui/mainframe/AuiLayout.cpp
Expand Up @@ -23,11 +23,15 @@ namespace
{
const std::string RKEY_ROOT = "user/ui/mainFrame/aui";

// Minimum size of docked panels
const wxSize MIN_SIZE(128, 128);

// Return a pane info with default options
wxAuiPaneInfo DEFAULT_PANE_INFO(const std::string& caption)
wxAuiPaneInfo DEFAULT_PANE_INFO(const std::string& caption,
const wxSize& minSize)
{
return wxAuiPaneInfo().Caption(caption).Layer(1).CloseButton(false)
.MinSize(wxSize(128, 128));
.MinSize(minSize);
}
}

Expand All @@ -37,6 +41,12 @@ AuiLayout::AuiLayout()
{
}

void AuiLayout::addPane(wxWindow* window, const wxAuiPaneInfo& info)
{
_auiMgr.AddPane(window, info);
_panes.push_back(window);
}

std::string AuiLayout::getName()
{
return AUI_LAYOUT_NAME;
Expand Down Expand Up @@ -85,12 +95,23 @@ void AuiLayout::activate()

// Add the camera and notebook to the left, as with the Embedded layout, and
// the 2D view on the right
_auiMgr.AddPane(_camWnd->getMainWidget(),
DEFAULT_PANE_INFO(_("Camera")).Left().Position(0));
_auiMgr.AddPane(notebookPanel,
DEFAULT_PANE_INFO(_("Properties")).Left().Position(1));
_auiMgr.AddPane(xywnd->getGLWidget(),
DEFAULT_PANE_INFO(_("2D View")).Right());
wxSize size = topLevelParent->GetSize();
size.Scale(0.5, 1.0);
addPane(xywnd->getGLWidget(),
DEFAULT_PANE_INFO(_("2D View"), size).Right());
addPane(_camWnd->getMainWidget(),
DEFAULT_PANE_INFO(_("Camera"), size).Left().Position(0));
addPane(notebookPanel,
DEFAULT_PANE_INFO(_("Properties"), size).Left().Position(1));
_auiMgr.Update();

// Nasty hack to get the panes sized properly. Since BestSize() is
// completely ignored (at least on Linux), we have to add the panes with a
// large *minimum* size and then reset this size after the initial addition.
for (wxWindow* w: _panes)
{
_auiMgr.GetPane(w).MinSize(MIN_SIZE);
}
_auiMgr.Update();

// Hide the camera toggle option for non-floating views
Expand Down
7 changes: 7 additions & 0 deletions radiant/ui/mainframe/AuiLayout.h
Expand Up @@ -26,9 +26,16 @@ class AuiLayout: public IMainFrameLayout
// Main AUI manager
wxAuiManager _auiMgr;

// List of panes managed by the AUI manager
using Panes = std::list<wxWindow*>;
Panes _panes;

// Main constructor
AuiLayout();

// Add a pane to the wxAuiManager and store it in the list
void addPane(wxWindow* window, const wxAuiPaneInfo& info);

public:
// IMainFrameLayout implementation
std::string getName() override;
Expand Down

0 comments on commit 29d4cb0

Please sign in to comment.