place the selection panel beside what it describes
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "ControlAction.h"
|
||||
#include "FloatingPanel.h"
|
||||
|
||||
class GameWorldView;
|
||||
class QLabel;
|
||||
@@ -29,7 +30,7 @@ class QVBoxLayout;
|
||||
// while the game is paused, so there is no tick to hang it on either. The rebuild is
|
||||
// skipped unless the resolved content actually differs, which is a vector of enums to
|
||||
// compare.
|
||||
class ControlsPanel : public QWidget
|
||||
class ControlsPanel : public QWidget, public FloatingPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -42,10 +43,11 @@ public:
|
||||
// Places the panel in the bottom-left corner of the game world view. It shares the
|
||||
// bottom edge with the build button bar rather than clearing its strip, the bar
|
||||
// being centered and sized to its buttons and so usually leaving the left free; it
|
||||
// rises above the bar only when the two would otherwise overlap. `buildBarRect` is
|
||||
// the bar's current geometry in the same coordinates, or a null rect when there is
|
||||
// none to avoid (REQ-UI-CONTROLS-PANEL, REQ-UI-BUILD-BAR).
|
||||
void anchorTo(const QRect& worldRect, const QRect& buildBarRect);
|
||||
// rises above the bar only when the two would otherwise overlap
|
||||
// (REQ-UI-CONTROLS-PANEL, REQ-UI-BUILD-BAR). The bar is the only thing placed before
|
||||
// it, so it is the only rect it ever has to rise above.
|
||||
void placeIn(const QRect& viewRect,
|
||||
const std::vector<QRect>& occupiedRects) override;
|
||||
|
||||
protected:
|
||||
// Clicking the heading collapses and expands the panel (REQ-UI-CONTROLS-PANEL).
|
||||
@@ -59,8 +61,8 @@ private:
|
||||
// The heading's "<name> * <detail>" text for the context, detail omitted when the
|
||||
// context has none.
|
||||
QString getHeadingText(const ControlContext& context) const;
|
||||
// Re-fits the panel to its content within the anchored band.
|
||||
void refit();
|
||||
// Asks for the placement pass to be re-run, the panel's own size having changed.
|
||||
void invalidateLayout();
|
||||
|
||||
const GameWorldView* m_view;
|
||||
|
||||
@@ -82,9 +84,4 @@ private:
|
||||
// Survives context changes and simulation restarts; presentation only, never a
|
||||
// command (REQ-UI-CONTROLS-PANEL).
|
||||
bool m_collapsed = false;
|
||||
|
||||
// The world view the panel sits in, and the build button bar it steps around, both
|
||||
// in the coordinates of its parent. Null until the owner has anchored it.
|
||||
QRect m_worldRect;
|
||||
QRect m_buildBarRect;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user