diff options
Diffstat (limited to 'indra/llui/llpanel.cpp')
-rw-r--r-- | indra/llui/llpanel.cpp | 129 |
1 files changed, 75 insertions, 54 deletions
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 22934450e7..2edbbe6abc 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -58,8 +58,6 @@ #include "llresizebar.h" #include "llcriticaldamp.h" -LLPanel::alert_queue_t LLPanel::sAlertQueue; - const S32 RESIZE_BAR_OVERLAP = 1; const S32 RESIZE_BAR_HEIGHT = 3; @@ -344,14 +342,14 @@ BOOL LLPanel::checkRequirements() { if (!mRequirementsError.empty()) { - LLStringUtil::format_map_t args; - args["[COMPONENTS]"] = mRequirementsError; - args["[FLOATER]"] = getName(); + LLSD args; + args["COMPONENTS"] = mRequirementsError; + args["FLOATER"] = getName(); llwarns << getName() << " failed requirements check on: \n" << mRequirementsError << llendl; - - alertXml(std::string("FailedRequirementsCheck"), args); + + LLNotifications::instance().add(LLNotification::Params("FailedRequirementsCheck").payload(args)); mRequirementsError.clear(); return FALSE; } @@ -359,25 +357,6 @@ BOOL LLPanel::checkRequirements() return TRUE; } -//static -void LLPanel::alertXml(const std::string& label, LLStringUtil::format_map_t args) -{ - sAlertQueue.push(LLAlertInfo(label,args)); -} - -//static -BOOL LLPanel::nextAlert(LLAlertInfo &alert) -{ - if (!sAlertQueue.empty()) - { - alert = sAlertQueue.front(); - sAlertQueue.pop(); - return TRUE; - } - - return FALSE; -} - void LLPanel::setFocus(BOOL b) { if( b ) @@ -1039,9 +1018,9 @@ void LLPanel::childDisplayNotFound() mExpectedMembers.insert(*itor); } mNewExpectedMembers.clear(); - LLStringUtil::format_map_t args; - args["[CONTROLS]"] = msg; - LLAlertDialog::showXml("FloaterNotFound", args); + LLSD args; + args["CONTROLS"] = msg; + LLNotifications::instance().add("FloaterNotFound", args); } void LLPanel::storeRectControl() @@ -1065,6 +1044,8 @@ struct LLLayoutStack::LLEmbeddedPanel mAutoResize(auto_resize), mUserResize(user_resize), mOrientation(orientation), + mCollapsed(FALSE), + mCollapseAmt(0.f), mVisibleAmt(1.f) // default to fully visible { LLResizeBar::Side side = (orientation == HORIZONTAL) ? LLResizeBar::RIGHT : LLResizeBar::BOTTOM; @@ -1095,14 +1076,28 @@ struct LLLayoutStack::LLEmbeddedPanel mResizeBar = NULL; } + F32 getCollapseFactor() + { + if (mOrientation == HORIZONTAL) + { + return mVisibleAmt * clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, (F32)mMinWidth / (F32)mPanel->getRect().getWidth()); + } + else + { + return mVisibleAmt * clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, (F32)mMinHeight / (F32)mPanel->getRect().getHeight()); + } + } + LLPanel* mPanel; S32 mMinWidth; S32 mMinHeight; BOOL mAutoResize; BOOL mUserResize; + BOOL mCollapsed; LLResizeBar* mResizeBar; eLayoutOrientation mOrientation; F32 mVisibleAmt; + F32 mCollapseAmt; }; static LLRegisterWidget<LLLayoutStack> r2("layout_stack"); @@ -1123,28 +1118,27 @@ LLLayoutStack::~LLLayoutStack() void LLLayoutStack::draw() { updateLayout(); + + e_panel_list_t::iterator panel_it; + for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { - e_panel_list_t::iterator panel_it; - for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) + // clip to layout rectangle, not bounding rectangle + LLRect clip_rect = (*panel_it)->mPanel->getRect(); + // scale clipping rectangle by visible amount + if (mOrientation == HORIZONTAL) { - // clip to layout rectangle, not bounding rectangle - LLRect clip_rect = (*panel_it)->mPanel->getRect(); - // scale clipping rectangle by visible amount - if (mOrientation == HORIZONTAL) - { - clip_rect.mRight = clip_rect.mLeft + llround((F32)clip_rect.getWidth() * (*panel_it)->mVisibleAmt); - } - else - { - clip_rect.mBottom = clip_rect.mTop - llround((F32)clip_rect.getHeight() * (*panel_it)->mVisibleAmt); - } + clip_rect.mRight = clip_rect.mLeft + llround((F32)clip_rect.getWidth() * (*panel_it)->getCollapseFactor()); + } + else + { + clip_rect.mBottom = clip_rect.mTop - llround((F32)clip_rect.getHeight() * (*panel_it)->getCollapseFactor()); + } - LLPanel* panelp = (*panel_it)->mPanel; + LLPanel* panelp = (*panel_it)->mPanel; - LLLocalClipRect clip(clip_rect); - // only force drawing invisible children if visible amount is non-zero - drawChild(panelp, 0, 0, !clip_rect.isNull()); - } + LLLocalClipRect clip(clip_rect); + // only force drawing invisible children if visible amount is non-zero + drawChild(panelp, 0, 0, !clip_rect.isNull()); } } @@ -1276,8 +1270,13 @@ S32 LLLayoutStack::getDefaultWidth(S32 cur_width) return cur_width; } -void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, S32 index) +void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, EAnimate animate, S32 index) { + // panel starts off invisible (collapsed) + if (animate == ANIMATE) + { + panel->setVisible(FALSE); + } LLEmbeddedPanel* embedded_panel = new LLEmbeddedPanel(panel, mOrientation, min_width, min_height, auto_resize, user_resize); mPanels.insert(mPanels.begin() + llclamp(index, 0, (S32)mPanels.size()), embedded_panel); @@ -1293,6 +1292,11 @@ void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL sendChildToFront(resize_barp); } + // start expanding panel animation + if (animate == ANIMATE) + { + panel->setVisible(TRUE); + } } void LLLayoutStack::removePanel(LLPanel* panel) @@ -1300,6 +1304,14 @@ void LLLayoutStack::removePanel(LLPanel* panel) removeChild(panel); } +void LLLayoutStack::collapsePanel(LLPanel* panel, BOOL collapsed) +{ + LLEmbeddedPanel* panel_container = findEmbeddedPanel(panel); + if (!panel_container) return; + + panel_container->mCollapsed = collapsed; +} + void LLLayoutStack::updateLayout(BOOL force_resize) { calcMinExtents(); @@ -1332,6 +1344,15 @@ void LLLayoutStack::updateLayout(BOOL force_resize) } } + if ((*panel_it)->mCollapsed) + { + (*panel_it)->mCollapseAmt = lerp((*panel_it)->mCollapseAmt, 1.f, LLCriticalDamp::getInterpolant(ANIM_CLOSE_TIME)); + } + else + { + (*panel_it)->mCollapseAmt = lerp((*panel_it)->mCollapseAmt, 0.f, LLCriticalDamp::getInterpolant(ANIM_CLOSE_TIME)); + } + if (mOrientation == HORIZONTAL) { // enforce minimize size constraint by default @@ -1339,7 +1360,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) { panelp->reshape((*panel_it)->mMinWidth, panelp->getRect().getHeight()); } - total_width += llround(panelp->getRect().getWidth() * (*panel_it)->mVisibleAmt); + total_width += llround(panelp->getRect().getWidth() * (*panel_it)->getCollapseFactor()); // want n-1 panel gaps for n panels if (panel_it != mPanels.begin()) { @@ -1353,7 +1374,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) { panelp->reshape(panelp->getRect().getWidth(), (*panel_it)->mMinHeight); } - total_height += llround(panelp->getRect().getHeight() * (*panel_it)->mVisibleAmt); + total_height += llround(panelp->getRect().getHeight() * (*panel_it)->getCollapseFactor()); if (panel_it != mPanels.begin()) { total_height += mPanelSpacing; @@ -1367,7 +1388,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { // panels that are not fully visible do not count towards shrink headroom - if ((*panel_it)->mVisibleAmt < 1.f) + if ((*panel_it)->getCollapseFactor() < 1.f) { continue; } @@ -1431,7 +1452,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) S32 delta_size = 0; // if panel can automatically resize (not animating, and resize flag set)... - if ((*panel_it)->mVisibleAmt == 1.f + if ((*panel_it)->getCollapseFactor() == 1.f && (force_resize || (*panel_it)->mAutoResize) && !(*panel_it)->mResizeBar->hasMouseCapture()) { @@ -1515,11 +1536,11 @@ void LLLayoutStack::updateLayout(BOOL force_resize) if (mOrientation == HORIZONTAL) { - cur_x += llround(new_width * (*panel_it)->mVisibleAmt) + mPanelSpacing; + cur_x += llround(new_width * (*panel_it)->getCollapseFactor()) + mPanelSpacing; } else //VERTICAL { - cur_y -= llround(new_height * (*panel_it)->mVisibleAmt) + mPanelSpacing; + cur_y -= llround(new_height * (*panel_it)->getCollapseFactor()) + mPanelSpacing; } } |