diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-09-15 23:05:16 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-09-15 23:05:16 +0300 |
commit | b162094c7609fa37f2eef6be3fed0e26830bc506 (patch) | |
tree | 072b83f0ce6b7f871acd9a2d2c6c49b8dac7dc64 /src/gui/widgets/tabbedarea.cpp | |
parent | 4031a5068859fb99f604dfecceb2fb1c954e166f (diff) | |
download | plus-b162094c7609fa37f2eef6be3fed0e26830bc506.tar.gz plus-b162094c7609fa37f2eef6be3fed0e26830bc506.tar.bz2 plus-b162094c7609fa37f2eef6be3fed0e26830bc506.tar.xz plus-b162094c7609fa37f2eef6be3fed0e26830bc506.zip |
Improve a bit widgets speed.
Diffstat (limited to 'src/gui/widgets/tabbedarea.cpp')
-rw-r--r-- | src/gui/widgets/tabbedarea.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 06af8a83a..1cc990f21 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -139,10 +139,9 @@ void TabbedArea::addTab(gcn::Tab* tab, gcn::Widget* widget) gcn::TabbedArea::addTab(tab, widget); - const int width = getWidth() - 2 * getFrameSize(); - const int height = getHeight() - 2 * getFrameSize() - - mTabContainer->getHeight(); - widget->setSize(width, height); + const int frameSize = 2 * getFrameSize(); + widget->setSize(getWidth() - frameSize, + getHeight() - frameSize - mTabContainer->getHeight()); updateTabsWidth(); updateArrowEnableState(); @@ -193,8 +192,9 @@ void TabbedArea::removeTab(gcn::Tab *tab) } } - if (tabIndexToBeSelected >= static_cast<signed>(mTabs.size())) - tabIndexToBeSelected = static_cast<int>(mTabs.size()) - 1; + const int tabsSize = static_cast<int>(mTabs.size()); + if (tabIndexToBeSelected >= tabsSize) + tabIndexToBeSelected = tabsSize - 1; if (tabIndexToBeSelected < -1) tabIndexToBeSelected = -1; @@ -269,10 +269,11 @@ void TabbedArea::setSelectedTabByPos(int tab) void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED) { - const int width = getWidth() - 2 * getFrameSize() - - 2 * mWidgetContainer->getFrameSize(); - const int height = getHeight() - 2 * getFrameSize() - - mWidgetContainer->getY() - 2 * mWidgetContainer->getFrameSize(); + const int frameSize = 2 * getFrameSize(); + const int widgetFrameSize = 2 * mWidgetContainer->getFrameSize(); + const int width = getWidth() - frameSize - widgetFrameSize; + const int height = getHeight() - frameSize + - mWidgetContainer->getY() - widgetFrameSize; mWidgetContainer->setSize(width, height); gcn::Widget *const w = getCurrentWidget(); @@ -356,11 +357,12 @@ void TabbedArea::updateVisibleTabsWidth() void TabbedArea::adjustTabPositions() { int maxTabHeight = 0; - size_t sz = mTabs.size(); + const size_t sz = mTabs.size(); for (size_t i = 0; i < sz; ++i) { - if (mTabs[i].first && mTabs[i].first->getHeight() > maxTabHeight) - maxTabHeight = mTabs[i].first->getHeight(); + const gcn::Tab *const tab = mTabs[i].first; + if (tab && tab->getHeight() > maxTabHeight) + maxTabHeight = tab->getHeight(); } int x = mArrowButton[0]->isVisible() ? mArrowButton[0]->getWidth() : 0; |