From 860962d365ba49d063d2f934706a6e4832352b4b Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 12 Sep 2011 18:00:52 -0700 Subject: EXP-1063 FIX Destination Guide link in side panel does not open to destination guide specific search window fixed param->LLSD serialization to not introduce empty strings --- indra/llui/llsdparam.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp index 9ad13054cb..7deedb18b8 100644 --- a/indra/llui/llsdparam.cpp +++ b/indra/llui/llsdparam.cpp @@ -159,6 +159,11 @@ LLSD* LLParamSDParser::getSDWriteNode(const parser_t::name_stack_t& name_stack) it != name_stack.end(); ++it) { + if (it->first.empty()) + { + continue; + } + bool new_array_entry = false; if (prev_it == mNameStack.end()) { -- cgit v1.2.3 From 2809778bf1a487e2a2786301d7fd651c82290432 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 14 Sep 2011 19:45:00 -0700 Subject: EXP-1201 FIX Quit button option not present in Mode Changing and Exit viewer dialogs --- indra/llui/llnotifications.cpp | 1 - indra/llui/llsdparam.cpp | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'indra/llui') 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/llsdparam.cpp b/indra/llui/llsdparam.cpp index 7deedb18b8..04919e6991 100644 --- a/indra/llui/llsdparam.cpp +++ b/indra/llui/llsdparam.cpp @@ -159,11 +159,6 @@ LLSD* LLParamSDParser::getSDWriteNode(const parser_t::name_stack_t& name_stack) it != name_stack.end(); ++it) { - if (it->first.empty()) - { - continue; - } - bool new_array_entry = false; if (prev_it == mNameStack.end()) { @@ -188,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()) { -- cgit v1.2.3 From 03e965a7324ca9ecc3d99faf27e2ea4d7b2fbc52 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 15 Sep 2011 16:16:33 -0700 Subject: EXP-974 FIX Inventory Keystroke Behavior No Longer Working --- indra/llui/llscrollcontainer.cpp | 9 +++++++++ indra/llui/llscrollcontainer.h | 1 + 2 files changed, 10 insertions(+) (limited to 'indra/llui') 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, -- cgit v1.2.3 From c10832bb9ade5efa2a501cb3b39f769aa3024363 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 16 Sep 2011 11:57:57 -0700 Subject: added Flag as new param type... usage: will set the bar flag on foo LLSD foo; foo["bar"]; will set the bar flag on foo converted notifications unique to use flag --- indra/llui/llnotificationtemplate.h | 4 ++-- indra/llui/lluictrlfactory.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llui') 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 - // + // // as well as // ... - Optional dummy_val; + Flag dummy_val; public: Multiple contexts; 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 - class ParamDefaults : public LLSingleton > + class ParamDefaults : public LLSingleton > { public: - const LLInitParam::BaseBlock& get() { return mBaseBlock; } + const LLInitParam::BaseBlockWithFlags& get() { return mBaseBlock; } private: - LLInitParam::BaseBlock mBaseBlock; + LLInitParam::BaseBlockWithFlags mBaseBlock; }; public: -- cgit v1.2.3 From 64f30a302dfbcaf56502676fa4b8d8a06f355b40 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 20 Sep 2011 16:37:21 -0700 Subject: EXP-1228 FIX Create toolbar widget class that displays list of buttons horizontally or vertically buttons are now centered and sized according to content created floater_test_toolbar.xml to test --- indra/llui/llbutton.cpp | 4 +- indra/llui/llbutton.h | 21 ++++---- indra/llui/lllayoutstack.cpp | 14 ++++- indra/llui/lllayoutstack.h | 26 ++++++---- indra/llui/lltoolbar.cpp | 121 ++++++++++++++++++++++++++++++++++++------- indra/llui/lltoolbar.h | 26 ++++++++-- 6 files changed, 162 insertions(+), 50 deletions(-) (limited to 'indra/llui') 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 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(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(border_panel_p)); + LLLayoutPanel* center_panel = LLUICtrlFactory::create(center_panel_p); + centering_stack->addChild(center_panel); + centering_stack->addChild(LLUICtrlFactory::create(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(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(panel_p); - LLButton* button = LLUICtrlFactory::create(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(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(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 + { + }; + + LLToolBarButton(const Params& p) : LLButton(p) {} + +}; + class LLToolBar : public LLUICtrl { public: + struct Params : public LLInitParam::Block { - Mandatory orientation; - Multiple buttons; + Mandatory orientation; + Multiple 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 mButtons; }; -- cgit v1.2.3 From 305b65f6f600b81de9a78e1246d2a5353cc3189b Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 21 Sep 2011 12:11:23 -0700 Subject: EXP-1205 PROGRESS -- As a User, I want a toybox which will contain all buttons that I can d&d into the toolbars EXP-1210 FIX -- Implement new toybox floater window EXP-1231 FIX -- Add menu option to toggle the toybox floater on and off * Basic toybox floater implemented as its own class * Toybox is available through "Me -> Toolbars..." menu option or ctrl-T shortcut * Toolbars now have "side" type rather than simple orientation, as well as button state for "icons only" or "icons with text". Reviewed by Richard --- indra/llui/lltoolbar.cpp | 58 ++++++++++++++++++++++++++++++++++++++++-------- indra/llui/lltoolbar.h | 55 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 96 insertions(+), 17 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index cdd3a50205..2c1e141ca7 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -32,23 +32,45 @@ //static LLDefaultChildRegistry::Register 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::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 = p.orientation; + centering_stack_p.orientation = orientation; centering_stack_p.name = "centering_stack"; LLLayoutPanel::Params border_panel_p; @@ -75,8 +97,8 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) LLLayoutStack::Params stack_p; stack_p.rect = getLocalRect(); stack_p.name = "button_stack"; - stack_p.orientation = p.orientation; - stack_p.follows.flags = (mOrientation == LLLayoutStack::HORIZONTAL) + stack_p.orientation = orientation; + stack_p.follows.flags = (orientation == LLLayoutStack::HORIZONTAL) ? (FOLLOWS_TOP|FOLLOWS_BOTTOM) // horizontal : (FOLLOWS_LEFT|FOLLOWS_RIGHT); // vertical @@ -88,7 +110,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) // remove any offset from button LLRect button_rect(button_p.rect); - if (mOrientation == LLLayoutStack::HORIZONTAL) + if (orientation == LLLayoutStack::HORIZONTAL) { button_rect.setOriginAndSize(0, 0, 0, getRect().getHeight()); } @@ -139,7 +161,7 @@ void LLToolBar::updateLayout() max_height = llmax(button->getRect().getHeight(), max_height); } - if (mOrientation == LLLayoutStack::HORIZONTAL) + if (LLToolBarEnums::getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) { mStack->reshape(total_width, mStack->getParent()->getRect().getHeight()); } @@ -153,6 +175,24 @@ void LLToolBar::updateLayout() void LLToolBar::draw() { + //gl_rect_2d(getLocalRect(), LLColor4::blue, TRUE); LLUICtrl::draw(); } +namespace LLInitParam +{ + void TypeValues::declareValues() + { + declare("icons_only", LLToolBarEnums::BTNTYPE_ICONS_ONLY); + declare("icons_with_text", LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT); + } + + void TypeValues::declareValues() + { + 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 fb03095c56..60a848a6e3 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -32,6 +32,7 @@ #include "lllayoutstack.h" #include "llbutton.h" + class LLToolBarButton : public LLButton { public: @@ -40,9 +41,44 @@ public: }; 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 : public TypeValuesHelper + { + static void declareValues(); + }; + + template<> + struct TypeValues : public TypeValuesHelper + { + static void declareValues(); + }; +} + + class LLToolBar : public LLUICtrl { @@ -50,26 +86,29 @@ public: struct Params : public LLInitParam::Block { - Mandatory orientation; - Multiple buttons; + Mandatory button_display_mode; + Multiple buttons; + Mandatory side; Params(); }; - /*virtual*/ void draw(); + // 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 mButtons; + std::list mButtons; + LLToolBarEnums::ButtonType mButtonType; + LLToolBarEnums::SideType mSideType; + LLLayoutStack* mStack; }; -- cgit v1.2.3 From 7bc6e626f40a910b4a3e5b88161e96b9967bd24d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 21 Sep 2011 14:24:38 -0700 Subject: EXP-1207 : LLToolbarView skeleton, nothing operational yet... --- indra/llui/CMakeLists.txt | 2 ++ indra/llui/lltoolbarview.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++ indra/llui/lltoolbarview.h | 52 +++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 indra/llui/lltoolbarview.cpp create mode 100644 indra/llui/lltoolbarview.h (limited to 'indra/llui') diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index cf3f9b1a7b..d81801a0d2 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -100,6 +100,7 @@ set(llui_SOURCE_FILES lltransutil.cpp lltoggleablemenu.cpp lltoolbar.cpp + lltoolbarview.cpp lltooltip.cpp llui.cpp lluicolortable.cpp @@ -202,6 +203,7 @@ set(llui_HEADER_FILES lltimectrl.h lltoggleablemenu.h lltoolbar.h + lltoolbarview.h lltooltip.h lltransutil.h lluicolortable.h diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp new file mode 100644 index 0000000000..40d1ac3418 --- /dev/null +++ b/indra/llui/lltoolbarview.cpp @@ -0,0 +1,74 @@ +/** + * @file lltoolbarview.cpp + * @author Merov Linden + * @brief User customizable toolbar class + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "lltoolbarview.h" +#include "llbutton.h" + +LLToolBarView* gToolBarView = NULL; + +static LLDefaultChildRegistry::Register r("toolbar_view"); + +LLToolBarView::LLToolBarView(const Params& p) +: LLUICtrl(p) +{ +} + +BOOL LLToolBarView::postBuild() +{ + LLButton* btn = getChild("color_pipette"); + btn->setVisible(TRUE); + LLRect ctrl_rect = getRect(); + LLRect btn_rect = btn->getRect(); + llinfos << "Merov debug : control rect = " << ctrl_rect.mLeft << ", " << ctrl_rect.mTop << ", " << ctrl_rect.mRight << ", " << ctrl_rect.mBottom << llendl; + llinfos << "Merov debug : button rect = " << btn_rect.mLeft << ", " << btn_rect.mTop << ", " << btn_rect.mRight << ", " << btn_rect.mBottom << llendl; + btn_rect.mLeft = 0; + btn_rect.mTop = ctrl_rect.getHeight(); + btn_rect.mRight = 28; + btn_rect.mBottom = btn_rect.mTop - 28; + btn->setRect(btn_rect); + btn_rect = btn->getRect(); + llinfos << "Merov debug : button rect = " << btn_rect.mLeft << ", " << btn_rect.mTop << ", " << btn_rect.mRight << ", " << btn_rect.mBottom << llendl; + return TRUE; +} + +void LLToolBarView::draw() +{ + LLButton* btn = getChild("color_pipette"); + btn->setVisible(TRUE); + static bool debug_print = true; + if (debug_print) + { + LLRect ctrl_rect = getRect(); + LLRect btn_rect = btn->getRect(); + llinfos << "Merov debug : draw control rect = " << ctrl_rect.mLeft << ", " << ctrl_rect.mTop << ", " << ctrl_rect.mRight << ", " << ctrl_rect.mBottom << llendl; + llinfos << "Merov debug : draw button rect = " << btn_rect.mLeft << ", " << btn_rect.mTop << ", " << btn_rect.mRight << ", " << btn_rect.mBottom << llendl; + debug_print = false; + } + LLUICtrl::draw(); +} diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h new file mode 100644 index 0000000000..0bd0070ab7 --- /dev/null +++ b/indra/llui/lltoolbarview.h @@ -0,0 +1,52 @@ +/** + * @file lltoolbarview.h + * @author Merov Linden + * @brief User customizable toolbar class + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLTOOLBARVIEW_H +#define LL_LLTOOLBARVIEW_H + +#include "lluictrl.h" + +// Parent of all LLToolBar + +class LLToolBarView : public LLUICtrl +{ +public: + struct Params : public LLInitParam::Block {}; + void draw(); + /*virtual*/ BOOL postBuild(); + +protected: + friend class LLUICtrlFactory; + LLToolBarView(const Params&); + +private: + LLHandle mSnapView; +}; + +extern LLToolBarView* gToolBarView; + +#endif // LL_LLTOOLBARVIEW_H -- cgit v1.2.3 From 412e29ed9d62e975a5290c6008558a739b88065d Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 21 Sep 2011 17:25:38 -0700 Subject: EXP-1205 PROGRESS -- As a User, I want a toybox which will contain all buttons that I can d&d into the toolbars EXP-1232 FIX -- Create class to load and hold all of the command meta data associated with FUI toolbar actions * Added basic commands.xml file to define FUI-related toolbar actions. For now a basic "avatar" and "places" button are defined. * Added basic command manager to parse and hold strings that define potential toolbar command actions. * Broke out a separate floater function as a placeholder for the 3-state toolbar floater toggling. * LLUI::initClass now parses the new commands.xml file Reviewed by Richard. --- indra/llui/CMakeLists.txt | 2 + indra/llui/llcommandmanager.cpp | 138 ++++++++++++++++++++++++++++++++++++++++ indra/llui/llcommandmanager.h | 97 ++++++++++++++++++++++++++++ indra/llui/llfloaterreg.cpp | 11 ++++ indra/llui/llfloaterreg.h | 1 + indra/llui/llui.cpp | 5 ++ 6 files changed, 254 insertions(+) create mode 100644 indra/llui/llcommandmanager.cpp create mode 100644 indra/llui/llcommandmanager.h (limited to 'indra/llui') diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index cf3f9b1a7b..0687cf55d8 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -35,6 +35,7 @@ set(llui_SOURCE_FILES llcheckboxctrl.cpp llclipboard.cpp llcombobox.cpp + llcommandmanager.cpp llconsole.cpp llcontainerview.cpp llctrlselectioninterface.cpp @@ -132,6 +133,7 @@ set(llui_HEADER_FILES llcheckboxctrl.h llclipboard.h llcombobox.h + llcommandmanager.h llconsole.h llcontainerview.h llctrlselectioninterface.h diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp new file mode 100644 index 0000000000..306b357d6a --- /dev/null +++ b/indra/llui/llcommandmanager.cpp @@ -0,0 +1,138 @@ +/** + * @file llcommandmanager.cpp + * @brief LLCommandManager class + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +// A control that displays the name of the chosen item, which when +// clicked shows a scrolling box of options. + +#include "linden_common.h" + +#include "llcommandmanager.h" +#include "lldir.h" +#include "llerror.h" +#include "llxuiparser.h" + +#include + + +// +// LLCommand class +// + +LLCommand::Params::Params() + : function("function") + , icon("icon") + , label_ref("label_ref") + , name("name") + , param("param") + , tooltip_ref("tooltip_ref") +{ +} + +LLCommand::LLCommand(const LLCommand::Params& p) + : mFunction(p.function) + , mIcon(p.icon) + , mLabelRef(p.label_ref) + , mName(p.name) + , mParam(p.param) + , mTooltipRef(p.tooltip_ref) +{ +} + + +// +// LLCommandManager class +// + +LLCommandManager::LLCommandManager() +{ +} + +LLCommandManager::~LLCommandManager() +{ +} + +U32 LLCommandManager::count() const +{ + return mCommands.size(); +} + +LLCommand * LLCommandManager::getCommand(U32 commandIndex) +{ + return mCommands[commandIndex]; +} + +LLCommand * LLCommandManager::getCommand(const std::string& commandName) +{ + LLCommand * command_name_match = NULL; + + for (CommandVector::iterator it = mCommands.begin(); it != mCommands.end(); ++it) + { + LLCommand * command = *it; + + if (command->name() == commandName) + { + command_name_match = command; + break; + } + } + + return command_name_match; +} + +//static +bool LLCommandManager::load() +{ + LLCommandManager& mgr = LLCommandManager::instance(); + + std::string commands_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "commands.xml"); + + LLCommandManager::Params commandsParams; + + LLSimpleXUIParser parser; + + if (!parser.readXUI(commands_file, commandsParams)) + { + llerrs << "Unable to load xml file: " << commands_file << llendl; + return false; + } + + if (!commandsParams.validateBlock()) + { + llerrs << "Unable to validate commands param block from file: " << commands_file << llendl; + return false; + } + + BOOST_FOREACH(LLCommand::Params& commandParams, commandsParams.commands) + { + LLCommand * command = new LLCommand(commandParams); + + mgr.mCommands.push_back(command); + + llinfos << "Successfully loaded command: " << command->name() << llendl; + } + + return true; +} diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h new file mode 100644 index 0000000000..4f3c9b2ada --- /dev/null +++ b/indra/llui/llcommandmanager.h @@ -0,0 +1,97 @@ +/** + * @file llcommandmanager.h + * @brief LLCommandManager class to hold commands + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_COMMANDMANAGER_H +#define LL_COMMANDMANAGER_H + +#include "llinitparam.h" +#include "llsingleton.h" + + +class LLCommand +{ +public: + struct Params : public LLInitParam::Block + { + Mandatory function; + Mandatory icon; + Mandatory label_ref; + Mandatory name; + Optional param; + Mandatory tooltip_ref; + + Params(); + }; + + LLCommand(const LLCommand::Params& p); + + const std::string& functionName() const { return mFunction; } + const std::string& icon() const { return mIcon; } + const std::string& labelRef() const { return mLabelRef; } + const std::string& name() const { return mName; } + const std::string& param() const { return mParam; } + const std::string& tooltipRef() const { return mTooltipRef; } + +private: + std::string mFunction; + std::string mIcon; + std::string mLabelRef; + std::string mName; + std::string mParam; + std::string mTooltipRef; +}; + + +class LLCommandManager +: public LLSingleton +{ +public: + struct Params : public LLInitParam::Block + { + Multiple< LLCommand::Params, AtLeast<1> > commands; + + Params() + : commands("command") + { + } + }; + + LLCommandManager(); + ~LLCommandManager(); + + U32 count() const; + LLCommand * getCommand(U32 commandIndex); + LLCommand * getCommand(const std::string& commandName); + + static bool load(); + +private: + typedef std::vector CommandVector; + CommandVector mCommands; +}; + + +#endif // LL_COMMANDMANAGER_H diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index fc7dcfcc4e..bc740dde17 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -452,6 +452,17 @@ void LLFloaterReg::toggleFloaterInstance(const LLSD& sdname) toggleInstance(name, key); } +//static +void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) +{ + // Do some extra logic here for 3-state toolbar floater toggling madness :) + + LLSD key; + std::string name = sdname.asString(); + parse_name_key(name, key); + toggleInstance(name, key); +} + //static bool LLFloaterReg::floaterInstanceVisible(const LLSD& sdname) { diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index a2027a77a0..6239d98a7d 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -127,6 +127,7 @@ public: static void showFloaterInstance(const LLSD& sdname); static void hideFloaterInstance(const LLSD& sdname); static void toggleFloaterInstance(const LLSD& sdname); + static void toggleToolbarFloaterInstance(const LLSD& sdname); static bool floaterInstanceVisible(const LLSD& sdname); static bool floaterInstanceMinimized(const LLSD& sdname); diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 593354ee9b..1bc575438c 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -41,6 +41,7 @@ #include "llgl.h" // Project includes +#include "llcommandmanager.h" #include "llcontrol.h" #include "llui.h" #include "lluicolortable.h" @@ -1617,6 +1618,7 @@ void LLUI::initClass(const settings_map_t& settings, // Callbacks for associating controls with floater visibilty: reg.add("Floater.Toggle", boost::bind(&LLFloaterReg::toggleFloaterInstance, _2)); + reg.add("Floater.ToolbarToggle", boost::bind(&LLFloaterReg::toggleToolbarFloaterInstance, _2)); reg.add("Floater.Show", boost::bind(&LLFloaterReg::showFloaterInstance, _2)); reg.add("Floater.Hide", boost::bind(&LLFloaterReg::hideFloaterInstance, _2)); reg.add("Floater.InitToVisibilityControl", boost::bind(&LLFloaterReg::initUICtrlToFloaterVisibilityControl, _1, _2)); @@ -1635,6 +1637,9 @@ void LLUI::initClass(const settings_map_t& settings, // Used by menus along with Floater.Toggle to display visibility as a checkmark LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", boost::bind(&LLFloaterReg::floaterInstanceVisible, _2)); + + // Parse the master list of commands + LLCommandManager::load(); } void LLUI::cleanupClass() -- cgit v1.2.3 From 7e308b551c7fde9178e354dba005a5b35f793245 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 21 Sep 2011 18:48:39 -0700 Subject: EXP-1239 WIP make toolbars wrap when there is not enough room initial pass at wrapping --- indra/llui/lltoolbar.cpp | 196 ++++++++++++++++++++++++++++++++--------------- indra/llui/lltoolbar.h | 27 ++++++- 2 files changed, 160 insertions(+), 63 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 2c1e141ca7..1e8be93f17 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -30,9 +30,10 @@ #include "boost/foreach.hpp" #include "lltoolbar.h" +// uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit +// thanks, MSVC! //static LLDefaultChildRegistry::Register r1("toolbar"); - namespace LLToolBarEnums { LLLayoutStack::ELayoutOrientation getOrientation(SideType sideType) @@ -47,85 +48,88 @@ namespace LLToolBarEnums return orientation; } } - +using namespace LLToolBarEnums; LLToolBar::Params::Params() : button_display_mode("button_display_mode"), buttons("button"), - side("side") + side("side"), + button_icon("button_icon"), + button_icon_and_text("button_icon_and_text"), + wrap("wrap", true), + min_width("min_width", 0), + max_width("max_width", S32_MAX), + background_image("background_image") {} LLToolBar::LLToolBar(const Params& p) : LLUICtrl(p), mButtonType(p.button_display_mode), mSideType(p.side), - mStack(NULL) + mWrap(p.wrap), + mNeedsLayout(false), + mCenterPanel(NULL), + mCenteringStack(NULL), + mMinWidth(p.min_width), + mMaxWidth(p.max_width), + mBackgroundImage(p.background_image) { } void LLToolBar::initFromParams(const LLToolBar::Params& p) { - LLLayoutStack::ELayoutOrientation orientation = LLToolBarEnums::getOrientation(p.side); + LLLayoutStack::ELayoutOrientation orientation = getOrientation(p.side); LLLayoutStack::Params centering_stack_p; + centering_stack_p.name = "centering_stack"; centering_stack_p.rect = getLocalRect(); centering_stack_p.follows.flags = FOLLOWS_ALL; centering_stack_p.orientation = orientation; - centering_stack_p.name = "centering_stack"; + mCenteringStack = LLUICtrlFactory::create(centering_stack_p); + addChild(mCenteringStack); + 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(centering_stack_p); - addChild(centering_stack); + mCenteringStack->addChild(LLUICtrlFactory::create(border_panel_p)); + 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; + mCenterPanel = LLUICtrlFactory::create(center_panel_p); + mCenteringStack->addChild(mCenterPanel); + + mCenteringStack->addChild(LLUICtrlFactory::create(border_panel_p)); - centering_stack->addChild(LLUICtrlFactory::create(border_panel_p)); - LLLayoutPanel* center_panel = LLUICtrlFactory::create(center_panel_p); - centering_stack->addChild(center_panel); - centering_stack->addChild(LLUICtrlFactory::create(border_panel_p)); - - LLLayoutStack::Params stack_p; - stack_p.rect = getLocalRect(); - stack_p.name = "button_stack"; - stack_p.orientation = orientation; - stack_p.follows.flags = (orientation == LLLayoutStack::HORIZONTAL) - ? (FOLLOWS_TOP|FOLLOWS_BOTTOM) // horizontal - : (FOLLOWS_LEFT|FOLLOWS_RIGHT); // vertical - - mStack = LLUICtrlFactory::create(stack_p); - center_panel->addChild(mStack); + addRow(); 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()); + { // remove any offset from button + if (orientation == LLLayoutStack::HORIZONTAL) + { + button_rect.setOriginAndSize(0, 0, mMinWidth, getRect().getHeight()); + } + else // VERTICAL + { + button_rect.setOriginAndSize(0, 0, mMinWidth, button_rect.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(button_p); + button_p.fillFrom((mButtonType == BTNTYPE_ICONS_ONLY) + ? p.button_icon // icon only + : p.button_icon_and_text); // icon + text - addButton(button); + mButtons.push_back(LLUICtrlFactory::create(button_p)); + mNeedsLayout = true; } updateLayout(); @@ -142,57 +146,127 @@ void LLToolBar::addButton(LLToolBarButton* buttonp) LLLayoutPanel* panel = LLUICtrlFactory::create(panel_p); panel->addChild(buttonp); - mStack->addChild(panel); - mButtons.push_back(buttonp); + mStacks.back()->addChild(panel); } void LLToolBar::updateLayout() { - S32 total_width = 0; - S32 total_height = 0; - S32 max_width = getRect().getWidth(); - S32 max_height = getRect().getHeight(); + mCenteringStack->updateLayout(); + + if (!mNeedsLayout) return; + mNeedsLayout = false; + + { // clean up existing rows + BOOST_FOREACH(LLToolBarButton* button, mButtons) + { + if (button->getParent()) + { + button->getParent()->removeChild(button); + } + } + + BOOST_FOREACH(LLLayoutStack* stack, mStacks) + { + delete stack; + } + mStacks.clear(); + } + // start with one row of buttons + addRow(); + S32 total_width = 0, total_height = 0; + S32 max_total_width = 0, max_total_height = 0; + S32 max_width = getRect().getWidth(), max_height = getRect().getHeight(); BOOST_FOREACH(LLToolBarButton* button, mButtons) { - total_width += button->getRect().getWidth(); - total_height += button->getRect().getHeight(); + S32 button_width = button->getRect().getWidth(); + S32 button_height = button->getRect().getHeight(); + + if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL + && total_width + button_height > getRect().getWidth()) + { + addRow(); + total_width = 0; + } + addButton(button); + + total_width += button_width; + total_height += button_height; + max_total_width = llmax(max_total_width, total_width); + max_total_height = llmax(max_total_height, total_height); max_width = llmax(button->getRect().getWidth(), max_width); max_height = llmax(button->getRect().getHeight(), max_height); } - if (LLToolBarEnums::getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) + if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) { - mStack->reshape(total_width, mStack->getParent()->getRect().getHeight()); + BOOST_FOREACH(LLLayoutStack* stack, mStacks) + { + stack->reshape(max_total_width, stack->getParent()->getRect().getHeight()); + stack->updateLayout(); + } } else { - mStack->reshape(mStack->getParent()->getRect().getWidth(), total_height); - reshape(max_width, getRect().getHeight()); + BOOST_FOREACH(LLLayoutStack* stack, mStacks) + { + stack->reshape(stack->getParent()->getRect().getWidth(), max_total_height); + stack->updateLayout(); + } + + reshape(max_total_width, getRect().getHeight()); } } void LLToolBar::draw() { - //gl_rect_2d(getLocalRect(), LLColor4::blue, TRUE); + updateLayout(); + + { // draw background + LLRect bg_rect; + localRectToOtherView(mCenterPanel->getRect(),&bg_rect, this); + mBackgroundImage->draw(bg_rect); + } LLUICtrl::draw(); } +void LLToolBar::addRow() +{ + LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType); + + LLLayoutStack::Params stack_p; + stack_p.rect = getLocalRect(); + stack_p.name = llformat("button_stack_%d", mStacks.size()); + stack_p.orientation = orientation; + stack_p.follows.flags = (orientation == LLLayoutStack::HORIZONTAL) + ? (FOLLOWS_TOP|FOLLOWS_BOTTOM) // horizontal + : (FOLLOWS_LEFT|FOLLOWS_RIGHT); // vertical + + mStacks.push_back(LLUICtrlFactory::create(stack_p)); + mCenterPanel->addChild(mStacks.back()); +} + +void LLToolBar::reshape(S32 width, S32 height, BOOL called_from_parent) +{ + LLUICtrl::reshape(width, height, called_from_parent); + mNeedsLayout = true; +} + namespace LLInitParam { - void TypeValues::declareValues() + void TypeValues::declareValues() { - declare("icons_only", LLToolBarEnums::BTNTYPE_ICONS_ONLY); - declare("icons_with_text", LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT); + declare("icons_only", BTNTYPE_ICONS_ONLY); + declare("icons_with_text", BTNTYPE_ICONS_WITH_TEXT); } - void TypeValues::declareValues() + void TypeValues::declareValues() { - 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); + declare("none", SIDE_NONE); + declare("bottom", SIDE_BOTTOM); + declare("left", SIDE_LEFT); + declare("right", SIDE_RIGHT); + declare("top", SIDE_TOP); } } diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 60a848a6e3..3a593e42d9 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -87,14 +87,25 @@ public: struct Params : public LLInitParam::Block { Mandatory button_display_mode; - Multiple buttons; Mandatory side; + Optional button_icon, + button_icon_and_text; + + Optional wrap; + Optional min_width, + max_width; + // get rid of this + Multiple buttons; + + Optional background_image; + Params(); }; // virtuals void draw(); + void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); protected: friend class LLUICtrlFactory; @@ -105,10 +116,22 @@ protected: void updateLayout(); private: + void addRow(); + std::list mButtons; LLToolBarEnums::ButtonType mButtonType; + LLLayoutStack* mCenteringStack; + LLLayoutStack* mWrapStack; + LLLayoutPanel* mCenterPanel; LLToolBarEnums::SideType mSideType; - LLLayoutStack* mStack; + + std::vector mStacks; + bool mWrap; + bool mNeedsLayout; + S32 mMinWidth, + mMaxWidth; + + LLUIImagePtr mBackgroundImage; }; -- cgit v1.2.3 From 65892a01cad5d22403f36a10187af40b37b48383 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 21 Sep 2011 19:31:07 -0700 Subject: EXP-1207 : More work on LLToolbarView, still not operational... --- indra/llui/lltoolbarview.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 40d1ac3418..0e54c91cea 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -28,6 +28,7 @@ #include "linden_common.h" #include "lltoolbarview.h" +#include "lltoolbar.h" #include "llbutton.h" LLToolBarView* gToolBarView = NULL; @@ -41,34 +42,40 @@ LLToolBarView::LLToolBarView(const Params& p) BOOL LLToolBarView::postBuild() { - LLButton* btn = getChild("color_pipette"); - btn->setVisible(TRUE); LLRect ctrl_rect = getRect(); + LLButton* btn = getChild("test"); LLRect btn_rect = btn->getRect(); llinfos << "Merov debug : control rect = " << ctrl_rect.mLeft << ", " << ctrl_rect.mTop << ", " << ctrl_rect.mRight << ", " << ctrl_rect.mBottom << llendl; - llinfos << "Merov debug : button rect = " << btn_rect.mLeft << ", " << btn_rect.mTop << ", " << btn_rect.mRight << ", " << btn_rect.mBottom << llendl; - btn_rect.mLeft = 0; - btn_rect.mTop = ctrl_rect.getHeight(); - btn_rect.mRight = 28; - btn_rect.mBottom = btn_rect.mTop - 28; - btn->setRect(btn_rect); - btn_rect = btn->getRect(); - llinfos << "Merov debug : button rect = " << btn_rect.mLeft << ", " << btn_rect.mTop << ", " << btn_rect.mRight << ", " << btn_rect.mBottom << llendl; + llinfos << "Merov debug : test rect = " << btn_rect.mLeft << ", " << btn_rect.mTop << ", " << btn_rect.mRight << ", " << btn_rect.mBottom << llendl; return TRUE; } void LLToolBarView::draw() { - LLButton* btn = getChild("color_pipette"); - btn->setVisible(TRUE); static bool debug_print = true; + + LLToolBar* toolbar_bottom = getChild("toolbar_bottom"); + LLToolBar* toolbar_left = getChild("toolbar_left"); + LLToolBar* toolbar_right = getChild("toolbar_right"); + + LLRect bottom_rect = toolbar_bottom->getRect(); + LLRect left_rect = toolbar_left->getRect(); + LLRect right_rect = toolbar_right->getRect(); + if (debug_print) { LLRect ctrl_rect = getRect(); - LLRect btn_rect = btn->getRect(); llinfos << "Merov debug : draw control rect = " << ctrl_rect.mLeft << ", " << ctrl_rect.mTop << ", " << ctrl_rect.mRight << ", " << ctrl_rect.mBottom << llendl; - llinfos << "Merov debug : draw button rect = " << btn_rect.mLeft << ", " << btn_rect.mTop << ", " << btn_rect.mRight << ", " << btn_rect.mBottom << llendl; + llinfos << "Merov debug : draw bottom rect = " << bottom_rect.mLeft << ", " << bottom_rect.mTop << ", " << bottom_rect.mRight << ", " << bottom_rect.mBottom << llendl; + llinfos << "Merov debug : draw left rect = " << left_rect.mLeft << ", " << left_rect.mTop << ", " << left_rect.mRight << ", " << left_rect.mBottom << llendl; + llinfos << "Merov debug : draw right rect = " << right_rect.mLeft << ", " << right_rect.mTop << ", " << right_rect.mRight << ", " << right_rect.mBottom << llendl; debug_print = false; } + // Debug draw + gl_rect_2d(getLocalRect(), LLColor4::blue, TRUE); + gl_rect_2d(bottom_rect, LLColor4::red, TRUE); + gl_rect_2d(left_rect, LLColor4::green, TRUE); + gl_rect_2d(right_rect, LLColor4::yellow, TRUE); + LLUICtrl::draw(); } -- cgit v1.2.3 From 00f66ccf409b0f7fb974f23cd157cdd0b8a6ab96 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 22 Sep 2011 15:08:59 -0700 Subject: EXP-1239 WIP make toolbars wrap when there is not enough room added more toolbars to floater_test_toolbar.xml removed layout stack and got basic wrapping working reviewed by Leslie --- indra/llui/lltoolbar.cpp | 196 +++++++++++++++++++++++++---------------------- indra/llui/lltoolbar.h | 13 ++-- 2 files changed, 109 insertions(+), 100 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 1e8be93f17..f623d99dc7 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -57,8 +57,8 @@ LLToolBar::Params::Params() button_icon("button_icon"), button_icon_and_text("button_icon_and_text"), wrap("wrap", true), - min_width("min_width", 0), - max_width("max_width", S32_MAX), + min_button_width("min_button_width", 0), + max_button_width("max_button_width", S32_MAX), background_image("background_image") {} @@ -70,8 +70,8 @@ LLToolBar::LLToolBar(const Params& p) mNeedsLayout(false), mCenterPanel(NULL), mCenteringStack(NULL), - mMinWidth(p.min_width), - mMaxWidth(p.max_width), + mMinButtonWidth(p.min_button_width), + mMaxButtonWidth(p.max_button_width), mBackgroundImage(p.background_image) { } @@ -108,120 +108,148 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) mCenteringStack->addChild(LLUICtrlFactory::create(border_panel_p)); - addRow(); - BOOST_FOREACH (LLToolBarButton::Params button_p, p.buttons) { + // buttons always follow left and top, for all orientations + button_p.follows.flags = FOLLOWS_LEFT|FOLLOWS_TOP; + button_p.fillFrom((mButtonType == BTNTYPE_ICONS_ONLY) + ? p.button_icon // icon only + : p.button_icon_and_text); // icon + text + LLRect button_rect(button_p.rect); { // remove any offset from button if (orientation == LLLayoutStack::HORIZONTAL) { - button_rect.setOriginAndSize(0, 0, mMinWidth, getRect().getHeight()); + button_rect.setOriginAndSize(0, 0, mMinButtonWidth, button_rect.getHeight()); } else // VERTICAL { - button_rect.setOriginAndSize(0, 0, mMinWidth, button_rect.getHeight()); + button_rect.setOriginAndSize(0, 0, mMinButtonWidth, button_rect.getHeight()); } } - button_p.fillFrom((mButtonType == BTNTYPE_ICONS_ONLY) - ? p.button_icon // icon only - : p.button_icon_and_text); // icon + text + // use our calculated rect + button_p.rect = button_rect; + LLToolBarButton* buttonp = LLUICtrlFactory::create(button_p); + + mButtons.push_back(buttonp); + mCenterPanel->addChild(buttonp); - mButtons.push_back(LLUICtrlFactory::create(button_p)); mNeedsLayout = true; } - - updateLayout(); } -void LLToolBar::addButton(LLToolBarButton* buttonp) +void LLToolBar::updateLayoutAsNeeded() { - 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; + if (!mNeedsLayout) return; - LLLayoutPanel* panel = LLUICtrlFactory::create(panel_p); - - panel->addChild(buttonp); - mStacks.back()->addChild(panel); -} + LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType); -void LLToolBar::updateLayout() -{ - mCenteringStack->updateLayout(); + // our terminology for orientation-agnostic layout is that + // length refers to a distance in the direction we stack the buttons + // and girth refers to a distance in the direction buttons wrap + S32 total_length = 0; + S32 max_length = (orientation == LLLayoutStack::HORIZONTAL) + ? getRect().getWidth() + : getRect().getHeight(); + S32 max_row_girth = 0; + S32 cur_start = 0; + S32 cur_row = 0; - if (!mNeedsLayout) return; - mNeedsLayout = false; + LLRect panel_rect = mCenterPanel->getLocalRect(); - { // clean up existing rows - BOOST_FOREACH(LLToolBarButton* button, mButtons) - { - if (button->getParent()) + std::vector buttons_in_row; + + BOOST_FOREACH(LLToolBarButton* button, mButtons) + { + S32 button_clamped_width = llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth); + S32 button_length = (orientation == LLLayoutStack::HORIZONTAL) + ? button_clamped_width + : button->getRect().getHeight(); + S32 button_girth = (orientation == LLLayoutStack::HORIZONTAL) + ? button->getRect().getHeight() + : button_clamped_width; + + // handle wrapping + if (total_length + button_length > max_length + && cur_start != 0) // not first button in row + { // go ahead and wrap + if (orientation == LLLayoutStack::VERTICAL) + { + // row girth is clamped to allowable button widths + max_row_girth = llclamp(max_row_girth, mMinButtonWidth, mMaxButtonWidth); + } + // make buttons in current row all same girth + BOOST_FOREACH(LLToolBarButton* button, buttons_in_row) { - button->getParent()->removeChild(button); + if (orientation == LLLayoutStack::HORIZONTAL) + { + button->reshape(llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth), max_row_girth); + } + else // VERTICAL + { + button->reshape(max_row_girth, button->getRect().getHeight()); + } } - } + buttons_in_row.clear(); - BOOST_FOREACH(LLLayoutStack* stack, mStacks) - { - delete stack; + total_length = 0; + cur_start = 0; + cur_row += max_row_girth; + max_row_girth = 0; } - mStacks.clear(); - } - // start with one row of buttons - addRow(); - - S32 total_width = 0, total_height = 0; - S32 max_total_width = 0, max_total_height = 0; - S32 max_width = getRect().getWidth(), max_height = getRect().getHeight(); - BOOST_FOREACH(LLToolBarButton* button, mButtons) - { - S32 button_width = button->getRect().getWidth(); - S32 button_height = button->getRect().getHeight(); - if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL - && total_width + button_height > getRect().getWidth()) + LLRect button_rect; + if (orientation == LLLayoutStack::HORIZONTAL) + { + button_rect.setLeftTopAndSize(cur_start, panel_rect.mTop - cur_row, button_clamped_width, button->getRect().getHeight()); + } + else // VERTICAL { - addRow(); - total_width = 0; + button_rect.setLeftTopAndSize(cur_row, panel_rect.mTop - cur_start, button_clamped_width, button->getRect().getHeight()); } - addButton(button); - - total_width += button_width; - total_height += button_height; - max_total_width = llmax(max_total_width, total_width); - max_total_height = llmax(max_total_height, total_height); - max_width = llmax(button->getRect().getWidth(), max_width); - max_height = llmax(button->getRect().getHeight(), max_height); + button->setShape(button_rect); + + buttons_in_row.push_back(button); + + total_length += button_length; + cur_start = total_length; + max_row_girth = llmax(button_girth, max_row_girth); } - if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) + // final resizing in "girth" direction + S32 total_girth = cur_row + max_row_girth; // increment by size of final row + + // grow and optionally shift toolbar to accomodate buttons + if (orientation == LLLayoutStack::HORIZONTAL) { - BOOST_FOREACH(LLLayoutStack* stack, mStacks) - { - stack->reshape(max_total_width, stack->getParent()->getRect().getHeight()); - stack->updateLayout(); + if (mSideType == SIDE_TOP) + { // shift down to maintain top edge + translate(0, getRect().getHeight() - total_girth); } + + reshape(getRect().getWidth(), total_girth); } - else + else // VERTICAL { - BOOST_FOREACH(LLLayoutStack* stack, mStacks) - { - stack->reshape(stack->getParent()->getRect().getWidth(), max_total_height); - stack->updateLayout(); + if (mSideType == SIDE_RIGHT) + { // shift left to maintain right edge + translate(getRect().getWidth() - total_girth, 0); } - - reshape(max_total_width, getRect().getHeight()); + reshape(total_girth, getRect().getHeight()); } + + // recenter toolbar buttons + mCenteringStack->updateLayout(); + + // don't clear flag until after we've resized ourselves, to avoid laying out every frame + mNeedsLayout = false; } void LLToolBar::draw() { - updateLayout(); + updateLayoutAsNeeded(); { // draw background LLRect bg_rect; @@ -231,22 +259,6 @@ void LLToolBar::draw() LLUICtrl::draw(); } -void LLToolBar::addRow() -{ - LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType); - - LLLayoutStack::Params stack_p; - stack_p.rect = getLocalRect(); - stack_p.name = llformat("button_stack_%d", mStacks.size()); - stack_p.orientation = orientation; - stack_p.follows.flags = (orientation == LLLayoutStack::HORIZONTAL) - ? (FOLLOWS_TOP|FOLLOWS_BOTTOM) // horizontal - : (FOLLOWS_LEFT|FOLLOWS_RIGHT); // vertical - - mStacks.push_back(LLUICtrlFactory::create(stack_p)); - mCenterPanel->addChild(mStacks.back()); -} - void LLToolBar::reshape(S32 width, S32 height, BOOL called_from_parent) { LLUICtrl::reshape(width, height, called_from_parent); diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 3a593e42d9..31729e32b4 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -93,8 +93,8 @@ public: button_icon_and_text; Optional wrap; - Optional min_width, - max_width; + Optional min_button_width, + max_button_width; // get rid of this Multiple buttons; @@ -112,11 +112,9 @@ protected: LLToolBar(const Params&); void initFromParams(const Params&); - void addButton(LLToolBarButton* buttonp); - void updateLayout(); private: - void addRow(); + void updateLayoutAsNeeded(); std::list mButtons; LLToolBarEnums::ButtonType mButtonType; @@ -125,11 +123,10 @@ private: LLLayoutPanel* mCenterPanel; LLToolBarEnums::SideType mSideType; - std::vector mStacks; bool mWrap; bool mNeedsLayout; - S32 mMinWidth, - mMaxWidth; + S32 mMinButtonWidth, + mMaxButtonWidth; LLUIImagePtr mBackgroundImage; }; -- cgit v1.2.3 From 6c209d0fc8c8b171262074e1970c4e9ff299f9f0 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 22 Sep 2011 15:10:30 -0700 Subject: variable rename --- indra/llui/lltoolbar.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index f623d99dc7..8ed828efd3 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -148,7 +148,7 @@ void LLToolBar::updateLayoutAsNeeded() // our terminology for orientation-agnostic layout is that // length refers to a distance in the direction we stack the buttons // and girth refers to a distance in the direction buttons wrap - S32 total_length = 0; + S32 row_running_length = 0; S32 max_length = (orientation == LLLayoutStack::HORIZONTAL) ? getRect().getWidth() : getRect().getHeight(); @@ -171,7 +171,7 @@ void LLToolBar::updateLayoutAsNeeded() : button_clamped_width; // handle wrapping - if (total_length + button_length > max_length + if (row_running_length + button_length > max_length && cur_start != 0) // not first button in row { // go ahead and wrap if (orientation == LLLayoutStack::VERTICAL) @@ -193,7 +193,7 @@ void LLToolBar::updateLayoutAsNeeded() } buttons_in_row.clear(); - total_length = 0; + row_running_length = 0; cur_start = 0; cur_row += max_row_girth; max_row_girth = 0; @@ -212,8 +212,8 @@ void LLToolBar::updateLayoutAsNeeded() buttons_in_row.push_back(button); - total_length += button_length; - cur_start = total_length; + row_running_length += button_length; + cur_start = row_running_length; max_row_girth = llmax(button_girth, max_row_girth); } -- cgit v1.2.3 From 565483ee1f2ea7b8d525c6d89700452216481c5e Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 22 Sep 2011 15:43:08 -0700 Subject: EXP-1205 PROGRESS -- As a User, I want a toybox which will contain all buttons that I can d&d into the toolbars EXP-1233 PROGRESS -- Populate the toybox floater window with all FUI toolbar buttons EXP-1236 FIX -- The toybox floater should remember its position for the user * Basic addCommand function to the LLToolBar. Need proper implementation. * Added map for faster lookup of commands * Toybox now adds commands to its toolbar for basic button setup Reviewed by Richard. --- indra/llui/llcommandmanager.cpp | 32 ++++++++++------- indra/llui/llcommandmanager.h | 16 ++++++--- indra/llui/lltoolbar.cpp | 77 +++++++++++++++++++++++++++++++++-------- indra/llui/lltoolbar.h | 9 +++++ 4 files changed, 103 insertions(+), 31 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index 306b357d6a..6be616b980 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -72,9 +72,15 @@ LLCommandManager::LLCommandManager() LLCommandManager::~LLCommandManager() { + for (CommandVector::iterator cmdIt = mCommands.begin(); cmdIt != mCommands.end(); ++cmdIt) + { + LLCommand * command = *cmdIt; + + delete command; + } } -U32 LLCommandManager::count() const +U32 LLCommandManager::commandCount() const { return mCommands.size(); } @@ -88,20 +94,24 @@ LLCommand * LLCommandManager::getCommand(const std::string& commandName) { LLCommand * command_name_match = NULL; - for (CommandVector::iterator it = mCommands.begin(); it != mCommands.end(); ++it) + CommandIndexMap::const_iterator found = mCommandIndices.find(commandName); + + if (found != mCommandIndices.end()) { - LLCommand * command = *it; - - if (command->name() == commandName) - { - command_name_match = command; - break; - } + command_name_match = mCommands[found->second]; } return command_name_match; } +void LLCommandManager::addCommand(LLCommand * command) +{ + mCommandIndices[command->name()] = mCommands.size(); + mCommands.push_back(command); + + llinfos << "Successfully added command: " << command->name() << llendl; +} + //static bool LLCommandManager::load() { @@ -129,9 +139,7 @@ bool LLCommandManager::load() { LLCommand * command = new LLCommand(commandParams); - mgr.mCommands.push_back(command); - - llinfos << "Successfully loaded command: " << command->name() << llendl; + mgr.addCommand(command); } return true; diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 4f3c9b2ada..24378ecd62 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -24,8 +24,8 @@ * $/LicenseInfo$ */ -#ifndef LL_COMMANDMANAGER_H -#define LL_COMMANDMANAGER_H +#ifndef LL_LLCOMMANDMANAGER_H +#define LL_LLCOMMANDMANAGER_H #include "llinitparam.h" #include "llsingleton.h" @@ -82,16 +82,22 @@ public: LLCommandManager(); ~LLCommandManager(); - U32 count() const; + U32 commandCount() const; LLCommand * getCommand(U32 commandIndex); LLCommand * getCommand(const std::string& commandName); static bool load(); +protected: + void addCommand(LLCommand * command); + private: + typedef std::map CommandIndexMap; typedef std::vector CommandVector; - CommandVector mCommands; + + CommandVector mCommands; + CommandIndexMap mCommandIndices; }; -#endif // LL_COMMANDMANAGER_H +#endif // LL_LLCOMMANDMANAGER_H diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 8ed828efd3..bbd7706a11 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -27,9 +27,12 @@ #include "linden_common.h" -#include "boost/foreach.hpp" +#include #include "lltoolbar.h" +#include "llcommandmanager.h" +#include "lltrans.h" + // uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit // thanks, MSVC! //static LLDefaultChildRegistry::Register r1("toolbar"); @@ -74,6 +77,8 @@ LLToolBar::LLToolBar(const Params& p) mMaxButtonWidth(p.max_button_width), mBackgroundImage(p.background_image) { + mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; + mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; } void LLToolBar::initFromParams(const LLToolBar::Params& p) @@ -112,9 +117,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) { // buttons always follow left and top, for all orientations button_p.follows.flags = FOLLOWS_LEFT|FOLLOWS_TOP; - button_p.fillFrom((mButtonType == BTNTYPE_ICONS_ONLY) - ? p.button_icon // icon only - : p.button_icon_and_text); // icon + text + button_p.fillFrom(mButtonParams[mButtonType]); LLRect button_rect(button_p.rect); { // remove any offset from button @@ -139,12 +142,58 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) } } +bool LLToolBar::addCommand(LLCommand * command) +{ + // + // Init basic toolbar button params + // + + LLToolBarButton::Params button_p; + button_p.fillFrom(mButtonParams[mButtonType]); + + button_p.name = command->name(); + button_p.label = LLTrans::getString(command->labelRef()); + button_p.tool_tip = LLTrans::getString(command->tooltipRef()); + + // + // Set up the button rectangle + // + + S32 btn_width = mMinButtonWidth; + S32 btn_height = mButtonParams[mButtonType].rect.height; + + if ((mSideType == LLToolBarEnums::SIDE_BOTTOM) || (mSideType == LLToolBarEnums::SIDE_TOP)) + { + btn_height = getRect().getHeight(); + } + + LLRect button_rect; + button_rect.setOriginAndSize(0, 0, btn_width, btn_height); + + button_p.rect = button_rect; + + // + // Add it to the list of buttons + // + + LLToolBarButton * toolbar_button = LLUICtrlFactory::create(button_p); + + toolbar_button->reshape(llclamp(toolbar_button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth), toolbar_button->getRect().getHeight()); + + mButtons.push_back(toolbar_button); + mCenterPanel->addChild(toolbar_button); + + mNeedsLayout = true; + + return true; +} + void LLToolBar::updateLayoutAsNeeded() { if (!mNeedsLayout) return; LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType); - + // our terminology for orientation-agnostic layout is that // length refers to a distance in the direction we stack the buttons // and girth refers to a distance in the direction buttons wrap @@ -160,8 +209,8 @@ void LLToolBar::updateLayoutAsNeeded() std::vector buttons_in_row; - BOOST_FOREACH(LLToolBarButton* button, mButtons) - { + BOOST_FOREACH(LLToolBarButton* button, mButtons) + { S32 button_clamped_width = llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth); S32 button_length = (orientation == LLLayoutStack::HORIZONTAL) ? button_clamped_width @@ -185,23 +234,23 @@ void LLToolBar::updateLayoutAsNeeded() if (orientation == LLLayoutStack::HORIZONTAL) { button->reshape(llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth), max_row_girth); - } + } else // VERTICAL - { + { button->reshape(max_row_girth, button->getRect().getHeight()); } - } + } buttons_in_row.clear(); row_running_length = 0; cur_start = 0; cur_row += max_row_girth; max_row_girth = 0; - } + } LLRect button_rect; if (orientation == LLLayoutStack::HORIZONTAL) - { + { button_rect.setLeftTopAndSize(cur_start, panel_rect.mTop - cur_row, button_clamped_width, button->getRect().getHeight()); } else // VERTICAL @@ -209,7 +258,7 @@ void LLToolBar::updateLayoutAsNeeded() button_rect.setLeftTopAndSize(cur_row, panel_rect.mTop - cur_start, button_clamped_width, button->getRect().getHeight()); } button->setShape(button_rect); - + buttons_in_row.push_back(button); row_running_length += button_length; @@ -237,7 +286,7 @@ void LLToolBar::updateLayoutAsNeeded() translate(getRect().getWidth() - total_girth, 0); } reshape(total_girth, getRect().getHeight()); - } + } // recenter toolbar buttons mCenteringStack->updateLayout(); diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 31729e32b4..85cd6d5170 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -33,6 +33,9 @@ #include "llbutton.h" +class LLCommand; + + class LLToolBarButton : public LLButton { public: @@ -50,6 +53,8 @@ namespace LLToolBarEnums { BTNTYPE_ICONS_ONLY = 0, BTNTYPE_ICONS_WITH_TEXT, + + BTNTYPE_COUNT }; enum SideType @@ -107,6 +112,8 @@ public: void draw(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); + bool addCommand(LLCommand * command); + protected: friend class LLUICtrlFactory; LLToolBar(const Params&); @@ -129,6 +136,8 @@ private: mMaxButtonWidth; LLUIImagePtr mBackgroundImage; + + LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT]; }; -- cgit v1.2.3 From 1bcf6882c5faa94385f045e1c591da96408bb032 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 23 Sep 2011 15:09:37 -0700 Subject: EXP-1207 : More on lltoolbarview. Still not rendering --- indra/llui/lltoolbar.cpp | 9 +++++---- indra/llui/lltoolbarview.cpp | 36 ++++++++++++++++++++++++------------ indra/llui/lltoolbarview.h | 8 ++++++-- indra/llui/llui.cpp | 1 - indra/llui/lluictrlfactory.h | 4 ++-- 5 files changed, 37 insertions(+), 21 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 1e8be93f17..167dbfcc47 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -30,9 +30,7 @@ #include "boost/foreach.hpp" #include "lltoolbar.h" -// uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit -// thanks, MSVC! -//static LLDefaultChildRegistry::Register r1("toolbar"); +static LLDefaultChildRegistry::Register r1("toolbar"); namespace LLToolBarEnums { @@ -62,7 +60,7 @@ LLToolBar::Params::Params() background_image("background_image") {} -LLToolBar::LLToolBar(const Params& p) +LLToolBar::LLToolBar(const LLToolBar::Params& p) : LLUICtrl(p), mButtonType(p.button_display_mode), mSideType(p.side), @@ -78,6 +76,9 @@ LLToolBar::LLToolBar(const Params& p) void LLToolBar::initFromParams(const LLToolBar::Params& p) { + // Initialize the base object + LLUICtrl::initFromParams(p); + LLLayoutStack::ELayoutOrientation orientation = getOrientation(p.side); LLLayoutStack::Params centering_stack_p; diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 0e54c91cea..590cd4ffca 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -28,6 +28,7 @@ #include "linden_common.h" #include "lltoolbarview.h" + #include "lltoolbar.h" #include "llbutton.h" @@ -35,33 +36,39 @@ LLToolBarView* gToolBarView = NULL; static LLDefaultChildRegistry::Register r("toolbar_view"); -LLToolBarView::LLToolBarView(const Params& p) +LLToolBarView::LLToolBarView(const LLToolBarView::Params& p) : LLUICtrl(p) { } -BOOL LLToolBarView::postBuild() +void LLToolBarView::initFromParams(const LLToolBarView::Params& p) +{ + // Initialize the base object + LLUICtrl::initFromParams(p); +} + +LLToolBarView::~LLToolBarView() { - LLRect ctrl_rect = getRect(); - LLButton* btn = getChild("test"); - LLRect btn_rect = btn->getRect(); - llinfos << "Merov debug : control rect = " << ctrl_rect.mLeft << ", " << ctrl_rect.mTop << ", " << ctrl_rect.mRight << ", " << ctrl_rect.mBottom << llendl; - llinfos << "Merov debug : test rect = " << btn_rect.mLeft << ", " << btn_rect.mTop << ", " << btn_rect.mRight << ", " << btn_rect.mBottom << llendl; - return TRUE; } void LLToolBarView::draw() { static bool debug_print = true; + static S32 old_width = 0; + static S32 old_height = 0; LLToolBar* toolbar_bottom = getChild("toolbar_bottom"); LLToolBar* toolbar_left = getChild("toolbar_left"); LLToolBar* toolbar_right = getChild("toolbar_right"); + LLPanel* sizer_left = getChild("sizer_left"); LLRect bottom_rect = toolbar_bottom->getRect(); LLRect left_rect = toolbar_left->getRect(); LLRect right_rect = toolbar_right->getRect(); + LLRect sizer_left_rect = sizer_left->getRect(); + if ((old_width != getRect().getWidth()) || (old_height != getRect().getHeight())) + debug_print = true; if (debug_print) { LLRect ctrl_rect = getRect(); @@ -69,13 +76,18 @@ void LLToolBarView::draw() llinfos << "Merov debug : draw bottom rect = " << bottom_rect.mLeft << ", " << bottom_rect.mTop << ", " << bottom_rect.mRight << ", " << bottom_rect.mBottom << llendl; llinfos << "Merov debug : draw left rect = " << left_rect.mLeft << ", " << left_rect.mTop << ", " << left_rect.mRight << ", " << left_rect.mBottom << llendl; llinfos << "Merov debug : draw right rect = " << right_rect.mLeft << ", " << right_rect.mTop << ", " << right_rect.mRight << ", " << right_rect.mBottom << llendl; + llinfos << "Merov debug : draw s left rect = " << sizer_left_rect.mLeft << ", " << sizer_left_rect.mTop << ", " << sizer_left_rect.mRight << ", " << sizer_left_rect.mBottom << llendl; + old_width = ctrl_rect.getWidth(); + old_height = ctrl_rect.getHeight(); debug_print = false; } // Debug draw - gl_rect_2d(getLocalRect(), LLColor4::blue, TRUE); - gl_rect_2d(bottom_rect, LLColor4::red, TRUE); - gl_rect_2d(left_rect, LLColor4::green, TRUE); - gl_rect_2d(right_rect, LLColor4::yellow, TRUE); + LLColor4 back_color = LLColor4::blue; + back_color[VALPHA] = 0.5f; +// gl_rect_2d(getLocalRect(), back_color, TRUE); +// gl_rect_2d(bottom_rect, LLColor4::red, TRUE); +// gl_rect_2d(left_rect, LLColor4::green, TRUE); +// gl_rect_2d(right_rect, LLColor4::yellow, TRUE); LLUICtrl::draw(); } diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 0bd0070ab7..73278e226b 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -30,19 +30,23 @@ #include "lluictrl.h" +class LLUICtrlFactory; + // Parent of all LLToolBar class LLToolBarView : public LLUICtrl { public: struct Params : public LLInitParam::Block {}; - void draw(); - /*virtual*/ BOOL postBuild(); + virtual ~LLToolBarView(); + virtual void draw(); protected: friend class LLUICtrlFactory; LLToolBarView(const Params&); + void initFromParams(const Params&); + private: LLHandle mSnapView; }; diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 1bc575438c..a4303780fd 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -93,7 +93,6 @@ std::list gUntranslated; static LLDefaultChildRegistry::Register register_filter_editor("filter_editor"); static LLDefaultChildRegistry::Register register_flyout_button("flyout_button"); static LLDefaultChildRegistry::Register register_search_editor("search_editor"); -static LLDefaultChildRegistry::Register r1("toolbar"); // register other widgets which otherwise may not be linked in static LLDefaultChildRegistry::Register register_loading_indicator("loading_indicator"); diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index d345ad4cd0..71c38237c1 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -172,7 +172,7 @@ public: static T* createFromFile(const std::string &filename, LLView *parent, const widget_registry_t& registry, LLXMLNodePtr output_node = NULL) { T* widget = NULL; - + std::string skinned_filename = findSkinnedFilename(filename); instance().pushFileName(filename); { @@ -201,10 +201,10 @@ public: // not of right type, so delete it if (!widget) { + llwarns << "Widget in " << filename << " was of type " << typeid(view).name() << " instead of expected type " << typeid(T).name() << llendl; delete view; view = NULL; } - } } fail: -- cgit v1.2.3