mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
LibGUI: Do not allow tree column to shrink beyond indent and icon
We always display the tree indent and the icon, so we shouldn't allow the tree column to shrink beyond that size.
This commit is contained in:
parent
ab2719fd53
commit
1408aa1295
Notes:
sideshowbarker
2024-07-18 07:14:47 +09:00
Author: https://github.com/sin-ack Commit: https://github.com/SerenityOS/serenity/commit/1408aa12958 Pull-request: https://github.com/SerenityOS/serenity/pull/9282
2 changed files with 18 additions and 0 deletions
|
@ -738,4 +738,20 @@ Gfx::IntRect TreeView::content_rect(ModelIndex const& index) const
|
|||
return found_rect;
|
||||
}
|
||||
|
||||
int TreeView::minimum_column_width(int column)
|
||||
{
|
||||
if (column != model()->tree_column()) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
int maximum_indent_level = 1;
|
||||
|
||||
traverse_in_paint_order([&](ModelIndex const&, Gfx::IntRect const&, Gfx::IntRect const&, int indent_level) {
|
||||
maximum_indent_level = max(maximum_indent_level, indent_level);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
return indent_width_in_pixels() * maximum_indent_level + icon_size() + icon_spacing() + 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
virtual Gfx::IntRect content_rect(ModelIndex const&) const override;
|
||||
virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const& index) const override { return content_rect(index); }
|
||||
|
||||
virtual int minimum_column_width(int column) override;
|
||||
|
||||
protected:
|
||||
TreeView();
|
||||
|
||||
|
|
Loading…
Reference in a new issue