summaryrefslogtreecommitdiff
path: root/Widgets/Widget.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-10 16:49:36 +0200
committerAndreas Kling <awesomekling@gmail.com>2018-10-10 16:49:36 +0200
commit6f37429f5744066e28a1dbfdd30d6406ec653c27 (patch)
treeeceec39f7e0a886888c021ec2b220708c682a154 /Widgets/Widget.h
parent8c84f9749e3220de767c78a2588808f0d9c54d79 (diff)
downloadserenity-6f37429f5744066e28a1dbfdd30d6406ec653c27.zip
Intense hacking on Widgets.
Diffstat (limited to 'Widgets/Widget.h')
-rw-r--r--Widgets/Widget.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/Widgets/Widget.h b/Widgets/Widget.h
index be6966300d..b934a157a9 100644
--- a/Widgets/Widget.h
+++ b/Widgets/Widget.h
@@ -2,6 +2,7 @@
#include "Event.h"
#include "Object.h"
+#include "Rect.h"
class Widget : public Object {
public:
@@ -18,9 +19,25 @@ public:
virtual void onMouseDown(MouseEvent&);
virtual void onMouseUp(MouseEvent&);
+ Rect rect() const { return m_rect; }
+ int x() const { return rect().x(); }
+ int y() const { return rect().y(); }
+ int width() const { return rect().width(); }
+ int height() const { return rect().height(); }
+
void update();
+ struct HitTestResult {
+ Widget* widget { nullptr };
+ int localX { 0 };
+ int localY { 0 };
+ };
+ HitTestResult hitTest(int x, int y);
+
+ virtual const char* className() const override { return "Widget"; }
+
+ void setRect(const Rect&);
+
private:
- int m_x { 0 };
- int m_y { 0 };
+ Rect m_rect;
};