Skip to content

Truly independent web browser

UI/Qt: Keep the Ladybird button in place as the sidebar toggles

Andreas Klingde6bac7fb8b0
diff --git a/UI/Qt/ChromeLayout.h b/UI/Qt/ChromeLayout.h
index 19424750caa..9cf8dcb4db5 100644
--- a/UI/Qt/ChromeLayout.h
+++ b/UI/Qt/ChromeLayout.h
@@ -19,6 +19,8 @@ static constexpr int NATIVE_MACOS_WINDOW_CONTROLS_GAP = 14;
// The Ladybird button keeps 24 px clear to the traffic lights before it.
// NB: The traffic lights reach 3 px past the room kept for them.
static constexpr int LADYBIRD_BUTTON_TRAFFIC_LIGHTS_GAP = 27;
+// The toolbar's contents start this far in from its leading edge.
+static constexpr int TOOLBAR_HORIZONTAL_MARGIN = 8;
// Empty parts of a widget with this property move the window, and a double click on them maximizes it.
static constexpr auto WINDOW_DRAG_REGION_PROPERTY = "LadybirdWindowDragRegion";
diff --git a/UI/Qt/TabBar.cpp b/UI/Qt/TabBar.cpp
index 1dde271ef64..b7f73d99eb4 100644
--- a/UI/Qt/TabBar.cpp
+++ b/UI/Qt/TabBar.cpp
@@ -299,6 +299,15 @@ static constexpr int vertical_tabs_side_margin(bool expanded)
return expanded ? VERTICAL_TABS_EXPANDED_SIDE_MARGIN : VERTICAL_TABS_COLLAPSED_SIDE_MARGIN;
}
+// The Ladybird button stays where it is as the sidebar on the left toggles: where the toolbar beside the collapsed
+// sidebar starts, or past the traffic lights while the open sidebar holds them.
+static constexpr int sidebar_ladybird_button_inset(bool after_traffic_lights)
+{
+ if (after_traffic_lights)
+ return NATIVE_MACOS_WINDOW_CONTROLS_INSET + NATIVE_MACOS_WINDOW_CONTROLS_WIDTH + LADYBIRD_BUTTON_TRAFFIC_LIGHTS_GAP;
+ return TOOLBAR_HORIZONTAL_MARGIN;
+}
+
static constexpr int vertical_tabs_horizontal_margin_width(TabLayout tab_layout)
{
return vertical_tabs_side_margin(tab_layout != TabLayout::VerticalCollapsed) * 2;
@@ -3628,7 +3637,7 @@ void TabWidget::float_sidebar_buttons_while_toggling()
auto& ladybird_buttons = *m_floating_ladybird_buttons;
auto& toggle = *m_floating_sidebar_toggle;
- auto ladybird_x = column_origin.x() + (vertical_tabs_hold_window_controls() ? NATIVE_MACOS_WINDOW_CONTROLS_INSET + NATIVE_MACOS_WINDOW_CONTROLS_WIDTH + LADYBIRD_BUTTON_TRAFFIC_LIGHTS_GAP : vertical_tabs_side_margin(true));
+ auto ladybird_x = column_origin.x() + sidebar_ladybird_button_inset(vertical_tabs_hold_window_controls());
auto collapsed_toggle_x = ladybird_x + ladybird_buttons.width() + m_toolbar->sidebar_slot().layout()->spacing();
auto at_edge_x = column_origin.x() + current_vertical_tabs_width() - vertical_tabs_side_margin(true) - SIDEBAR_TOGGLE_PAGE_SIDE_MARGIN - toggle.width();
toggle.move(max(collapsed_toggle_x, at_edge_x), center_y(toggle));
@@ -4387,8 +4396,7 @@ void TabWidget::rebuild_layout_for_vertical_tabs()
top_row_layout->addStretch(1);
top_row_layout->addWidget(m_ladybird_buttons, 0, Qt::AlignVCenter);
} else {
- if (vertical_tabs_hold_window_controls())
- top_row_layout->addSpacing(NATIVE_MACOS_WINDOW_CONTROLS_INSET + NATIVE_MACOS_WINDOW_CONTROLS_WIDTH + LADYBIRD_BUTTON_TRAFFIC_LIGHTS_GAP - vertical_tabs_side_margin(true));
+ top_row_layout->addSpacing(sidebar_ladybird_button_inset(vertical_tabs_hold_window_controls()) - vertical_tabs_side_margin(true));
top_row_layout->addWidget(m_ladybird_buttons, 0, Qt::AlignVCenter);
top_row_layout->addStretch(1);
top_row_layout->addSpacing(SIDEBAR_TOGGLE_MINIMUM_GAP);
diff --git a/UI/Qt/WindowToolbar.cpp b/UI/Qt/WindowToolbar.cpp
index 737a610bce8..d57975bd89c 100644
--- a/UI/Qt/WindowToolbar.cpp
+++ b/UI/Qt/WindowToolbar.cpp
@@ -530,7 +530,6 @@ static ButtonType* create_toolbar_button(QWidget& parent, QAction& action)
return button;
}
-static constexpr int TOOLBAR_HORIZONTAL_MARGIN = 8;
// The buttons in the toolbar sit close together, while the address field keeps a wider gap on either side.
static constexpr int TOOLBAR_SPACING = 2;
// The separator after the collapsed sidebar's buttons keeps a little more room on either side.