1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:17:35 +00:00

LibGUI: Add "override text" to GUI::Statusbar

Each statusbar segment now has an optional "override text" which can
be set, and if non-null will be displayed instead of the regular text.

This allows programs to display contextual information in the statusbar
temporarily without losing whatever text was already on there.
This commit is contained in:
Andreas Kling 2021-04-17 18:34:30 +02:00
parent 3bf2f7a329
commit 22ed6a70eb
2 changed files with 42 additions and 12 deletions

View file

@ -36,9 +36,11 @@ public:
virtual ~Statusbar() override;
String text() const;
String text(int index) const;
String text(size_t index) const;
void set_text(String);
void set_text(int index, String);
void set_text(size_t index, String);
void set_override_text(String);
void set_override_text(size_t index, String);
protected:
explicit Statusbar(int label_count = 1);
@ -47,7 +49,13 @@ protected:
private:
NonnullRefPtr<Label> create_label();
NonnullRefPtrVector<Label> m_labels;
struct Segment {
NonnullRefPtr<GUI::Label> label;
String text;
String override_text;
};
void update_label(size_t);
Vector<Segment> m_segments;
RefPtr<ResizeCorner> m_corner;
};