Skip to content

Truly independent web browser

UI/Qt: Always show the close button on unpinned tabs

Andreas Kling766cf84c3526
diff --git a/Documentation/UI/QuietDesign.md b/Documentation/UI/QuietDesign.md
index 89c4e291a63..885f98e5795 100644
--- a/Documentation/UI/QuietDesign.md
+++ b/Documentation/UI/QuietDesign.md
@@ -97,7 +97,7 @@ All sizes are in logical pixels.
| Active tab | 30 px tall | 8 px top radius plus an 8 px inverted "foot" on each side where it joins the toolbar. 5 px of strip shows above it. Its contents are vertically centered in it, which puts them on the shared center line. |
| End insets | Favicon 7 px from the left edge; × glyph 11 px from the right edge | Rule: each end item is as far from the tab's side as it is from the tab's top (the 16 px favicon sits 7 px down, the 8 px × glyph 11 px down). Padding: active 0 6 px 0 7 px; inactive 3 px inset + 0 3 px 0 4 px, so favicons and × never move when a tab becomes active. |
| Favicon to title | 8 px | |
-| Close button | 18 px hover square, 7 px × (14 px glyph box); click area extends to the full tab height | The slot is reserved on every tab; the × shows on hover and on the active tab. Indicators like the speaker sit to its left, so nothing moves on hover. |
+| Close button | 18 px hover square, 7 px × (14 px glyph box); click area extends to the full tab height | The × is always visible on every tab except pinned tabs, in `muted`; its hover square appears on hover. Indicators like the speaker sit to its left. |
| Tab width | 20 to 232 px | Tabs shrink until only the favicon is left, giving up their padding below 32 px, then the strip scrolls. A tab too narrow for its favicon beside its × shows only the favicon; the active one shows its × in the favicon's place. |
| Pinned tab | 44 px wide | Favicon only, always first |
| New tab (+) | 26 px button, 14 px glyph | Follows the last tab directly, 8 px after it (just clear of the active tab's foot), centered on the tab row; with few tabs it does not move to the end of the strip. Click area at least 32 px. |
@@ -427,8 +427,8 @@ Don't invent new shadows. Pick a level.
| State | Look |
|---|---|
-| Default | Favicon and title; the close slot is reserved but empty |
-| Hover | The active tab's shape in `hover` fill, no feet; the × fades into its slot |
+| Default | Favicon, title and × |
+| Hover | The active tab's shape in `hover` fill, no feet |
| Active | Joins the toolbar; title in full `text` color, weight 400 |
| Dragging | Stays in the strip with a Lift shadow, flat (no tilt), slides sideways only |
| Loading | Accent ring (20 px, 1.5 px line) around the favicon, reaching only 2 px past the favicon slot so the title keeps about 6 px of room and nothing moves. The favicon shrinks to 10 px inside the ring so square icons never touch it. |
@@ -587,7 +587,7 @@ zoom chip, drag and drop) is on the canvas's motion spec board.
| Situation | Behavior |
|---|---|
| Tooltips | After 500 ms of hover. Once one has shown, neighbouring tooltips appear at once for the next 1.5 s. |
-| Tab close | Every tab reserves a 20 px slot for the ×. It fades in on hover with no delay and always shows on the active tab, so nothing on a tab moves when hovered. Middle-click anywhere on a tab closes it. |
+| Tab close | Every tab except pinned tabs always shows its ×. A tab too narrow for both its favicon and its × shows only its favicon, and once selected, its × in the favicon's place. Nothing appears or moves on hover. Middle-click anywhere on a tab closes it. In the collapsed sidebar rail the × stays a hover badge, so favicons aren't covered. |
| Width lock | After closing a tab by clicking, tab widths stay fixed until the pointer leaves the strip, plus 300 ms, so the next × lands under the cursor. |
| Dragging tabs | Starts after 4 px. The tab stays in the strip and slides along it until pulled 40 px away (up or down; sideways out of the sidebar in vertical mode), then comes loose as a window preview. Esc cancels. |
| Dropping | A link, URL or file dropped on the strip opens a new tab at the marker; on the bookmarks bar it becomes a bookmark; on the page, the page decides. |
diff --git a/UI/Qt/TabBar.cpp b/UI/Qt/TabBar.cpp
index f0545542ebb..f53465332c9 100644
--- a/UI/Qt/TabBar.cpp
+++ b/UI/Qt/TabBar.cpp
@@ -2963,22 +2963,23 @@ void TabBar::update_tab_button_geometry()
// NB: A tab shows its buttons once it has grown to its width.
auto is_growing = is_growing_horizontal_tab(index, tab_rect);
- // The close button ends the tab's content, and only shows on the selected tab and the hovered one.
+ // The close button ends the tab's content, and shows on every tab, so nothing on a tab changes as it is
+ // hovered.
auto* close_button = tabButton(index, QTabBar::RightSide);
prepare_button(close_button, TabBarButton::Placement::Tab);
auto trailing_edge = qRound(content_rect.right());
if (close_button) {
QPoint close_button_position { trailing_edge - close_button->width(), button_y_in(close_button, shape_rect) };
- // NB: Every tab with room for it keeps a slot for its close button, which shows on the selected tab and
- // the hovered one. While the strip scrolls, only the selected tab shows it. A tab too narrow for
- // its favicon beside the slot, such as one opening or closing, has none.
+ // NB: A tab too narrow for its favicon beside the close button, such as one opening or closing, or one
+ // of many in a full strip, has none, unless it is selected (see
+ // horizontal_tab_close_button_replaces_favicon()).
auto has_room = horizontal_tab_has_room_for_favicon_before(close_button_position.x(), content_rect.left());
auto replaces_favicon = horizontal_tab_close_button_replaces_favicon(content_rect, *close_button, is_selected, left_button);
if (replaces_favicon)
close_button_position.setX(qRound(content_rect.center().x() - (close_button->width() / 2.0)));
if (close_button->pos() != close_button_position)
close_button->move(close_button_position);
- auto show_close_button = !is_dragged && !is_growing && (has_room || replaces_favicon) && (is_selected || (index == m_hovered_tab_index && max_scroll_offset() <= 0)) && is_in_view(close_button);
+ auto show_close_button = !is_dragged && !is_growing && (has_room || replaces_favicon) && is_in_view(close_button);
// NB: A close button that stood in the favicon's place hides at once as its tab is deselected, rather
// than fading out over the favicon.
if (!show_close_button && !has_room && close_button->isVisible())
@@ -3043,10 +3044,9 @@ void TabBar::update_tab_button_geometry()
did_update_button = true;
}
- // NB: The close buttons stay hidden while the sidebar opens or closes, as the titles fade.
+ // NB: Every row shows its close button, but for while the sidebar opens or closes, as the titles fade.
auto is_toggling = m_tab_widget && m_tab_widget->vertical_tabs_are_toggling();
- auto should_be_visible = index != dragged_index && has_room_for_icon
- && (position != QTabBar::RightSide || ((index == currentIndex() || index == m_hovered_tab_index) && !is_toggling));
+ auto should_be_visible = index != dragged_index && has_room_for_icon && (position != QTabBar::RightSide || !is_toggling);
if (button->isVisible() != should_be_visible) {
button->setVisible(should_be_visible);
did_update_button = true;