diff options
author | Richard Linden <none@none> | 2011-09-20 16:37:45 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2011-09-20 16:37:45 -0700 |
commit | c196013b697102805e8aa160a85f38dccb623851 (patch) | |
tree | c577700db340312d9415f3c6aff22d0be6983c11 /indra/llui | |
parent | eb3a643f3bcddb159622e2d38ef65f661b204653 (diff) | |
parent | 64f30a302dfbcaf56502676fa4b8d8a06f355b40 (diff) |
Automated merge with ssh://hg.lindenlab.com/richard/viewer-experience-fui
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llbutton.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llbutton.h | 21 | ||||
-rw-r--r-- | indra/llui/lllayoutstack.cpp | 14 | ||||
-rw-r--r-- | indra/llui/lllayoutstack.h | 26 | ||||
-rw-r--r-- | indra/llui/lltoolbar.cpp | 121 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 26 |
6 files changed, 162 insertions, 50 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 2459429f6e..6c08ec7431 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -314,7 +314,7 @@ boost::signals2::connection LLButton::setHeldDownCallback( const commit_signal_t } -// *TODO: Deprecate (for backwards compatability only) +// *TODO: Deprecate (for backwards compatibility only) boost::signals2::connection LLButton::setClickedCallback( button_callback_t cb, void* data ) { return setClickedCallback(boost::bind(cb, data)); @@ -919,7 +919,7 @@ void LLButton::setToggleState(BOOL b) void LLButton::setFlashing( BOOL b ) { - if (b != mFlashing) + if ((bool)b != mFlashing) { mFlashing = b; mFlashingTimer.reset(); diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 5968916006..bc5e69fad5 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -327,15 +327,14 @@ private: LLUIColor mImageColor; LLUIColor mDisabledImageColor; - BOOL mIsToggle; - BOOL mScaleImage; + bool mIsToggle; + bool mScaleImage; - BOOL mDropShadowedText; - BOOL mAutoResize; - BOOL mUseEllipses; - BOOL mBorderEnabled; - - BOOL mFlashing; + bool mDropShadowedText; + bool mAutoResize; + bool mUseEllipses; + bool mBorderEnabled; + bool mFlashing; LLFontGL::HAlign mHAlign; S32 mLeftHPad; @@ -355,9 +354,9 @@ private: F32 mHoverGlowStrength; F32 mCurGlowStrength; - BOOL mNeedsHighlight; - BOOL mCommitOnReturn; - BOOL mFadeWhenDisabled; + bool mNeedsHighlight; + bool mCommitOnReturn; + bool mFadeWhenDisabled; bool mForcePressedState; LLFrameTimer mFlashingTimer; diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index a250404292..0d1f608e61 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -55,6 +55,7 @@ LLLayoutPanel::LLLayoutPanel(const Params& p) mMaxDim(p.max_dim), mAutoResize(p.auto_resize), mUserResize(p.user_resize), + mFitContent(p.fit_content), mCollapsed(FALSE), mCollapseAmt(0.f), mVisibleAmt(1.f), // default to fully visible @@ -104,6 +105,14 @@ F32 LLLayoutPanel::getCollapseFactor(LLLayoutStack::ELayoutOrientation orientati } } +void LLLayoutPanel::fitToContent() +{ + if (mFitContent) + { + setShape(calcBoundingRect()); + } +} + // // LLLayoutStack // @@ -324,6 +333,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { LLLayoutPanel* panelp = (*panel_it); + panelp->fitToContent(); if (panelp->getVisible()) { if (mAnimate) @@ -478,7 +488,9 @@ void LLLayoutStack::updateLayout(BOOL force_resize) { // shrink proportionally to amount over minimum // so we can do this in one pass - delta_size = (shrink_headroom_available > 0) ? llround((F32)pixels_to_distribute * ((F32)(cur_width - relevant_min) / (F32)shrink_headroom_available)) : 0; + delta_size = (shrink_headroom_available > 0) + ? llround((F32)pixels_to_distribute * ((F32)(cur_width - relevant_min) / (F32)shrink_headroom_available)) + : 0; shrink_headroom_available -= (cur_width - relevant_min); } else diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index d8ef0aeaca..2ed32a2fa9 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -161,14 +161,16 @@ public: min_dim, max_dim; Optional<bool> user_resize, - auto_resize; + auto_resize, + fit_content; Params() : expanded_min_dim("expanded_min_dim", 0), min_dim("min_dim", 0), max_dim("max_dim", 0), user_resize("user_resize", true), - auto_resize("auto_resize", true) + auto_resize("auto_resize", true), + fit_content("fit_content", false) { addSynonym(min_dim, "min_width"); addSynonym(min_dim, "min_height"); @@ -206,18 +208,20 @@ protected: LLLayoutPanel(const Params& p); F32 getCollapseFactor(LLLayoutStack::ELayoutOrientation orientation); + void fitToContent(); - bool mExpandedMinDimSpecified; - S32 mExpandedMinDim; + bool mExpandedMinDimSpecified; + S32 mExpandedMinDim; - S32 mMinDim; - S32 mMaxDim; - BOOL mAutoResize; - BOOL mUserResize; - BOOL mCollapsed; + S32 mMinDim; + S32 mMaxDim; + bool mAutoResize; + bool mUserResize; + bool mCollapsed; + bool mFitContent; + F32 mVisibleAmt; + F32 mCollapseAmt; class LLResizeBar* mResizeBar; - F32 mVisibleAmt; - F32 mCollapseAmt; }; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 0356fd5c8a..cdd3a50205 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -41,37 +41,118 @@ LLToolBar::LLToolBar(const Params& p) : LLUICtrl(p), mOrientation(p.orientation), mStack(NULL) +{} + +void LLToolBar::initFromParams(const LLToolBar::Params& p) { + LLLayoutStack::Params centering_stack_p; + centering_stack_p.rect = getLocalRect(); + centering_stack_p.follows.flags = FOLLOWS_ALL; + centering_stack_p.orientation = p.orientation; + centering_stack_p.name = "centering_stack"; -} + LLLayoutPanel::Params border_panel_p; + border_panel_p.name = "border_panel"; + border_panel_p.rect = getLocalRect(); + border_panel_p.auto_resize = true; + border_panel_p.user_resize = false; -void LLToolBar::draw() -{ - gl_rect_2d(getLocalRect(), LLColor4::blue, TRUE); -} + LLLayoutStack* centering_stack = LLUICtrlFactory::create<LLLayoutStack>(centering_stack_p); + addChild(centering_stack); + + LLLayoutPanel::Params center_panel_p; + center_panel_p.name = "center_panel"; + center_panel_p.rect = getLocalRect(); + center_panel_p.auto_resize = false; + center_panel_p.user_resize = false; + center_panel_p.fit_content = true; + + centering_stack->addChild(LLUICtrlFactory::create<LLLayoutPanel>(border_panel_p)); + LLLayoutPanel* center_panel = LLUICtrlFactory::create<LLLayoutPanel>(center_panel_p); + centering_stack->addChild(center_panel); + centering_stack->addChild(LLUICtrlFactory::create<LLLayoutPanel>(border_panel_p)); -void LLToolBar::initFromParams(const LLToolBar::Params& p) -{ LLLayoutStack::Params stack_p; stack_p.rect = getLocalRect(); - stack_p.follows.flags = FOLLOWS_ALL; stack_p.name = "button_stack"; stack_p.orientation = p.orientation; + stack_p.follows.flags = (mOrientation == LLLayoutStack::HORIZONTAL) + ? (FOLLOWS_TOP|FOLLOWS_BOTTOM) // horizontal + : (FOLLOWS_LEFT|FOLLOWS_RIGHT); // vertical mStack = LLUICtrlFactory::create<LLLayoutStack>(stack_p); - addChild(mStack); + center_panel->addChild(mStack); - BOOST_FOREACH (LLButton::Params button_p, p.buttons) + BOOST_FOREACH (LLToolBarButton::Params button_p, p.buttons) { - LLLayoutPanel::Params panel_p; - panel_p.name = button_p.name() + "_panel"; - panel_p.rect = button_p.rect; - panel_p.user_resize = false; - panel_p.auto_resize= false; - - LLLayoutPanel* panel = LLUICtrlFactory::create<LLLayoutPanel>(panel_p); - LLButton* button = LLUICtrlFactory::create<LLButton>(button_p); - panel->addChild(button); - mStack->addChild(panel); + // remove any offset from button + LLRect button_rect(button_p.rect); + + if (mOrientation == LLLayoutStack::HORIZONTAL) + { + button_rect.setOriginAndSize(0, 0, 0, getRect().getHeight()); + } + else // VERTICAL + { + button_rect.setOriginAndSize(0, 0, 0, button_rect.getHeight()); + } + button_p.follows.flags = FOLLOWS_NONE; + button_p.rect = button_rect; + button_p.chrome = true; + button_p.auto_resize = true; + + LLToolBarButton* button = LLUICtrlFactory::create<LLToolBarButton>(button_p); + + addButton(button); } + + updateLayout(); +} + +void LLToolBar::addButton(LLToolBarButton* buttonp) +{ + LLLayoutPanel::Params panel_p; + panel_p.name = buttonp->getName() + "_panel"; + panel_p.user_resize = false; + panel_p.auto_resize= false; + panel_p.fit_content = true; + + LLLayoutPanel* panel = LLUICtrlFactory::create<LLLayoutPanel>(panel_p); + + panel->addChild(buttonp); + mStack->addChild(panel); + mButtons.push_back(buttonp); } + +void LLToolBar::updateLayout() +{ + S32 total_width = 0; + S32 total_height = 0; + S32 max_width = getRect().getWidth(); + S32 max_height = getRect().getHeight(); + + BOOST_FOREACH(LLToolBarButton* button, mButtons) + { + total_width += button->getRect().getWidth(); + total_height += button->getRect().getHeight(); + max_width = llmax(button->getRect().getWidth(), max_width); + max_height = llmax(button->getRect().getHeight(), max_height); + } + + if (mOrientation == LLLayoutStack::HORIZONTAL) + { + mStack->reshape(total_width, mStack->getParent()->getRect().getHeight()); + } + else + { + mStack->reshape(mStack->getParent()->getRect().getWidth(), total_height); + reshape(max_width, getRect().getHeight()); + } +} + + +void LLToolBar::draw() +{ + LLUICtrl::draw(); +} + diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index dd454e3f0b..fb03095c56 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -32,28 +32,44 @@ #include "lllayoutstack.h" #include "llbutton.h" +class LLToolBarButton : public LLButton +{ +public: + struct Params : public LLInitParam::Block<Params, LLButton::Params> + { + }; + + LLToolBarButton(const Params& p) : LLButton(p) {} + +}; + class LLToolBar : public LLUICtrl { public: + struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> { - Mandatory<LLLayoutStack::ELayoutOrientation> orientation; - Multiple<LLButton::Params> buttons; + Mandatory<LLLayoutStack::ELayoutOrientation, + LLLayoutStack::OrientationNames> orientation; + Multiple<LLToolBarButton::Params> buttons; Params(); }; - void draw(); + /*virtual*/ void draw(); protected: friend class LLUICtrlFactory; LLToolBar(const Params&); void initFromParams(const Params&); + void addButton(LLToolBarButton* buttonp); + void updateLayout(); private: - LLLayoutStack::ELayoutOrientation mOrientation; - LLLayoutStack* mStack; + LLLayoutStack::ELayoutOrientation mOrientation; + LLLayoutStack* mStack; + std::list<LLToolBarButton*> mButtons; }; |