diff options
author | Monroe Linden <monroe@lindenlab.com> | 2010-12-20 11:21:17 -0800 |
---|---|---|
committer | Monroe Linden <monroe@lindenlab.com> | 2010-12-20 11:21:17 -0800 |
commit | dee57bea2526c84fb753abfd08e22c19f1cad21c (patch) | |
tree | 7fbe9a8cbb5957b78a37eb13f58f8b6786ec8cac /indra/newview/llpanelprofile.cpp | |
parent | 67ca1c0b62cec74495104c0d78fc3743775bfd4e (diff) | |
parent | 25eef545fd7f6513ae4c590126aef1dc06494f56 (diff) |
Merge from viewer-development.
Diffstat (limited to 'indra/newview/llpanelprofile.cpp')
-rw-r--r-- | indra/newview/llpanelprofile.cpp | 139 |
1 files changed, 126 insertions, 13 deletions
diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 4e63563979..b035d7d473 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -114,11 +114,109 @@ public: LLAgentHandler gAgentHandler; +//-- LLPanelProfile::ChildStack begins ---------------------------------------- +LLPanelProfile::ChildStack::ChildStack() +: mParent(NULL) +{ +} + +void LLPanelProfile::ChildStack::setParent(LLPanel* parent) +{ + llassert_always(parent != NULL); + mParent = parent; +} + +/// Save current parent's child views and remove them from the child list. +bool LLPanelProfile::ChildStack::push() +{ + view_list_t vlist = *mParent->getChildList(); + + for (view_list_t::const_iterator it = vlist.begin(); it != vlist.end(); ++it) + { + LLView* viewp = *it; + mParent->removeChild(viewp); + } + + mStack.push_back(vlist); + dump(); + return true; +} + +/// Restore saved children (adding them back to the child list). +bool LLPanelProfile::ChildStack::pop() +{ + if (mStack.size() == 0) + { + llwarns << "Empty stack" << llendl; + llassert(mStack.size() == 0); + return false; + } + + view_list_t& top = mStack.back(); + for (view_list_t::const_iterator it = top.begin(); it != top.end(); ++it) + { + LLView* viewp = *it; + mParent->addChild(viewp); + } + + mStack.pop_back(); + dump(); + return true; +} + +/// Temporarily add all saved children back. +void LLPanelProfile::ChildStack::preParentReshape() +{ + mSavedStack = mStack; + while(mStack.size() > 0) + { + pop(); + } +} + +/// Add the temporarily saved children back. +void LLPanelProfile::ChildStack::postParentReshape() +{ + mStack = mSavedStack; + mSavedStack = stack_t(); + + for (stack_t::const_iterator stack_it = mStack.begin(); stack_it != mStack.end(); ++stack_it) + { + const view_list_t& vlist = (*stack_it); + for (view_list_t::const_iterator list_it = vlist.begin(); list_it != vlist.end(); ++list_it) + { + LLView* viewp = *list_it; + lldebugs << "removing " << viewp->getName() << llendl; + mParent->removeChild(viewp); + } + } +} + +void LLPanelProfile::ChildStack::dump() +{ + unsigned lvl = 0; + lldebugs << "child stack dump:" << llendl; + for (stack_t::const_iterator stack_it = mStack.begin(); stack_it != mStack.end(); ++stack_it, ++lvl) + { + std::ostringstream dbg_line; + dbg_line << "lvl #" << lvl << ":"; + const view_list_t& vlist = (*stack_it); + for (view_list_t::const_iterator list_it = vlist.begin(); list_it != vlist.end(); ++list_it) + { + dbg_line << " " << (*list_it)->getName(); + } + lldebugs << dbg_line.str() << llendl; + } +} + +//-- LLPanelProfile::ChildStack ends ------------------------------------------ + LLPanelProfile::LLPanelProfile() : LLPanel() , mTabCtrl(NULL) , mAvatarId(LLUUID::null) { + mChildStack.setParent(this); } BOOL LLPanelProfile::postBuild() @@ -136,6 +234,15 @@ BOOL LLPanelProfile::postBuild() return TRUE; } +// virtual +void LLPanelProfile::reshape(S32 width, S32 height, BOOL called_from_parent) +{ + // Temporarily add saved children back and reshape them. + mChildStack.preParentReshape(); + LLPanel::reshape(width, height, called_from_parent); + mChildStack.postParentReshape(); +} + void LLPanelProfile::onOpen(const LLSD& key) { // open the desired panel @@ -177,7 +284,6 @@ void LLPanelProfile::onOpen(const LLSD& key) } } -//*TODO redo panel toggling void LLPanelProfile::togglePanel(LLPanel* panel, const LLSD& key) { // TRUE - we need to open/expand "panel" @@ -204,19 +310,12 @@ void LLPanelProfile::onTabSelected(const LLSD& param) } } -void LLPanelProfile::setAllChildrenVisible(BOOL visible) -{ - const child_list_t* child_list = getChildList(); - child_list_const_iter_t child_it = child_list->begin(); - for (; child_it != child_list->end(); ++child_it) - { - LLView* viewp = *child_it; - viewp->setVisible(visible); - } -} - void LLPanelProfile::openPanel(LLPanel* panel, const LLSD& params) { + // Hide currently visible panel (STORM-690). + mChildStack.push(); + + // Add the panel or bring it to front. if (panel->getParent() != this) { addChild(panel); @@ -227,7 +326,7 @@ void LLPanelProfile::openPanel(LLPanel* panel, const LLSD& params) } panel->setVisible(TRUE); - + panel->setFocus(TRUE); // prevent losing focus by the floater panel->onOpen(params); LLRect new_rect = getRect(); @@ -243,6 +342,20 @@ void LLPanelProfile::closePanel(LLPanel* panel) if (panel->getParent() == this) { removeChild(panel); + + // Make the underlying panel visible. + mChildStack.pop(); + + // Prevent losing focus by the floater + const child_list_t* child_list = getChildList(); + if (child_list->size() > 0) + { + child_list->front()->setFocus(TRUE); + } + else + { + llwarns << "No underlying panel to focus." << llendl; + } } } |