mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
WindowServer+LibGfx: Move window frame rect calculation to WindowTheme
This commit is contained in:
parent
0e627b0273
commit
de1a54c378
Notes:
sideshowbarker
2024-07-19 04:04:20 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/de1a54c3780
4 changed files with 41 additions and 22 deletions
|
@ -147,7 +147,30 @@ void ClassicWindowTheme::paint_notification_frame(Painter& painter, const IntRec
|
|||
painter.draw_line({ titlebar_rect.x() + i, stripe_top }, { titlebar_rect.x() + i, stripe_bottom }, palette.active_window_title_stripes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IntRect ClassicWindowTheme::frame_rect_for_window(WindowType window_type, const IntRect& window_rect, const Gfx::Palette& palette) const
|
||||
{
|
||||
auto window_titlebar_height = palette.window_title_height();
|
||||
|
||||
switch (window_type) {
|
||||
case WindowType::Normal:
|
||||
return {
|
||||
window_rect.x() - 4,
|
||||
window_rect.y() - window_titlebar_height - 6,
|
||||
window_rect.width() + 8,
|
||||
window_rect.height() + 10 + window_titlebar_height
|
||||
};
|
||||
case WindowType::Notification:
|
||||
return {
|
||||
window_rect.x() - 3,
|
||||
window_rect.y() - 3,
|
||||
window_rect.width() + 6 + window_titlebar_height,
|
||||
window_rect.height() + 6
|
||||
};
|
||||
default:
|
||||
return window_rect;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
virtual IntRect title_bar_icon_rect(WindowType, const IntRect& window_rect, const Palette&) const override;
|
||||
virtual IntRect title_bar_text_rect(WindowType, const IntRect& window_rect, const Palette&) const override;
|
||||
|
||||
virtual IntRect frame_rect_for_window(WindowType, const IntRect& window_rect, const Palette&) const override;
|
||||
|
||||
private:
|
||||
struct FrameColors {
|
||||
Color title_color;
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
enum class WindowType {
|
||||
Normal,
|
||||
Notification,
|
||||
Other,
|
||||
};
|
||||
|
||||
enum class WindowState {
|
||||
|
@ -56,6 +57,8 @@ public:
|
|||
virtual IntRect title_bar_icon_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0;
|
||||
virtual IntRect title_bar_text_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0;
|
||||
|
||||
virtual IntRect frame_rect_for_window(WindowType, const IntRect& window_rect, const Palette&) const = 0;
|
||||
|
||||
protected:
|
||||
WindowTheme() { }
|
||||
};
|
||||
|
|
|
@ -39,6 +39,18 @@
|
|||
|
||||
namespace WindowServer {
|
||||
|
||||
static Gfx::WindowTheme::WindowType to_theme_window_type(WindowType type)
|
||||
{
|
||||
switch (type) {
|
||||
case WindowType::Normal:
|
||||
return Gfx::WindowTheme::WindowType::Normal;
|
||||
case WindowType::Notification:
|
||||
return Gfx::WindowTheme::WindowType::Notification;
|
||||
default:
|
||||
return Gfx::WindowTheme::WindowType::Other;
|
||||
}
|
||||
}
|
||||
|
||||
static Gfx::Bitmap* s_minimize_icon;
|
||||
static Gfx::Bitmap* s_maximize_icon;
|
||||
static Gfx::Bitmap* s_restore_icon;
|
||||
|
@ -207,28 +219,7 @@ static Gfx::IntRect frame_rect_for_window(Window& window, const Gfx::IntRect& re
|
|||
{
|
||||
if (window.is_frameless())
|
||||
return rect;
|
||||
|
||||
auto type = window.type();
|
||||
auto window_titlebar_height = WindowManager::the().palette().window_title_height();
|
||||
|
||||
switch (type) {
|
||||
case WindowType::Normal:
|
||||
return {
|
||||
rect.x() - 4,
|
||||
rect.y() - window_titlebar_height - 6,
|
||||
rect.width() + 8,
|
||||
rect.height() + 10 + window_titlebar_height
|
||||
};
|
||||
case WindowType::Notification:
|
||||
return {
|
||||
rect.x() - 3,
|
||||
rect.y() - 3,
|
||||
rect.width() + 6 + window_titlebar_height,
|
||||
rect.height() + 6
|
||||
};
|
||||
default:
|
||||
return rect;
|
||||
}
|
||||
return Gfx::WindowTheme::current().frame_rect_for_window(to_theme_window_type(window.type()), rect, WindowManager::the().palette());
|
||||
}
|
||||
|
||||
static Gfx::IntRect frame_rect_for_window(Window& window)
|
||||
|
|
Loading…
Reference in a new issue