mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00

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.
34 lines
774 B
C++
34 lines
774 B
C++
#pragma once
|
|
|
|
#include <SharedGraphics/Rect.h>
|
|
#include <AK/Function.h>
|
|
#include <AK/Retained.h>
|
|
|
|
class CharacterBitmap;
|
|
class Painter;
|
|
class WSMouseEvent;
|
|
|
|
class WSButton {
|
|
public:
|
|
WSButton(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() }; }
|
|
|
|
void paint(Painter&);
|
|
|
|
void on_mouse_event(const WSMouseEvent&);
|
|
|
|
Function<void()> on_click;
|
|
|
|
bool is_visible() const { return m_visible; }
|
|
|
|
private:
|
|
Rect m_relative_rect;
|
|
Retained<CharacterBitmap> m_bitmap;
|
|
bool m_pressed { false };
|
|
bool m_visible { true };
|
|
};
|