mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-24 05:25:13 +00:00
LibGUI: Scale TabWidget tabs according to available space
In TabWidgets with the "uniform tabs" mode on, we will now scale tabs between a minimum and maximum size, distributing the available space. Partially addresses #1971.
This commit is contained in:
parent
a80ddf584f
commit
8fc6ff94fe
Notes:
sideshowbarker
2024-07-19 07:10:06 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8fc6ff94fea
1 changed files with 7 additions and 1 deletions
|
@ -197,7 +197,13 @@ void TabWidget::paint_event(PaintEvent& event)
|
|||
|
||||
int TabWidget::uniform_tab_width() const
|
||||
{
|
||||
return 160;
|
||||
int minimum_tab_width = 24;
|
||||
int maximum_tab_width = 160;
|
||||
int total_tab_width = m_tabs.size() * maximum_tab_width;
|
||||
int tab_width = maximum_tab_width;
|
||||
if (total_tab_width > width())
|
||||
tab_width = width() / m_tabs.size();
|
||||
return max(tab_width, minimum_tab_width);
|
||||
}
|
||||
|
||||
Gfx::Rect TabWidget::button_rect(int index) const
|
||||
|
|
Loading…
Add table
Reference in a new issue