summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/HeaderView.h
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2021-03-17 20:11:44 -0400
committerAndreas Kling <kling@serenityos.org>2021-03-18 07:49:55 +0100
commit3cc7862487d7eefe7f89d4c446c2251497575e5f (patch)
treef374a94886e51f794fb10ab83210645ff391849e /Userland/Libraries/LibGUI/HeaderView.h
parent663fd9abb44d2181f5845f70e374e748d16b60cd (diff)
downloadserenity-3cc7862487d7eefe7f89d4c446c2251497575e5f.zip
LibGUI: Support double-click resizing column headers
Columns can now be best-fit resized by double-clicking their grabbable edges. When a default width is set and all data is empty, double-clicking will restore the column to its original state.
Diffstat (limited to 'Userland/Libraries/LibGUI/HeaderView.h')
-rw-r--r--Userland/Libraries/LibGUI/HeaderView.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/HeaderView.h b/Userland/Libraries/LibGUI/HeaderView.h
index 5132be3fb6..7f10ccea6e 100644
--- a/Userland/Libraries/LibGUI/HeaderView.h
+++ b/Userland/Libraries/LibGUI/HeaderView.h
@@ -45,6 +45,10 @@ public:
void set_section_size(int section, int size);
int section_size(int section) const;
+ void set_default_section_size(int section, int size);
+ int default_section_size(int section) const;
+ bool is_default_section_size_initialized(int section) const;
+
Gfx::TextAlignment section_alignment(int section) const;
void set_section_alignment(int section, Gfx::TextAlignment);
@@ -54,6 +58,8 @@ public:
int section_count() const;
Gfx::IntRect section_rect(int section) const;
+ Function<void(int section)> on_resize_doubleclick;
+
private:
HeaderView(AbstractTableView&, Gfx::Orientation);
@@ -61,6 +67,7 @@ private:
virtual void mousedown_event(MouseEvent&) override;
virtual void mousemove_event(MouseEvent&) override;
virtual void mouseup_event(MouseEvent&) override;
+ virtual void doubleclick_event(MouseEvent&) override;
virtual void context_menu_event(ContextMenuEvent&) override;
virtual void leave_event(Core::Event&) override;
@@ -78,7 +85,9 @@ private:
struct SectionData {
int size { 0 };
+ int default_size { 0 };
bool has_initialized_size { false };
+ bool has_initialized_default_size { false };
bool visibility { true };
RefPtr<Action> visibility_action;
Gfx::TextAlignment alignment { Gfx::TextAlignment::CenterLeft };