diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-12-16 01:47:39 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-12-16 01:47:39 +0300 |
commit | abee7cd42ffa9c4fe6e789f6ceb98d7b695f8c72 (patch) | |
tree | 6e6841d6b8d0d25fbfad1de753f0a01cb96fce30 /src/gui/widgets | |
parent | ddfa72d8d01dacdcd38c159ea8dc024fe9d5562a (diff) | |
download | plus-abee7cd42ffa9c4fe6e789f6ceb98d7b695f8c72.tar.gz plus-abee7cd42ffa9c4fe6e789f6ceb98d7b695f8c72.tar.bz2 plus-abee7cd42ffa9c4fe6e789f6ceb98d7b695f8c72.tar.xz plus-abee7cd42ffa9c4fe6e789f6ceb98d7b695f8c72.zip |
Fix hiding tabs in skill dialog.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/tabbedarea.cpp | 50 | ||||
-rw-r--r-- | src/gui/widgets/tabbedarea.h | 2 |
2 files changed, 41 insertions, 11 deletions
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index fa874133b..9c45226ed 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -238,7 +238,7 @@ void TabbedArea::addTab(Tab *const tab, mTabContainer->add(tab); mTabs.push_back(std::pair<Tab*, Widget*>(tab, widget)); - if (!mSelectedTab) + if (!mSelectedTab && tab->mVisible == Visible_true) setSelectedTab(tab); adjustTabPositions(); @@ -248,6 +248,7 @@ void TabbedArea::addTab(Tab *const tab, widget->setSize(getWidth() - frameSize, getHeight() - frameSize - mTabContainer->getHeight()); + widgetResized(Event(nullptr)); updateTabsWidth(); updateArrowEnableState(); } @@ -419,6 +420,23 @@ void TabbedArea::setSelectedTab(Tab *const tab) widgetResized(Event(nullptr)); } +void TabbedArea::setSelectedTabDefault() +{ + if (mSelectedTab == nullptr || + mSelectedTab->mVisible == Visible_false) + { + for (size_t i = 0; i < mTabs.size(); i++) + { + Tab *const tab = mTabs[i].first; + if (tab && tab->mVisible == Visible_true) + { + setSelectedTab(tab); + return; + } + } + } +} + int TabbedArea::getSelectedTabIndex() const { for (unsigned int i = 0, fsz = CAST_U32(mTabs.size()); @@ -492,9 +510,13 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED) int newWidth = mVisibleTabsWidth; while (mTabScrollIndex && newWidth < innerWidth) { - newWidth += mTabs[mTabScrollIndex - 1].first->getWidth(); - if (newWidth < innerWidth) - --mTabScrollIndex; + Tab *const tab = mTabs[mTabScrollIndex - 1].first; + if (tab && tab->mVisible == Visible_true) + { + newWidth += tab->getWidth(); + if (newWidth < innerWidth) + --mTabScrollIndex; + } } if (mArrowButton[1]) @@ -516,8 +538,9 @@ void TabbedArea::updateTabsWidth() mTabsWidth = 0; FOR_EACH (TabContainer::const_iterator, itr, mTabs) { - if ((*itr).first) - mTabsWidth += (*itr).first->getWidth(); + Tab *const tab = (*itr).first; + if (tab && tab->mVisible == Visible_true) + mTabsWidth += tab->getWidth(); } updateVisibleTabsWidth(); } @@ -527,8 +550,9 @@ void TabbedArea::updateVisibleTabsWidth() mVisibleTabsWidth = 0; for (size_t i = mTabScrollIndex, sz = mTabs.size(); i < sz; ++i) { - if (mTabs[i].first) - mVisibleTabsWidth += CAST_S32(mTabs[i].first->getWidth()); + Tab *const tab = mTabs[i].first; + if (tab && tab->mVisible == Visible_true) + mVisibleTabsWidth += CAST_S32(tab->getWidth()); } } @@ -576,8 +600,12 @@ void TabbedArea::adjustTabPositions() for (size_t i = 0; i < sz; ++i) { const Tab *const tab = mTabs[i].first; - if (tab && tab->getHeight() > maxTabHeight) + if (tab && + tab->mVisible == Visible_true && + tab->getHeight() > maxTabHeight) + { maxTabHeight = tab->getHeight(); + } } int x = (mEnableScrollButtons && mArrowButton[0]->mVisible == Visible_true) @@ -585,7 +613,7 @@ void TabbedArea::adjustTabPositions() for (size_t i = mTabScrollIndex; i < sz; ++i) { Tab *const tab = mTabs[i].first; - if (!tab) + if (!tab || tab->mVisible == Visible_false) continue; tab->setPosition(x, maxTabHeight - tab->getHeight()); x += tab->getWidth(); @@ -598,7 +626,7 @@ void TabbedArea::adjustTabPositions() for (unsigned i = 0; i < mTabScrollIndex; ++i) { Tab *const tab = mTabs[i].first; - if (tab) + if (tab && tab->mVisible == Visible_true) { x -= tab->getWidth(); tab->setPosition(x, maxTabHeight - tab->getHeight()); diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 6d8bc84d2..e2d88eacf 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -167,6 +167,8 @@ class TabbedArea final : public ActionListener, void setSelectedTab(Tab *const tab); + void setSelectedTabDefault(); + void setSelectedTabByIndex(const size_t index); int getSelectedTabIndex() const A_WARN_UNUSED; |