From 876e370925a021bb6731703c3db2db2945f62f85 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 19 Oct 2012 14:59:36 +0300 Subject: Fix tabbed area containers size. --- src/gui/widgets/tabbedarea.cpp | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src/gui') diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 31bab2599..b1d0ca35e 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -62,8 +62,6 @@ TabbedArea::TabbedArea() : add(mTabContainer); add(mWidgetContainer); - - mWidgetContainer->setOpaque(false); addWidgetListener(this); @@ -170,7 +168,6 @@ void TabbedArea::addTab(Tab* tab, gcn::Widget* widget) if (!tab || !widget) return; - tab->setTabbedArea(this); tab->addActionListener(this); @@ -183,8 +180,6 @@ void TabbedArea::addTab(Tab* tab, gcn::Widget* widget) adjustTabPositions(); adjustSize(); - - const int frameSize = 2 * getFrameSize(); widget->setSize(getWidth() - frameSize, getHeight() - frameSize - mTabContainer->getHeight()); @@ -374,25 +369,25 @@ void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED) if (w) { int newScroll = 0; - ScrollArea* scr = nullptr; - if (mFollowDownScroll && height != 0) + ScrollArea* scr = dynamic_cast(w); + if (scr) { - const gcn::Rectangle rect = w->getDimension(); - if (rect.height != 0 && rect.height > height + 2) + if (mFollowDownScroll && height != 0) { - scr = dynamic_cast(w); - if (scr && scr->getVerticalScrollAmount() - >= scr->getVerticalMaxScroll() - 2 - && scr->getVerticalScrollAmount() - <= scr->getVerticalMaxScroll() + 2) + const gcn::Rectangle rect = w->getDimension(); + if (rect.height != 0 && rect.height > height + 2) { - newScroll = scr->getVerticalScrollAmount() - + rect.height - height; + if (scr && scr->getVerticalScrollAmount() + >= scr->getVerticalMaxScroll() - 2 + && scr->getVerticalScrollAmount() + <= scr->getVerticalMaxScroll() + 2) + { + newScroll = scr->getVerticalScrollAmount() + + rect.height - height; + } } } } - w->setSize(mWidgetContainer->getWidth(), - mWidgetContainer->getHeight()); if (scr && newScroll) scr->setVerticalScrollAmount(newScroll); } @@ -463,6 +458,16 @@ void TabbedArea::adjustSize() mWidgetContainer->setPosition(0, maxTabHeight); mWidgetContainer->setSize(getWidth(), getHeight() - maxTabHeight); + gcn::Widget *const w = getCurrentWidget(); + if (w) + { + const int wFrameSize = w->getFrameSize(); + const int frame2 = 2 * wFrameSize; + + w->setPosition(wFrameSize, wFrameSize); + w->setSize(mWidgetContainer->getWidth() - frame2, + mWidgetContainer->getHeight() - frame2); + } } void TabbedArea::adjustTabPositions() -- cgit v1.2.3-60-g2f50