From f86c5b1fa741bd09bb173e10cb16e7bd40cd5545 Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Wed, 21 Sep 2022 08:07:24 -0400 Subject: [PATCH] LibGUI: Allow setting max visible items for ComboBoxes This will govern the maximum number of items ComboBox windows display before scrolling content. --- Userland/Libraries/LibGUI/ComboBox.cpp | 1 + Userland/Libraries/LibGUI/ComboBox.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index a452fe1c7b..3b265b6ecd 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -58,6 +58,7 @@ ComboBox::ComboBox() { REGISTER_STRING_PROPERTY("placeholder", editor_placeholder, set_editor_placeholder); REGISTER_BOOL_PROPERTY("model_only", only_allow_values_from_model, set_only_allow_values_from_model); + REGISTER_INT_PROPERTY("max_visible_items", max_visible_items, set_max_visible_items); set_min_size({ 40, 22 }); set_preferred_size({ SpecialDimension::OpportunisticGrow, 22 }); diff --git a/Userland/Libraries/LibGUI/ComboBox.h b/Userland/Libraries/LibGUI/ComboBox.h index 598b080940..20b5764002 100644 --- a/Userland/Libraries/LibGUI/ComboBox.h +++ b/Userland/Libraries/LibGUI/ComboBox.h @@ -44,6 +44,9 @@ public: void set_editor_placeholder(StringView placeholder); String const& editor_placeholder() const; + int max_visible_items() const { return m_max_visible_items; } + void set_max_visible_items(int max) { m_max_visible_items = max; } + Function on_change; Function on_return_pressed; @@ -63,6 +66,7 @@ private: Optional m_selected_index; bool m_only_allow_values_from_model { false }; bool m_updating_model { false }; + int m_max_visible_items { 15 }; }; }