diff options
author | Vadim Savchuk <vsavchuk@productengine.com> | 2010-09-09 21:05:13 +0300 |
---|---|---|
committer | Vadim Savchuk <vsavchuk@productengine.com> | 2010-09-09 21:05:13 +0300 |
commit | 6b77ce904eedfa8bbcc9e2fd2d9f96e4f0093b95 (patch) | |
tree | 9ea5aabd3ff1b456cf2e4bd4562f0567a526a286 /indra/newview/llsidetray.cpp | |
parent | 244aa5db98ad828c766d615aad82e25c5cee98d7 (diff) |
STORM-92 FIXED Avoid redundant visibility changes when attaching/detaching side tray tabs.
Also happens to fix STORM-96 (Empty space appears in the top of Home side panel after redocking).
Diffstat (limited to 'indra/newview/llsidetray.cpp')
-rw-r--r-- | indra/newview/llsidetray.cpp | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp index 7af3ad9896..1d32b58948 100644 --- a/indra/newview/llsidetray.cpp +++ b/indra/newview/llsidetray.cpp @@ -244,9 +244,7 @@ void LLSideTrayTab::toggleTabDocked() LLFloater* floater_tab = LLFloaterReg::getInstance("side_bar_tab", tab_name); if (!floater_tab) return; - LLFloaterReg::toggleInstance("side_bar_tab", tab_name); - - bool docking = !LLFloater::isShown(floater_tab); + bool docking = LLFloater::isShown(floater_tab); // Hide the "Tear Off" button when a tab gets undocked // and show "Dock" button instead. @@ -261,6 +259,10 @@ void LLSideTrayTab::toggleTabDocked() { undock(floater_tab); } + + // Open/close the floater *after* we reparent the tab panel, + // so that it doesn't receive redundant visibility change notifications. + LLFloaterReg::toggleInstance("side_bar_tab", tab_name); } void LLSideTrayTab::dock() @@ -282,7 +284,7 @@ void LLSideTrayTab::dock() if (side_tray->getCollapsed()) { - side_tray->expandSideBar(); + side_tray->expandSideBar(false); } } @@ -291,6 +293,10 @@ void LLSideTrayTab::undock(LLFloater* floater_tab) LLSideTray* side_tray = getSideTray(); if (!side_tray) return; + // Remember whether the tab have been active before detaching + // because removeTab() will change active tab. + bool was_active = side_tray->getActiveTab() == this; + // Remove the tab from Side Tray's tabs list. // We have to do it despite removing the tab from Side Tray's child view tree // by addChild(). Otherwise the tab could be accessed by the pointer in LLSideTray::mTabs. @@ -300,7 +306,12 @@ void LLSideTrayTab::undock(LLFloater* floater_tab) return; } - setVisible(true); // *HACK: restore visibility after being hidden by LLSideTray::selectTabByName(). + // If we're undocking while side tray is collapsed we need to explicitly show the panel. + if (!getVisible()) + { + setVisible(true); + } + floater_tab->addChild(this); floater_tab->setTitle(mTabTitle); @@ -334,7 +345,7 @@ void LLSideTrayTab::undock(LLFloater* floater_tab) side_tray->collapseSideBar(); } - if (side_tray->getActiveTab() != this) + if (!was_active) { // When a tab other then current active tab is detached from Side Tray // onOpen() should be called as tab visibility is changed. @@ -618,8 +629,9 @@ bool LLSideTray::selectTabByIndex(size_t index) return selectTabByName(sidebar_tab->getName()); } -bool LLSideTray::selectTabByName (const std::string& name) +bool LLSideTray::selectTabByName(const std::string& name, bool keep_prev_visible) { + LLSideTrayTab* tab_to_keep_visible = NULL; LLSideTrayTab* new_tab = getTab(name); if (!new_tab) return false; @@ -630,6 +642,8 @@ bool LLSideTray::selectTabByName (const std::string& name) //deselect old tab if (mActiveTab) { + // Keep previously active tab visible if requested. + if (keep_prev_visible) tab_to_keep_visible = mActiveTab; toggleTabButton(mActiveTab); } @@ -650,9 +664,17 @@ bool LLSideTray::selectTabByName (const std::string& name) for ( child_it = mTabs.begin(); child_it != mTabs.end(); ++child_it) { LLSideTrayTab* sidebar_tab = *child_it; + + bool vis = sidebar_tab == mActiveTab; + + // Force keeping the tab visible if requested. + vis |= sidebar_tab == tab_to_keep_visible; + // When the last tab gets detached, for a short moment the "Toggle Sidebar" pseudo-tab // is shown. So, to avoid the flicker we make sure it never gets visible. - sidebar_tab->setVisible(sidebar_tab == mActiveTab && (*child_it)->getName() != "sidebar_openclose"); + vis &= (*child_it)->getName() != "sidebar_openclose"; + + sidebar_tab->setVisible(vis); } return true; } @@ -741,7 +763,7 @@ bool LLSideTray::removeTab(LLSideTrayTab* tab) { child_vector_iter_t next_tab_it = (tab_it < (mTabs.end() - 1)) ? tab_it + 1 : mTabs.begin(); - selectTabByName((*next_tab_it)->getName()); + selectTabByName((*next_tab_it)->getName(), true); // Don't hide the tab being removed. } // Remove the tab. @@ -1016,7 +1038,7 @@ void LLSideTray::collapseSideBar() setFocus( FALSE ); } -void LLSideTray::expandSideBar() +void LLSideTray::expandSideBar(bool open_active) { mCollapsed = false; LLSideTrayTab* openclose_tab = getTab("sidebar_openclose"); @@ -1024,8 +1046,11 @@ void LLSideTray::expandSideBar() { mCollapseButton->setImageOverlay( openclose_tab->mImageSelected ); } - LLSD key;//empty - mActiveTab->onOpen(key); + + if (open_active) + { + mActiveTab->onOpen(LLSD()); + } reflectCollapseChange(); |