summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorNick Vella <nick@nxk.io>2021-01-29 16:26:04 +1100
committerAndreas Kling <kling@serenityos.org>2021-02-13 19:49:30 +0100
commita6fdc17f3f0add00fd15a1223415e8dd04ceb6f8 (patch)
treec160c0adde1d1b2fa7eefd2d8dc4b377940e2a6c /Userland
parent35a1e12459365bf82f6f15557c95e7a01a5d2876 (diff)
downloadserenity-a6fdc17f3f0add00fd15a1223415e8dd04ceb6f8.zip
LibGUI: add 'always_wrap_item_labels' property to IconView.
In some circumstances (like template selection dialogs,) displaying as much item label as possible, on all items, may be desired. The default setting is 'false', which matches the default behaviour from before; only wrapping on hover or selection.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGUI/IconView.cpp2
-rw-r--r--Userland/Libraries/LibGUI/IconView.h5
2 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/IconView.cpp b/Userland/Libraries/LibGUI/IconView.cpp
index 24d8765a2c..5026073027 100644
--- a/Userland/Libraries/LibGUI/IconView.cpp
+++ b/Userland/Libraries/LibGUI/IconView.cpp
@@ -431,7 +431,7 @@ void IconView::get_item_rects(int item_index, ItemData& item_data, const Gfx::Fo
item_data.text_rect = { 0, item_data.icon_rect.bottom() + 6 + 1, 0, font.glyph_height() };
item_data.wrapped_text_lines.clear();
- if ((unwrapped_text_width > available_width) && (item_data.selected || m_hovered_index == item_data.index || cursor_index() == item_data.index)) {
+ if ((unwrapped_text_width > available_width) && (item_data.selected || m_hovered_index == item_data.index || cursor_index() == item_data.index || m_always_wrap_item_labels)) {
int current_line_width = 0;
int current_line_start = 0;
int widest_line_width = 0;
diff --git a/Userland/Libraries/LibGUI/IconView.h b/Userland/Libraries/LibGUI/IconView.h
index c36960a1e2..c26d34b766 100644
--- a/Userland/Libraries/LibGUI/IconView.h
+++ b/Userland/Libraries/LibGUI/IconView.h
@@ -53,6 +53,9 @@ public:
Gfx::IntSize effective_item_size() const { return m_effective_item_size; }
+ bool always_wrap_item_labels() const { return m_always_wrap_item_labels; }
+ void set_always_wrap_item_labels(bool value) { m_always_wrap_item_labels = value; }
+
int model_column() const { return m_model_column; }
void set_model_column(int column) { m_model_column = column; }
@@ -157,6 +160,8 @@ private:
Gfx::IntSize m_effective_item_size { 80, 80 };
+ bool m_always_wrap_item_labels { false };
+
bool m_rubber_banding { false };
bool m_rubber_banding_store_selection { false };
RefPtr<Core::Timer> m_out_of_view_timer;