Truly independent web browser
UI/Qt: Give the private tab strip room for a distinct hover
Andreas Kling64ac716a3aa5
diff --git a/Documentation/UI/QuietDesign.md b/Documentation/UI/QuietDesign.mdindex e51d8bb78ac..a50c4260a98 100644--- a/Documentation/UI/QuietDesign.md+++ b/Documentation/UI/QuietDesign.md@@ -258,17 +258,25 @@ bluer, lighter lavender, and its dark surfaces carry less tint than other themes| Token | Private ||---|---|-| `strip` | `#1D1430` |+| `strip` | `#110A20` || `toolbar` | `#2F2347` || `text` | `#F3F0FA` || `muted`, `tab-title` | `#B3AAC4` || `icon` | `#E2DCEF` || `disabled` | `#5E566E` || `field` | White 9% |-| `hover` | White 7% |+| `hover` | White 7% (toolbar and sidebar) |+| `strip-hover` | White 6% (background tabs, the + button and the All tabs button on the strip) || `separator` | `#4A3D63` || `divider` | `#0F0A19` |+Hover strength follows the surface a control sits on, not the kind of control. On the+toolbar's 7%, a hovered tab on the strip would land almost on the active tab, so the strip+is darker and its hover is 6%. That makes strip, hovered tab and active tab about+17 / 31 / 47 in red: steps of 14 and 16, slightly wider than normal dark (20 / 34 / 46),+because violet tones are harder to tell apart than neutral grays. The Ladybird button keeps+its own hover and press fills everywhere.+The Ladybird button shows a filled domino mask (20 px, eye holes cut out) instead of the logomark. The window is titled"Ladybird (Private)" in the Window menu, app switcher and taskbar. There is no "Private"text badge in the toolbar.diff --git a/UI/Qt/ChromeStyle.cpp b/UI/Qt/ChromeStyle.cppindex 31d708a8b04..04fdc975888 100644--- a/UI/Qt/ChromeStyle.cpp+++ b/UI/Qt/ChromeStyle.cpp@@ -2195,6 +2195,13 @@ static void paint_circular_control_frame(QPainter& painter, QRect const& rect, q}}+bool is_in_tab_strip_button_group(QWidget const& button)+{+ auto const* group = button.parentWidget();+ auto const* row = group ? group->parentWidget() : nullptr;+ return row && row->objectName() == QLatin1StringView("LadybirdTabStrip");+}+Optional<ControlFrameColors> control_frame_colors(QAbstractButton const& button, ControlFrameStyle frame_style){if (!button.isEnabled())@@ -2212,7 +2219,7 @@ Optional<ControlFrameColors> control_frame_colors(QAbstractButton const& button,if (pressed)return ControlFrameColors { Theme::panel().pressed, Qt::transparent };if (hovered)- return ControlFrameColors { Theme::chrome(button.palette()).hover, Qt::transparent };+ return ControlFrameColors { is_in_tab_strip_button_group(button) ? Theme::chrome(button.palette()).strip_hover : Theme::chrome(button.palette()).hover, Qt::transparent };return {};}diff --git a/UI/Qt/ChromeStyle.h b/UI/Qt/ChromeStyle.hindex c40d0457d4e..457ece83135 100644--- a/UI/Qt/ChromeStyle.h+++ b/UI/Qt/ChromeStyle.h@@ -125,6 +125,9 @@ struct ControlFrameColors {// The corner radius of a button's frame on the chrome.constexpr inline qreal CONTROL_FRAME_RADIUS = 6;// The colors of a button's frame in the button's current state, or nothing while it shows no frame.+// The Ladybird and all-tabs buttons sit in a group that moves between the tab strip and the sidebar or the toolbar.+bool is_in_tab_strip_button_group(QWidget const&);+Optional<ControlFrameColors> control_frame_colors(QAbstractButton const&, ControlFrameStyle = ControlFrameStyle::InteractionOnly);void paint_control_frame(QPainter&, QAbstractButton const&, ControlFrameStyle = ControlFrameStyle::InteractionOnly);// The frame of a badge over a collapsed sidebar's tab that is not a button, as a button's frame looks at rest.diff --git a/UI/Qt/TabBar.cpp b/UI/Qt/TabBar.cppindex 1e599de250d..2eb3952dc59 100644--- a/UI/Qt/TabBar.cpp+++ b/UI/Qt/TabBar.cpp@@ -438,13 +438,23 @@ static QRect tab_card_shape_rect(QRect const& rect)return rect.adjusted(TAB_CARD_SHAPE_HORIZONTAL_INSET, TAB_CARD_SHAPE_TOP_INSET, -TAB_CARD_SHAPE_HORIZONTAL_INSET, -TAB_CARD_SHAPE_BOTTOM_INSET);}-static QColor tab_hover_surface(QPalette const& palette, qreal hover_progress)+static QColor tab_hover_surface(QColor color, qreal hover_progress){- auto color = Theme::chrome(palette).hover;color.setAlphaF(color.alphaF() * static_cast<float>(hover_progress));return color;}+static QColor horizontal_tab_hover_surface(QPalette const& palette, qreal hover_progress)+{+ return tab_hover_surface(Theme::chrome(palette).strip_hover, hover_progress);+}++// NB: The sidebar is lighter than the tab strip, so tabs on it take the same hover fill as the toolbar's buttons.+static QColor vertical_tab_hover_surface(QPalette const& palette, qreal hover_progress)+{+ return tab_hover_surface(Theme::chrome(palette).hover, hover_progress);+}+static QColor horizontal_tab_separator(QPalette const& palette){return Theme::chrome(palette).separator;@@ -552,7 +562,7 @@ private:if (auto colors = ChromeStyle::control_frame_colors(*this); colors.has_value()) {// NB: Hovered but not pressed, it lights up like the tabs beside it.if (hovered && !isDown())- colors->background = tab_hover_surface(Theme::chrome_palette(*this), 1.0);+ colors->background = is_horizontal_new_tab_button ? horizontal_tab_hover_surface(Theme::chrome_palette(*this), 1.0) : vertical_tab_hover_surface(Theme::chrome_palette(*this), 1.0);painter.setBrush(colors->background);painter.setPen(colors->border.alpha() > 0 ? QPen(colors->border, 1) : QPen(Qt::NoPen));painter.drawPath(tab_path);@@ -1289,7 +1299,7 @@ void TabBar::paintEvent(QPaintEvent*)auto body_rect = horizontal_selected_tab_body_rect(QRectF(tab_rect), horizontal_tab_end_room(index));if (body_rect.width() < 2 * HORIZONTAL_SELECTED_TAB_RADIUS)return;- painter.setBrush(tab_hover_surface(Theme::chrome_palette(*this), hover_progress));+ painter.setBrush(horizontal_tab_hover_surface(Theme::chrome_palette(*this), hover_progress));painter.setPen(Qt::NoPen);painter.drawPath(horizontal_hovered_tab_path(body_rect));};@@ -1374,13 +1384,13 @@ void TabBar::paintEvent(QPaintEvent*)// NB: The hovered horizontal tabs were filled before any tab was painted.if (selection < 1.0 && is_hovered && is_vertical) {- painter.setBrush(tab_hover_surface(Theme::chrome_palette(*this), hover_progress));+ painter.setBrush(vertical_tab_hover_surface(Theme::chrome_palette(*this), hover_progress));painter.setPen(Qt::NoPen);painter.drawPath(tab_path);} else if (selection < 1.0 && is_vertical && !is_collapsed_vertical && is_pinned_tile) {// The pinned tiles at the top of the sidebar are always filled, so they read as a grid of buttons. The fill// fades as they move into the collapsed sidebar's column, where they are not.- painter.setBrush(tab_hover_surface(Theme::chrome_palette(*this), 1.0 - region.collapsedness));+ painter.setBrush(vertical_tab_hover_surface(Theme::chrome_palette(*this), 1.0 - region.collapsedness));painter.setPen(Qt::NoPen);painter.drawPath(tab_path);}@@ -1436,7 +1446,8 @@ void TabBar::paintEvent(QPaintEvent*)painter.setRenderHint(QPainter::Antialiasing);painter.setPen(Qt::NoPen);auto backing = is_vertical ? ChromeStyle::chrome_sidebar_background(Theme::chrome_palette(*this)) : ChromeStyle::chrome_tab_strip_background(Theme::chrome_palette(*this));- painter.setBrush(is_hovered ? tab_hover_surface(Theme::chrome_palette(*this), 1.0) : backing);+ auto hover_surface = is_vertical ? vertical_tab_hover_surface(Theme::chrome_palette(*this), 1.0) : horizontal_tab_hover_surface(Theme::chrome_palette(*this), 1.0);+ painter.setBrush(is_hovered ? hover_surface : backing);painter.drawEllipse(dot_center, ATTENTION_DOT_RADIUS + 1.5, ATTENTION_DOT_RADIUS + 1.5);painter.setBrush(Theme::accent());painter.drawEllipse(dot_center, ATTENTION_DOT_RADIUS, ATTENTION_DOT_RADIUS);diff --git a/UI/Qt/Theme.cpp b/UI/Qt/Theme.cppindex a15d1c14821..339a7f40175 100644--- a/UI/Qt/Theme.cpp+++ b/UI/Qt/Theme.cpp@@ -68,6 +68,7 @@ static ChromeColors const light_chrome {.icon = rgb(0x3a3a40),.disabled = rgb(0xb3b3b9),.hover = rgba(0, 0, 0, 0.06),+ .strip_hover = rgba(0, 0, 0, 0.06),.row_title = rgb(0x3f3f45),.separator = rgb(0xbcbcc2),.divider = rgb(0xd2d2d6),@@ -91,6 +92,7 @@ static ChromeColors const dark_chrome {.icon = rgb(0xdcdce1),.disabled = rgb(0x5b5b61),.hover = rgba(255, 255, 255, 0.06),+ .strip_hover = rgba(255, 255, 255, 0.06),.row_title = rgb(0xcfcfd6),.separator = rgb(0x3d3d42),.divider = rgb(0x0a0a0c),@@ -103,7 +105,7 @@ static ChromeColors const dark_chrome {};static ChromeColors const private_chrome {- .strip = rgb(0x1d1430),+ .strip = rgb(0x110a20),.toolbar = rgb(0x2f2347),.sidebar = rgb(0x2f2347),.field = rgba(255, 255, 255, 0.09),@@ -114,6 +116,8 @@ static ChromeColors const private_chrome {.icon = rgb(0xe2dcef),.disabled = rgb(0x5e566e),.hover = rgba(255, 255, 255, 0.07),+ // NB: The strip and the active tab are close in lightness here, so the normal hover would look like the active tab.+ .strip_hover = rgba(255, 255, 255, 0.06),.row_title = rgb(0xd5cee2),.separator = rgb(0x4a3d63),.divider = rgb(0x0f0a19),@@ -137,6 +141,7 @@ static ChromeColors const light_increased_contrast_chrome {.icon = rgb(0x1d1d1f),.disabled = rgb(0x8e8e93),.hover = rgba(0, 0, 0, 0.10),+ .strip_hover = rgba(0, 0, 0, 0.10),.row_title = rgb(0x1d1d1f),.separator = rgb(0x8e8e93),.divider = rgb(0x6e6e73),@@ -160,6 +165,7 @@ static ChromeColors const dark_increased_contrast_chrome {.icon = rgb(0xf2f2f5),.disabled = rgb(0x8a8a90),.hover = rgba(255, 255, 255, 0.14),+ .strip_hover = rgba(255, 255, 255, 0.14),.row_title = rgb(0xf2f2f5),.separator = rgb(0x8a8a90),.divider = rgb(0x8a8a90),diff --git a/UI/Qt/Theme.h b/UI/Qt/Theme.hindex 68227069463..54e887a13dc 100644--- a/UI/Qt/Theme.h+++ b/UI/Qt/Theme.h@@ -35,6 +35,7 @@ struct ChromeColors {QColor icon; // Toolbar iconsQColor disabled; // Disabled controlsQColor hover; // Hover fills+ QColor strip_hover; // Hover fill of controls on the tab stripQColor row_title; // Unselected tab titles in the sidebarQColor separator; // Between inactive tabsQColor divider; // Chrome / page edge