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/widgets/basiccontainer.cpp | |
parent | d9afcb2f48bebddf25c80a8489cd4041ddb7c8b5 (diff) | |
download | mv-917d35d6cbea488f07596d0403d0bef8d6413f8a.tar.gz mv-917d35d6cbea488f07596d0403d0bef8d6413f8a.tar.bz2 mv-917d35d6cbea488f07596d0403d0bef8d6413f8a.tar.xz mv-917d35d6cbea488f07596d0403d0bef8d6413f8a.zip |
Improve a bit basiccontainer.
Diffstat (limited to 'src/gui/widgets/basiccontainer.cpp')
-rw-r--r-- | src/gui/widgets/basiccontainer.cpp | 35 |
1 files changed, 16 insertions, 19 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); } } |