#pragma once #include #include #include #include class QLabel; // The card header's right slot (REQ-UI-SELECTION-CARD): a colored dot with a short // caption beside it. It carries a building's production status // (REQ-UI-SELECTION-STATUS), a ship's current behavior (REQ-UI-SHIP-BEHAVIOR), or an // aggregated selection's object count (REQ-UI-SELECTION-AGGREGATE) -- never more than // one of them, which is why they share one part. class StatusPill : public QWidget { Q_OBJECT public: explicit StatusPill(QWidget* parent = nullptr); // An invalid dot color leaves the dot off, for the slots that are a plain caption. // An empty caption hides the pill entirely. void setStatus(const QColor& dotColor, const QColor& outlineColor, const QString& caption); // Reserves room for the widest of the captions this pill can show, so the header -- // and with it the panel, which is sized to its content (REQ-UI-SELECTION-PANEL) -- // keeps its width as the caption changes. Without it the whole panel jumps every // time a building's status does, and a card whose chips wrap changes height with it. void reserveFor(const QStringList& captions); private: QLabel* m_dotLabel; QLabel* m_captionLabel; // What the width is currently reserved for, so re-reserving the same set on every // refresh costs nothing. QStringList m_reservedFor; };