From e4088c3bbfd71f1a9f4ae7344bd5c43202b2ed3e Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 29 Nov 2015 21:27:20 +0100 Subject: Fix find of child widgets starting 'before' (0,0). --- plugingui/widget.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'plugingui/widget.cc') 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; } -- cgit v1.2.3