mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
WindowServer: Make WSButton behave more like a normal button.
Previously it would just close the window on MouseDown. Now we do the normal thing where we require a MouseUp inside the button rect before committing.
This commit is contained in:
parent
0d60c56b51
commit
0fc3ccaa52
6 changed files with 56 additions and 8 deletions
|
@ -7,16 +7,18 @@
|
|||
class CharacterBitmap;
|
||||
class Painter;
|
||||
class WSMouseEvent;
|
||||
class WSWindowFrame;
|
||||
|
||||
class WSButton {
|
||||
class WSButton final {
|
||||
public:
|
||||
WSButton(Retained<CharacterBitmap>&&, Function<void()>&& on_click_handler);
|
||||
WSButton(WSWindowFrame&, Retained<CharacterBitmap>&&, Function<void()>&& on_click_handler);
|
||||
~WSButton();
|
||||
|
||||
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() }; }
|
||||
Rect screen_rect() const;
|
||||
|
||||
void paint(Painter&);
|
||||
|
||||
|
@ -27,6 +29,7 @@ public:
|
|||
bool is_visible() const { return m_visible; }
|
||||
|
||||
private:
|
||||
WSWindowFrame& m_frame;
|
||||
Rect m_relative_rect;
|
||||
Retained<CharacterBitmap> m_bitmap;
|
||||
bool m_pressed { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue