place the selection panel beside what it describes
This commit is contained in:
@@ -172,19 +172,50 @@ void MainWindow::layoutPanels()
|
||||
const QRect worldRect(0, headerH, totalW, totalH - headerH);
|
||||
m_headerBar->setGeometry(0, 0, totalW, headerH);
|
||||
m_gameWorldView->setGeometry(worldRect);
|
||||
// Sizes itself to its buttons and centers along the bottom of the world view
|
||||
// (REQ-UI-BUILD-BAR).
|
||||
m_buildButtonBar->anchorTo(worldRect);
|
||||
// The panel confines itself to what the bar leaves free, so the bar never has to
|
||||
// move for it (REQ-UI-SELECTION-PANEL, REQ-UI-BUILD-BAR).
|
||||
m_selectionPanel->anchorTo(
|
||||
worldRect.adjusted(0, 0, 0, -m_buildButtonBar->getStripHeightPx()));
|
||||
// The opposite corner: bottom-left of the view, sharing the bottom edge with the
|
||||
// bar rather than clearing its whole strip, and rising only if the two would meet.
|
||||
// Anchored after the bar so the geometry it steps around is the current one
|
||||
// (REQ-UI-CONTROLS-PANEL).
|
||||
m_controlsPanel->anchorTo(worldRect, m_buildButtonBar->geometry());
|
||||
m_dimOverlay->setGeometry(0, 0, totalW, totalH);
|
||||
|
||||
// The floating widgets are placed in one ordered pass, each into the space the
|
||||
// earlier ones have not taken (FloatingPanel.h). The order is the priority the
|
||||
// requirements state: the build button bar takes what it wants and never moves for
|
||||
// anyone (REQ-UI-BUILD-BAR), the controls panel steps around the bar
|
||||
// (REQ-UI-CONTROLS-PANEL), and the selection panel keeps clear of both
|
||||
// (REQ-UI-SELECTION-PANEL). A widget with nothing to show hides itself in placeIn()
|
||||
// and takes no space.
|
||||
//
|
||||
// Re-entry is refused rather than queued: setGeometry() on a widget in the pass can
|
||||
// reach code that asks for another pass, and the one already running is about to
|
||||
// produce the same answer.
|
||||
if (m_layingOut)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_layingOut = true;
|
||||
|
||||
const std::vector<QWidget*> floatingWidgets = {
|
||||
m_buildButtonBar, m_controlsPanel, m_selectionPanel };
|
||||
const std::vector<FloatingPanel*> floatingPanels = {
|
||||
m_buildButtonBar, m_controlsPanel, m_selectionPanel };
|
||||
|
||||
std::vector<QRect> occupiedRects;
|
||||
for (std::size_t i = 0; i < floatingPanels.size(); ++i)
|
||||
{
|
||||
floatingPanels[i]->placeIn(worldRect, occupiedRects);
|
||||
if (floatingWidgets[i]->isVisible())
|
||||
{
|
||||
occupiedRects.push_back(floatingWidgets[i]->geometry());
|
||||
}
|
||||
}
|
||||
|
||||
m_layingOut = false;
|
||||
}
|
||||
|
||||
void MainWindow::handleEvent(
|
||||
std::shared_ptr<const FloatingLayoutInvalidatedEvent> /*event*/)
|
||||
{
|
||||
// One of the floating widgets changed size or visibility. What each of them may take
|
||||
// depends on the ones placed before it, so the answer is the whole pass rather than
|
||||
// that one widget re-placing itself.
|
||||
layoutPanels();
|
||||
}
|
||||
|
||||
void MainWindow::handleEvent(std::shared_ptr<const SchematicChoicesAvailableEvent> event)
|
||||
|
||||
Reference in New Issue
Block a user