1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

WindowServer: Make WSWindowFrame and WSButton deal in relative coordinates.

This was a bit painful to get right. The code is a lot more pleasant to
deal with now that all coordinates are relative to their local system
instead of being absolute screen coordinates.
This commit is contained in:
Andreas Kling 2019-04-05 21:33:34 +02:00
parent 2ac2d79a8e
commit 0d60c56b51
6 changed files with 67 additions and 79 deletions

View file

@ -13,8 +13,10 @@ public:
WSButton(Retained<CharacterBitmap>&&, Function<void()>&& on_click_handler);
~WSButton();
Rect rect() const { return m_rect; }
void set_rect(const Rect& rect) { m_rect = rect; }
Rect relative_rect() const { return m_relative_rect; }
void set_relative_rect(const Rect& rect) { m_relative_rect = rect; }
Rect rect() const { return { { }, m_relative_rect.size() }; }
void paint(Painter&);
@ -25,7 +27,7 @@ public:
bool is_visible() const { return m_visible; }
private:
Rect m_rect;
Rect m_relative_rect;
Retained<CharacterBitmap> m_bitmap;
bool m_pressed { false };
bool m_visible { true };