1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:37:45 +00:00

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.
This commit is contained in:
Nick Vella 2021-01-29 16:26:04 +11:00 committed by Andreas Kling
parent 35a1e12459
commit a6fdc17f3f
2 changed files with 6 additions and 1 deletions

View file

@ -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.text_rect = { 0, item_data.icon_rect.bottom() + 6 + 1, 0, font.glyph_height() };
item_data.wrapped_text_lines.clear(); 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_width = 0;
int current_line_start = 0; int current_line_start = 0;
int widest_line_width = 0; int widest_line_width = 0;

View file

@ -53,6 +53,9 @@ public:
Gfx::IntSize effective_item_size() const { return m_effective_item_size; } 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; } int model_column() const { return m_model_column; }
void set_model_column(int column) { m_model_column = column; } void set_model_column(int column) { m_model_column = column; }
@ -157,6 +160,8 @@ private:
Gfx::IntSize m_effective_item_size { 80, 80 }; Gfx::IntSize m_effective_item_size { 80, 80 };
bool m_always_wrap_item_labels { false };
bool m_rubber_banding { false }; bool m_rubber_banding { false };
bool m_rubber_banding_store_selection { false }; bool m_rubber_banding_store_selection { false };
RefPtr<Core::Timer> m_out_of_view_timer; RefPtr<Core::Timer> m_out_of_view_timer;