summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/widget.cc17
-rw-r--r--plugingui/widget.h14
2 files changed, 15 insertions, 16 deletions
diff --git a/plugingui/widget.cc b/plugingui/widget.cc
index 9b766df..4b92e65 100644
--- a/plugingui/widget.cc
+++ b/plugingui/widget.cc
@@ -103,6 +103,8 @@ void Widget::resize(int width, int height)
_width = width;
_height = height;
pixbuf.realloc(width, height);
+
+ sizeChangeNotifier(width, height);
}
void Widget::move(size_t x, size_t y)
@@ -111,12 +113,12 @@ void Widget::move(size_t x, size_t y)
_y = y;
}
-size_t Widget::x()
+int Widget::x()
{
return _x;
}
-size_t Widget::y()
+int Widget::y()
{
return _y;
}
@@ -153,26 +155,21 @@ size_t Widget::windowY()
return window_y;
}
-Widget* Widget::find(size_t x, size_t y)
+Widget* Widget::find(int x, int y)
{
for(auto i = children.rbegin(); i != children.rend(); ++i)
{
Widget* widget = *i;
if(widget->visible())
{
- if((widget->x() <= x) && ((widget->x() + widget->width()) >= x) &&
- (widget->y() <= y) && ((widget->y() + widget->height()) >= y))
+ if((x >= widget->x()) && (x < (widget->x() + (int)widget->width())) &&
+ (y >= widget->y()) && (y < (widget->y() + (int)widget->height())))
{
return widget->find(x - widget->x(), y - widget->y());
}
}
}
- if((x > width()) || (y > height()))
- {
- return nullptr;
- }
-
return this;
}
diff --git a/plugingui/widget.h b/plugingui/widget.h
index 9827641..6bfffb5 100644
--- a/plugingui/widget.h
+++ b/plugingui/widget.h
@@ -37,7 +37,7 @@ namespace GUI {
class Window;
-class Widget : public Listener, LayoutItem {
+class Widget : public Listener, public LayoutItem {
friend class Painter;
public:
Widget(Widget* parent);
@@ -49,8 +49,8 @@ public:
// From LayoutItem
virtual void resize(int width, int height) override;
virtual void move(size_t x, size_t y) override;
- virtual size_t x() override;
- virtual size_t y() override;
+ virtual int x() override;
+ virtual int y() override;
virtual size_t width() override;
virtual size_t height() override;
@@ -71,7 +71,7 @@ public:
virtual void mouseLeaveEvent() {}
virtual void mouseEnterEvent() {}
- Widget* find(size_t x, size_t y);
+ Widget* find(int x, int y);
virtual Window* window();
@@ -82,6 +82,8 @@ public:
bool visible();
void setVisible(bool visible);
+ Notifier<int, int> sizeChangeNotifier; // (int, width, int height)
+
protected:
void repaintChildren(RepaintEvent* repaintEvent);
@@ -92,8 +94,8 @@ protected:
Widget* parent = nullptr;
Window* _window = nullptr;
- size_t _x{0};
- size_t _y{0};
+ int _x{0};
+ int _y{0};
size_t _width{0};
size_t _height{0};