Skip to content

Commit

Permalink
LibGUI: Scale TabWidget tabs according to available space
Browse files Browse the repository at this point in the history
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 SerenityOS#1971.
  • Loading branch information
awesomekling committed Apr 30, 2020
1 parent a80ddf5 commit 8fc6ff9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Libraries/LibGUI/TabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8fc6ff9

Please sign in to comment.