From 3aa95dd4d5be91898d912a39c97a432b05c6f401 Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Tue, 22 Feb 2022 07:20:05 -0500 Subject: [PATCH] LibGUI+Apps: Convert Statusbar Labels to Segments Segments inherit from Button and let us add clickable widgets to status bars. This patch also adds proportional, fixed and autosized modes for segments and lets the status bar consume all non-clickable segments for override text. --- .../HexEditor/GoToOffsetDialog.gml | 2 +- .../HexEditor/HexEditorWindow.gml | 2 +- .../TextEditor/TextEditorWindow.gml | 2 +- Userland/Games/Solitaire/Solitaire.gml | 2 +- Userland/Games/Spider/Spider.gml | 2 +- Userland/Libraries/LibGUI/Statusbar.cpp | 163 +++++++++++------- Userland/Libraries/LibGUI/Statusbar.h | 66 +++++-- 7 files changed, 159 insertions(+), 80 deletions(-) diff --git a/Userland/Applications/HexEditor/GoToOffsetDialog.gml b/Userland/Applications/HexEditor/GoToOffsetDialog.gml index cfd7d9495f..9504757f94 100644 --- a/Userland/Applications/HexEditor/GoToOffsetDialog.gml +++ b/Userland/Applications/HexEditor/GoToOffsetDialog.gml @@ -57,6 +57,6 @@ @GUI::Statusbar { name: "statusbar" - label_count: 2 + segment_count: 2 } } diff --git a/Userland/Applications/HexEditor/HexEditorWindow.gml b/Userland/Applications/HexEditor/HexEditorWindow.gml index 4a7d4e0935..10a271af1b 100644 --- a/Userland/Applications/HexEditor/HexEditorWindow.gml +++ b/Userland/Applications/HexEditor/HexEditorWindow.gml @@ -31,6 +31,6 @@ @GUI::Statusbar { name: "statusbar" - label_count: 5 + segment_count: 5 } } diff --git a/Userland/Applications/TextEditor/TextEditorWindow.gml b/Userland/Applications/TextEditor/TextEditorWindow.gml index 3f567a9a47..b8556df9a8 100644 --- a/Userland/Applications/TextEditor/TextEditorWindow.gml +++ b/Userland/Applications/TextEditor/TextEditorWindow.gml @@ -106,6 +106,6 @@ @GUI::Statusbar { name: "statusbar" - label_count: 2 + segment_count: 3 } } diff --git a/Userland/Games/Solitaire/Solitaire.gml b/Userland/Games/Solitaire/Solitaire.gml index 7dc3180ede..c2089f680a 100644 --- a/Userland/Games/Solitaire/Solitaire.gml +++ b/Userland/Games/Solitaire/Solitaire.gml @@ -10,6 +10,6 @@ @GUI::Statusbar { name: "statusbar" - label_count: 3 + segment_count: 3 } } diff --git a/Userland/Games/Spider/Spider.gml b/Userland/Games/Spider/Spider.gml index 83ad529034..1ed45a5299 100644 --- a/Userland/Games/Spider/Spider.gml +++ b/Userland/Games/Spider/Spider.gml @@ -10,6 +10,6 @@ @GUI::Statusbar { name: "statusbar" - label_count: 3 + segment_count: 3 } } diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp index cc66795e81..abce4af03c 100644 --- a/Userland/Libraries/LibGUI/Statusbar.cpp +++ b/Userland/Libraries/LibGUI/Statusbar.cpp @@ -5,7 +5,6 @@ */ #include -#include #include #include #include @@ -17,7 +16,7 @@ REGISTER_WIDGET(GUI, Statusbar) namespace GUI { -Statusbar::Statusbar(int label_count) +Statusbar::Statusbar(int count) { set_fixed_height(18); set_layout(); @@ -25,26 +24,76 @@ Statusbar::Statusbar(int label_count) layout()->set_spacing(2); m_corner = add(); - set_label_count(label_count); + set_segment_count(count); REGISTER_STRING_PROPERTY("text", text, set_text); - REGISTER_INT_PROPERTY("label_count", label_count, set_label_count); + REGISTER_INT_PROPERTY("segment_count", segment_count, set_segment_count); } Statusbar::~Statusbar() { } -NonnullRefPtr