diff options
author | Jacek Antonelli | 2008-08-15 23:45:04 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:04 -0500 |
commit | 117e22047c5752352342d64e3fb7ce00a4eb8113 (patch) | |
tree | e32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/llui/lltabcontainer.cpp | |
parent | Second Life viewer sources 1.18.0.6 (diff) | |
download | meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2 meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz |
Second Life viewer sources 1.18.1.2
Diffstat (limited to 'linden/indra/llui/lltabcontainer.cpp')
-rw-r--r-- | linden/indra/llui/lltabcontainer.cpp | 114 |
1 files changed, 60 insertions, 54 deletions
diff --git a/linden/indra/llui/lltabcontainer.cpp b/linden/indra/llui/lltabcontainer.cpp index 01c06c3..135931d 100644 --- a/linden/indra/llui/lltabcontainer.cpp +++ b/linden/indra/llui/lltabcontainer.cpp | |||
@@ -70,6 +70,7 @@ LLTabContainerCommon::LLTabContainerCommon( | |||
70 | : | 70 | : |
71 | LLPanel(name, rect, bordered), | 71 | LLPanel(name, rect, bordered), |
72 | mCurrentTabIdx(-1), | 72 | mCurrentTabIdx(-1), |
73 | mTabsHidden(FALSE), | ||
73 | mScrolled(FALSE), | 74 | mScrolled(FALSE), |
74 | mScrollPos(0), | 75 | mScrollPos(0), |
75 | mScrollPosPixels(0), | 76 | mScrollPosPixels(0), |
@@ -95,6 +96,7 @@ LLTabContainerCommon::LLTabContainerCommon( | |||
95 | : | 96 | : |
96 | LLPanel(name, rect_control, bordered), | 97 | LLPanel(name, rect_control, bordered), |
97 | mCurrentTabIdx(-1), | 98 | mCurrentTabIdx(-1), |
99 | mTabsHidden(FALSE), | ||
98 | mScrolled(FALSE), | 100 | mScrolled(FALSE), |
99 | mScrollPos(0), | 101 | mScrollPos(0), |
100 | mScrollPosPixels(0), | 102 | mScrollPosPixels(0), |
@@ -147,11 +149,11 @@ void LLTabContainerCommon::addPlaceholder(LLPanel* child, const LLString& label) | |||
147 | addTabPanel(child, label, FALSE, NULL, NULL, 0, TRUE); | 149 | addTabPanel(child, label, FALSE, NULL, NULL, 0, TRUE); |
148 | } | 150 | } |
149 | 151 | ||
150 | void LLTabContainerCommon::lockTabs() | 152 | void LLTabContainerCommon::lockTabs(S32 num_tabs) |
151 | { | 153 | { |
152 | // count current tabs and ensure no new tabs get | 154 | // count current tabs or use supplied value and ensure no new tabs get |
153 | // inserted between them | 155 | // inserted between them |
154 | mLockedTabCount = getTabCount(); | 156 | mLockedTabCount = num_tabs > 0 ? num_tabs : getTabCount(); |
155 | } | 157 | } |
156 | 158 | ||
157 | void LLTabContainerCommon::removeTabPanel(LLPanel* child) | 159 | void LLTabContainerCommon::removeTabPanel(LLPanel* child) |
@@ -542,12 +544,12 @@ void LLTabContainerCommon::setTabPanelFlashing(LLPanel* child, BOOL state ) | |||
542 | } | 544 | } |
543 | } | 545 | } |
544 | 546 | ||
545 | void LLTabContainerCommon::setTabImage(LLPanel* child, std::string img_name) | 547 | void LLTabContainerCommon::setTabImage(LLPanel* child, std::string img_name, const LLColor4& color) |
546 | { | 548 | { |
547 | LLTabTuple* tuple = getTabByPanel(child); | 549 | LLTabTuple* tuple = getTabByPanel(child); |
548 | if( tuple ) | 550 | if( tuple ) |
549 | { | 551 | { |
550 | tuple->mButton->setImageOverlay(img_name, LLFontGL::RIGHT); | 552 | tuple->mButton->setImageOverlay(img_name, LLFontGL::RIGHT, color); |
551 | } | 553 | } |
552 | } | 554 | } |
553 | 555 | ||
@@ -667,6 +669,8 @@ LLView* LLTabContainerCommon::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtr | |||
667 | } | 669 | } |
668 | } | 670 | } |
669 | 671 | ||
672 | node->getAttributeBOOL("hide_tabs", tab_container->mTabsHidden); | ||
673 | |||
670 | tab_container->setPanelParameters(node, parent); | 674 | tab_container->setPanelParameters(node, parent); |
671 | 675 | ||
672 | if (LLFloater::getFloaterHost()) | 676 | if (LLFloater::getFloaterHost()) |
@@ -1036,10 +1040,11 @@ void LLTabContainer::setPanelTitle(S32 index, const LLString& title) | |||
1036 | { | 1040 | { |
1037 | if (index >= 0 && index < (S32)mTabList.size()) | 1041 | if (index >= 0 && index < (S32)mTabList.size()) |
1038 | { | 1042 | { |
1039 | LLButton* tab_button = mTabList[index]->mButton; | 1043 | LLTabTuple* tuple = mTabList[index]; |
1044 | LLButton* tab_button = tuple->mButton; | ||
1040 | const LLFontGL* fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL ); | 1045 | const LLFontGL* fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL ); |
1041 | mTotalTabWidth -= tab_button->getRect().getWidth(); | 1046 | mTotalTabWidth -= tab_button->getRect().getWidth(); |
1042 | tab_button->reshape(llclamp(fontp->getWidth(title) + TAB_PADDING, mMinTabWidth, mMaxTabWidth), tab_button->getRect().getHeight()); | 1047 | tab_button->reshape(llclamp(fontp->getWidth(title) + TAB_PADDING + tuple->mPadding, mMinTabWidth, mMaxTabWidth), tab_button->getRect().getHeight()); |
1043 | mTotalTabWidth += tab_button->getRect().getWidth(); | 1048 | mTotalTabWidth += tab_button->getRect().getWidth(); |
1044 | tab_button->setLabelSelected(title); | 1049 | tab_button->setLabelSelected(title); |
1045 | tab_button->setLabelUnselected(title); | 1050 | tab_button->setLabelUnselected(title); |
@@ -1245,63 +1250,60 @@ void LLTabContainer::draw() | |||
1245 | 1250 | ||
1246 | LLPanel::draw(); | 1251 | LLPanel::draw(); |
1247 | 1252 | ||
1248 | // Show all the buttons | 1253 | // if tabs are hidden, don't draw them and leave them in the invisible state |
1249 | for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) | 1254 | if (!mTabsHidden) |
1250 | { | 1255 | { |
1251 | LLTabTuple* tuple = *iter; | 1256 | // Show all the buttons |
1252 | tuple->mButton->setVisible( TRUE ); | 1257 | for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) |
1253 | } | 1258 | { |
1254 | 1259 | LLTabTuple* tuple = *iter; | |
1255 | // Draw some of the buttons... | 1260 | tuple->mButton->setVisible( TRUE ); |
1261 | } | ||
1256 | 1262 | ||
1257 | LLGLEnable scissor_test(has_scroll_arrows ? GL_SCISSOR_TEST : GL_FALSE); | 1263 | // Draw some of the buttons... |
1258 | if( has_scroll_arrows ) | 1264 | LLRect clip_rect = getLocalRect(); |
1259 | { | 1265 | if (has_scroll_arrows) |
1260 | // ...but clip them. | ||
1261 | S32 x1 = mLeftArrowBtn->getRect().mRight; | ||
1262 | S32 y1 = 0; | ||
1263 | S32 x2 = mRightArrowBtn->getRect().mLeft; | ||
1264 | S32 y2 = 1; | ||
1265 | if (mTabList.size() > 0) | ||
1266 | { | 1266 | { |
1267 | y2 = mTabList[0]->mButton->getRect().mTop; | 1267 | // ...but clip them. |
1268 | clip_rect.mLeft = mLeftArrowBtn->getRect().mRight; | ||
1269 | clip_rect.mRight = mRightArrowBtn->getRect().mLeft; | ||
1268 | } | 1270 | } |
1269 | LLUI::setScissorRegionLocal(LLRect(x1, y2, x2, y1)); | 1271 | LLLocalClipRect clip(clip_rect); |
1270 | } | ||
1271 | 1272 | ||
1272 | S32 max_scroll_visible = mTabList.size() - mMaxScrollPos + mScrollPos; | 1273 | S32 max_scroll_visible = mTabList.size() - mMaxScrollPos + mScrollPos; |
1273 | S32 idx = 0; | 1274 | S32 idx = 0; |
1274 | for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) | 1275 | for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) |
1275 | { | 1276 | { |
1276 | LLTabTuple* tuple = *iter; | 1277 | LLTabTuple* tuple = *iter; |
1277 | 1278 | ||
1278 | tuple->mButton->translate( left - tuple->mButton->getRect().mLeft, 0 ); | 1279 | tuple->mButton->translate( left - tuple->mButton->getRect().mLeft, 0 ); |
1279 | left += tuple->mButton->getRect().getWidth(); | 1280 | left += tuple->mButton->getRect().getWidth(); |
1280 | 1281 | ||
1281 | if( idx < mScrollPos ) | 1282 | if( idx < mScrollPos ) |
1282 | { | ||
1283 | if( tuple->mButton->getFlashing() ) | ||
1284 | { | 1283 | { |
1285 | mLeftArrowBtn->setFlashing( TRUE ); | 1284 | if( tuple->mButton->getFlashing() ) |
1285 | { | ||
1286 | mLeftArrowBtn->setFlashing( TRUE ); | ||
1287 | } | ||
1286 | } | 1288 | } |
1287 | } | 1289 | else |
1288 | else | 1290 | if( max_scroll_visible < idx ) |
1289 | if( max_scroll_visible < idx ) | ||
1290 | { | ||
1291 | if( tuple->mButton->getFlashing() ) | ||
1292 | { | 1291 | { |
1293 | mRightArrowBtn->setFlashing( TRUE ); | 1292 | if( tuple->mButton->getFlashing() ) |
1293 | { | ||
1294 | mRightArrowBtn->setFlashing( TRUE ); | ||
1295 | } | ||
1294 | } | 1296 | } |
1295 | } | ||
1296 | 1297 | ||
1297 | LLUI::pushMatrix(); | 1298 | LLUI::pushMatrix(); |
1298 | { | 1299 | { |
1299 | LLUI::translate((F32)tuple->mButton->getRect().mLeft, (F32)tuple->mButton->getRect().mBottom, 0.f); | 1300 | LLUI::translate((F32)tuple->mButton->getRect().mLeft, (F32)tuple->mButton->getRect().mBottom, 0.f); |
1300 | tuple->mButton->draw(); | 1301 | tuple->mButton->draw(); |
1302 | } | ||
1303 | LLUI::popMatrix(); | ||
1304 | |||
1305 | idx++; | ||
1301 | } | 1306 | } |
1302 | LLUI::popMatrix(); | ||
1303 | |||
1304 | idx++; | ||
1305 | } | 1307 | } |
1306 | 1308 | ||
1307 | mLeftArrowBtn->setFlashing(FALSE); | 1309 | mLeftArrowBtn->setFlashing(FALSE); |
@@ -1628,12 +1630,12 @@ BOOL LLTabContainer::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDrag | |||
1628 | return LLView::handleDragAndDrop(x, y, mask, drop, type, cargo_data, accept, tooltip); | 1630 | return LLView::handleDragAndDrop(x, y, mask, drop, type, cargo_data, accept, tooltip); |
1629 | } | 1631 | } |
1630 | 1632 | ||
1631 | void LLTabContainer::setTabImage(LLPanel* child, std::string image_name) | 1633 | void LLTabContainer::setTabImage(LLPanel* child, std::string image_name, const LLColor4& color) |
1632 | { | 1634 | { |
1633 | LLTabTuple* tuple = getTabByPanel(child); | 1635 | LLTabTuple* tuple = getTabByPanel(child); |
1634 | if( tuple ) | 1636 | if( tuple ) |
1635 | { | 1637 | { |
1636 | tuple->mButton->setImageOverlay(image_name, LLFontGL::RIGHT); | 1638 | tuple->mButton->setImageOverlay(image_name, LLFontGL::RIGHT, color); |
1637 | 1639 | ||
1638 | const LLFontGL* fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL ); | 1640 | const LLFontGL* fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL ); |
1639 | // remove current width from total tab strip width | 1641 | // remove current width from total tab strip width |
@@ -1642,7 +1644,11 @@ void LLTabContainer::setTabImage(LLPanel* child, std::string image_name) | |||
1642 | S32 image_overlay_width = tuple->mButton->getImageOverlay().notNull() ? | 1644 | S32 image_overlay_width = tuple->mButton->getImageOverlay().notNull() ? |
1643 | tuple->mButton->getImageOverlay()->getWidth(0) : | 1645 | tuple->mButton->getImageOverlay()->getWidth(0) : |
1644 | 0; | 1646 | 0; |
1645 | tuple->mButton->reshape(llclamp(fontp->getWidth(tuple->mButton->getLabelSelected()) + TAB_PADDING + image_overlay_width, mMinTabWidth, mMaxTabWidth), | 1647 | |
1648 | tuple->mPadding = image_overlay_width; | ||
1649 | |||
1650 | tuple->mButton->setRightHPad(tuple->mPadding + LLBUTTON_H_PAD); | ||
1651 | tuple->mButton->reshape(llclamp(fontp->getWidth(tuple->mButton->getLabelSelected()) + TAB_PADDING + tuple->mPadding, mMinTabWidth, mMaxTabWidth), | ||
1646 | tuple->mButton->getRect().getHeight()); | 1652 | tuple->mButton->getRect().getHeight()); |
1647 | // add back in button width to total tab strip width | 1653 | // add back in button width to total tab strip width |
1648 | mTotalTabWidth += tuple->mButton->getRect().getWidth(); | 1654 | mTotalTabWidth += tuple->mButton->getRect().getWidth(); |