ladybird/UI/Qt/WindowControlButton.h
Andreas Kling 4f314b0aa0 UI/Qt: Unify browser chrome layout
Treat the toolbar, tab strip, and vertical sidebar as one browser
chrome surface. Add an explicit layout policy for platform window
controls and sidebar widths. This lets macOS use left-side traffic
lights while other platforms keep right-side custom controls.

Keep the macOS toolbar stable in vertical-tabs mode. Traffic lights and
navigation controls stay in the top row, and the sidebar sits below it.
Draw chrome/content separators explicitly so the content edge remains
clear without adding seams inside the chrome surface.

Retune tab, toolbar, and omnibox styling for the unified chrome. Tabs
use card-like selected states, quiet inactive states, and matching
horizontal and vertical geometry.

Make hover-expanded vertical tabs draw as a chrome overlay so the web
content does not relayout. Keep the overlay above native web views and
route macOS window drags through AppKit events for reliable dragging
from custom chrome.
2026-06-03 02:53:37 +02:00

61 lines
1.6 KiB
C++

/*
* Copyright (c) 2026-present, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <QPoint>
#include <QSize>
#include <QString>
#include <QToolButton>
class QEnterEvent;
class QEvent;
class QMouseEvent;
class QPaintEvent;
class QWidget;
namespace Ladybird {
enum class WindowControlButtonType {
Minimize,
Maximize,
Close,
};
class WindowControlButton final : public QToolButton {
public:
WindowControlButton(WindowControlButtonType, QString const& tool_tip, QSize icon_size, QSize button_size, QWidget* parent = nullptr);
static QSize default_size(QSize non_macos_size);
static int default_spacing();
private:
virtual void paintEvent(QPaintEvent*) override;
virtual void enterEvent(QEnterEvent*) override;
virtual void leaveEvent(QEvent*) override;
virtual void mouseMoveEvent(QMouseEvent*) override;
virtual void mouseDoubleClickEvent(QMouseEvent*) override;
virtual void mousePressEvent(QMouseEvent*) override;
virtual void mouseReleaseEvent(QMouseEvent*) override;
void reset_transient_state();
void set_pressed_outside(bool);
void update_pressed_position(QPoint const&);
[[maybe_unused]] WindowControlButtonType m_type {};
bool m_tracking_press { false };
};
struct WindowControlButtons {
QWidget* container { nullptr };
WindowControlButton* minimize { nullptr };
WindowControlButton* maximize { nullptr };
WindowControlButton* close { nullptr };
};
WindowControlButtons create_window_control_buttons(QWidget& parent, char const* object_name, QSize icon_size, QSize non_macos_button_size);
}