diff options
author | richard <none@none> | 2009-11-09 15:29:47 -0800 |
---|---|---|
committer | richard <none@none> | 2009-11-09 15:29:47 -0800 |
commit | 4eb72a12a2280d3be6ac556ad80eb953d249e8eb (patch) | |
tree | 9316784e58adc830d5cd893694698e38786af561 /indra/llui | |
parent | fac0b6836a59681443fb2bbd13e6b5eb9c07cef5 (diff) |
data driven layout of top-level UI elements
EXT-1219 Side tray slide-out animation
cleaned up some layout of bottom tray contents
reviewed by James
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llconsole.cpp | 2 | ||||
-rw-r--r-- | indra/llui/lllayoutstack.cpp | 43 | ||||
-rw-r--r-- | indra/llui/lllayoutstack.h | 8 | ||||
-rw-r--r-- | indra/llui/lluictrlfactory.h | 2 | ||||
-rw-r--r-- | indra/llui/llview.cpp | 3 | ||||
-rw-r--r-- | indra/llui/llview.h | 3 |
6 files changed, 47 insertions, 14 deletions
diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp index e0053b4cc7..48c76cf105 100644 --- a/indra/llui/llconsole.cpp +++ b/indra/llui/llconsole.cpp @@ -60,6 +60,8 @@ LLConsole* gConsole = NULL; // Created and destroyed in LLViewerWindow. const F32 FADE_DURATION = 2.f; const S32 MIN_CONSOLE_WIDTH = 200; +static LLDefaultChildRegistry::Register<LLConsole> r("console"); + LLConsole::LLConsole(const LLConsole::Params& p) : LLUICtrl(p), LLFixedBuffer(p.max_lines), diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index bac5491943..596b3a3e70 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -137,6 +137,7 @@ LLLayoutStack::LLLayoutStack(const LLLayoutStack::Params& p) mPanelSpacing(p.border_size), mOrientation((p.orientation() == "vertical") ? VERTICAL : HORIZONTAL), mAnimate(p.animate), + mAnimatedThisFrame(false), mClip(p.clip) {} @@ -172,6 +173,7 @@ void LLLayoutStack::draw() // only force drawing invisible children if visible amount is non-zero drawChild(panelp, 0, 0, !clip_rect.isEmpty()); } + mAnimatedThisFrame = false; } void LLLayoutStack::removeChild(LLView* view) @@ -411,8 +413,10 @@ void LLLayoutStack::updatePanelAutoResize(const std::string& panel_name, BOOL au } } +static LLFastTimer::DeclareTimer FTM_UPDATE_LAYOUT("Update LayoutStacks"); void LLLayoutStack::updateLayout(BOOL force_resize) { + LLFastTimer ft(FTM_UPDATE_LAYOUT); static LLUICachedControl<S32> resize_bar_overlap ("UIResizeBarOverlap", 0); calcMinExtents(); @@ -431,10 +435,13 @@ void LLLayoutStack::updateLayout(BOOL force_resize) { if (mAnimate) { - (*panel_it)->mVisibleAmt = lerp((*panel_it)->mVisibleAmt, 1.f, LLCriticalDamp::getInterpolant(ANIM_OPEN_TIME)); - if ((*panel_it)->mVisibleAmt > 0.99f) + if (!mAnimatedThisFrame) { - (*panel_it)->mVisibleAmt = 1.f; + (*panel_it)->mVisibleAmt = lerp((*panel_it)->mVisibleAmt, 1.f, LLCriticalDamp::getInterpolant(ANIM_OPEN_TIME)); + if ((*panel_it)->mVisibleAmt > 0.99f) + { + (*panel_it)->mVisibleAmt = 1.f; + } } } else @@ -446,10 +453,13 @@ void LLLayoutStack::updateLayout(BOOL force_resize) { if (mAnimate) { - (*panel_it)->mVisibleAmt = lerp((*panel_it)->mVisibleAmt, 0.f, LLCriticalDamp::getInterpolant(ANIM_CLOSE_TIME)); - if ((*panel_it)->mVisibleAmt < 0.001f) + if (!mAnimatedThisFrame) { - (*panel_it)->mVisibleAmt = 0.f; + (*panel_it)->mVisibleAmt = lerp((*panel_it)->mVisibleAmt, 0.f, LLCriticalDamp::getInterpolant(ANIM_CLOSE_TIME)); + if ((*panel_it)->mVisibleAmt < 0.001f) + { + (*panel_it)->mVisibleAmt = 0.f; + } } } else @@ -631,10 +641,10 @@ void LLLayoutStack::updateLayout(BOOL force_resize) // adjust running headroom count based on new sizes shrink_headroom_total += delta_size; - panelp->reshape(new_width, new_height); - panelp->setOrigin(cur_x, cur_y - new_height); + LLRect panel_rect; + panel_rect.setLeftTopAndSize(cur_x, cur_y, new_width, new_height); + panelp->setShape(panel_rect); - LLRect panel_rect = panelp->getRect(); LLRect resize_bar_rect = panel_rect; if (mOrientation == HORIZONTAL) { @@ -705,6 +715,8 @@ void LLLayoutStack::updateLayout(BOOL force_resize) llassert_always(force_resize == FALSE); updateLayout(TRUE); } + + mAnimatedThisFrame = true; } // end LLLayoutStack::updateLayout @@ -772,3 +784,16 @@ void LLLayoutStack::calcMinExtents() } } } + +// update layout stack animations, etc. once per frame +// NOTE: we use this to size world view based on animating UI, *before* we draw the UI +// we might still need to call updateLayout during UI draw phase, in case UI elements +// are resizing themselves dynamically +//static +void LLLayoutStack::idle() +{ + for (LLInstanceTracker::instance_iter it = beginInstances(); it != endInstances(); ++it) + { + (*it)->updateLayout(); + } +} diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 9ded48ef6a..11d604b7ec 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -38,7 +38,7 @@ class LLPanel; -class LLLayoutStack : public LLView +class LLLayoutStack : public LLView, LLInstanceTracker<LLLayoutStack> { public: struct Params : public LLInitParam::Block<Params, LLView::Params> @@ -81,6 +81,10 @@ public: S32 getNumPanels() { return mPanels.size(); } void updatePanelAutoResize(const std::string& panel_name, BOOL auto_resize); + + + static void idle(); + protected: LLLayoutStack(const Params&); friend class LLUICtrlFactory; @@ -105,6 +109,8 @@ private: S32 mMinHeight; // calculated by calcMinExtents S32 mPanelSpacing; + // true if we already applied animation this frame + bool mAnimatedThisFrame; bool mAnimate; bool mClip; }; // end class LLLayoutStack diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 17e32dc7a9..0ccd3047f6 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -188,7 +188,7 @@ public: T* widget = new T(params); widget->initFromParams(params); if (parent) - widget->setParent(parent); + parent->addChild(widget); return widget; } diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index fe7fd59de8..da564befa9 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -1698,8 +1698,11 @@ LLView* LLView::getChildView(const std::string& name, BOOL recurse) const return child; } +static LLFastTimer::DeclareTimer FTM_FIND_VIEWS("Find Widgets"); + LLView* LLView::findChildView(const std::string& name, BOOL recurse) const { + LLFastTimer ft(FTM_FIND_VIEWS); //richard: should we allow empty names? //if(name.empty()) // return NULL; diff --git a/indra/llui/llview.h b/indra/llui/llview.h index c3b442e022..2607120e17 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -267,9 +267,6 @@ public: // remove the specified child from the view, and set it's parent to NULL. virtual void removeChild(LLView* view); - // helper function for lluictrlfactory.h create<> template - void setParent(LLView* parent) { if (parent) parent->addChild(this); } - virtual BOOL postBuild() { return TRUE; } child_tab_order_t getCtrlOrder() const { return mCtrlOrder; } |