diff options
author | Merov Linden <merov@lindenlab.com> | 2011-09-21 14:25:48 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2011-09-21 14:25:48 -0700 |
commit | 5ae6bbc848e0146bb4b5ea5dd4a5d26d2c5702ba (patch) | |
tree | cfd1c052aef51bfa95298613a95fc78f64c3aefc /indra/llui | |
parent | 7bc6e626f40a910b4a3e5b88161e96b9967bd24d (diff) | |
parent | 305b65f6f600b81de9a78e1246d2a5353cc3189b (diff) |
EXP-1207 : merge with 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/llnotifications.cpp | 1 | ||||
-rw-r--r-- | indra/llui/llnotificationtemplate.h | 4 | ||||
-rw-r--r-- | indra/llui/llscrollcontainer.cpp | 9 | ||||
-rw-r--r-- | indra/llui/llscrollcontainer.h | 1 | ||||
-rw-r--r-- | indra/llui/llsdparam.cpp | 2 | ||||
-rw-r--r-- | indra/llui/lltoolbar.cpp | 167 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 63 | ||||
-rw-r--r-- | indra/llui/lluictrlfactory.h | 6 |
12 files changed, 259 insertions, 59 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/llnotifications.cpp b/indra/llui/llnotifications.cpp index 6085c61f9a..ffe5908a9d 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -245,7 +245,6 @@ LLNotificationForm::LLNotificationForm(const std::string& name, const LLNotifica LLParamSDParser parser; parser.writeSD(mFormData, p.form_elements); - mFormData = mFormData[""]; if (!mFormData.isArray()) { // change existing contents to a one element array diff --git a/indra/llui/llnotificationtemplate.h b/indra/llui/llnotificationtemplate.h index eff572b553..ab777d37a5 100644 --- a/indra/llui/llnotificationtemplate.h +++ b/indra/llui/llnotificationtemplate.h @@ -88,10 +88,10 @@ struct LLNotificationTemplate { private: // this idiom allows - // <notification unique="true"> + // <notification> <unique/> </notification> // as well as // <notification> <unique> <context></context> </unique>... - Optional<bool> dummy_val; + Flag dummy_val; public: Multiple<UniquenessContext> contexts; diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp index b44b4c36b6..fe3f688fc5 100644 --- a/indra/llui/llscrollcontainer.cpp +++ b/indra/llui/llscrollcontainer.cpp @@ -223,6 +223,15 @@ BOOL LLScrollContainer::handleKeyHere(KEY key, MASK mask) return FALSE; } +BOOL LLScrollContainer::handleUnicodeCharHere(llwchar uni_char) +{ + if (mScrolledView && mScrolledView->handleUnicodeCharHere(uni_char)) + { + return TRUE; + } + return FALSE; +} + BOOL LLScrollContainer::handleScrollWheel( S32 x, S32 y, S32 clicks ) { // Give event to my child views - they may have scroll bars diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h index 46a71a7e30..3aa79cc255 100644 --- a/indra/llui/llscrollcontainer.h +++ b/indra/llui/llscrollcontainer.h @@ -103,6 +103,7 @@ public: // LLView functionality virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); virtual BOOL handleKeyHere(KEY key, MASK mask); + virtual BOOL handleUnicodeCharHere(llwchar uni_char); virtual BOOL handleScrollWheel( S32 x, S32 y, S32 clicks ); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp index 9ad13054cb..04919e6991 100644 --- a/indra/llui/llsdparam.cpp +++ b/indra/llui/llsdparam.cpp @@ -183,7 +183,7 @@ LLSD* LLParamSDParser::getSDWriteNode(const parser_t::name_stack_t& name_stack) } } - LLSD* child_sd = &(*sd_to_write)[it->first]; + LLSD* child_sd = it->first.empty() ? sd_to_write : &(*sd_to_write)[it->first]; if (child_sd->isArray()) { diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 0356fd5c8a..2c1e141ca7 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -32,46 +32,167 @@ //static LLDefaultChildRegistry::Register<LLToolBar> r1("toolbar"); + +namespace LLToolBarEnums +{ + LLLayoutStack::ELayoutOrientation getOrientation(SideType sideType) + { + LLLayoutStack::ELayoutOrientation orientation = LLLayoutStack::HORIZONTAL; + + if ((sideType == SIDE_LEFT) || (sideType == SIDE_RIGHT)) + { + orientation = LLLayoutStack::VERTICAL; + } + + return orientation; + } +} + + LLToolBar::Params::Params() -: orientation("orientation"), - buttons("button") +: button_display_mode("button_display_mode"), + buttons("button"), + side("side") {} LLToolBar::LLToolBar(const Params& p) : LLUICtrl(p), - mOrientation(p.orientation), + mButtonType(p.button_display_mode), + mSideType(p.side), mStack(NULL) { - -} - -void LLToolBar::draw() -{ - gl_rect_2d(getLocalRect(), LLColor4::blue, TRUE); } void LLToolBar::initFromParams(const LLToolBar::Params& p) { + LLLayoutStack::ELayoutOrientation orientation = LLToolBarEnums::getOrientation(p.side); + + LLLayoutStack::Params centering_stack_p; + centering_stack_p.rect = getLocalRect(); + centering_stack_p.follows.flags = FOLLOWS_ALL; + centering_stack_p.orientation = 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; + + 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)); + 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.orientation = orientation; + stack_p.follows.flags = (orientation == 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 (LLToolBarButton::Params button_p, p.buttons) + { + // remove any offset from button + LLRect button_rect(button_p.rect); + + if (orientation == 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 (LLToolBarEnums::getOrientation(mSideType) == 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() +{ + //gl_rect_2d(getLocalRect(), LLColor4::blue, TRUE); + LLUICtrl::draw(); +} + +namespace LLInitParam +{ + void TypeValues<LLToolBarEnums::ButtonType>::declareValues() + { + declare("icons_only", LLToolBarEnums::BTNTYPE_ICONS_ONLY); + declare("icons_with_text", LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT); + } - BOOST_FOREACH (LLButton::Params button_p, p.buttons) + void TypeValues<LLToolBarEnums::SideType>::declareValues() { - 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); + declare("none", LLToolBarEnums::SIDE_NONE); + declare("bottom", LLToolBarEnums::SIDE_BOTTOM); + declare("left", LLToolBarEnums::SIDE_LEFT); + declare("right", LLToolBarEnums::SIDE_RIGHT); + declare("top", LLToolBarEnums::SIDE_TOP); } } diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index dd454e3f0b..60a848a6e3 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -32,28 +32,83 @@ #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) {} +}; + + +namespace LLToolBarEnums +{ + enum ButtonType + { + BTNTYPE_ICONS_ONLY = 0, + BTNTYPE_ICONS_WITH_TEXT, + }; + + enum SideType + { + SIDE_NONE = 0, + SIDE_BOTTOM, + SIDE_LEFT, + SIDE_RIGHT, + SIDE_TOP, + }; +} + +// NOTE: This needs to occur before Param block declaration for proper compilation. +namespace LLInitParam +{ + template<> + struct TypeValues<LLToolBarEnums::ButtonType> : public TypeValuesHelper<LLToolBarEnums::ButtonType> + { + static void declareValues(); + }; + + template<> + struct TypeValues<LLToolBarEnums::SideType> : public TypeValuesHelper<LLToolBarEnums::SideType> + { + static void declareValues(); + }; +} + + class LLToolBar : public LLUICtrl { public: + struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> { - Mandatory<LLLayoutStack::ELayoutOrientation> orientation; - Multiple<LLButton::Params> buttons; + Mandatory<LLToolBarEnums::ButtonType> button_display_mode; + Multiple<LLToolBarButton::Params> buttons; + Mandatory<LLToolBarEnums::SideType> side; Params(); }; + // virtuals 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; + std::list<LLToolBarButton*> mButtons; + LLToolBarEnums::ButtonType mButtonType; + LLToolBarEnums::SideType mSideType; + LLLayoutStack* mStack; }; diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index f0ba7fc7d7..d345ad4cd0 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -125,12 +125,12 @@ private: // base case for recursion, there are NO base classes of LLInitParam::BaseBlock template<int DUMMY> - class ParamDefaults<LLInitParam::BaseBlock, DUMMY> : public LLSingleton<ParamDefaults<LLInitParam::BaseBlock, DUMMY> > + class ParamDefaults<LLInitParam::BaseBlockWithFlags, DUMMY> : public LLSingleton<ParamDefaults<LLInitParam::BaseBlockWithFlags, DUMMY> > { public: - const LLInitParam::BaseBlock& get() { return mBaseBlock; } + const LLInitParam::BaseBlockWithFlags& get() { return mBaseBlock; } private: - LLInitParam::BaseBlock mBaseBlock; + LLInitParam::BaseBlockWithFlags mBaseBlock; }; public: |