diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-27 17:35:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-27 17:35:08 +0300 |
commit | 917d35d6cbea488f07596d0403d0bef8d6413f8a (patch) | |
tree | e8ae5cdd0c7a271669aee556cf54e4d7aff3b915 /src/gui | |
parent | d9afcb2f48bebddf25c80a8489cd4041ddb7c8b5 (diff) | |
download | plus-917d35d6cbea488f07596d0403d0bef8d6413f8a.tar.gz plus-917d35d6cbea488f07596d0403d0bef8d6413f8a.tar.bz2 plus-917d35d6cbea488f07596d0403d0bef8d6413f8a.tar.xz plus-917d35d6cbea488f07596d0403d0bef8d6413f8a.zip |
Improve a bit basiccontainer.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/basiccontainer.cpp | 35 | ||||
-rw-r--r-- | src/gui/widgets/basiccontainer.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/widget.h | 2 |
5 files changed, 22 insertions, 23 deletions
diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp index 96dfffef7..e8f29ff9b 100644 --- a/src/gui/widgets/basiccontainer.cpp +++ b/src/gui/widgets/basiccontainer.cpp @@ -382,38 +382,35 @@ void BasicContainer::logicChildren() BLOCK_END("BasicContainer::logicChildren") } -void BasicContainer::showWidgetPart(Widget *const widget, Rect area) +void BasicContainer::showWidgetPart(Widget *const widget, const Rect &area) { const Rect widgetArea = getChildrenArea(); const int x = widget->mDimension.x; const int y = widget->mDimension.y; - area.x += x; - area.y += y; - - if (area.x + area.width > widgetArea.width) - widget->setX(x - area.x - area.width + widgetArea.width); - - if (area.y + area.height > widgetArea.height) - widget->setY(y - area.y - area.height + widgetArea.height); - - if (area.x < 0) - widget->setX(x - area.x); - - if (area.y < 0) - widget->setY(y - area.y); + const int ax = area.x + x; + const int ay = area.y + y; + + if (ax < 0) + widget->setX(-area.x); + else if (ax + area.width > widgetArea.width) + widget->setX(widgetArea.width - area.x - area.width); + + if (ay < 0) + widget->setY(-area.y); + else if (ay + area.height > widgetArea.height) + widget->setY(widgetArea.height - area.y - area.height); } void BasicContainer::setInternalFocusHandler(FocusHandler* focusHandler) { Widget::setInternalFocusHandler(focusHandler); + FocusHandler *handler = mInternalFocusHandler ? + mInternalFocusHandler : getFocusHandler(); FOR_EACH (WidgetListConstIterator, iter, mWidgets) { - if (!mInternalFocusHandler) - (*iter)->setFocusHandler(getFocusHandler()); - else - (*iter)->setFocusHandler(mInternalFocusHandler); + (*iter)->setFocusHandler(handler); } } diff --git a/src/gui/widgets/basiccontainer.h b/src/gui/widgets/basiccontainer.h index ecc79cba2..ec4a39115 100644 --- a/src/gui/widgets/basiccontainer.h +++ b/src/gui/widgets/basiccontainer.h @@ -105,7 +105,8 @@ class BasicContainer notfinal : public Widget, * itself to be visible. * @param rectangle The rectangle to be visible. */ - void showWidgetPart(Widget *const widget, Rect area) override; + void showWidgetPart(Widget *const widget, + const Rect &area) override; // Inherited from Widget diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 1eb5417e8..23b681907 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -1275,7 +1275,7 @@ void ScrollArea::setScrollbarWidth(const int width) mScrollbarWidth = width; } -void ScrollArea::showWidgetPart(Widget *const widget, Rect area) +void ScrollArea::showWidgetPart(Widget *const widget, const Rect &area) { const Widget *const content = getContent(); if (widget != content) diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index d166f235c..deb24ff79 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -412,7 +412,8 @@ class ScrollArea final : public BasicContainer, int getDownButtonScrollAmount() const { return mDownButtonScrollAmount; } - void showWidgetPart(Widget *const widget, Rect area) override final; + void showWidgetPart(Widget *const widget, + const Rect &area) override final; Rect getChildrenArea() override final; diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index 7c3134302..2c8c121e0 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -968,7 +968,7 @@ class Widget notfinal : public Widget2 * @since 0.1.0 */ virtual void showWidgetPart(Widget *const widget A_UNUSED, - Rect area A_UNUSED) + const Rect &area A_UNUSED) { } /** |