mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
LibGfx: Fix position of maximized glass window theme title buttons
Previously, the buttons would be cropped (by the border thickness) as the border is not shown on maximized windows. This patch adjusts the button positions to correct for that.
This commit is contained in:
1 parent
d725fba0c5
commit
026bbb46f2
9 files changed
+19
-14
No files matched your search
@@ -94,9 +94,9 @@ IsDark=false
|
||||
TitleButtonsIconOnly=true
|
||||
|
||||
[Metrics]
|
||||
BorderThickness=6
|
||||
BorderThickness=5
|
||||
BorderRadius=5
|
||||
TitleHeight=20
|
||||
TitleHeight=23
|
||||
TitleButtonWidth=29
|
||||
TitleButtonHeight=15
|
||||
|
||||
|
||||
@@ -198,8 +198,9 @@ IntRect ClassicWindowTheme::frame_rect_for_window(WindowType window_type, Window
|
||||
}
|
||||
}
|
||||
|
||||
Vector<IntRect> ClassicWindowTheme::layout_buttons(WindowType window_type, WindowMode window_mode, IntRect const& window_rect, Palette const& palette, size_t buttons) const
|
||||
Vector<IntRect> ClassicWindowTheme::layout_buttons(WindowType window_type, WindowMode window_mode, IntRect const& window_rect, Palette const& palette, size_t buttons, bool is_maximized) const
|
||||
{
|
||||
(void)is_maximized;
|
||||
int window_button_width = palette.window_title_button_width();
|
||||
int window_button_height = palette.window_title_button_height();
|
||||
int pos;
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
virtual IntRect frame_rect_for_window(WindowType, WindowMode, IntRect const& window_rect, Palette const&, int menu_row_count) const override;
|
||||
|
||||
virtual Vector<IntRect> layout_buttons(WindowType, WindowMode, IntRect const& window_rect, Palette const&, size_t buttons) const override;
|
||||
virtual Vector<IntRect> layout_buttons(WindowType, WindowMode, IntRect const& window_rect, Palette const&, size_t buttons, bool is_maximized = false) const override;
|
||||
virtual bool is_simple_rect_frame() const override { return true; }
|
||||
virtual bool frame_uses_alpha(WindowState state, Palette const& palette) const override
|
||||
{
|
||||
|
||||
@@ -130,12 +130,16 @@ void GlassWindowTheme::paint_normal_frame(Painter& painter, WindowState window_s
|
||||
}
|
||||
}
|
||||
|
||||
Vector<IntRect> GlassWindowTheme::layout_buttons(WindowType window_type, WindowMode window_mode, IntRect const& window_rect, Palette const& palette, size_t buttons) const
|
||||
Vector<IntRect> GlassWindowTheme::layout_buttons(WindowType window_type, WindowMode window_mode, IntRect const& window_rect, Palette const& palette, size_t buttons, bool is_maximized) const
|
||||
{
|
||||
auto button_rects = ClassicWindowTheme::layout_buttons(window_type, window_mode, window_rect, palette, buttons);
|
||||
for (auto& rect : button_rects)
|
||||
rect.translate_by(-s_window_border_radius_mask.width() - 1, 1);
|
||||
auto button_rects = ClassicWindowTheme::layout_buttons(window_type, window_mode, window_rect, palette, buttons, is_maximized);
|
||||
auto button_offset = [&](IntRect button_rect) -> IntPoint {
|
||||
return { -max(palette.window_border_thickness(), s_window_border_radius_mask.width()) - 1,
|
||||
-button_rect.y() + (is_maximized ? palette.window_border_thickness() : 1) + 3 };
|
||||
};
|
||||
|
||||
for (auto& button_rect : button_rects)
|
||||
button_rect.translate_by(button_offset(button_rect));
|
||||
return button_rects;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class GlassWindowTheme : public ClassicWindowTheme {
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual Vector<IntRect> layout_buttons(WindowType, WindowMode, IntRect const& window_rect, Palette const&, size_t buttons) const override;
|
||||
virtual Vector<IntRect> layout_buttons(WindowType, WindowMode, IntRect const& window_rect, Palette const&, size_t buttons, bool is_maximized = false) const override;
|
||||
|
||||
virtual float frame_alpha_hit_threshold(WindowState) const override { return 0.6f; }
|
||||
|
||||
|
||||
@@ -133,9 +133,9 @@ void PlasticWindowTheme::paint_normal_frame(Painter& painter, WindowState window
|
||||
}
|
||||
}
|
||||
|
||||
Vector<IntRect> PlasticWindowTheme::layout_buttons(WindowType window_type, WindowMode window_mode, IntRect const& window_rect, Palette const& palette, size_t buttons) const
|
||||
Vector<IntRect> PlasticWindowTheme::layout_buttons(WindowType window_type, WindowMode window_mode, IntRect const& window_rect, Palette const& palette, size_t buttons, bool is_maximized) const
|
||||
{
|
||||
auto button_rects = ClassicWindowTheme::layout_buttons(window_type, window_mode, window_rect, palette, buttons);
|
||||
auto button_rects = ClassicWindowTheme::layout_buttons(window_type, window_mode, window_rect, palette, buttons, is_maximized);
|
||||
for (auto& rect : button_rects)
|
||||
rect.translate_by(-s_window_border_radius_mask.width(), 2);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class PlasticWindowTheme : public ClassicWindowTheme {
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual Vector<IntRect> layout_buttons(WindowType, WindowMode, IntRect const& window_rect, Palette const&, size_t buttons) const override;
|
||||
virtual Vector<IntRect> layout_buttons(WindowType, WindowMode, IntRect const& window_rect, Palette const&, size_t buttons, bool is_maximized = false) const override;
|
||||
|
||||
virtual void paint_taskbar(Painter&, IntRect const& taskbar_rect, Palette const&) const override;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
virtual IntRect frame_rect_for_window(WindowType, WindowMode, IntRect const& window_rect, Palette const&, int menu_row_count) const = 0;
|
||||
|
||||
virtual Vector<IntRect> layout_buttons(WindowType, WindowMode, IntRect const& window_rect, Palette const&, size_t buttons) const = 0;
|
||||
virtual Vector<IntRect> layout_buttons(WindowType, WindowMode, IntRect const& window_rect, Palette const&, size_t buttons, bool is_maximized = false) const = 0;
|
||||
virtual bool is_simple_rect_frame() const = 0;
|
||||
virtual bool frame_uses_alpha(WindowState, Palette const&) const = 0;
|
||||
virtual bool taskbar_uses_alpha() const = 0;
|
||||
|
||||
@@ -669,7 +669,7 @@ void WindowFrame::window_rect_changed(Gfx::IntRect const& old_rect, Gfx::IntRect
|
||||
|
||||
void WindowFrame::layout_buttons()
|
||||
{
|
||||
auto button_rects = current_window_theme().layout_buttons(to_theme_window_type(m_window.type()), to_theme_window_mode(m_window.mode()), m_window.rect(), WindowManager::the().palette(), m_buttons.size());
|
||||
auto button_rects = current_window_theme().layout_buttons(to_theme_window_type(m_window.type()), to_theme_window_mode(m_window.mode()), m_window.rect(), WindowManager::the().palette(), m_buttons.size(), m_window.is_maximized());
|
||||
for (size_t i = 0; i < m_buttons.size(); i++)
|
||||
m_buttons[i]->set_relative_rect(button_rects[i]);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user