mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
WindowServer+LibGfx: Move window frame rect calculation to WindowTheme
This commit is contained in:
parent
0e627b0273
commit
de1a54c378
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());
|
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_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 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:
|
private:
|
||||||
struct FrameColors {
|
struct FrameColors {
|
||||||
Color title_color;
|
Color title_color;
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
enum class WindowType {
|
enum class WindowType {
|
||||||
Normal,
|
Normal,
|
||||||
Notification,
|
Notification,
|
||||||
|
Other,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class WindowState {
|
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_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 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:
|
protected:
|
||||||
WindowTheme() { }
|
WindowTheme() { }
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,6 +39,18 @@
|
||||||
|
|
||||||
namespace WindowServer {
|
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_minimize_icon;
|
||||||
static Gfx::Bitmap* s_maximize_icon;
|
static Gfx::Bitmap* s_maximize_icon;
|
||||||
static Gfx::Bitmap* s_restore_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())
|
if (window.is_frameless())
|
||||||
return rect;
|
return rect;
|
||||||
|
return Gfx::WindowTheme::current().frame_rect_for_window(to_theme_window_type(window.type()), rect, WindowManager::the().palette());
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Gfx::IntRect frame_rect_for_window(Window& window)
|
static Gfx::IntRect frame_rect_for_window(Window& window)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue