From 65fe2367a8241f0eb5ff4d27401f661b257e9736 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 19 Sep 2011 15:44:03 -0700 Subject: EXP-1228 WIP Create toolbar widget class that displays list of buttons horizontally or vertically created toolbar class and widget --- indra/llui/CMakeLists.txt | 2 ++ indra/llui/llui.cpp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index b3b2f4ae56..cf3f9b1a7b 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -99,6 +99,7 @@ set(llui_SOURCE_FILES lltimectrl.cpp lltransutil.cpp lltoggleablemenu.cpp + lltoolbar.cpp lltooltip.cpp llui.cpp lluicolortable.cpp @@ -200,6 +201,7 @@ set(llui_HEADER_FILES lltextvalidate.h lltimectrl.h lltoggleablemenu.h + lltoolbar.h lltooltip.h lltransutil.h lluicolortable.h diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 58ba9e05f5..593354ee9b 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -57,6 +57,7 @@ #include "llfiltereditor.h" #include "llflyoutbutton.h" #include "llsearcheditor.h" +#include "lltoolbar.h" // for XUIParse #include "llquaternion.h" @@ -91,6 +92,7 @@ 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"); -- cgit v1.2.3 From fef08c439ae7c8a310af444c10ab500bc8b14b79 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 19 Sep 2011 16:59:50 -0700 Subject: fix build --- indra/llui/lltoolbar.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ indra/llui/lltoolbar.h | 60 +++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 indra/llui/lltoolbar.cpp create mode 100644 indra/llui/lltoolbar.h (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp new file mode 100644 index 0000000000..0356fd5c8a --- /dev/null +++ b/indra/llui/lltoolbar.cpp @@ -0,0 +1,77 @@ +/** + * @file lltoolbar.cpp + * @author Richard Nelson + * @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 "boost/foreach.hpp" +#include "lltoolbar.h" + +//static LLDefaultChildRegistry::Register r1("toolbar"); + +LLToolBar::Params::Params() +: orientation("orientation"), + buttons("button") +{} + +LLToolBar::LLToolBar(const Params& p) +: LLUICtrl(p), + mOrientation(p.orientation), + mStack(NULL) +{ + +} + +void LLToolBar::draw() +{ + gl_rect_2d(getLocalRect(), LLColor4::blue, TRUE); +} + +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; + + mStack = LLUICtrlFactory::create(stack_p); + addChild(mStack); + + BOOST_FOREACH (LLButton::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); + } +} diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h new file mode 100644 index 0000000000..768f42309d --- /dev/null +++ b/indra/llui/lltoolbar.h @@ -0,0 +1,60 @@ +/** + * @file lltoolbar.h + * @author Richard Nelson + * @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_LLTOOLBAR_H +#define LL_LLTOOLBAR_H + +#include "lluictrl.h" +#include "lllayoutstack.h" +#include "llbutton.h" + +class LLToolBar +: public LLUICtrl +{ +public: + struct Params : public LLInitParam::Block + { + Mandatory orientation; + Multiple buttons; + + Params(); + }; + + void draw(); + +protected: + friend LLUICtrlFactory; + LLToolBar(const Params&); + void initFromParams(const Params&); + +private: + LLLayoutStack::ELayoutOrientation mOrientation; + LLLayoutStack* mStack; +}; + + +#endif // LL_LLTOOLBAR_H -- cgit v1.2.3 From 3df9545017a4835e162801d3e8a13d68c8bc44ad Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 19 Sep 2011 17:34:23 -0700 Subject: Fix gcc compiling error --- indra/llui/lltoolbar.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 768f42309d..dd454e3f0b 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -47,7 +47,7 @@ public: void draw(); protected: - friend LLUICtrlFactory; + friend class LLUICtrlFactory; LLToolBar(const Params&); void initFromParams(const Params&); -- 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 c155483fc206768e21d180fac9ccdd85db8f582e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 22 Sep 2011 17:34:42 -0700 Subject: EXP-1239 WIP make toolbars wrap when there is not enough room toolbar button height configured by button_height attribute vertical toolbar buttons now share common width wrap attribute now controls wrapping --- indra/llui/lltoolbar.cpp | 60 +++++++++++++++++++++++++++++------------------- indra/llui/lltoolbar.h | 7 ++++-- 2 files changed, 42 insertions(+), 25 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 8ed828efd3..e10a254197 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -59,6 +59,7 @@ LLToolBar::Params::Params() wrap("wrap", true), min_button_width("min_button_width", 0), max_button_width("max_button_width", S32_MAX), + button_height("button_height"), background_image("background_image") {} @@ -72,6 +73,7 @@ LLToolBar::LLToolBar(const Params& p) mCenteringStack(NULL), mMinButtonWidth(p.min_button_width), mMaxButtonWidth(p.max_button_width), + mButtonHeight(p.button_height), mBackgroundImage(p.background_image) { } @@ -120,11 +122,11 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) { // remove any offset from button if (orientation == LLLayoutStack::HORIZONTAL) { - button_rect.setOriginAndSize(0, 0, mMinButtonWidth, button_rect.getHeight()); + button_rect.setOriginAndSize(0, 0, mMinButtonWidth, mButtonHeight); } else // VERTICAL { - button_rect.setOriginAndSize(0, 0, mMinButtonWidth, button_rect.getHeight()); + button_rect.setOriginAndSize(0, 0, mMinButtonWidth, mButtonHeight); } } @@ -139,19 +141,38 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) } } +void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row, S32 max_row_girth) +{ + // make buttons in current row all same girth + BOOST_FOREACH(LLToolBarButton* button, buttons_in_row) + { + if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) + { + button->reshape(llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth), max_row_girth); + } + else // VERTICAL + { + button->reshape(max_row_girth, button->getRect().getHeight()); + } + } +} + void LLToolBar::updateLayoutAsNeeded() { if (!mNeedsLayout) return; LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType); - // our terminology for orientation-agnostic layout is that + // our terminology for orientation-agnostic layout is such 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 row_running_length = 0; S32 max_length = (orientation == LLLayoutStack::HORIZONTAL) ? getRect().getWidth() : getRect().getHeight(); + S32 max_total_girth = (orientation == LLLayoutStack::HORIZONTAL) + ? getRect().getHeight() + : getRect().getWidth(); S32 max_row_girth = 0; S32 cur_start = 0; S32 cur_row = 0; @@ -170,27 +191,18 @@ void LLToolBar::updateLayoutAsNeeded() ? button->getRect().getHeight() : button_clamped_width; - // handle wrapping - if (row_running_length + button_length > max_length - && cur_start != 0) // not first button in row - { // go ahead and wrap + // wrap if needed + if (mWrap + && row_running_length + button_length > max_length // out of room... + && cur_start != 0) // ...and not first button in row + { if (orientation == LLLayoutStack::VERTICAL) - { - // row girth is clamped to allowable button widths + { // row girth (width in this case) 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) - { - 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()); - } - } + resizeButtonsInRow(buttons_in_row, max_row_girth); buttons_in_row.clear(); row_running_length = 0; @@ -218,9 +230,11 @@ void LLToolBar::updateLayoutAsNeeded() } // final resizing in "girth" direction - S32 total_girth = cur_row + max_row_girth; // increment by size of final row + S32 total_girth = cur_row // current row position... + + max_row_girth; // ...incremented by size of final row + resizeButtonsInRow(buttons_in_row, max_row_girth); - // grow and optionally shift toolbar to accomodate buttons + // grow and optionally shift toolbar to accommodate buttons if (orientation == LLLayoutStack::HORIZONTAL) { if (mSideType == SIDE_TOP) @@ -239,7 +253,7 @@ void LLToolBar::updateLayoutAsNeeded() reshape(total_girth, getRect().getHeight()); } - // recenter toolbar buttons + // re-center toolbar buttons mCenteringStack->updateLayout(); // don't clear flag until after we've resized ourselves, to avoid laying out every frame diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 31729e32b4..83e482a946 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -94,7 +94,8 @@ public: Optional wrap; Optional min_button_width, - max_button_width; + max_button_width, + button_height; // get rid of this Multiple buttons; @@ -115,6 +116,7 @@ protected: private: void updateLayoutAsNeeded(); + void resizeButtonsInRow(std::vector& buttons_in_row, S32 max_row_girth); std::list mButtons; LLToolBarEnums::ButtonType mButtonType; @@ -126,7 +128,8 @@ private: bool mWrap; bool mNeedsLayout; S32 mMinButtonWidth, - mMaxButtonWidth; + mMaxButtonWidth, + mButtonHeight; LLUIImagePtr mBackgroundImage; }; -- 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 From b6d7f99f065c87f7409a1e5e1ba1b59f3f4a3efb Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 23 Sep 2011 17:01:15 -0700 Subject: EXP-1239 FIX make toolbars wrap when there is not enough room spacing between buttons now configurable and correct background art now wraps buttons correctly created customizable panel for button background --- indra/llui/lltoolbar.cpp | 235 +++++++++++++++++++++++++---------------------- indra/llui/lltoolbar.h | 20 ++-- 2 files changed, 139 insertions(+), 116 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index b2cf7e6554..3311ed4a1b 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -53,17 +53,40 @@ namespace LLToolBarEnums } using namespace LLToolBarEnums; + +namespace LLInitParam +{ + void TypeValues::declareValues() + { + declare("icons_only", BTNTYPE_ICONS_ONLY); + declare("icons_with_text", BTNTYPE_ICONS_WITH_TEXT); + } + + void TypeValues::declareValues() + { + declare("bottom", SIDE_BOTTOM); + declare("left", SIDE_LEFT); + declare("right", SIDE_RIGHT); + declare("top", SIDE_TOP); + } +} + LLToolBar::Params::Params() : button_display_mode("button_display_mode"), buttons("button"), - side("side"), + side("side", SIDE_TOP), button_icon("button_icon"), button_icon_and_text("button_icon_and_text"), wrap("wrap", true), min_button_width("min_button_width", 0), max_button_width("max_button_width", S32_MAX), button_height("button_height"), - background_image("background_image") + pad_left("pad_left"), + pad_top("pad_top"), + pad_right("pad_right"), + pad_bottom("pad_bottom"), + pad_between("pad_between"), + button_panel("button_panel") {} LLToolBar::LLToolBar(const Params& p) @@ -72,12 +95,16 @@ LLToolBar::LLToolBar(const Params& p) mSideType(p.side), mWrap(p.wrap), mNeedsLayout(false), - mCenterPanel(NULL), + mButtonPanel(NULL), mCenteringStack(NULL), - mMinButtonWidth(p.min_button_width), - mMaxButtonWidth(p.max_button_width), + mMinButtonWidth(llmin(p.min_button_width(), p.max_button_width())), + mMaxButtonWidth(llmax(p.max_button_width(), p.min_button_width())), mButtonHeight(p.button_height), - mBackgroundImage(p.background_image) + mPadLeft(p.pad_left), + mPadRight(p.pad_right), + mPadTop(p.pad_top), + mPadBottom(p.pad_bottom), + mPadBetween(p.pad_between) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; @@ -110,102 +137,81 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) 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); + LLLayoutPanel* center_panel = LLUICtrlFactory::create(center_panel_p); + mCenteringStack->addChild(center_panel); + + LLPanel::Params button_panel_p(p.button_panel); + button_panel_p.rect = center_panel->getLocalRect(); + switch(p.side()) + { + case SIDE_LEFT: + button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_LEFT; + break; + case SIDE_RIGHT: + button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_RIGHT; + break; + case SIDE_TOP: + button_panel_p.follows.flags = FOLLOWS_TOP|FOLLOWS_LEFT; + break; + case SIDE_BOTTOM: + button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_LEFT; + break; + } + mButtonPanel = LLUICtrlFactory::create(button_panel_p); + center_panel->addChild(mButtonPanel); mCenteringStack->addChild(LLUICtrlFactory::create(border_panel_p)); 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(mButtonParams[mButtonType]); - - LLRect button_rect(button_p.rect); - { // remove any offset from button - if (orientation == LLLayoutStack::HORIZONTAL) - { - button_rect.setOriginAndSize(0, 0, mMinButtonWidth, mButtonHeight); - } - else // VERTICAL - { - button_rect.setOriginAndSize(0, 0, mMinButtonWidth, mButtonHeight); - } - } - - // use our calculated rect - button_p.rect = button_rect; LLToolBarButton* buttonp = LLUICtrlFactory::create(button_p); mButtons.push_back(buttonp); - mCenterPanel->addChild(buttonp); + mButtonPanel->addChild(buttonp); mNeedsLayout = true; } } -void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row, S32 max_row_girth) -{ - // make buttons in current row all same girth - BOOST_FOREACH(LLToolBarButton* button, buttons_in_row) - { - if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) - { - button->reshape(llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth), max_row_girth); - } - else // VERTICAL - { - button->reshape(max_row_girth, button->getRect().getHeight()); - } - } -} - bool LLToolBar::addCommand(LLCommand * command) { // // Init basic toolbar button params // - - LLToolBarButton::Params button_p; - button_p.fillFrom(mButtonParams[mButtonType]); - + LLToolBarButton::Params button_p(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); + mButtonPanel->addChild(toolbar_button); mNeedsLayout = true; return true; } +void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row, S32 max_row_girth) +{ + // make buttons in current row all same girth + BOOST_FOREACH(LLToolBarButton* button, buttons_in_row) + { + if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) + { + button->reshape(llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth), max_row_girth); + } + else // VERTICAL + { + button->reshape(max_row_girth, button->getRect().getHeight()); + } + } +} + void LLToolBar::updateLayoutAsNeeded() { if (!mNeedsLayout) return; @@ -215,23 +221,51 @@ void LLToolBar::updateLayoutAsNeeded() // our terminology for orientation-agnostic layout is such 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 row_running_length = 0; - S32 max_length = (orientation == LLLayoutStack::HORIZONTAL) - ? getRect().getWidth() - : getRect().getHeight(); - S32 max_total_girth = (orientation == LLLayoutStack::HORIZONTAL) - ? getRect().getHeight() - : getRect().getWidth(); S32 max_row_girth = 0; - S32 cur_start = 0; - S32 cur_row = 0; + S32 max_row_length = 0; - LLRect panel_rect = mCenterPanel->getLocalRect(); + S32 max_length; + S32 max_total_girth; + S32 cur_start; + S32 cur_row ; + S32 row_pad_start; + S32 row_pad_end; + S32 girth_pad_end; + S32 row_running_length; + + if (orientation == LLLayoutStack::HORIZONTAL) + { + max_length = getRect().getWidth() - mPadLeft - mPadRight; + max_total_girth = getRect().getHeight() - mPadTop - mPadBottom; + row_pad_start = mPadLeft; + row_running_length = row_pad_start; + row_pad_end = mPadRight; + cur_row = mPadTop; + girth_pad_end = mPadBottom; + } + else // VERTICAL + { + max_length = getRect().getHeight() - mPadTop - mPadBottom; + max_total_girth = getRect().getWidth() - mPadLeft - mPadRight; + row_pad_start = mPadTop; + row_running_length = row_pad_start; + row_pad_end = mPadBottom; + cur_row = mPadLeft; + girth_pad_end = mPadRight; + } + + cur_start = row_pad_start; + + + LLRect panel_rect = mButtonPanel->getLocalRect(); std::vector buttons_in_row; BOOST_FOREACH(LLToolBarButton* button, mButtons) { + button->reshape(mMinButtonWidth, mButtonHeight); + button->autoResize(); + S32 button_clamped_width = llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth); S32 button_length = (orientation == LLLayoutStack::HORIZONTAL) ? button_clamped_width @@ -254,9 +288,10 @@ void LLToolBar::updateLayoutAsNeeded() resizeButtonsInRow(buttons_in_row, max_row_girth); buttons_in_row.clear(); - row_running_length = 0; - cur_start = 0; - cur_row += max_row_girth; + max_row_length = llmax(max_row_length, row_running_length); + row_running_length = row_pad_start; + cur_start = row_pad_start; + cur_row += max_row_girth + mPadBetween; max_row_girth = 0; } @@ -273,14 +308,17 @@ void LLToolBar::updateLayoutAsNeeded() buttons_in_row.push_back(button); - row_running_length += button_length; + row_running_length += button_length + mPadBetween; cur_start = row_running_length; max_row_girth = llmax(button_girth, max_row_girth); } // final resizing in "girth" direction S32 total_girth = cur_row // current row position... - + max_row_girth; // ...incremented by size of final row + + max_row_girth // ...incremented by size of final row... + + girth_pad_end; // ...plus padding reserved on end + max_row_length = llmax(max_row_length, row_running_length - mPadBetween + row_pad_end); + resizeButtonsInRow(buttons_in_row, max_row_girth); // grow and optionally shift toolbar to accommodate buttons @@ -288,18 +326,18 @@ void LLToolBar::updateLayoutAsNeeded() { if (mSideType == SIDE_TOP) { // shift down to maintain top edge - translate(0, getRect().getHeight() - total_girth); + mButtonPanel->translate(0, mButtonPanel->getRect().getHeight() - total_girth); } - reshape(getRect().getWidth(), total_girth); + mButtonPanel->reshape(max_row_length, total_girth); } else // VERTICAL { if (mSideType == SIDE_RIGHT) { // shift left to maintain right edge - translate(getRect().getWidth() - total_girth, 0); + mButtonPanel->translate(mButtonPanel->getRect().getWidth() - total_girth, 0); } - reshape(total_girth, getRect().getHeight()); + mButtonPanel->reshape(total_girth, max_row_length); } // re-center toolbar buttons @@ -313,12 +351,6 @@ void LLToolBar::updateLayoutAsNeeded() void LLToolBar::draw() { updateLayoutAsNeeded(); - - { // draw background - LLRect bg_rect; - localRectToOtherView(mCenterPanel->getRect(),&bg_rect, this); - mBackgroundImage->draw(bg_rect); - } LLUICtrl::draw(); } @@ -328,20 +360,3 @@ void LLToolBar::reshape(S32 width, S32 height, BOOL called_from_parent) mNeedsLayout = true; } -namespace LLInitParam -{ - void TypeValues::declareValues() - { - declare("icons_only", BTNTYPE_ICONS_ONLY); - declare("icons_with_text", BTNTYPE_ICONS_WITH_TEXT); - } - - void TypeValues::declareValues() - { - 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 9b08b26ce4..92c289cd3f 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -59,7 +59,6 @@ namespace LLToolBarEnums enum SideType { - SIDE_NONE = 0, SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT, @@ -101,10 +100,16 @@ public: Optional min_button_width, max_button_width, button_height; + + Optional pad_left, + pad_top, + pad_right, + pad_bottom, + pad_between; // get rid of this Multiple buttons; - Optional background_image; + Optional button_panel; Params(); }; @@ -129,16 +134,19 @@ private: LLToolBarEnums::ButtonType mButtonType; LLLayoutStack* mCenteringStack; LLLayoutStack* mWrapStack; - LLLayoutPanel* mCenterPanel; + LLPanel* mButtonPanel; LLToolBarEnums::SideType mSideType; bool mWrap; bool mNeedsLayout; S32 mMinButtonWidth, mMaxButtonWidth, - mButtonHeight; - - LLUIImagePtr mBackgroundImage; + mButtonHeight, + mPadLeft, + mPadRight, + mPadTop, + mPadBottom, + mPadBetween; LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT]; }; -- cgit v1.2.3 From c27d6ee5aa8428cf82486264779f266b9a2fb00a Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 23 Sep 2011 17:19:38 -0700 Subject: EXP-1239 FIX make toolbars wrap when there is not enough room fixed overeager wrapping --- indra/llui/lltoolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 3311ed4a1b..e5ffe391a6 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -277,7 +277,7 @@ void LLToolBar::updateLayoutAsNeeded() // wrap if needed if (mWrap && row_running_length + button_length > max_length // out of room... - && cur_start != 0) // ...and not first button in row + && cur_start != row_pad_start) // ...and not first button in row { if (orientation == LLLayoutStack::VERTICAL) { // row girth (width in this case) is clamped to allowable button widths -- cgit v1.2.3 From 105b15436d37149f6df71866125871448ee4fbcb Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 23 Sep 2011 19:24:55 -0700 Subject: EXP-1027 : Fix the children creation code in LLToolBarView. Only a left panel is displayed now. --- indra/llui/lltoolbar.cpp | 2 +- indra/llui/lltoolbarview.cpp | 8 ++++---- indra/llui/lltoolbarview.h | 3 +++ indra/llui/llui.cpp | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index e052c1c876..ac07e6dd0b 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -33,7 +33,7 @@ #include "llcommandmanager.h" #include "lltrans.h" -static LLDefaultChildRegistry::Register r1("toolbar"); +//static LLDefaultChildRegistry::Register r1("toolbar"); namespace LLToolBarEnums { diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 590cd4ffca..c99b573b35 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -84,10 +84,10 @@ void LLToolBarView::draw() // Debug draw 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); + //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 73278e226b..0e6545015d 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -41,6 +41,9 @@ public: virtual ~LLToolBarView(); virtual void draw(); + // valid children for LLToolBarView are stored in this registry + typedef LLDefaultChildRegistry child_registry_t; + protected: friend class LLUICtrlFactory; LLToolBarView(const Params&); diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index a4303780fd..4f129ccfba 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -96,6 +96,7 @@ static LLDefaultChildRegistry::Register register_search_editor(" // register other widgets which otherwise may not be linked in static LLDefaultChildRegistry::Register register_loading_indicator("loading_indicator"); +static LLDefaultChildRegistry::Register register_toolbar("toolbar"); // // Functions -- cgit v1.2.3 From 6aa7ddc238b1a8f8a4dd184dd2758f93f6a55bec Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 23 Sep 2011 19:56:07 -0700 Subject: fix for widget registration and crash on login --- indra/llui/lldockcontrol.cpp | 1 + indra/llui/lltoolbar.cpp | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lldockcontrol.cpp b/indra/llui/lldockcontrol.cpp index b1c27126d9..7b9084671d 100644 --- a/indra/llui/lldockcontrol.cpp +++ b/indra/llui/lldockcontrol.cpp @@ -97,6 +97,7 @@ void LLDockControl::getAllowedRect(LLRect& rect) void LLDockControl::repositionDockable() { + if (!mDockWidget) return; LLRect dockRect = mDockWidget->calcScreenRect(); LLRect rootRect; mGetAllowedRectCallback(rootRect); diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 31a18dc707..96f892d974 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -33,9 +33,7 @@ #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"); +static LLDefaultChildRegistry::Register r1("toolbar"); namespace LLToolBarEnums { @@ -264,8 +262,8 @@ void LLToolBar::updateLayoutAsNeeded() std::vector buttons_in_row; - BOOST_FOREACH(LLToolBarButton* button, mButtons) - { + BOOST_FOREACH(LLToolBarButton* button, mButtons) + { button->reshape(mMinButtonWidth, mButtonHeight); button->autoResize(); @@ -296,11 +294,11 @@ void LLToolBar::updateLayoutAsNeeded() cur_start = row_pad_start; cur_row += max_row_girth + mPadBetween; 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 @@ -341,7 +339,7 @@ void LLToolBar::updateLayoutAsNeeded() mButtonPanel->translate(mButtonPanel->getRect().getWidth() - total_girth, 0); } mButtonPanel->reshape(total_girth, max_row_length); - } + } // re-center toolbar buttons mCenteringStack->updateLayout(); -- cgit v1.2.3 From c5d930b280c71dfd6ba2f63960c91895083ecc19 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 23 Sep 2011 20:06:35 -0700 Subject: made LLView a possible parent for all default widgets --- indra/llui/llpanel.h | 3 --- indra/llui/llview.h | 6 ++---- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 790025cb2d..ab1c87caff 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -96,9 +96,6 @@ public: Params(); }; - // valid children for LLPanel are stored in this registry - typedef LLDefaultChildRegistry child_registry_t; - protected: friend class LLUICtrlFactory; // RN: for some reason you can't just use LLUICtrlFactory::getDefaultParams as a default argument in VC8 diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 594a5eec6b..43986a3a84 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -95,9 +95,6 @@ private: static std::vector sDrawContextStack; }; -class LLViewWidgetRegistry : public LLChildRegistry -{}; - class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElement { public: @@ -150,7 +147,8 @@ public: Params(); }; - typedef LLViewWidgetRegistry child_registry_t; + // most widgets are valid children of LLView + typedef LLDefaultChildRegistry child_registry_t; void initFromParams(const LLView::Params&); -- cgit v1.2.3 From 9da5a8d01085f13c0586bba4c818ed540335ae2e Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 26 Sep 2011 14:34:42 -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-1235 FIX -- Make the toybox available through the context menus associated with the other toolbars EXP-1248 FIX -- Implement context menu on toolbars * New commands are listed * Toolbars can now be made read-only (as in the toybox) or editable (as in the others) * Toolbars that are not read-only have a context menu that allows button type editing. Reviewed by Richard. --- indra/llui/lltoolbar.cpp | 113 +++++++++++++++++++++++++++++++++++++++++++---- indra/llui/lltoolbar.h | 18 ++++++-- 2 files changed, 120 insertions(+), 11 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 31a18dc707..a9513b759a 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -31,6 +31,7 @@ #include "lltoolbar.h" #include "llcommandmanager.h" +#include "llmenugl.h" #include "lltrans.h" // uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit @@ -51,6 +52,7 @@ namespace LLToolBarEnums return orientation; } } + using namespace LLToolBarEnums; @@ -58,8 +60,8 @@ namespace LLInitParam { void TypeValues::declareValues() { - declare("icons_only", BTNTYPE_ICONS_ONLY); declare("icons_with_text", BTNTYPE_ICONS_WITH_TEXT); + declare("icons_only", BTNTYPE_ICONS_ONLY); } void TypeValues::declareValues() @@ -77,6 +79,7 @@ LLToolBar::Params::Params() side("side", SIDE_TOP), button_icon("button_icon"), button_icon_and_text("button_icon_and_text"), + read_only("read_only", false), wrap("wrap", true), min_button_width("min_button_width", 0), max_button_width("max_button_width", S32_MAX), @@ -91,6 +94,7 @@ LLToolBar::Params::Params() LLToolBar::LLToolBar(const LLToolBar::Params& p) : LLUICtrl(p), + mReadOnly(p.read_only), mButtonType(p.button_display_mode), mSideType(p.side), mWrap(p.wrap), @@ -104,10 +108,47 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) mPadRight(p.pad_right), mPadTop(p.pad_top), mPadBottom(p.pad_bottom), - mPadBetween(p.pad_between) + mPadBetween(p.pad_between), + mPopupMenuHandle() { - mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; + mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; +} + +LLToolBar::~LLToolBar() +{ + LLView::deleteViewByHandle(mPopupMenuHandle); +} + +BOOL LLToolBar::postBuild() +{ + if (!mReadOnly) + { + LLUICtrl::CommitCallbackRegistry::Registrar& commit_reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar(); + commit_reg.add("Toolbars.EnableSetting", boost::bind(&LLToolBar::onSettingEnable, this, _2)); + + LLUICtrl::EnableCallbackRegistry::Registrar& enable_reg = LLUICtrl::EnableCallbackRegistry::defaultRegistrar(); + enable_reg.add("Toolbars.CheckSetting", boost::bind(&LLToolBar::isSettingChecked, this, _2)); + + // + // Setup the context menu + // + + LLMenuGL* menu = LLUICtrlFactory::instance().createFromFile("menu_toolbars.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); + + if (menu) + { + menu->setBackgroundColor(LLUIColorTable::instance().getColor("MenuPopupBgColor")); + + mPopupMenuHandle = menu->getHandle(); + } + else + { + llwarns << "Unable to load toolbars context menu." << llendl; + } + } + + return TRUE; } void LLToolBar::initFromParams(const LLToolBar::Params& p) @@ -199,6 +240,61 @@ bool LLToolBar::addCommand(LLCommand * command) return true; } +BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + BOOL handle_it_here = !mReadOnly; + + if (handle_it_here) + { + LLMenuGL * menu = (LLMenuGL *) mPopupMenuHandle.get(); + + if (menu) + { + LLMenuGL::showPopup(this, menu, x, y); + } + } + + return handle_it_here; +} + +BOOL LLToolBar::isSettingChecked(const LLSD& userdata) +{ + BOOL retval = FALSE; + + const std::string setting_name = userdata.asString(); + + if (setting_name == "icons_and_labels") + { + retval = (mButtonType == BTNTYPE_ICONS_WITH_TEXT); + } + else if (setting_name == "icons_only") + { + retval = (mButtonType == BTNTYPE_ICONS_ONLY); + } + + return retval; +} + +void LLToolBar::onSettingEnable(const LLSD& userdata) +{ + llassert(!mReadOnly); + + const std::string setting_name = userdata.asString(); + + const ButtonType current_button_type = mButtonType; + + if (setting_name == "icons_and_labels") + { + mButtonType = BTNTYPE_ICONS_WITH_TEXT; + } + else if (setting_name == "icons_only") + { + mButtonType = BTNTYPE_ICONS_ONLY; + } + + mNeedsLayout |= (current_button_type != mButtonType); +} + void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row, S32 max_row_girth) { // make buttons in current row all same girth @@ -264,8 +360,8 @@ void LLToolBar::updateLayoutAsNeeded() std::vector buttons_in_row; - BOOST_FOREACH(LLToolBarButton* button, mButtons) - { + BOOST_FOREACH(LLToolBarButton* button, mButtons) + { button->reshape(mMinButtonWidth, mButtonHeight); button->autoResize(); @@ -296,11 +392,11 @@ void LLToolBar::updateLayoutAsNeeded() cur_start = row_pad_start; cur_row += max_row_girth + mPadBetween; 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 @@ -340,8 +436,9 @@ void LLToolBar::updateLayoutAsNeeded() { // shift left to maintain right edge mButtonPanel->translate(mButtonPanel->getRect().getWidth() - total_girth, 0); } + mButtonPanel->reshape(total_girth, max_row_length); - } + } // re-center toolbar buttons mCenteringStack->updateLayout(); diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 92c289cd3f..5028c39fb8 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -51,8 +51,8 @@ namespace LLToolBarEnums { enum ButtonType { - BTNTYPE_ICONS_ONLY = 0, - BTNTYPE_ICONS_WITH_TEXT, + BTNTYPE_ICONS_WITH_TEXT = 0, + BTNTYPE_ICONS_ONLY, BTNTYPE_COUNT }; @@ -96,7 +96,9 @@ public: Optional button_icon, button_icon_and_text; - Optional wrap; + Optional read_only, + wrap; + Optional min_button_width, max_button_width, button_height; @@ -116,6 +118,7 @@ public: // virtuals void draw(); + BOOL postBuild(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); bool addCommand(LLCommand * command); @@ -123,13 +126,20 @@ public: protected: friend class LLUICtrlFactory; LLToolBar(const Params&); + ~LLToolBar(); void initFromParams(const Params&); + BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); + BOOL isSettingChecked(const LLSD& userdata); + void onSettingEnable(const LLSD& userdata); + private: void updateLayoutAsNeeded(); void resizeButtonsInRow(std::vector& buttons_in_row, S32 max_row_girth); + const bool mReadOnly; + std::list mButtons; LLToolBarEnums::ButtonType mButtonType; LLLayoutStack* mCenteringStack; @@ -149,6 +159,8 @@ private: mPadBetween; LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT]; + + LLHandle mPopupMenuHandle; }; -- cgit v1.2.3 From e3199b98be55c7d3355258e836b6cab522922cfa Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 26 Sep 2011 15:19:04 -0700 Subject: EXP-1207 : Display toolbars only after login, use correct position (temporary), follow resize correctly, store pointers to toolbars, debug display (temporary) --- indra/llui/lltoolbarview.cpp | 35 +++++++++++++++++++++++++---------- indra/llui/lltoolbarview.h | 8 +++++++- 2 files changed, 32 insertions(+), 11 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index c99b573b35..0b0fcef52c 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -37,7 +37,10 @@ LLToolBarView* gToolBarView = NULL; static LLDefaultChildRegistry::Register r("toolbar_view"); LLToolBarView::LLToolBarView(const LLToolBarView::Params& p) -: LLUICtrl(p) +: LLUICtrl(p), + mToolbarLeft(NULL), + mToolbarRight(NULL), + mToolbarBottom(NULL) { } @@ -51,20 +54,28 @@ LLToolBarView::~LLToolBarView() { } +BOOL LLToolBarView::postBuild() +{ + mToolbarLeft = getChild("toolbar_left"); + mToolbarRight = getChild("toolbar_right"); + mToolbarBottom = getChild("toolbar_bottom"); + 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 bottom_rect, left_rect, right_rect; + + if (mToolbarBottom) bottom_rect = mToolbarBottom->getRect(); + if (mToolbarLeft) left_rect = mToolbarLeft->getRect(); + if (mToolbarRight) right_rect = mToolbarRight->getRect(); + LLRect sizer_left_rect = sizer_left->getRect(); if ((old_width != getRect().getWidth()) || (old_height != getRect().getHeight())) @@ -83,11 +94,15 @@ void LLToolBarView::draw() } // Debug draw LLColor4 back_color = LLColor4::blue; + LLColor4 back_color_vert = LLColor4::red; + LLColor4 back_color_hori = LLColor4::yellow; back_color[VALPHA] = 0.5f; + back_color_hori[VALPHA] = 0.5f; + back_color_vert[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); + gl_rect_2d(bottom_rect, back_color_hori, TRUE); + gl_rect_2d(left_rect, back_color_vert, TRUE); + gl_rect_2d(right_rect, back_color_vert, TRUE); LLUICtrl::draw(); } diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 0e6545015d..24735d69e9 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -29,6 +29,7 @@ #define LL_LLTOOLBARVIEW_H #include "lluictrl.h" +#include "lltoolbar.h" class LLUICtrlFactory; @@ -38,7 +39,10 @@ class LLToolBarView : public LLUICtrl { public: struct Params : public LLInitParam::Block {}; + virtual ~LLToolBarView(); + /*virtual*/ BOOL postBuild(); + virtual void draw(); // valid children for LLToolBarView are stored in this registry @@ -51,7 +55,9 @@ protected: void initFromParams(const Params&); private: - LLHandle mSnapView; + LLToolBar* mToolbarLeft; + LLToolBar* mToolbarRight; + LLToolBar* mToolbarBottom; }; extern LLToolBarView* gToolBarView; -- cgit v1.2.3 From bb1776de6865715b2dd96185140d35e46d63c837 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 26 Sep 2011 16:06:57 -0700 Subject: EXP-1207 : Introduced an hasCommand() method for toolbars and toolbar view --- indra/llui/lltoolbar.cpp | 14 ++++++++++++++ indra/llui/lltoolbar.h | 1 + indra/llui/lltoolbarview.cpp | 18 ++++++++++++++++++ indra/llui/lltoolbarview.h | 2 ++ 4 files changed, 35 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index a9513b759a..5802d2adda 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -240,6 +240,20 @@ bool LLToolBar::addCommand(LLCommand * command) return true; } +bool LLToolBar::hasCommand(const std::string& command_name) +{ + bool has_command = false; + for (std::list::iterator cmd = mButtons.begin(); cmd != mButtons.end(); cmd++) + { + if ((*cmd)->getName() == command_name) + { + has_command = true; + break; + } + } + return has_command; +} + BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask) { BOOL handle_it_here = !mReadOnly; diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 5028c39fb8..00e6ed131a 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -122,6 +122,7 @@ public: void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); bool addCommand(LLCommand * command); + bool hasCommand(const std::string& command_name); protected: friend class LLUICtrlFactory; diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 0b0fcef52c..3b4960fdd5 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -62,6 +62,24 @@ BOOL LLToolBarView::postBuild() return TRUE; } +bool LLToolBarView::hasCommand(const std::string& command_name) +{ + bool has_command = false; + if (mToolbarLeft && !has_command) + { + has_command = mToolbarLeft->hasCommand(command_name); + } + if (mToolbarRight && !has_command) + { + has_command = mToolbarRight->hasCommand(command_name); + } + if (mToolbarBottom && !has_command) + { + has_command = mToolbarBottom->hasCommand(command_name); + } + return has_command; +} + void LLToolBarView::draw() { static bool debug_print = true; diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 24735d69e9..65d339315b 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -45,6 +45,8 @@ public: virtual void draw(); + bool hasCommand(const std::string& command_name); + // valid children for LLToolBarView are stored in this registry typedef LLDefaultChildRegistry child_registry_t; -- cgit v1.2.3 From a465f816b8e7674aa3f22023d7708106ca35b350 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 26 Sep 2011 17:36:07 -0700 Subject: EXP-1239 FIX make toolbars wrap when there is not enough room toolbars resize to fit buttons toolbar view uses layout stacks to organize toolbars reviewed by Leslie --- indra/llui/llcommandmanager.cpp | 2 +- indra/llui/lldockcontrol.cpp | 3 ++- indra/llui/lltoolbar.cpp | 27 +++++++++------------------ indra/llui/lltoolbarview.cpp | 3 --- 4 files changed, 12 insertions(+), 23 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index 6be616b980..071ab24cda 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -109,7 +109,7 @@ void LLCommandManager::addCommand(LLCommand * command) mCommandIndices[command->name()] = mCommands.size(); mCommands.push_back(command); - llinfos << "Successfully added command: " << command->name() << llendl; + lldebugs << "Successfully added command: " << command->name() << llendl; } //static diff --git a/indra/llui/lldockcontrol.cpp b/indra/llui/lldockcontrol.cpp index b1c27126d9..6e39fcd714 100644 --- a/indra/llui/lldockcontrol.cpp +++ b/indra/llui/lldockcontrol.cpp @@ -97,6 +97,7 @@ void LLDockControl::getAllowedRect(LLRect& rect) void LLDockControl::repositionDockable() { + if (!mDockWidget) return; LLRect dockRect = mDockWidget->calcScreenRect(); LLRect rootRect; mGetAllowedRectCallback(rootRect); @@ -160,7 +161,7 @@ bool LLDockControl::isDockVisible() case TOP: { // check is dock inside parent rect - // assume that parent for all dockable flaoters + // assume that parent for all dockable floaters // is the root view LLRect dockParentRect = mDockWidget->getRootView()->calcScreenRect(); diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 31a18dc707..90ade136e8 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -122,6 +122,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) centering_stack_p.rect = getLocalRect(); centering_stack_p.follows.flags = FOLLOWS_ALL; centering_stack_p.orientation = orientation; + centering_stack_p.mouse_opaque = false; mCenteringStack = LLUICtrlFactory::create(centering_stack_p); addChild(mCenteringStack); @@ -131,6 +132,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) border_panel_p.rect = getLocalRect(); border_panel_p.auto_resize = true; border_panel_p.user_resize = false; + border_panel_p.mouse_opaque = false; mCenteringStack->addChild(LLUICtrlFactory::create(border_panel_p)); @@ -145,21 +147,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) LLPanel::Params button_panel_p(p.button_panel); button_panel_p.rect = center_panel->getLocalRect(); - switch(p.side()) - { - case SIDE_LEFT: - button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_LEFT; - break; - case SIDE_RIGHT: - button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_RIGHT; - break; - case SIDE_TOP: - button_panel_p.follows.flags = FOLLOWS_TOP|FOLLOWS_LEFT; - break; - case SIDE_BOTTOM: - button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_LEFT; - break; - } + button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_LEFT; mButtonPanel = LLUICtrlFactory::create(button_panel_p); center_panel->addChild(mButtonPanel); @@ -329,19 +317,22 @@ void LLToolBar::updateLayoutAsNeeded() { if (mSideType == SIDE_TOP) { // shift down to maintain top edge - mButtonPanel->translate(0, mButtonPanel->getRect().getHeight() - total_girth); + translate(0, getRect().getHeight() - total_girth); } + reshape(getRect().getWidth(), total_girth); mButtonPanel->reshape(max_row_length, total_girth); } else // VERTICAL { if (mSideType == SIDE_RIGHT) { // shift left to maintain right edge - mButtonPanel->translate(mButtonPanel->getRect().getWidth() - total_girth, 0); + translate(getRect().getWidth() - total_girth, 0); } + + reshape(total_girth, getRect().getHeight()); mButtonPanel->reshape(total_girth, max_row_length); - } + } // re-center toolbar buttons mCenteringStack->updateLayout(); diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index c99b573b35..27d67184d8 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -60,12 +60,10 @@ void LLToolBarView::draw() 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; @@ -76,7 +74,6 @@ 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; -- cgit v1.2.3 From 53a486649381af53d21de28aced388bc2aacac0f Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 26 Sep 2011 17:38:10 -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 * Command buttons are now enabled/disabled in toybox based on whether or not the LLToolBarView has them anywhere. * Commands now have argument to specify whether or not they should be in the toybox. * LLCommandId is now used a universal reference for commands. Reviewed by Richard. --- indra/llui/llcommandmanager.cpp | 24 +++++++++----- indra/llui/llcommandmanager.h | 50 ++++++++++++++++++++++++++--- indra/llui/lltoolbar.cpp | 71 +++++++++++++++++++++++++++++------------ indra/llui/lltoolbar.h | 11 ++++--- indra/llui/lltoolbarview.cpp | 8 ++--- indra/llui/lltoolbarview.h | 3 +- 6 files changed, 125 insertions(+), 42 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index 6be616b980..62e1d186f5 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -37,12 +37,19 @@ #include +// +// LLCommandId class +// + +const LLCommandId LLCommandId::null("null command"); + // // LLCommand class // LLCommand::Params::Params() : function("function") + , available_in_toybox("available_in_toybox", false) , icon("icon") , label_ref("label_ref") , name("name") @@ -53,9 +60,10 @@ LLCommand::Params::Params() LLCommand::LLCommand(const LLCommand::Params& p) : mFunction(p.function) + , mAvailableInToybox(p.available_in_toybox) , mIcon(p.icon) + , mIdentifier(p.name) , mLabelRef(p.label_ref) - , mName(p.name) , mParam(p.param) , mTooltipRef(p.tooltip_ref) { @@ -90,26 +98,26 @@ LLCommand * LLCommandManager::getCommand(U32 commandIndex) return mCommands[commandIndex]; } -LLCommand * LLCommandManager::getCommand(const std::string& commandName) +LLCommand * LLCommandManager::getCommand(const LLCommandId& commandId) { - LLCommand * command_name_match = NULL; + LLCommand * command_match = NULL; - CommandIndexMap::const_iterator found = mCommandIndices.find(commandName); + CommandIndexMap::const_iterator found = mCommandIndices.find(commandId); if (found != mCommandIndices.end()) { - command_name_match = mCommands[found->second]; + command_match = mCommands[found->second]; } - return command_name_match; + return command_match; } void LLCommandManager::addCommand(LLCommand * command) { - mCommandIndices[command->name()] = mCommands.size(); + mCommandIndices[command->id()] = mCommands.size(); mCommands.push_back(command); - llinfos << "Successfully added command: " << command->name() << llendl; + llinfos << "Successfully added command: " << command->id().name() << llendl; } //static diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 24378ecd62..5b53b65500 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -31,11 +31,50 @@ #include "llsingleton.h" +class LLCommand; +class LLCommandManager; + + +class LLCommandId +{ +public: + friend LLCommand; + friend LLCommandManager; + + LLCommandId(const std::string& name) + : mName(name) + { + } + + const std::string& name() const { return mName; } + + bool operator!=(const LLCommandId& command) const + { + return (mName != command.mName); + } + + bool operator==(const LLCommandId& command) const + { + return (mName == command.mName); + } + + bool operator<(const LLCommandId& command) const + { + return (mName < command.mName); + } + + static const LLCommandId null; + +private: + std::string mName; +}; + class LLCommand { public: struct Params : public LLInitParam::Block { + Mandatory available_in_toybox; Mandatory function; Mandatory icon; Mandatory label_ref; @@ -48,18 +87,21 @@ public: LLCommand(const LLCommand::Params& p); + const bool availableInToybox() const { return mAvailableInToybox; } const std::string& functionName() const { return mFunction; } const std::string& icon() const { return mIcon; } + const LLCommandId& id() const { return mIdentifier; } 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: + LLCommandId mIdentifier; + + bool mAvailableInToybox; std::string mFunction; std::string mIcon; std::string mLabelRef; - std::string mName; std::string mParam; std::string mTooltipRef; }; @@ -84,7 +126,7 @@ public: U32 commandCount() const; LLCommand * getCommand(U32 commandIndex); - LLCommand * getCommand(const std::string& commandName); + LLCommand * getCommand(const LLCommandId& commandId); static bool load(); @@ -92,7 +134,7 @@ protected: void addCommand(LLCommand * command); private: - typedef std::map CommandIndexMap; + typedef std::map CommandIndexMap; typedef std::vector CommandVector; CommandVector mCommands; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 5802d2adda..1e1cb16fbb 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -30,7 +30,6 @@ #include #include "lltoolbar.h" -#include "llcommandmanager.h" #include "llmenugl.h" #include "lltrans.h" @@ -212,48 +211,79 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) LLToolBarButton* buttonp = LLUICtrlFactory::create(button_p); mButtons.push_back(buttonp); + mButtonCommands.push_back(LLCommandId::null); mButtonPanel->addChild(buttonp); mNeedsLayout = true; } } -bool LLToolBar::addCommand(LLCommand * command) +bool LLToolBar::addCommand(const LLCommandId& commandId) { + LLCommand * command = LLCommandManager::instance().getCommand(commandId); + + bool add_command = (command != NULL); + // // Init basic toolbar button params // - LLToolBarButton::Params button_p(mButtonParams[mButtonType]); - button_p.name = command->name(); - button_p.label = LLTrans::getString(command->labelRef()); - button_p.tool_tip = LLTrans::getString(command->tooltipRef()); + if (add_command) + { + LLToolBarButton::Params button_p(mButtonParams[mButtonType]); + button_p.name = commandId.name(); + button_p.label = LLTrans::getString(command->labelRef()); + button_p.tool_tip = LLTrans::getString(command->tooltipRef()); - // - // Add it to the list of buttons - // - LLToolBarButton * toolbar_button = LLUICtrlFactory::create(button_p); - mButtons.push_back(toolbar_button); - mButtonPanel->addChild(toolbar_button); + // + // Add it to the list of buttons + // + LLToolBarButton * toolbar_button = LLUICtrlFactory::create(button_p); + mButtons.push_back(toolbar_button); + mButtonCommands.push_back(commandId); + mButtonPanel->addChild(toolbar_button); - mNeedsLayout = true; + mNeedsLayout = true; + } - return true; + return add_command; } -bool LLToolBar::hasCommand(const std::string& command_name) +bool LLToolBar::hasCommand(const LLCommandId& commandId) const { bool has_command = false; - for (std::list::iterator cmd = mButtons.begin(); cmd != mButtons.end(); cmd++) + + if (commandId != LLCommandId::null) { - if ((*cmd)->getName() == command_name) + for (std::list::const_iterator cmd = mButtonCommands.begin(); cmd != mButtonCommands.end(); ++cmd) { - has_command = true; - break; + if ((*cmd) == commandId) + { + has_command = true; + break; + } } } + return has_command; } +bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled) +{ + LLButton * command_button = NULL; + + if (commandId != LLCommandId::null) + { + command_button = mButtonPanel->findChild(commandId.name()); + + if (command_button) + { + command_button->setEnabled(enabled); + } + } + + return (command_button != NULL); +} + BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask) { BOOL handle_it_here = !mReadOnly; @@ -351,7 +381,6 @@ void LLToolBar::updateLayoutAsNeeded() max_length = getRect().getWidth() - mPadLeft - mPadRight; max_total_girth = getRect().getHeight() - mPadTop - mPadBottom; row_pad_start = mPadLeft; - row_running_length = row_pad_start; row_pad_end = mPadRight; cur_row = mPadTop; girth_pad_end = mPadBottom; @@ -361,12 +390,12 @@ void LLToolBar::updateLayoutAsNeeded() max_length = getRect().getHeight() - mPadTop - mPadBottom; max_total_girth = getRect().getWidth() - mPadLeft - mPadRight; row_pad_start = mPadTop; - row_running_length = row_pad_start; row_pad_end = mPadBottom; cur_row = mPadLeft; girth_pad_end = mPadRight; } + row_running_length = row_pad_start; cur_start = row_pad_start; diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 00e6ed131a..f7562b29d2 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -28,9 +28,10 @@ #ifndef LL_LLTOOLBAR_H #define LL_LLTOOLBAR_H -#include "lluictrl.h" -#include "lllayoutstack.h" #include "llbutton.h" +#include "llcommandmanager.h" +#include "lllayoutstack.h" +#include "lluictrl.h" class LLCommand; @@ -121,8 +122,9 @@ public: BOOL postBuild(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); - bool addCommand(LLCommand * command); - bool hasCommand(const std::string& command_name); + bool addCommand(const LLCommandId& commandId); + bool hasCommand(const LLCommandId& commandId) const; + bool enableCommand(const LLCommandId& commandId, bool enabled); protected: friend class LLUICtrlFactory; @@ -142,6 +144,7 @@ private: const bool mReadOnly; std::list mButtons; + std::list mButtonCommands; LLToolBarEnums::ButtonType mButtonType; LLLayoutStack* mCenteringStack; LLLayoutStack* mWrapStack; diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 3b4960fdd5..6c29e566b8 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -62,20 +62,20 @@ BOOL LLToolBarView::postBuild() return TRUE; } -bool LLToolBarView::hasCommand(const std::string& command_name) +bool LLToolBarView::hasCommand(const LLCommandId& commandId) const { bool has_command = false; if (mToolbarLeft && !has_command) { - has_command = mToolbarLeft->hasCommand(command_name); + has_command = mToolbarLeft->hasCommand(commandId); } if (mToolbarRight && !has_command) { - has_command = mToolbarRight->hasCommand(command_name); + has_command = mToolbarRight->hasCommand(commandId); } if (mToolbarBottom && !has_command) { - has_command = mToolbarBottom->hasCommand(command_name); + has_command = mToolbarBottom->hasCommand(commandId); } return has_command; } diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 65d339315b..2e7885f391 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -30,6 +30,7 @@ #include "lluictrl.h" #include "lltoolbar.h" +#include "llcommandmanager.h" class LLUICtrlFactory; @@ -45,7 +46,7 @@ public: virtual void draw(); - bool hasCommand(const std::string& command_name); + bool hasCommand(const LLCommandId& commandId) const; // valid children for LLToolBarView are stored in this registry typedef LLDefaultChildRegistry child_registry_t; -- cgit v1.2.3 From 87318979bf8ce1ba68c1e90190737cf99ecc7c50 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 26 Sep 2011 18:04:50 -0700 Subject: EXP-1202 : Fix Mac compilation failure --- indra/llui/llcommandmanager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 5b53b65500..7ed8785f17 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -38,8 +38,8 @@ class LLCommandManager; class LLCommandId { public: - friend LLCommand; - friend LLCommandManager; + friend class LLCommand; + friend class LLCommandManager; LLCommandId(const std::string& name) : mName(name) -- cgit v1.2.3 From 7fd0e8c69e6dced4a770da4fac10c154eac5899f Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 26 Sep 2011 18:51:43 -0700 Subject: fixed toolbar context menu deprecated pointless LLView::deleteViewByHandle --- indra/llui/llmenugl.cpp | 2 +- indra/llui/lltoolbar.cpp | 18 +++++++----------- indra/llui/lltoolbar.h | 11 +++++------ indra/llui/lltoolbarview.cpp | 6 +++--- indra/llui/llview.cpp | 7 ------- indra/llui/llview.h | 1 - 6 files changed, 16 insertions(+), 29 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 6cac841cde..badba7a416 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -947,7 +947,7 @@ LLMenuItemBranchGL::LLMenuItemBranchGL(const LLMenuItemBranchGL::Params& p) LLMenuItemBranchGL::~LLMenuItemBranchGL() { - LLView::deleteViewByHandle(mBranchHandle); + delete mBranchHandle.get(); } // virtual diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 278c04aef8..bd45cf4656 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -116,12 +116,12 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) LLToolBar::~LLToolBar() { - LLView::deleteViewByHandle(mPopupMenuHandle); + delete mPopupMenuHandle.get(); } -BOOL LLToolBar::postBuild() +void LLToolBar::createContextMenu() { - if (!mReadOnly) + if (!mPopupMenuHandle.get()) { LLUICtrl::CommitCallbackRegistry::Registrar& commit_reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar(); commit_reg.add("Toolbars.EnableSetting", boost::bind(&LLToolBar::onSettingEnable, this, _2)); @@ -129,11 +129,7 @@ BOOL LLToolBar::postBuild() LLUICtrl::EnableCallbackRegistry::Registrar& enable_reg = LLUICtrl::EnableCallbackRegistry::defaultRegistrar(); enable_reg.add("Toolbars.CheckSetting", boost::bind(&LLToolBar::isSettingChecked, this, _2)); - // - // Setup the context menu - // - - LLMenuGL* menu = LLUICtrlFactory::instance().createFromFile("menu_toolbars.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); + LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile("menu_toolbars.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); if (menu) { @@ -146,8 +142,6 @@ BOOL LLToolBar::postBuild() llwarns << "Unable to load toolbars context menu." << llendl; } } - - return TRUE; } void LLToolBar::initFromParams(const LLToolBar::Params& p) @@ -278,10 +272,12 @@ BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask) if (handle_it_here) { - LLMenuGL * menu = (LLMenuGL *) mPopupMenuHandle.get(); + createContextMenu(); + LLContextMenu * menu = (LLContextMenu *) mPopupMenuHandle.get(); if (menu) { + menu->show(x, y); LLMenuGL::showPopup(this, menu, x, y); } } diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index f7562b29d2..657e928319 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -119,8 +119,8 @@ public: // virtuals void draw(); - BOOL postBuild(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); + BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); bool addCommand(const LLCommandId& commandId); bool hasCommand(const LLCommandId& commandId) const; @@ -133,13 +133,12 @@ protected: void initFromParams(const Params&); - BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); - BOOL isSettingChecked(const LLSD& userdata); - void onSettingEnable(const LLSD& userdata); - private: + void createContextMenu(); void updateLayoutAsNeeded(); void resizeButtonsInRow(std::vector& buttons_in_row, S32 max_row_girth); + BOOL isSettingChecked(const LLSD& userdata); + void onSettingEnable(const LLSD& userdata); const bool mReadOnly; @@ -164,7 +163,7 @@ private: LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT]; - LLHandle mPopupMenuHandle; + LLHandle mPopupMenuHandle; }; diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 21d3785c82..6ae10fbf1d 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -90,9 +90,9 @@ void LLToolBarView::draw() LLRect bottom_rect, left_rect, right_rect; - if (mToolbarBottom) bottom_rect = mToolbarBottom->getRect(); - if (mToolbarLeft) left_rect = mToolbarLeft->getRect(); - if (mToolbarRight) right_rect = mToolbarRight->getRect(); + if (mToolbarBottom) mToolbarBottom->localRectToOtherView(mToolbarBottom->getLocalRect(), &bottom_rect, this); + if (mToolbarLeft) mToolbarLeft->localRectToOtherView(mToolbarLeft->getLocalRect(), &left_rect, this); + if (mToolbarRight) mToolbarRight->localRectToOtherView(mToolbarRight->getLocalRect(), &right_rect, this); if ((old_width != getRect().getWidth()) || (old_height != getRect().getHeight())) diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 60452b9ae4..e10c2f0d1e 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -1826,13 +1826,6 @@ LLView* LLView::findNextSibling(LLView* child) return (next_it != mChildList.end()) ? *next_it : NULL; } -void LLView::deleteViewByHandle(LLHandle handle) -{ - LLView* viewp = handle.get(); - - delete viewp; -} - LLCoordGL getNeededTranslation(const LLRect& input, const LLRect& constraint, BOOL allow_partial_outside) { diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 594a5eec6b..7a1b2e4ba0 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -482,7 +482,6 @@ public: // return query for iterating over focus roots in tab order static const LLCtrlQuery & getFocusRootsQuery(); - static void deleteViewByHandle(LLHandle handle); static LLWindow* getWindow(void) { return LLUI::sWindow; } // Set up params after XML load before calling new(), -- cgit v1.2.3 From f56bf69dfed63d8b7d5d8994c0c3cafced803a0f Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 26 Sep 2011 19:48:17 -0700 Subject: initial support for switching between icons only and icons + text --- indra/llui/llcommandmanager.h | 16 +++++++-- indra/llui/lltoolbar.cpp | 79 +++++++++++++++++++++++-------------------- indra/llui/lltoolbar.h | 7 ++-- 3 files changed, 60 insertions(+), 42 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 7ed8785f17..8435d915f3 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -41,10 +41,22 @@ public: friend class LLCommand; friend class LLCommandManager; + struct Params : public LLInitParam::Block + { + Mandatory name; + + Params() + : name("name") + {} + }; + LLCommandId(const std::string& name) : mName(name) - { - } + {} + + LLCommandId(const Params& p) + : mName(p.name) + {} const std::string& name() const { return mName; } diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index bd45cf4656..2fb9f249d4 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -74,7 +74,7 @@ namespace LLInitParam LLToolBar::Params::Params() : button_display_mode("button_display_mode"), - buttons("button"), + commands("command"), side("side", SIDE_TOP), button_icon("button_icon"), button_icon_and_text("button_icon_and_text"), @@ -187,17 +187,13 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) mCenteringStack->addChild(LLUICtrlFactory::create(border_panel_p)); - BOOST_FOREACH (LLToolBarButton::Params button_p, p.buttons) + BOOST_FOREACH (const LLCommandId::Params& command_id, p.commands) { - button_p.fillFrom(mButtonParams[mButtonType]); - LLToolBarButton* buttonp = LLUICtrlFactory::create(button_p); - - mButtons.push_back(buttonp); - mButtonCommands.push_back(LLCommandId::null); - mButtonPanel->addChild(buttonp); - - mNeedsLayout = true; + mButtonCommands.push_back(command_id); } + createButtons(); + + mNeedsLayout = true; } bool LLToolBar::addCommand(const LLCommandId& commandId) @@ -206,26 +202,8 @@ bool LLToolBar::addCommand(const LLCommandId& commandId) bool add_command = (command != NULL); - // - // Init basic toolbar button params - // - if (add_command) - { - LLToolBarButton::Params button_p(mButtonParams[mButtonType]); - button_p.name = commandId.name(); - button_p.label = LLTrans::getString(command->labelRef()); - button_p.tool_tip = LLTrans::getString(command->tooltipRef()); - - // - // Add it to the list of buttons - // - LLToolBarButton * toolbar_button = LLUICtrlFactory::create(button_p); - mButtons.push_back(toolbar_button); - mButtonCommands.push_back(commandId); - mButtonPanel->addChild(toolbar_button); - - mNeedsLayout = true; - } + mButtonCommands.push_back(commandId); + createButtons(); return add_command; } @@ -320,7 +298,10 @@ void LLToolBar::onSettingEnable(const LLSD& userdata) mButtonType = BTNTYPE_ICONS_ONLY; } - mNeedsLayout |= (current_button_type != mButtonType); + if(current_button_type != mButtonType) + { + createButtons(); + } } void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row, S32 max_row_girth) @@ -387,8 +368,8 @@ void LLToolBar::updateLayoutAsNeeded() std::vector buttons_in_row; - BOOST_FOREACH(LLToolBarButton* button, mButtons) - { + BOOST_FOREACH(LLToolBarButton* button, mButtons) + { button->reshape(mMinButtonWidth, mButtonHeight); button->autoResize(); @@ -421,8 +402,8 @@ void LLToolBar::updateLayoutAsNeeded() max_row_girth = 0; } - LLRect button_rect; - if (orientation == LLLayoutStack::HORIZONTAL) + LLRect button_rect; + if (orientation == LLLayoutStack::HORIZONTAL) { button_rect.setLeftTopAndSize(cur_start, panel_rect.mTop - cur_row, button_clamped_width, button->getRect().getHeight()); } @@ -467,7 +448,7 @@ void LLToolBar::updateLayoutAsNeeded() reshape(total_girth, getRect().getHeight()); mButtonPanel->reshape(total_girth, max_row_length); - } + } // re-center toolbar buttons mCenteringStack->updateLayout(); @@ -489,3 +470,29 @@ void LLToolBar::reshape(S32 width, S32 height, BOOL called_from_parent) mNeedsLayout = true; } +void LLToolBar::createButtons() +{ + BOOST_FOREACH(LLToolBarButton* button, mButtons) + { + delete button; + } + mButtons.clear(); + + BOOST_FOREACH(LLCommandId& command_id, mButtonCommands) + { + LLCommand* commandp = LLCommandManager::instance().getCommand(command_id); + if (!commandp) continue; + + LLToolBarButton::Params button_p; + button_p.label = LLTrans::getString(commandp->labelRef()); + button_p.image_overlay = LLUI::getUIImage(commandp->icon()); + button_p.overwriteFrom(mButtonParams[mButtonType]); + LLToolBarButton* button = LLUICtrlFactory::create(button_p); + + mButtons.push_back(button); + mButtonPanel->addChild(button); + } + + mNeedsLayout = true; +} + diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 657e928319..75ae499a3d 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -32,9 +32,7 @@ #include "llcommandmanager.h" #include "lllayoutstack.h" #include "lluictrl.h" - - -class LLCommand; +#include "llcommandmanager.h" class LLToolBarButton : public LLButton @@ -110,7 +108,7 @@ public: pad_bottom, pad_between; // get rid of this - Multiple buttons; + Multiple commands; Optional button_panel; @@ -136,6 +134,7 @@ protected: private: void createContextMenu(); void updateLayoutAsNeeded(); + void createButtons(); void resizeButtonsInRow(std::vector& buttons_in_row, S32 max_row_girth); BOOL isSettingChecked(const LLSD& userdata); void onSettingEnable(const LLSD& userdata); -- cgit v1.2.3 From cc56958452b8c10e1de176edb1924179ad04768a Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 26 Sep 2011 19:48:27 -0700 Subject: initial support for switching between icons only and icons + text --- indra/llui/llbutton.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 6c08ec7431..06781f1bdf 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -989,11 +989,27 @@ void LLButton::resize(LLUIString label) // get current btn length S32 btn_width =getRect().getWidth(); // check if it need resize - if (mAutoResize == TRUE) + if (mAutoResize) { - if (btn_width - (mRightHPad + mLeftHPad) < label_width) + S32 min_width = label_width + mLeftHPad + mRightHPad; + if (mImageOverlay) { - setRect(LLRect( getRect().mLeft, getRect().mTop, getRect().mLeft + label_width + mLeftHPad + mRightHPad , getRect().mBottom)); + switch(mImageOverlayAlignment) + { + case LLFontGL::LEFT: + case LLFontGL::RIGHT: + min_width += mImageOverlay->getWidth() + mImgOverlayLabelSpace; + break; + case LLFontGL::HCENTER: + break; + default: + // draw nothing + break; + } + } + if (btn_width < min_width) + { + reshape(min_width, getRect().getHeight()); } } } -- cgit v1.2.3 From b7cf5ff947161d0b7e42a9ed8fe10741bb7af100 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 27 Sep 2011 09:33:58 -0700 Subject: Commenting out unused variable to fix mac build. --- indra/llui/lltoolbarview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 6ae10fbf1d..9df6f4946f 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -86,7 +86,7 @@ void LLToolBarView::draw() static S32 old_width = 0; static S32 old_height = 0; - LLPanel* sizer_left = getChild("sizer_left"); + //LLPanel* sizer_left = getChild("sizer_left"); LLRect bottom_rect, left_rect, right_rect; -- cgit v1.2.3 From a686aeabffe619c9a467455982f1a39968fbd9e3 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 27 Sep 2011 12:40:47 -0700 Subject: * Modified toolbar context menus to bind to the specific instance of the toolbar --- indra/llui/lltoolbar.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 2fb9f249d4..9986eece2d 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -123,12 +123,16 @@ void LLToolBar::createContextMenu() { if (!mPopupMenuHandle.get()) { + // Setup bindings specific to this instance for the context menu options + LLUICtrl::CommitCallbackRegistry::Registrar& commit_reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar(); commit_reg.add("Toolbars.EnableSetting", boost::bind(&LLToolBar::onSettingEnable, this, _2)); LLUICtrl::EnableCallbackRegistry::Registrar& enable_reg = LLUICtrl::EnableCallbackRegistry::defaultRegistrar(); enable_reg.add("Toolbars.CheckSetting", boost::bind(&LLToolBar::isSettingChecked, this, _2)); + // Create the context menu + LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile("menu_toolbars.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); if (menu) @@ -141,6 +145,10 @@ void LLToolBar::createContextMenu() { llwarns << "Unable to load toolbars context menu." << llendl; } + + // Remove this instance's bindings + commit_reg.remove("Toolbars.EnableSetting"); + enable_reg.remove("Toolbars.CheckSetting"); } } @@ -251,11 +259,13 @@ BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask) if (handle_it_here) { createContextMenu(); + LLContextMenu * menu = (LLContextMenu *) mPopupMenuHandle.get(); if (menu) { menu->show(x, y); + LLMenuGL::showPopup(this, menu, x, y); } } -- cgit v1.2.3 From 0e4f226b56cb2dea1e8d5e9f1267a16c302bb5a9 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 27 Sep 2011 14:58:20 -0700 Subject: EXP-1211 : Read toolbar default settings from toolbars.xml, no saving of settings done yet. --- indra/llui/lltoolbar.cpp | 13 +++--- indra/llui/lltoolbarview.cpp | 101 ++++++++++++++++++++++++++++++++++++++++++- indra/llui/lltoolbarview.h | 32 +++++++++++--- 3 files changed, 132 insertions(+), 14 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 2fb9f249d4..f8effb5bb6 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -187,12 +187,6 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) mCenteringStack->addChild(LLUICtrlFactory::create(border_panel_p)); - BOOST_FOREACH (const LLCommandId::Params& command_id, p.commands) - { - mButtonCommands.push_back(command_id); - } - createButtons(); - mNeedsLayout = true; } @@ -202,8 +196,11 @@ bool LLToolBar::addCommand(const LLCommandId& commandId) bool add_command = (command != NULL); - mButtonCommands.push_back(commandId); - createButtons(); + if (add_command) + { + mButtonCommands.push_back(commandId); + createButtons(); + } return add_command; } diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 6ae10fbf1d..139a26a251 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -29,13 +29,108 @@ #include "lltoolbarview.h" +#include "lldir.h" +#include "llxmlnode.h" #include "lltoolbar.h" #include "llbutton.h" +#include + LLToolBarView* gToolBarView = NULL; static LLDefaultChildRegistry::Register r("toolbar_view"); +LLToolBarView::Toolbar::Toolbar() +: commands("command") +{} + +LLToolBarView::ToolbarSet::ToolbarSet() +: left_toolbar("left_toolbar"), + right_toolbar("right_toolbar"), + bottom_toolbar("bottom_toolbar") +{} + +bool LLToolBarView::load() +{ + LLToolBarView::ToolbarSet toolbar_set; + + // Load the default toolbars.xml file + // *TODO : pick up the user's toolbar setting if existing + std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); + + LLXMLNodePtr root; + if(!LLXMLNode::parseFile(toolbar_file, root, NULL)) + { + llerrs << "Unable to load toolbars from file: " << toolbar_file << llendl; + return false; + } + if(!root->hasName("toolbars")) + { + llwarns << toolbar_file << " is not a valid toolbars definition file" << llendl; + return false; + } + + // Parse the toolbar settings + LLXUIParser parser; + parser.readXUI(root, toolbar_set, toolbar_file); + if (!toolbar_set.validateBlock()) + { + llerrs << "Unable to validate toolbars from file: " << toolbar_file << llendl; + return false; + } + + // Add commands to each toolbar + // *TODO: factorize that code : tricky with Blocks though, simple lexical approach fails + LLCommandManager& mgr = LLCommandManager::instance(); + + if (toolbar_set.left_toolbar.isProvided() && mToolbarLeft) + { + BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands) + { + LLCommandId* commandId = new LLCommandId(command); + if (mgr.getCommand(*commandId)) + { + mToolbarLeft->addCommand(*commandId); + } + else + { + llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; + } + } + } + if (toolbar_set.right_toolbar.isProvided() && mToolbarRight) + { + BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands) + { + LLCommandId* commandId = new LLCommandId(command); + if (mgr.getCommand(*commandId)) + { + mToolbarRight->addCommand(*commandId); + } + else + { + llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; + } + } + } + if (toolbar_set.bottom_toolbar.isProvided() && mToolbarBottom) + { + BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands) + { + LLCommandId* commandId = new LLCommandId(command); + if (mgr.getCommand(*commandId)) + { + mToolbarBottom->addCommand(*commandId); + } + else + { + llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; + } + } + } + return true; +} + LLToolBarView::LLToolBarView(const LLToolBarView::Params& p) : LLUICtrl(p), mToolbarLeft(NULL), @@ -59,6 +154,10 @@ BOOL LLToolBarView::postBuild() mToolbarLeft = getChild("toolbar_left"); mToolbarRight = getChild("toolbar_right"); mToolbarBottom = getChild("toolbar_bottom"); + + // Load the toolbars from the settings + load(); + return TRUE; } @@ -86,7 +185,7 @@ void LLToolBarView::draw() static S32 old_width = 0; static S32 old_height = 0; - LLPanel* sizer_left = getChild("sizer_left"); +// LLPanel* sizer_left = getChild("sizer_left"); LLRect bottom_rect, left_rect, right_rect; diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 2e7885f391..0f16b89ecc 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -39,18 +39,36 @@ class LLUICtrlFactory; class LLToolBarView : public LLUICtrl { public: + // Xui structure of the toolbar panel struct Params : public LLInitParam::Block {}; + + // Note: valid children for LLToolBarView are stored in this registry + typedef LLDefaultChildRegistry child_registry_t; - virtual ~LLToolBarView(); - /*virtual*/ BOOL postBuild(); + // Xml structure of the toolbars.xml setting + // Those live in a toolbars.xml found in app_settings (for the default) and in + // the user folder for the user specific (saved) settings + struct Toolbar : public LLInitParam::Block + { + Multiple commands; + Toolbar(); + }; + struct ToolbarSet : public LLInitParam::Block + { + Optional left_toolbar, + right_toolbar, + bottom_toolbar; + ToolbarSet(); + }; + // Derived methods + virtual ~LLToolBarView(); + virtual BOOL postBuild(); virtual void draw(); + // Toolbar view interface with the rest of the world bool hasCommand(const LLCommandId& commandId) const; - // valid children for LLToolBarView are stored in this registry - typedef LLDefaultChildRegistry child_registry_t; - protected: friend class LLUICtrlFactory; LLToolBarView(const Params&); @@ -58,6 +76,10 @@ protected: void initFromParams(const Params&); private: + // Loads the toolbars from the existing user or default settings + bool load(); // return false if load fails + + // Pointers to the toolbars handled by the toolbar view LLToolBar* mToolbarLeft; LLToolBar* mToolbarRight; LLToolBar* mToolbarBottom; -- cgit v1.2.3 From 0207d7e9e4e5b509b5905256a56ac2138b35cac3 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Tue, 27 Sep 2011 15:41:06 -0700 Subject: EXP-1247 Nearby chat as part of chat floater --- indra/llui/llresizehandle.cpp | 12 ++++++++++++ indra/llui/llresizehandle.h | 5 +++++ 2 files changed, 17 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/llresizehandle.cpp b/indra/llui/llresizehandle.cpp index c3a51c36c9..942e84eeb6 100644 --- a/indra/llui/llresizehandle.cpp +++ b/indra/llui/llresizehandle.cpp @@ -55,6 +55,8 @@ LLResizeHandle::LLResizeHandle(const LLResizeHandle::Params& p) mImage( NULL ), mMinWidth( p.min_width ), mMinHeight( p.min_height ), + mMaxWidth(S32_MAX), + mMaxHeight(S32_MAX), mCorner( p.corner ) { if( RIGHT_BOTTOM == mCorner) @@ -177,6 +179,11 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) new_width = mMinWidth; delta_x = x_multiple * (mMinWidth - orig_rect.getWidth()); } + else if (new_width > mMaxWidth) + { + new_width = mMaxWidth; + delta_x = x_multiple * (mMaxWidth - orig_rect.getWidth()); + } S32 new_height = orig_rect.getHeight() + y_multiple * delta_y; if( new_height < mMinHeight ) @@ -184,6 +191,11 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) new_height = mMinHeight; delta_y = y_multiple * (mMinHeight - orig_rect.getHeight()); } + else if (new_height > mMaxHeight) + { + new_height = mMaxHeight; + delta_y = y_multiple * (mMaxHeight - orig_rect.getHeight()); + } switch( mCorner ) { diff --git a/indra/llui/llresizehandle.h b/indra/llui/llresizehandle.h index 531eb1db61..5cfe3fb63c 100644 --- a/indra/llui/llresizehandle.h +++ b/indra/llui/llresizehandle.h @@ -56,6 +56,9 @@ public: void setResizeLimits( S32 min_width, S32 min_height ) { mMinWidth = min_width; mMinHeight = min_height; } + void setMaxWidth(S32 width) { mMaxWidth = width;} + void setMaxHeight(S32 height) { mMaxHeight = height;} + private: BOOL pointInHandle( S32 x, S32 y ); @@ -66,7 +69,9 @@ private: LLCoordGL mLastMouseDir; LLPointer mImage; S32 mMinWidth; + S32 mMaxWidth; S32 mMinHeight; + S32 mMaxHeight; const ECorner mCorner; }; -- cgit v1.2.3 From 8912a9bef62386e5eecaa61ba9079d507ae16d90 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 27 Sep 2011 15:53:38 -0700 Subject: EXP-1258 WIP toggle buttons between icons and icons+text modes better button sizing also disabled context menu for non-toolbar region --- indra/llui/llbutton.cpp | 24 ++++++++++++++++++------ indra/llui/llbutton.h | 1 + indra/llui/lltoolbar.cpp | 4 +++- 3 files changed, 22 insertions(+), 7 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 06781f1bdf..02ac928dfb 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -554,6 +554,16 @@ BOOL LLButton::handleHover(S32 x, S32 y, MASK mask) return TRUE; } +void LLButton::getOverlayImageSize(S32& overlay_width, S32& overlay_height) +{ + overlay_width = mImageOverlay->getWidth(); + overlay_height = mImageOverlay->getHeight(); + + F32 scale_factor = llmin((F32)getRect().getWidth() / (F32)overlay_width, (F32)getRect().getHeight() / (F32)overlay_height, 1.f); + overlay_width = llround((F32)overlay_width * scale_factor); + overlay_height = llround((F32)overlay_height * scale_factor); +} + // virtual void LLButton::draw() @@ -781,12 +791,10 @@ void LLButton::draw() if (mImageOverlay.notNull()) { // get max width and height (discard level 0) - S32 overlay_width = mImageOverlay->getWidth(); - S32 overlay_height = mImageOverlay->getHeight(); + S32 overlay_width; + S32 overlay_height; - F32 scale_factor = llmin((F32)getRect().getWidth() / (F32)overlay_width, (F32)getRect().getHeight() / (F32)overlay_height, 1.f); - overlay_width = llround((F32)overlay_width * scale_factor); - overlay_height = llround((F32)overlay_height * scale_factor); + getOverlayImageSize(overlay_width, overlay_height); S32 center_x = getLocalRect().getCenterX(); S32 center_y = getLocalRect().getCenterY(); @@ -994,11 +1002,15 @@ void LLButton::resize(LLUIString label) S32 min_width = label_width + mLeftHPad + mRightHPad; if (mImageOverlay) { + S32 overlay_width = mImageOverlay->getWidth(); + F32 scale_factor = getRect().getHeight() / (F32)mImageOverlay->getHeight(); + overlay_width = llround((F32)overlay_width * scale_factor); + switch(mImageOverlayAlignment) { case LLFontGL::LEFT: case LLFontGL::RIGHT: - min_width += mImageOverlay->getWidth() + mImgOverlayLabelSpace; + min_width += overlay_width + mImgOverlayLabelSpace; break; case LLFontGL::HCENTER: break; diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index bc5e69fad5..08b45e01b3 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -270,6 +270,7 @@ public: protected: LLPointer getImageUnselected() const { return mImageUnselected; } LLPointer getImageSelected() const { return mImageSelected; } + void getOverlayImageSize(S32& overlay_width, S32& overlay_height); LLFrameTimer mMouseDownTimer; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 0c3052b1ab..9ca5a0f480 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -247,7 +247,9 @@ bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled) BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask) { - BOOL handle_it_here = !mReadOnly; + LLRect button_panel_rect; + mButtonPanel->localRectToOtherView(mButtonPanel->getLocalRect(), &button_panel_rect, this); + BOOL handle_it_here = !mReadOnly && button_panel_rect.pointInRect(x, y); if (handle_it_here) { -- cgit v1.2.3 From 68d5141fb3ccb5e898caa83e9eab84d76134e28c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 27 Sep 2011 19:06:02 -0700 Subject: EXP-1258 WIP toggle buttons between icons and icons+text modes fixed button layout for icon+text layout stack now uses floating point precision to avoid clamping panels to 0 --- indra/llui/llbutton.cpp | 2 + indra/llui/lllayoutstack.cpp | 252 +++++++++++++++---------------------------- indra/llui/lllayoutstack.h | 18 ++-- indra/llui/lltoolbar.cpp | 40 ++++--- 4 files changed, 119 insertions(+), 193 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 02ac928dfb..e1bea086b2 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -819,6 +819,7 @@ void LLButton::draw() { case LLFontGL::LEFT: text_left += overlay_width + mImgOverlayLabelSpace; + text_width -= overlay_width + mImgOverlayLabelSpace; mImageOverlay->draw( mLeftHPad, center_y - (overlay_height / 2), @@ -836,6 +837,7 @@ void LLButton::draw() break; case LLFontGL::RIGHT: text_right -= overlay_width + mImgOverlayLabelSpace; + text_width -= overlay_width + mImgOverlayLabelSpace; mImageOverlay->draw( getRect().getWidth() - mRightHPad - overlay_width, center_y - (overlay_height / 2), diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 0d1f608e61..89b3f671a4 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -55,11 +55,12 @@ 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 - mResizeBar(NULL) + mResizeBar(NULL), + mFractionalSize(0.f), + mOrientation(LLLayoutStack::HORIZONTAL) { // Set the expanded min dim if it is provided, otherwise it gets the p.min_dim value if (p.expanded_min_dim.isProvided()) @@ -89,9 +90,22 @@ LLLayoutPanel::~LLLayoutPanel() mResizeBar = NULL; } -F32 LLLayoutPanel::getCollapseFactor(LLLayoutStack::ELayoutOrientation orientation) +void LLLayoutPanel::reshape(S32 width, S32 height, BOOL called_from_parent) { - if (orientation == LLLayoutStack::HORIZONTAL) + if (mOrientation == LLLayoutStack::HORIZONTAL) + { + mFractionalSize += width - llround(mFractionalSize); + } + else + { + mFractionalSize += height - llround(mFractionalSize); + } + LLPanel::reshape(width, height, called_from_parent); +} + +F32 LLLayoutPanel::getCollapseFactor() +{ + if (mOrientation == LLLayoutStack::HORIZONTAL) { F32 collapse_amt = clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, (F32)getRelevantMinDim() / (F32)llmax(1, getRect().getWidth())); @@ -105,14 +119,6 @@ F32 LLLayoutPanel::getCollapseFactor(LLLayoutStack::ELayoutOrientation orientati } } -void LLLayoutPanel::fitToContent() -{ - if (mFitContent) - { - setShape(calcBoundingRect()); - } -} - // // LLLayoutStack // @@ -158,11 +164,11 @@ void LLLayoutStack::draw() // scale clipping rectangle by visible amount if (mOrientation == HORIZONTAL) { - clip_rect.mRight = clip_rect.mLeft + llround((F32)clip_rect.getWidth() * (*panel_it)->getCollapseFactor(mOrientation)); + clip_rect.mRight = clip_rect.mLeft + llround((F32)clip_rect.getWidth() * (*panel_it)->getCollapseFactor()); } else { - clip_rect.mBottom = clip_rect.mTop - llround((F32)clip_rect.getHeight() * (*panel_it)->getCollapseFactor(mOrientation)); + clip_rect.mBottom = clip_rect.mTop - llround((F32)clip_rect.getHeight() * (*panel_it)->getCollapseFactor()); } LLPanel* panelp = (*panel_it); @@ -202,36 +208,15 @@ bool LLLayoutStack::addChild(LLView* child, S32 tab_group) LLLayoutPanel* panelp = dynamic_cast(child); if (panelp) { + panelp->mFractionalSize = (mOrientation == HORIZONTAL) + ? panelp->getRect().getWidth() + : panelp->getRect().getHeight(); + panelp->setOrientation(mOrientation); mPanels.push_back(panelp); } return LLView::addChild(child, tab_group); } - -S32 LLLayoutStack::getDefaultHeight(S32 cur_height) -{ - // if we are spanning our children (crude upward propagation of size) - // then don't enforce our size on our children - if (mOrientation == HORIZONTAL) - { - cur_height = llmax(mMinHeight, getRect().getHeight()); - } - - return cur_height; -} - -S32 LLLayoutStack::getDefaultWidth(S32 cur_width) -{ - // if we are spanning our children (crude upward propagation of size) - // then don't enforce our size on our children - if (mOrientation == VERTICAL) - { - cur_width = llmax(mMinWidth, getRect().getWidth()); - } - - return cur_width; -} - void LLLayoutStack::movePanel(LLPanel* panel_to_move, LLPanel* target_panel, bool move_to_front) { LLLayoutPanel* embedded_panel_to_move = findEmbeddedPanel(panel_to_move); @@ -326,14 +311,15 @@ void LLLayoutStack::updateLayout(BOOL force_resize) createResizeBars(); // calculate current extents - S32 total_width = 0; - S32 total_height = 0; + F32 total_size = 0.f; + // + // animate visibility + // e_panel_list_t::iterator panel_it; for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { LLLayoutPanel* panelp = (*panel_it); - panelp->fitToContent(); if (panelp->getVisible()) { if (mAnimate) @@ -371,181 +357,110 @@ void LLLayoutStack::updateLayout(BOOL force_resize) } } - if (panelp->mCollapsed) - { - panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, 1.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); - } - else - { - panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, 0.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); - } + F32 collapse_state = panelp->mCollapsed ? 1.f : 0.f; + panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, collapse_state, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); - if (mOrientation == HORIZONTAL) + total_size += panelp->mFractionalSize * panelp->getCollapseFactor(); + // want n-1 panel gaps for n panels + if (panel_it != mPanels.begin()) { - // enforce minimize size constraint by default - if (panelp->getRect().getWidth() < panelp->getRelevantMinDim()) - { - panelp->reshape(panelp->getRelevantMinDim(), panelp->getRect().getHeight()); - } - total_width += llround(panelp->getRect().getWidth() * panelp->getCollapseFactor(mOrientation)); - // want n-1 panel gaps for n panels - if (panel_it != mPanels.begin()) - { - total_width += mPanelSpacing; - } - } - else //VERTICAL - { - // enforce minimize size constraint by default - if (panelp->getRect().getHeight() < panelp->getRelevantMinDim()) - { - panelp->reshape(panelp->getRect().getWidth(), panelp->getRelevantMinDim()); - } - total_height += llround(panelp->getRect().getHeight() * panelp->getCollapseFactor(mOrientation)); - if (panel_it != mPanels.begin()) - { - total_height += mPanelSpacing; - } + total_size += mPanelSpacing; } } S32 num_resizable_panels = 0; - S32 shrink_headroom_available = 0; - S32 shrink_headroom_total = 0; + F32 shrink_headroom_available = 0.f; + F32 shrink_headroom_total = 0.f; for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { + LLLayoutPanel* panelp = (*panel_it); + // panels that are not fully visible do not count towards shrink headroom - if ((*panel_it)->getCollapseFactor(mOrientation) < 1.f) + if (panelp->getCollapseFactor() < 1.f) { continue; } - S32 relevant_dimension = (mOrientation == HORIZONTAL) ? (*panel_it)->getRect().getWidth() : (*panel_it)->getRect().getHeight(); - S32 relevant_min = (*panel_it)->getRelevantMinDim(); + F32 cur_size = panelp->mFractionalSize; + F32 min_size = (F32)panelp->getRelevantMinDim(); // if currently resizing a panel or the panel is flagged as not automatically resizing // only track total available headroom, but don't use it for automatic resize logic - if ((*panel_it)->mResizeBar->hasMouseCapture() - || (!(*panel_it)->mAutoResize + if (panelp->mResizeBar->hasMouseCapture() + || (!panelp->mAutoResize && !force_resize)) { - shrink_headroom_total += relevant_dimension - relevant_min; + shrink_headroom_total += cur_size - min_size; } else { num_resizable_panels++; - shrink_headroom_available += relevant_dimension - relevant_min; - shrink_headroom_total += relevant_dimension - relevant_min; + shrink_headroom_available += cur_size - min_size; + shrink_headroom_total += cur_size - min_size; } } // calculate how many pixels need to be distributed among layout panels // positive means panels need to grow, negative means shrink - S32 pixels_to_distribute; - if (mOrientation == HORIZONTAL) - { - pixels_to_distribute = getRect().getWidth() - total_width; - } - else //VERTICAL - { - pixels_to_distribute = getRect().getHeight() - total_height; - } + F32 pixels_to_distribute = (mOrientation == HORIZONTAL) + ? getRect().getWidth() - total_size + : getRect().getHeight() - total_size; // now we distribute the pixels... - S32 cur_x = 0; - S32 cur_y = getRect().getHeight(); + F32 cur_x = 0.f; + F32 cur_y = (F32)getRect().getHeight(); for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { LLLayoutPanel* panelp = (*panel_it); - S32 cur_width = panelp->getRect().getWidth(); - S32 cur_height = panelp->getRect().getHeight(); - S32 new_width = cur_width; - S32 new_height = cur_height; - S32 relevant_min = panelp->getRelevantMinDim(); - - if (mOrientation == HORIZONTAL) - { - new_width = llmax(relevant_min, new_width); - } - else - { - new_height = llmax(relevant_min, new_height); - } - S32 delta_size = 0; + F32 min_size = panelp->getRelevantMinDim(); + F32 delta_size = 0.f; // if panel can automatically resize (not animating, and resize flag set)... - if (panelp->getCollapseFactor(mOrientation) == 1.f + if (panelp->getCollapseFactor() == 1.f && (force_resize || panelp->mAutoResize) && !panelp->mResizeBar->hasMouseCapture()) { - if (mOrientation == HORIZONTAL) + if (pixels_to_distribute < 0.f) { - // if we're shrinking - if (pixels_to_distribute < 0) - { - // 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; - shrink_headroom_available -= (cur_width - relevant_min); - } - else - { - // grow all elements equally - delta_size = llround((F32)pixels_to_distribute / (F32)num_resizable_panels); - num_resizable_panels--; - } - pixels_to_distribute -= delta_size; - new_width = llmax(relevant_min, cur_width + delta_size); + // shrink proportionally to amount over minimum + // so we can do this in one pass + delta_size = (shrink_headroom_available > 0.f) + ? pixels_to_distribute * ((F32)(panelp->mFractionalSize - min_size) / shrink_headroom_available) + : 0.f; + shrink_headroom_available -= (panelp->mFractionalSize - min_size); } else { - new_width = getDefaultWidth(new_width); - } - - if (mOrientation == VERTICAL) - { - if (pixels_to_distribute < 0) - { - // 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_height - relevant_min) / (F32)shrink_headroom_available)) : 0; - shrink_headroom_available -= (cur_height - relevant_min); - } - else - { - delta_size = llround((F32)pixels_to_distribute / (F32)num_resizable_panels); - num_resizable_panels--; - } - pixels_to_distribute -= delta_size; - new_height = llmax(relevant_min, cur_height + delta_size); - } - else - { - new_height = getDefaultHeight(new_height); - } - } - else - { - if (mOrientation == HORIZONTAL) - { - new_height = getDefaultHeight(new_height); - } - else // VERTICAL - { - new_width = getDefaultWidth(new_width); + // grow all elements equally + delta_size = pixels_to_distribute / (F32)num_resizable_panels; + num_resizable_panels--; } + + panelp->mFractionalSize = llmax(min_size, panelp->mFractionalSize + delta_size); + pixels_to_distribute -= delta_size; } // adjust running headroom count based on new sizes shrink_headroom_total += delta_size; LLRect panel_rect; - panel_rect.setLeftTopAndSize(cur_x, cur_y, new_width, new_height); + if (mOrientation == HORIZONTAL) + { + panel_rect.setLeftTopAndSize(llround(cur_x), + llround(cur_y), + llround(panelp->mFractionalSize), + getRect().getHeight()); + } + else + { + panel_rect.setLeftTopAndSize(llround(cur_x), + llround(cur_y), + getRect().getWidth(), + llround(panelp->mFractionalSize)); + } panelp->setShape(panel_rect); LLRect resize_bar_rect = panel_rect; @@ -561,13 +476,14 @@ void LLLayoutStack::updateLayout(BOOL force_resize) } (*panel_it)->mResizeBar->setRect(resize_bar_rect); + F32 size = ((*panel_it)->mFractionalSize * (*panel_it)->getCollapseFactor()) + (F32)mPanelSpacing; if (mOrientation == HORIZONTAL) { - cur_x += llround(new_width * (*panel_it)->getCollapseFactor(mOrientation)) + mPanelSpacing; + cur_x += size; } else //VERTICAL { - cur_y -= llround(new_height * (*panel_it)->getCollapseFactor(mOrientation)) + mPanelSpacing; + cur_y -= size; } } diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 2ed32a2fa9..5d79505fc3 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -126,8 +126,6 @@ protected: private: void createResizeBars(); void calcMinExtents(); - S32 getDefaultHeight(S32 cur_height); - S32 getDefaultWidth(S32 cur_width); const ELayoutOrientation mOrientation; @@ -161,16 +159,14 @@ public: min_dim, max_dim; Optional user_resize, - auto_resize, - fit_content; + auto_resize; 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), - fit_content("fit_content", false) + auto_resize("auto_resize", true) { addSynonym(min_dim, "min_width"); addSynonym(min_dim, "min_height"); @@ -183,6 +179,8 @@ public: void initFromParams(const Params& p); + void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); + S32 getMinDim() const { return mMinDim; } void setMinDim(S32 value) { mMinDim = value; if (!mExpandedMinDimSpecified) mExpandedMinDim = value; } @@ -204,11 +202,12 @@ public: return min_dim; } + void setOrientation(LLLayoutStack::ELayoutOrientation orientation) { mOrientation = orientation; } + protected: LLLayoutPanel(const Params& p); - F32 getCollapseFactor(LLLayoutStack::ELayoutOrientation orientation); - void fitToContent(); + F32 getCollapseFactor(); bool mExpandedMinDimSpecified; S32 mExpandedMinDim; @@ -218,9 +217,10 @@ protected: bool mAutoResize; bool mUserResize; bool mCollapsed; - bool mFitContent; F32 mVisibleAmt; F32 mCollapseAmt; + F32 mFractionalSize; + LLLayoutStack::ELayoutOrientation mOrientation; class LLResizeBar* mResizeBar; }; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 677d50a0c7..57a9151649 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -126,14 +126,13 @@ void LLToolBar::createContextMenu() { // Setup bindings specific to this instance for the context menu options - LLUICtrl::CommitCallbackRegistry::Registrar& commit_reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar(); + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar commit_reg; commit_reg.add("Toolbars.EnableSetting", boost::bind(&LLToolBar::onSettingEnable, this, _2)); - LLUICtrl::EnableCallbackRegistry::Registrar& enable_reg = LLUICtrl::EnableCallbackRegistry::defaultRegistrar(); + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_reg; enable_reg.add("Toolbars.CheckSetting", boost::bind(&LLToolBar::isSettingChecked, this, _2)); // Create the context menu - LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile("menu_toolbars.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); if (menu) @@ -146,10 +145,6 @@ void LLToolBar::createContextMenu() { llwarns << "Unable to load toolbars context menu." << llendl; } - - // Remove this instance's bindings - commit_reg.remove("Toolbars.EnableSetting"); - enable_reg.remove("Toolbars.CheckSetting"); } } @@ -184,7 +179,6 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) center_panel_p.rect = getLocalRect(); center_panel_p.auto_resize = false; center_panel_p.user_resize = false; - center_panel_p.fit_content = true; LLLayoutPanel* center_panel = LLUICtrlFactory::create(center_panel_p); mCenteringStack->addChild(center_panel); @@ -196,6 +190,11 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) mCenteringStack->addChild(LLUICtrlFactory::create(border_panel_p)); + BOOST_FOREACH(LLCommandId::Params params, p.commands) + { + addCommand(params); + } + mNeedsLayout = true; } @@ -207,8 +206,8 @@ bool LLToolBar::addCommand(const LLCommandId& commandId) if (add_command) { - mButtonCommands.push_back(commandId); - createButtons(); + mButtonCommands.push_back(commandId); + createButtons(); } return add_command; @@ -220,9 +219,9 @@ bool LLToolBar::hasCommand(const LLCommandId& commandId) const if (commandId != LLCommandId::null) { - for (std::list::const_iterator cmd = mButtonCommands.begin(); cmd != mButtonCommands.end(); ++cmd) + BOOST_FOREACH(LLCommandId cmd, mButtonCommands) { - if ((*cmd) == commandId) + if (cmd == commandId) { has_command = true; break; @@ -410,11 +409,11 @@ void LLToolBar::updateLayoutAsNeeded() cur_start = row_pad_start; cur_row += max_row_girth + mPadBetween; max_row_girth = 0; - } + } - LLRect button_rect; - if (orientation == LLLayoutStack::HORIZONTAL) - { + 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 @@ -460,6 +459,9 @@ void LLToolBar::updateLayoutAsNeeded() mButtonPanel->reshape(total_girth, max_row_length); } + // make parent fit button panel + mButtonPanel->getParent()->setShape(mButtonPanel->getLocalRect()); + // re-center toolbar buttons mCenteringStack->updateLayout(); @@ -470,7 +472,13 @@ void LLToolBar::updateLayoutAsNeeded() void LLToolBar::draw() { + if (mButtons.empty()) return; updateLayoutAsNeeded(); + // rect may have shifted during layout + LLUI::popMatrix(); + LLUI::pushMatrix(); + LLUI::translate((F32)getRect().mLeft, (F32)getRect().mBottom, 0.f); + LLUICtrl::draw(); } -- cgit v1.2.3 From 78eb989e50e7f91298294d34a743f8ac0e3dcce1 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 27 Sep 2011 19:22:09 -0700 Subject: EXP-1258 FIX toggle buttons between icons and icons+text modes fixed button layout for icon only buttons --- indra/llui/llbutton.cpp | 1 + indra/llui/lltoolbar.cpp | 30 ++++++++++++++++++------------ indra/llui/lltoolbar.h | 1 + 3 files changed, 20 insertions(+), 12 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index e1bea086b2..f259e8027e 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -1015,6 +1015,7 @@ void LLButton::resize(LLUIString label) min_width += overlay_width + mImgOverlayLabelSpace; break; case LLFontGL::HCENTER: + min_width = llmax(min_width, overlay_width + mLeftHPad + mRightHPad); break; default: // draw nothing diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 57a9151649..c5219b11e8 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -207,7 +207,7 @@ bool LLToolBar::addCommand(const LLCommandId& commandId) if (add_command) { mButtonCommands.push_back(commandId); - createButtons(); + createButton(commandId); } return add_command; @@ -498,19 +498,25 @@ void LLToolBar::createButtons() BOOST_FOREACH(LLCommandId& command_id, mButtonCommands) { - LLCommand* commandp = LLCommandManager::instance().getCommand(command_id); - if (!commandp) continue; + createButton(command_id); + } - LLToolBarButton::Params button_p; - button_p.label = LLTrans::getString(commandp->labelRef()); - button_p.image_overlay = LLUI::getUIImage(commandp->icon()); - button_p.overwriteFrom(mButtonParams[mButtonType]); - LLToolBarButton* button = LLUICtrlFactory::create(button_p); +} - mButtons.push_back(button); - mButtonPanel->addChild(button); - } +void LLToolBar::createButton(const LLCommandId& id) +{ + LLCommand* commandp = LLCommandManager::instance().getCommand(id); + if (!commandp) return; + + LLToolBarButton::Params button_p; + button_p.label = LLTrans::getString(commandp->labelRef()); + button_p.tool_tip = button_p.label(); + button_p.image_overlay = LLUI::getUIImage(commandp->icon()); + button_p.overwriteFrom(mButtonParams[mButtonType]); + LLToolBarButton* button = LLUICtrlFactory::create(button_p); + + mButtons.push_back(button); + mButtonPanel->addChild(button); mNeedsLayout = true; } - diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 75ae499a3d..02db58128c 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -135,6 +135,7 @@ private: void createContextMenu(); void updateLayoutAsNeeded(); void createButtons(); + void createButton(const LLCommandId& id); void resizeButtonsInRow(std::vector& buttons_in_row, S32 max_row_girth); BOOL isSettingChecked(const LLSD& userdata); void onSettingEnable(const LLSD& userdata); -- cgit v1.2.3 From 04a5c45020e72e7e24eed1cc1f53014da92594e5 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 27 Sep 2011 20:24:00 -0700 Subject: EXP-1207 : Commented out the red and yellow debug draw on the toolbars --- indra/llui/lltoolbarview.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 7047cca948..641c3eb0ab 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -193,7 +193,6 @@ void LLToolBarView::draw() if (mToolbarLeft) mToolbarLeft->localRectToOtherView(mToolbarLeft->getLocalRect(), &left_rect, this); if (mToolbarRight) mToolbarRight->localRectToOtherView(mToolbarRight->getLocalRect(), &right_rect, this); - if ((old_width != getRect().getWidth()) || (old_height != getRect().getHeight())) debug_print = true; if (debug_print) @@ -215,9 +214,9 @@ void LLToolBarView::draw() back_color_hori[VALPHA] = 0.5f; back_color_vert[VALPHA] = 0.5f; //gl_rect_2d(getLocalRect(), back_color, TRUE); - gl_rect_2d(bottom_rect, back_color_hori, TRUE); - gl_rect_2d(left_rect, back_color_vert, TRUE); - gl_rect_2d(right_rect, back_color_vert, TRUE); + //gl_rect_2d(bottom_rect, back_color_hori, TRUE); + //gl_rect_2d(left_rect, back_color_vert, TRUE); + //gl_rect_2d(right_rect, back_color_vert, TRUE); LLUICtrl::draw(); } -- cgit v1.2.3 From b234c23aa3c70ccac6d4332532a0da6184ec03db Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 27 Sep 2011 20:51:26 -0700 Subject: EXP-1211 : Factorize code a bit --- indra/llui/lltoolbarview.cpp | 48 +++++++++++++++++--------------------------- indra/llui/lltoolbarview.h | 1 + 2 files changed, 19 insertions(+), 30 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 641c3eb0ab..73c8c99418 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -80,52 +80,25 @@ bool LLToolBarView::load() } // Add commands to each toolbar - // *TODO: factorize that code : tricky with Blocks though, simple lexical approach fails - LLCommandManager& mgr = LLCommandManager::instance(); - if (toolbar_set.left_toolbar.isProvided() && mToolbarLeft) { BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands) { - LLCommandId* commandId = new LLCommandId(command); - if (mgr.getCommand(*commandId)) - { - mToolbarLeft->addCommand(*commandId); - } - else - { - llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; - } + addCommand(LLCommandId(command),mToolbarLeft); } } if (toolbar_set.right_toolbar.isProvided() && mToolbarRight) { BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands) { - LLCommandId* commandId = new LLCommandId(command); - if (mgr.getCommand(*commandId)) - { - mToolbarRight->addCommand(*commandId); - } - else - { - llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; - } + addCommand(LLCommandId(command),mToolbarRight); } } if (toolbar_set.bottom_toolbar.isProvided() && mToolbarBottom) { BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands) { - LLCommandId* commandId = new LLCommandId(command); - if (mgr.getCommand(*commandId)) - { - mToolbarBottom->addCommand(*commandId); - } - else - { - llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; - } + addCommand(LLCommandId(command),mToolbarBottom); } } return true; @@ -179,6 +152,21 @@ bool LLToolBarView::hasCommand(const LLCommandId& commandId) const return has_command; } +bool LLToolBarView::addCommand(const LLCommandId& command, LLToolBar* toolbar) +{ + LLCommandManager& mgr = LLCommandManager::instance(); + if (mgr.getCommand(command)) + { + toolbar->addCommand(command); + } + else + { + llwarns << "Toolbars creation : the command " << command.name() << " cannot be found in the command manager" << llendl; + return false; + } + return true; +} + void LLToolBarView::draw() { static bool debug_print = true; diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 0f16b89ecc..208660da8e 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -78,6 +78,7 @@ protected: private: // Loads the toolbars from the existing user or default settings bool load(); // return false if load fails + bool addCommand(const LLCommandId& commandId, LLToolBar* toolbar); // Pointers to the toolbars handled by the toolbar view LLToolBar* mToolbarLeft; -- cgit v1.2.3 From 15f3ea39d7deb0c956b56703a94f6d072b7f2d21 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 27 Sep 2011 22:45:09 -0700 Subject: EXP-1257 : Save toolbar settings in a per user toolbars.xml file --- indra/llui/llcommandmanager.h | 2 + indra/llui/lltoolbar.h | 3 +- indra/llui/lltoolbarview.cpp | 172 +++++++++++++++++++++++++++++------------- indra/llui/lltoolbarview.h | 3 +- 4 files changed, 124 insertions(+), 56 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 8435d915f3..4781f77177 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -81,6 +81,8 @@ private: std::string mName; }; +typedef std::list command_id_list_t; + class LLCommand { public: diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 02db58128c..8e484c7e13 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -123,6 +123,7 @@ public: bool addCommand(const LLCommandId& commandId); bool hasCommand(const LLCommandId& commandId) const; bool enableCommand(const LLCommandId& commandId, bool enabled); + command_id_list_t& getCommandsList() { return mButtonCommands; } protected: friend class LLUICtrlFactory; @@ -143,7 +144,7 @@ private: const bool mReadOnly; std::list mButtons; - std::list mButtonCommands; + command_id_list_t mButtonCommands; LLToolBarEnums::ButtonType mButtonType; LLLayoutStack* mCenteringStack; LLLayoutStack* mWrapStack; diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 73c8c99418..aee7ffa517 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -50,59 +50,6 @@ LLToolBarView::ToolbarSet::ToolbarSet() bottom_toolbar("bottom_toolbar") {} -bool LLToolBarView::load() -{ - LLToolBarView::ToolbarSet toolbar_set; - - // Load the default toolbars.xml file - // *TODO : pick up the user's toolbar setting if existing - std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); - - LLXMLNodePtr root; - if(!LLXMLNode::parseFile(toolbar_file, root, NULL)) - { - llerrs << "Unable to load toolbars from file: " << toolbar_file << llendl; - return false; - } - if(!root->hasName("toolbars")) - { - llwarns << toolbar_file << " is not a valid toolbars definition file" << llendl; - return false; - } - - // Parse the toolbar settings - LLXUIParser parser; - parser.readXUI(root, toolbar_set, toolbar_file); - if (!toolbar_set.validateBlock()) - { - llerrs << "Unable to validate toolbars from file: " << toolbar_file << llendl; - return false; - } - - // Add commands to each toolbar - if (toolbar_set.left_toolbar.isProvided() && mToolbarLeft) - { - BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands) - { - addCommand(LLCommandId(command),mToolbarLeft); - } - } - if (toolbar_set.right_toolbar.isProvided() && mToolbarRight) - { - BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands) - { - addCommand(LLCommandId(command),mToolbarRight); - } - } - if (toolbar_set.bottom_toolbar.isProvided() && mToolbarBottom) - { - BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands) - { - addCommand(LLCommandId(command),mToolbarBottom); - } - } - return true; -} LLToolBarView::LLToolBarView(const LLToolBarView::Params& p) : LLUICtrl(p), @@ -120,6 +67,7 @@ void LLToolBarView::initFromParams(const LLToolBarView::Params& p) LLToolBarView::~LLToolBarView() { + saveToolbars(); } BOOL LLToolBarView::postBuild() @@ -129,7 +77,7 @@ BOOL LLToolBarView::postBuild() mToolbarBottom = getChild("toolbar_bottom"); // Load the toolbars from the settings - load(); + loadToolbars(); return TRUE; } @@ -167,6 +115,122 @@ bool LLToolBarView::addCommand(const LLCommandId& command, LLToolBar* toolbar) return true; } +bool LLToolBarView::loadToolbars() +{ + LLToolBarView::ToolbarSet toolbar_set; + + // Load the default toolbars.xml file + // *TODO : pick up the user's toolbar setting if existing + std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); + + LLXMLNodePtr root; + if(!LLXMLNode::parseFile(toolbar_file, root, NULL)) + { + llerrs << "Unable to load toolbars from file: " << toolbar_file << llendl; + return false; + } + if(!root->hasName("toolbars")) + { + llwarns << toolbar_file << " is not a valid toolbars definition file" << llendl; + return false; + } + + // Parse the toolbar settings + LLXUIParser parser; + parser.readXUI(root, toolbar_set, toolbar_file); + if (!toolbar_set.validateBlock()) + { + llerrs << "Unable to validate toolbars from file: " << toolbar_file << llendl; + return false; + } + + // Add commands to each toolbar + if (toolbar_set.left_toolbar.isProvided() && mToolbarLeft) + { + BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands) + { + addCommand(LLCommandId(command),mToolbarLeft); + } + } + if (toolbar_set.right_toolbar.isProvided() && mToolbarRight) + { + BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands) + { + addCommand(LLCommandId(command),mToolbarRight); + } + } + if (toolbar_set.bottom_toolbar.isProvided() && mToolbarBottom) + { + BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands) + { + addCommand(LLCommandId(command),mToolbarBottom); + } + } + return true; +} + +void LLToolBarView::saveToolbars() const +{ + // Build the parameter tree from the toolbar data + LLToolBarView::ToolbarSet toolbar_set; + + // *TODO : factorize that code a bit... + if (mToolbarLeft) + { + command_id_list_t& command_list = mToolbarLeft->getCommandsList(); + for (command_id_list_t::const_iterator it = command_list.begin(); + it != command_list.end(); + ++it) + { + LLCommandId::Params command; + command.name = it->name(); + toolbar_set.left_toolbar.commands.add(command); + } + } + if (mToolbarRight) + { + command_id_list_t& command_list = mToolbarRight->getCommandsList(); + for (command_id_list_t::const_iterator it = command_list.begin(); + it != command_list.end(); + ++it) + { + LLCommandId::Params command; + command.name = it->name(); + toolbar_set.right_toolbar.commands.add(command); + } + } + if (mToolbarBottom) + { + command_id_list_t& command_list = mToolbarBottom->getCommandsList(); + for (command_id_list_t::const_iterator it = command_list.begin(); + it != command_list.end(); + ++it) + { + LLCommandId::Params command; + command.name = it->name(); + toolbar_set.bottom_toolbar.commands.add(command); + } + } + + // Serialize the parameter tree + LLXMLNodePtr output_node = new LLXMLNode("toolbars", false); + LLXUIParser parser; + parser.writeXUI(output_node, toolbar_set); + + // Write the resulting XML to file + if(!output_node->isNull()) + { + const std::string& filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml"); + LLFILE *fp = LLFile::fopen(filename, "w"); + if (fp != NULL) + { + LLXMLNode::writeHeaderToFile(fp); + output_node->writeToFile(fp); + fclose(fp); + } + } +} + void LLToolBarView::draw() { static bool debug_print = true; diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 208660da8e..646a1fd636 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -77,7 +77,8 @@ protected: private: // Loads the toolbars from the existing user or default settings - bool load(); // return false if load fails + bool loadToolbars(); // return false if load fails + void saveToolbars() const; bool addCommand(const LLCommandId& commandId, LLToolBar* toolbar); // Pointers to the toolbars handled by the toolbar view -- cgit v1.2.3 From e4e499e326812e66de9b9c0392ea9899a6e71e63 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 28 Sep 2011 10:27:03 -0700 Subject: EXP-1261 FIX Left hand toolbar does not show labels when icons and labels option selected --- indra/llui/lltoolbarview.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index aee7ffa517..b374a0bfc4 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -241,9 +241,21 @@ void LLToolBarView::draw() LLRect bottom_rect, left_rect, right_rect; - if (mToolbarBottom) mToolbarBottom->localRectToOtherView(mToolbarBottom->getLocalRect(), &bottom_rect, this); - if (mToolbarLeft) mToolbarLeft->localRectToOtherView(mToolbarLeft->getLocalRect(), &left_rect, this); - if (mToolbarRight) mToolbarRight->localRectToOtherView(mToolbarRight->getLocalRect(), &right_rect, this); + if (mToolbarBottom) + { + mToolbarBottom->getParent()->reshape(mToolbarBottom->getParent()->getRect().getWidth(), mToolbarBottom->getRect().getHeight()); + mToolbarBottom->localRectToOtherView(mToolbarBottom->getLocalRect(), &bottom_rect, this); + } + if (mToolbarLeft) + { + mToolbarLeft->getParent()->reshape(mToolbarLeft->getRect().getWidth(), mToolbarLeft->getParent()->getRect().getHeight()); + mToolbarLeft->localRectToOtherView(mToolbarLeft->getLocalRect(), &left_rect, this); + } + if (mToolbarRight) + { + mToolbarRight->getParent()->reshape(mToolbarRight->getRect().getWidth(), mToolbarRight->getParent()->getRect().getHeight()); + mToolbarRight->localRectToOtherView(mToolbarRight->getLocalRect(), &right_rect, this); + } if ((old_width != getRect().getWidth()) || (old_height != getRect().getHeight())) debug_print = true; -- cgit v1.2.3 From fc0f5173eb20fad8934420e6eec8873d71490894 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 28 Sep 2011 10:40:28 -0700 Subject: fix linux build --- indra/llui/lllayoutstack.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 89b3f671a4..4991c4afa6 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -498,13 +498,13 @@ void LLLayoutStack::updateLayout(BOOL force_resize) { (*panel_it)->mResizeBar->setResizeLimits( relevant_min, - relevant_min + shrink_headroom_total); + relevant_min + llround(shrink_headroom_total)); } else //VERTICAL { (*panel_it)->mResizeBar->setResizeLimits( relevant_min, - relevant_min + shrink_headroom_total); + relevant_min + llround(shrink_headroom_total)); } // toggle resize bars based on panel visibility, resizability, etc -- cgit v1.2.3 From 21543fdf26e8104d00bd683bdff5185d6dd620ef Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 28 Sep 2011 16:23:04 -0700 Subject: EXP-1257 : Implemented loading of toolbar settings per user account. Also factorize a bit and clean up the related saveToolbars code. --- indra/llui/lltoolbarview.cpp | 56 +++++++++++++++++--------------------------- indra/llui/lltoolbarview.h | 6 +++-- 2 files changed, 26 insertions(+), 36 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index aee7ffa517..140a26ddd5 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -76,9 +76,6 @@ BOOL LLToolBarView::postBuild() mToolbarRight = getChild("toolbar_right"); mToolbarBottom = getChild("toolbar_bottom"); - // Load the toolbars from the settings - loadToolbars(); - return TRUE; } @@ -120,8 +117,12 @@ bool LLToolBarView::loadToolbars() LLToolBarView::ToolbarSet toolbar_set; // Load the default toolbars.xml file - // *TODO : pick up the user's toolbar setting if existing - std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); + std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml"); + if (!gDirUtilp->fileExists(toolbar_file)) + { + llwarns << "User toolbars def not found -> use default" << llendl; + toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); + } LLXMLNodePtr root; if(!LLXMLNode::parseFile(toolbar_file, root, NULL)) @@ -173,43 +174,17 @@ void LLToolBarView::saveToolbars() const { // Build the parameter tree from the toolbar data LLToolBarView::ToolbarSet toolbar_set; - - // *TODO : factorize that code a bit... if (mToolbarLeft) { - command_id_list_t& command_list = mToolbarLeft->getCommandsList(); - for (command_id_list_t::const_iterator it = command_list.begin(); - it != command_list.end(); - ++it) - { - LLCommandId::Params command; - command.name = it->name(); - toolbar_set.left_toolbar.commands.add(command); - } + addToToolset(mToolbarLeft->getCommandsList(),toolbar_set.left_toolbar); } if (mToolbarRight) { - command_id_list_t& command_list = mToolbarRight->getCommandsList(); - for (command_id_list_t::const_iterator it = command_list.begin(); - it != command_list.end(); - ++it) - { - LLCommandId::Params command; - command.name = it->name(); - toolbar_set.right_toolbar.commands.add(command); - } + addToToolset(mToolbarRight->getCommandsList(),toolbar_set.right_toolbar); } if (mToolbarBottom) { - command_id_list_t& command_list = mToolbarBottom->getCommandsList(); - for (command_id_list_t::const_iterator it = command_list.begin(); - it != command_list.end(); - ++it) - { - LLCommandId::Params command; - command.name = it->name(); - toolbar_set.bottom_toolbar.commands.add(command); - } + addToToolset(mToolbarBottom->getCommandsList(),toolbar_set.bottom_toolbar); } // Serialize the parameter tree @@ -231,6 +206,19 @@ void LLToolBarView::saveToolbars() const } } +// Enumerate the commands in command_list and add them as Params to the toolbar +void LLToolBarView::addToToolset(command_id_list_t& command_list, Toolbar& toolbar) const +{ + for (command_id_list_t::const_iterator it = command_list.begin(); + it != command_list.end(); + ++it) + { + LLCommandId::Params command; + command.name = it->name(); + toolbar.commands.add(command); + } +} + void LLToolBarView::draw() { static bool debug_print = true; diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 646a1fd636..b19841997b 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -67,7 +67,10 @@ public: virtual void draw(); // Toolbar view interface with the rest of the world + // Checks if the commandId is being used somewhere in one of the toolbars bool hasCommand(const LLCommandId& commandId) const; + // Loads the toolbars from the existing user or default settings + bool loadToolbars(); // return false if load fails protected: friend class LLUICtrlFactory; @@ -76,10 +79,9 @@ protected: void initFromParams(const Params&); private: - // Loads the toolbars from the existing user or default settings - bool loadToolbars(); // return false if load fails void saveToolbars() const; bool addCommand(const LLCommandId& commandId, LLToolBar* toolbar); + void addToToolset(command_id_list_t& command_list, Toolbar& toolbar) const; // Pointers to the toolbars handled by the toolbar view LLToolBar* mToolbarLeft; -- cgit v1.2.3 From 6a49f2947f05963c577a1644c16a8affc779da63 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 28 Sep 2011 16:25:32 -0700 Subject: EXP-1234 WIP experimental drag and drop --- indra/llui/lltoolbar.cpp | 93 ++++++++++++++++++++++++++++++-------------- indra/llui/lltoolbar.h | 16 +++++++- indra/llui/lltoolbarview.cpp | 41 ++++++++++++++++++- indra/llui/lltoolbarview.h | 9 ++++- indra/llui/llview.h | 14 +++++++ 5 files changed, 140 insertions(+), 33 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index c5219b11e8..fe989cee22 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -33,6 +33,7 @@ #include "llcommandmanager.h" #include "llmenugl.h" #include "lltrans.h" +#include "lltoolbarview.h" // uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit // thanks, MSVC! @@ -201,35 +202,27 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) bool LLToolBar::addCommand(const LLCommandId& commandId) { LLCommand * command = LLCommandManager::instance().getCommand(commandId); + if (!command) return false; - bool add_command = (command != NULL); - - if (add_command) - { - mButtonCommands.push_back(commandId); - createButton(commandId); - } + mButtonCommands.push_back(commandId); + LLToolBarButton* button = createButton(commandId); + mButtons.push_back(button); + mButtonPanel->addChild(button); + mButtonMap.insert(std::make_pair(commandId, button)); + mNeedsLayout = true; - return add_command; + return true; } bool LLToolBar::hasCommand(const LLCommandId& commandId) const { - bool has_command = false; - if (commandId != LLCommandId::null) { - BOOST_FOREACH(LLCommandId cmd, mButtonCommands) - { - if (cmd == commandId) - { - has_command = true; - break; - } - } + command_id_map::const_iterator it = mButtonMap.find(commandId); + return (it != mButtonMap.end()); } - return has_command; + return false; } bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled) @@ -238,11 +231,10 @@ bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled) if (commandId != LLCommandId::null) { - command_button = mButtonPanel->findChild(commandId.name()); - - if (command_button) + command_id_map::iterator it = mButtonMap.find(commandId); + if (it != mButtonMap.end()) { - command_button->setEnabled(enabled); + it->second->setEnabled(enabled); } } @@ -498,15 +490,19 @@ void LLToolBar::createButtons() BOOST_FOREACH(LLCommandId& command_id, mButtonCommands) { - createButton(command_id); + LLToolBarButton* button = createButton(command_id); + mButtons.push_back(button); + mButtonPanel->addChild(button); + mButtonMap.insert(std::make_pair(command_id, button)); } + mNeedsLayout = true; } -void LLToolBar::createButton(const LLCommandId& id) +LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) { LLCommand* commandp = LLCommandManager::instance().getCommand(id); - if (!commandp) return; + if (!commandp) return NULL; LLToolBarButton::Params button_p; button_p.label = LLTrans::getString(commandp->labelRef()); @@ -515,8 +511,47 @@ void LLToolBar::createButton(const LLCommandId& id) button_p.overwriteFrom(mButtonParams[mButtonType]); LLToolBarButton* button = LLUICtrlFactory::create(button_p); - mButtons.push_back(button); - mButtonPanel->addChild(button); + button->setCommandId(id); + return button; +} - mNeedsLayout = true; +// +// LLToolBarButton +// + +LLToolBarButton::LLToolBarButton(const Params& p) +: LLButton(p), + mMouseDownX(0), + mMouseDownY(0), + mId("") +{} + + +BOOL LLToolBarButton::handleMouseDown(S32 x, S32 y, MASK mask) +{ + mMouseDownX = x; + mMouseDownY = y; + return LLButton::handleMouseDown(x, y, mask); +} + +BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask) +{ + if (hasMouseCapture()) + { + S32 dist_squared = (x - mMouseDownX) * (x - mMouseDownX) + (y - mMouseDownY) * (y - mMouseDownY); + S32 threshold = LLUI::sSettingGroups["config"]->getS32("DragAndDropDistanceThreshold"); + S32 threshold_squared = threshold * threshold; + if (dist_squared > threshold_squared) + { + // start drag and drop + LLToolBarView* view = getParentByType(); + LLToolBar* bar = getParentByType(); + if (view) + { + view->startDrag(bar->createButton(mId)); + setVisible(FALSE); + } + } + } + return LLButton::handleHover(x, y, mask); } diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 8e484c7e13..77bac87dbc 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -42,7 +42,15 @@ public: { }; - LLToolBarButton(const Params& p) : LLButton(p) {} + LLToolBarButton(const Params& p); + + BOOL handleMouseDown(S32 x, S32 y, MASK mask); + BOOL handleHover(S32 x, S32 y, MASK mask); + void setCommandId(const LLCommandId& id) { mId = id; } +private: + LLCommandId mId; + S32 mMouseDownX; + S32 mMouseDownY; }; @@ -125,6 +133,8 @@ public: bool enableCommand(const LLCommandId& commandId, bool enabled); command_id_list_t& getCommandsList() { return mButtonCommands; } + LLToolBarButton* createButton(const LLCommandId& id); + protected: friend class LLUICtrlFactory; LLToolBar(const Params&); @@ -136,7 +146,6 @@ private: void createContextMenu(); void updateLayoutAsNeeded(); void createButtons(); - void createButton(const LLCommandId& id); void resizeButtonsInRow(std::vector& buttons_in_row, S32 max_row_girth); BOOL isSettingChecked(const LLSD& userdata); void onSettingEnable(const LLSD& userdata); @@ -145,6 +154,9 @@ private: std::list mButtons; command_id_list_t mButtonCommands; + typedef std::map command_id_map; + command_id_map mButtonMap; + LLToolBarEnums::ButtonType mButtonType; LLLayoutStack* mCenteringStack; LLLayoutStack* mWrapStack; diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index b374a0bfc4..0c3a6bd0ac 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -55,7 +55,10 @@ LLToolBarView::LLToolBarView(const LLToolBarView::Params& p) : LLUICtrl(p), mToolbarLeft(NULL), mToolbarRight(NULL), - mToolbarBottom(NULL) + mToolbarBottom(NULL), + mDragButton(NULL), + mMouseX(0), + mMouseY(0) { } @@ -283,4 +286,40 @@ void LLToolBarView::draw() //gl_rect_2d(right_rect, back_color_vert, TRUE); LLUICtrl::draw(); + + if (mDragButton) + { + S32 cursor_x, cursor_y; + mDragButton->setOrigin(mMouseX - mDragButton->getRect().getWidth(), mMouseY - mDragButton->getRect().getHeight()); + drawChild(mDragButton); + } +} + +void LLToolBarView::startDrag(LLToolBarButton* button) +{ + mDragButton = button; + addChild(mDragButton); + gFocusMgr.setMouseCapture(this); +} + +BOOL LLToolBarView::handleHover(S32 x, S32 y, MASK mask) +{ + mMouseX = x; + mMouseY = y; + return LLUICtrl::handleHover(x, y, mask); +} + +BOOL LLToolBarView::handleMouseUp(S32 x, S32 y, MASK mask) +{ + if (hasMouseCapture()) + { + gFocusMgr.setMouseCapture(NULL); + } + return LLUICtrl::handleMouseUp(x, y, mask); +} + +void LLToolBarView::onMouseCaptureLost() +{ + delete mDragButton; + mDragButton = NULL; } diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 646a1fd636..cbe3d6c083 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -65,7 +65,10 @@ public: virtual ~LLToolBarView(); virtual BOOL postBuild(); virtual void draw(); - + virtual BOOL handleHover(S32 x, S32 y, MASK mask); + virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); + virtual void onMouseCaptureLost(); + void startDrag(LLToolBarButton*); // Toolbar view interface with the rest of the world bool hasCommand(const LLCommandId& commandId) const; @@ -85,6 +88,10 @@ private: LLToolBar* mToolbarLeft; LLToolBar* mToolbarRight; LLToolBar* mToolbarBottom; + bool mDragging; + LLToolBarButton* mDragButton; + S32 mMouseX; + S32 mMouseY; }; extern LLToolBarView* gToolBarView; diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 9039366e7e..f4e31b109a 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -465,6 +465,20 @@ public: return dynamic_cast(widgetp); } + template T* getParentByType() const + { + LLView* parent = getParent(); + while(parent) + { + if (dynamic_cast(parent)) + { + return static_cast(parent); + } + parent = parent->getParent(); + } + return NULL; + } + ////////////////////////////////////////////// // statics ////////////////////////////////////////////// -- cgit v1.2.3 From fdf042bdb9aeefa209694e04d4012a3a1f911a52 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 28 Sep 2011 16:54:34 -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 FIX -- Populate the toybox floater window with all FUI toolbar buttons indicated as such in the "commands.xml" definition. EXP-1267 FIX -- Enable/disable buttons in the toybox * Hooked up button callbacks to the toolbar buttons * Fixed toybox button enable/disable to function properly and live update as buttons change states. * Removed the toybox toolbar background image Reviewed by Leyla --- indra/llui/llcommandmanager.cpp | 4 ++-- indra/llui/llcommandmanager.h | 6 +++--- indra/llui/lltoolbar.cpp | 10 +++++++++- indra/llui/lluictrl.cpp | 10 ++++++++++ indra/llui/lluictrl.h | 3 +++ 5 files changed, 27 insertions(+), 6 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index 783990780b..b1147134c2 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -53,7 +53,7 @@ LLCommand::Params::Params() , icon("icon") , label_ref("label_ref") , name("name") - , param("param") + , parameter("parameter") , tooltip_ref("tooltip_ref") { } @@ -64,7 +64,7 @@ LLCommand::LLCommand(const LLCommand::Params& p) , mIcon(p.icon) , mIdentifier(p.name) , mLabelRef(p.label_ref) - , mParam(p.param) + , mParameter(p.parameter) , mTooltipRef(p.tooltip_ref) { } diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 4781f77177..6481a05689 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -93,7 +93,7 @@ public: Mandatory icon; Mandatory label_ref; Mandatory name; - Optional param; + Optional parameter; Mandatory tooltip_ref; Params(); @@ -106,7 +106,7 @@ public: const std::string& icon() const { return mIcon; } const LLCommandId& id() const { return mIdentifier; } const std::string& labelRef() const { return mLabelRef; } - const std::string& param() const { return mParam; } + const LLSD& parameter() const { return mParameter; } const std::string& tooltipRef() const { return mTooltipRef; } private: @@ -116,7 +116,7 @@ private: std::string mFunction; std::string mIcon; std::string mLabelRef; - std::string mParam; + LLSD mParameter; std::string mTooltipRef; }; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index c5219b11e8..45567d5859 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -500,7 +500,6 @@ void LLToolBar::createButtons() { createButton(command_id); } - } void LLToolBar::createButton(const LLCommandId& id) @@ -509,12 +508,21 @@ void LLToolBar::createButton(const LLCommandId& id) if (!commandp) return; LLToolBarButton::Params button_p; + button_p.name = id.name(); button_p.label = LLTrans::getString(commandp->labelRef()); button_p.tool_tip = button_p.label(); button_p.image_overlay = LLUI::getUIImage(commandp->icon()); button_p.overwriteFrom(mButtonParams[mButtonType]); LLToolBarButton* button = LLUICtrlFactory::create(button_p); + if (!mReadOnly) + { + LLUICtrl::CommitCallbackParam cbParam; + cbParam.function_name = commandp->functionName(); + cbParam.parameter = commandp->parameter(); + button->setCommitCallback(cbParam); + } + mButtons.push_back(button); mButtonPanel->addChild(button); diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index d58df5801b..5e8bf498c0 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -992,6 +992,16 @@ void LLUICtrl::setTransparencyType(ETypeTransparency type) mTransparencyType = type; } +boost::signals2::connection LLUICtrl::setCommitCallback(const CommitCallbackParam& cb) +{ + return setCommitCallback(initCommitCallback(cb)); +} + +boost::signals2::connection LLUICtrl::setValidateCallback(const EnableCallbackParam& cb) +{ + return setValidateCallback(initEnableCallback(cb)); +} + boost::signals2::connection LLUICtrl::setCommitCallback( const commit_signal_t::slot_type& cb ) { if (!mCommitSignal) mCommitSignal = new commit_signal_t(); diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 09bed9b958..fc56e5fc35 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -235,6 +235,9 @@ public: // topic then put in help_topic_out bool findHelpTopic(std::string& help_topic_out); + boost::signals2::connection setCommitCallback(const CommitCallbackParam& cb); + boost::signals2::connection setValidateCallback(const EnableCallbackParam& cb); + boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb ); boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb ); -- cgit v1.2.3 From 896ea6f81eaf409aae22158816226f09a459ca34 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 29 Sep 2011 14:42:30 -0700 Subject: EXP-1278 FIX -- Implement 3-way toolbar button functionality Toolbar buttons now affect their floaters as indicated in the FUI_Button_states wiki page -- https://wiki.lindenlab.com/wiki/FUI_Button_states --- indra/llui/llfloaterreg.cpp | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index bc740dde17..8a0513f246 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -455,12 +455,42 @@ void LLFloaterReg::toggleFloaterInstance(const LLSD& sdname) //static void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) { - // Do some extra logic here for 3-state toolbar floater toggling madness :) - + // + // Floaters controlled by the toolbar behave a bit differently from others. + // Namely they have 3-4 states as defined in the design wiki page here: + // https://wiki.lindenlab.com/wiki/FUI_Button_states + // + // The basic idea is this: + // * If the target floater is minimized, this button press will un-minimize it. + // * Else if the target floater is closed open it. + // * Else if the target floater does not have focus, give it focus. + // * Also, if it is not on top, bring it forward when focus is given. + // * Else the target floater is open, close it. + // + + // First parse the parameter LLSD key; std::string name = sdname.asString(); parse_name_key(name, key); - toggleInstance(name, key); + + LLFloater* instance = findInstance(name, key); + + if (LLFloater::isMinimized(instance)) + { + instance->setMinimized(FALSE); + } + else if (!LLFloater::isShown(instance)) + { + showInstance(name, key, TRUE); + } + else if (!instance->hasFocus()) + { + instance->setFocus(TRUE); + } + else + { + instance->closeFloater(); + } } //static -- cgit v1.2.3 From b07e7c7198fbc78ca852b3ba48d516ec2901da21 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 29 Sep 2011 15:01:15 -0700 Subject: EXP-1211, EXP-1257 : Save and load the button type along with the toolbars, add a force default load option, enforce consistency between menus and toolbars --- indra/llui/lltoolbar.cpp | 27 +++++++++++++++++++------- indra/llui/lltoolbar.h | 8 +++++++- indra/llui/lltoolbarview.cpp | 45 ++++++++++++++++++++++++++++++++++++++++---- indra/llui/lltoolbarview.h | 6 ++++-- 4 files changed, 72 insertions(+), 14 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 45567d5859..75c7d91f8a 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -213,6 +213,14 @@ bool LLToolBar::addCommand(const LLCommandId& commandId) return add_command; } +void LLToolBar::clearCommandsList() +{ + // Clears the commands list + mButtonCommands.clear(); + // This will clear the buttons + createButtons(); +} + bool LLToolBar::hasCommand(const LLCommandId& commandId) const { bool has_command = false; @@ -278,7 +286,7 @@ BOOL LLToolBar::isSettingChecked(const LLSD& userdata) const std::string setting_name = userdata.asString(); - if (setting_name == "icons_and_labels") + if (setting_name == "icons_with_text") { retval = (mButtonType == BTNTYPE_ICONS_WITH_TEXT); } @@ -296,18 +304,23 @@ void LLToolBar::onSettingEnable(const LLSD& userdata) const std::string setting_name = userdata.asString(); - const ButtonType current_button_type = mButtonType; - - if (setting_name == "icons_and_labels") + if (setting_name == "icons_with_text") { - mButtonType = BTNTYPE_ICONS_WITH_TEXT; + setButtonType(BTNTYPE_ICONS_WITH_TEXT); } else if (setting_name == "icons_only") { - mButtonType = BTNTYPE_ICONS_ONLY; + setButtonType(BTNTYPE_ICONS_ONLY); } +} - if(current_button_type != mButtonType) +void LLToolBar::setButtonType(LLToolBarEnums::ButtonType button_type) +{ + bool regenerate_buttons = (mButtonType != button_type); + + mButtonType = button_type; + + if (regenerate_buttons) { createButtons(); } diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 8e484c7e13..03b1756988 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -123,7 +123,6 @@ public: bool addCommand(const LLCommandId& commandId); bool hasCommand(const LLCommandId& commandId) const; bool enableCommand(const LLCommandId& commandId, bool enabled); - command_id_list_t& getCommandsList() { return mButtonCommands; } protected: friend class LLUICtrlFactory; @@ -132,6 +131,13 @@ protected: void initFromParams(const Params&); +public: + // Methods used in loading and saving toolbar settings + void setButtonType(LLToolBarEnums::ButtonType button_type); + LLToolBarEnums::ButtonType getButtonType() { return mButtonType; } + command_id_list_t& getCommandsList() { return mButtonCommands; } + void clearCommandsList(); + private: void createContextMenu(); void updateLayoutAsNeeded(); diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index f60598edcb..1c6cf3230b 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -41,7 +41,8 @@ LLToolBarView* gToolBarView = NULL; static LLDefaultChildRegistry::Register r("toolbar_view"); LLToolBarView::Toolbar::Toolbar() -: commands("command") +: button_display_mode("button_display_mode"), + commands("command") {} LLToolBarView::ToolbarSet::ToolbarSet() @@ -112,13 +113,17 @@ bool LLToolBarView::addCommand(const LLCommandId& command, LLToolBar* toolbar) return true; } -bool LLToolBarView::loadToolbars() +bool LLToolBarView::loadToolbars(bool force_default) { LLToolBarView::ToolbarSet toolbar_set; - // Load the default toolbars.xml file + // Load the toolbars.xml file std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml"); - if (!gDirUtilp->fileExists(toolbar_file)) + if (force_default) + { + toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); + } + else if (!gDirUtilp->fileExists(toolbar_file)) { llwarns << "User toolbars def not found -> use default" << llendl; toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); @@ -145,9 +150,28 @@ bool LLToolBarView::loadToolbars() return false; } + // Clear the toolbars now before adding the loaded commands and settings + if (mToolbarLeft) + { + mToolbarLeft->clearCommandsList(); + } + if (mToolbarRight) + { + mToolbarRight->clearCommandsList(); + } + if (mToolbarBottom) + { + mToolbarBottom->clearCommandsList(); + } + // Add commands to each toolbar if (toolbar_set.left_toolbar.isProvided() && mToolbarLeft) { + if (toolbar_set.left_toolbar.button_display_mode.isProvided()) + { + U32 button_type = toolbar_set.left_toolbar.button_display_mode; + mToolbarLeft->setButtonType((LLToolBarEnums::ButtonType)(button_type)); + } BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands) { addCommand(LLCommandId(command),mToolbarLeft); @@ -155,6 +179,11 @@ bool LLToolBarView::loadToolbars() } if (toolbar_set.right_toolbar.isProvided() && mToolbarRight) { + if (toolbar_set.right_toolbar.button_display_mode.isProvided()) + { + U32 button_type = toolbar_set.right_toolbar.button_display_mode; + mToolbarRight->setButtonType((LLToolBarEnums::ButtonType)(button_type)); + } BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands) { addCommand(LLCommandId(command),mToolbarRight); @@ -162,6 +191,11 @@ bool LLToolBarView::loadToolbars() } if (toolbar_set.bottom_toolbar.isProvided() && mToolbarBottom) { + if (toolbar_set.bottom_toolbar.button_display_mode.isProvided()) + { + U32 button_type = toolbar_set.bottom_toolbar.button_display_mode; + mToolbarBottom->setButtonType((LLToolBarEnums::ButtonType)(button_type)); + } BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands) { addCommand(LLCommandId(command),mToolbarBottom); @@ -176,14 +210,17 @@ void LLToolBarView::saveToolbars() const LLToolBarView::ToolbarSet toolbar_set; if (mToolbarLeft) { + toolbar_set.left_toolbar.button_display_mode = (int)(mToolbarLeft->getButtonType()); addToToolset(mToolbarLeft->getCommandsList(),toolbar_set.left_toolbar); } if (mToolbarRight) { + toolbar_set.right_toolbar.button_display_mode = (int)(mToolbarRight->getButtonType()); addToToolset(mToolbarRight->getCommandsList(),toolbar_set.right_toolbar); } if (mToolbarBottom) { + toolbar_set.bottom_toolbar.button_display_mode = (int)(mToolbarBottom->getButtonType()); addToToolset(mToolbarBottom->getCommandsList(),toolbar_set.bottom_toolbar); } diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index b19841997b..efe6920db8 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -50,7 +50,8 @@ public: // the user folder for the user specific (saved) settings struct Toolbar : public LLInitParam::Block { - Multiple commands; + Mandatory button_display_mode; + Multiple commands; Toolbar(); }; struct ToolbarSet : public LLInitParam::Block @@ -70,7 +71,8 @@ public: // Checks if the commandId is being used somewhere in one of the toolbars bool hasCommand(const LLCommandId& commandId) const; // Loads the toolbars from the existing user or default settings - bool loadToolbars(); // return false if load fails + bool loadToolbars(bool force_default = false); // return false if load fails + bool loadDefaultToolbars() { return loadToolbars(true); } protected: friend class LLUICtrlFactory; -- cgit v1.2.3 From 8fa45941b6ce99c462f19628a17d4db2396286b9 Mon Sep 17 00:00:00 2001 From: leyla_linden Date: Fri, 30 Sep 2011 10:00:49 -0700 Subject: EXP-1264 Chat log shows as blank if closing viewer with chat log open and then opening chat floater on next login EXP-1271 Remove UI hints --- indra/llui/llfloater.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 58c2d34253..fba59e82e1 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -293,7 +293,7 @@ public: protected: virtual void applySavedVariables(); - void applyRectControl(); + virtual void applyRectControl(); void applyDockState(); void storeRectControl(); void storeVisibilityControl(); -- cgit v1.2.3 From cdc80b1dd34ef533d7500bf1ab89abf3c5d81bb3 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Fri, 30 Sep 2011 15:25:02 -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-1268 FIX -- The "Restore Defaults" button should reset the left/right/bottom toolbars to their default states * LLToolBarView::loadDefaultToolbars now a static function * Toybox button callback hooked up to properly restore defaults Reviewed by Merov --- indra/llui/lltoolbarview.cpp | 15 ++++++++++++++- indra/llui/lltoolbarview.h | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 1c6cf3230b..12247519ad 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -114,7 +114,7 @@ bool LLToolBarView::addCommand(const LLCommandId& command, LLToolBar* toolbar) } bool LLToolBarView::loadToolbars(bool force_default) -{ +{ LLToolBarView::ToolbarSet toolbar_set; // Load the toolbars.xml file @@ -204,6 +204,19 @@ bool LLToolBarView::loadToolbars(bool force_default) return true; } +//static +bool LLToolBarView::loadDefaultToolbars() +{ + bool retval = false; + + if (gToolBarView) + { + retval = gToolBarView->loadToolbars(true); + } + + return retval; +} + void LLToolBarView::saveToolbars() const { // Build the parameter tree from the toolbar data diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index efe6920db8..95c09ece73 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -72,7 +72,8 @@ public: bool hasCommand(const LLCommandId& commandId) const; // Loads the toolbars from the existing user or default settings bool loadToolbars(bool force_default = false); // return false if load fails - bool loadDefaultToolbars() { return loadToolbars(true); } + + static bool loadDefaultToolbars(); protected: friend class LLUICtrlFactory; -- cgit v1.2.3 From 6fe4815217a11a36aa2e2b1d8b040eff007bb631 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Fri, 30 Sep 2011 15:26:48 -0700 Subject: Updated FUI floater toggle function to handle closing windows that are initialized with chrome. --- indra/llui/llfloaterreg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index 8a0513f246..27e96856b3 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -483,7 +483,7 @@ void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) { showInstance(name, key, TRUE); } - else if (!instance->hasFocus()) + else if (!instance->hasFocus() && !instance->getIsChrome()) { instance->setFocus(TRUE); } -- cgit v1.2.3 From 09e179b2381a4db03309839babae664feb9b0886 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 30 Sep 2011 16:57:08 -0700 Subject: param block cleanup added Flag as value type moved Batch to BatchBlock renamed Choice to ChoiceBlock made merging of parameters for ValueParams consistent (fillFrom and overwriteFrom are inverses of each other now) made iteration over Multiple type params easier initial schema param blocks --- indra/llui/lllineeditor.h | 2 +- indra/llui/llloadingindicator.cpp | 7 +++---- indra/llui/llloadingindicator.h | 4 ++-- indra/llui/llnotifications.h | 4 ++-- indra/llui/llnotificationtemplate.h | 4 ++-- indra/llui/llnotificationvisibilityrule.h | 2 +- indra/llui/llscrolllistcolumn.h | 4 ++-- indra/llui/llsdparam.cpp | 6 +++--- indra/llui/llsdparam.h | 4 ++-- indra/llui/lltextbase.h | 2 +- indra/llui/lltoolbar.cpp | 6 +++--- indra/llui/lltoolbarview.h | 4 ---- indra/llui/llui.cpp | 4 +++- indra/llui/llui.h | 2 +- indra/llui/lluicolortable.h | 2 +- indra/llui/lluictrl.h | 4 ++-- indra/llui/lluictrlfactory.h | 6 +++--- indra/llui/llview.h | 2 +- 18 files changed, 33 insertions(+), 36 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 583bde360a..2518dbe3c7 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -60,7 +60,7 @@ public: typedef boost::function keystroke_callback_t; - struct MaxLength : public LLInitParam::Choice + struct MaxLength : public LLInitParam::ChoiceBlock { Alternative bytes, chars; diff --git a/indra/llui/llloadingindicator.cpp b/indra/llui/llloadingindicator.cpp index c4eec1835c..6ac38f5ad4 100644 --- a/indra/llui/llloadingindicator.cpp +++ b/indra/llui/llloadingindicator.cpp @@ -34,6 +34,7 @@ // Project includes #include "lluictrlfactory.h" #include "lluiimage.h" +#include "boost/foreach.hpp" // registered in llui.cpp to avoid being left out by MS linker //static LLDefaultChildRegistry::Register r("loading_indicator"); @@ -51,11 +52,9 @@ LLLoadingIndicator::LLLoadingIndicator(const Params& p) void LLLoadingIndicator::initFromParams(const Params& p) { - for (LLInitParam::ParamIterator::const_iterator it = p.images().image.begin(), end_it = p.images().image.end(); - it != end_it; - ++it) + BOOST_FOREACH(LLUIImage* image, p.images.image) { - mImages.push_back(it->getValue()); + mImages.push_back(image); } // Start timer for switching images. diff --git a/indra/llui/llloadingindicator.h b/indra/llui/llloadingindicator.h index 7c44478848..c1f979c111 100644 --- a/indra/llui/llloadingindicator.h +++ b/indra/llui/llloadingindicator.h @@ -51,7 +51,7 @@ class LLLoadingIndicator LOG_CLASS(LLLoadingIndicator); public: - struct Images : public LLInitParam::Block + struct Images : public LLInitParam::BatchBlock { Multiple image; @@ -63,7 +63,7 @@ public: struct Params : public LLInitParam::Block { Optional images_per_sec; - Batch images; + Optional images; Params() : images_per_sec("images_per_sec", 1.0f), diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 0c4d4fc897..462d69be2e 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -201,7 +201,7 @@ public: FormInput(); }; - struct FormElement : public LLInitParam::Choice + struct FormElement : public LLInitParam::ChoiceBlock { Alternative button; Alternative input; @@ -312,7 +312,7 @@ public: Optional context; Optional responder; - struct Functor : public LLInitParam::Choice + struct Functor : public LLInitParam::ChoiceBlock { Alternative name; Alternative function; diff --git a/indra/llui/llnotificationtemplate.h b/indra/llui/llnotificationtemplate.h index ab777d37a5..fb50c9c123 100644 --- a/indra/llui/llnotificationtemplate.h +++ b/indra/llui/llnotificationtemplate.h @@ -91,7 +91,7 @@ struct LLNotificationTemplate // // as well as // ... - Flag dummy_val; + Optional dummy_val; public: Multiple contexts; @@ -147,7 +147,7 @@ struct LLNotificationTemplate {} }; - struct FormRef : public LLInitParam::Choice + struct FormRef : public LLInitParam::ChoiceBlock { Alternative form; Alternative form_template; diff --git a/indra/llui/llnotificationvisibilityrule.h b/indra/llui/llnotificationvisibilityrule.h index 78bdec2a8f..78788a275c 100644 --- a/indra/llui/llnotificationvisibilityrule.h +++ b/indra/llui/llnotificationvisibilityrule.h @@ -59,7 +59,7 @@ struct LLNotificationVisibilityRule {} }; - struct Rule : public LLInitParam::Choice + struct Rule : public LLInitParam::ChoiceBlock { Alternative show; Alternative hide; diff --git a/indra/llui/llscrolllistcolumn.h b/indra/llui/llscrolllistcolumn.h index 12baea8e0c..b4d4a6d05e 100644 --- a/indra/llui/llscrolllistcolumn.h +++ b/indra/llui/llscrolllistcolumn.h @@ -95,7 +95,7 @@ public: Optional sort_direction; Optional sort_ascending; - struct Width : public LLInitParam::Choice + struct Width : public LLInitParam::ChoiceBlock { Alternative dynamic_width; Alternative pixel_width; @@ -112,7 +112,7 @@ public: Optional width; // either an image or label is used in column header - struct Header : public LLInitParam::Choice
+ struct Header : public LLInitParam::ChoiceBlock
{ Alternative label; Alternative image; diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp index 04919e6991..4b69360e33 100644 --- a/indra/llui/llsdparam.cpp +++ b/indra/llui/llsdparam.cpp @@ -45,7 +45,7 @@ LLParamSDParser::LLParamSDParser() if (sReadFuncs.empty()) { - registerParserFuncs(readNoValue, &LLParamSDParser::writeNoValue); + registerParserFuncs(readFlag, &LLParamSDParser::writeFlag); registerParserFuncs(readS32, &LLParamSDParser::writeTypedValue); registerParserFuncs(readU32, &LLParamSDParser::writeU32Param); registerParserFuncs(readF32, &LLParamSDParser::writeTypedValue); @@ -72,7 +72,7 @@ bool LLParamSDParser::writeU32Param(LLParamSDParser::parser_t& parser, const voi return true; } -bool LLParamSDParser::writeNoValue(LLParamSDParser::parser_t& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack) +bool LLParamSDParser::writeFlag(LLParamSDParser::parser_t& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack) { LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; @@ -226,7 +226,7 @@ LLSD* LLParamSDParser::getSDWriteNode(const parser_t::name_stack_t& name_stack) return sd_to_write; } -bool LLParamSDParser::readNoValue(Parser& parser, void* val_ptr) +bool LLParamSDParser::readFlag(Parser& parser, void* val_ptr) { LLParamSDParser& self = static_cast(parser); return self.mCurReadSD == &NO_VALUE_MARKER; diff --git a/indra/llui/llsdparam.h b/indra/llui/llsdparam.h index f776c781b3..a371c28f68 100644 --- a/indra/llui/llsdparam.h +++ b/indra/llui/llsdparam.h @@ -63,9 +63,9 @@ private: LLSD* getSDWriteNode(const parser_t::name_stack_t& name_stack); static bool writeU32Param(Parser& parser, const void* value_ptr, const parser_t::name_stack_t& name_stack); - static bool writeNoValue(Parser& parser, const void* value_ptr, const parser_t::name_stack_t& name_stack); + static bool writeFlag(Parser& parser, const void* value_ptr, const parser_t::name_stack_t& name_stack); - static bool readNoValue(Parser& parser, void* val_ptr); + static bool readFlag(Parser& parser, void* val_ptr); static bool readS32(Parser& parser, void* val_ptr); static bool readU32(Parser& parser, void* val_ptr); static bool readF32(Parser& parser, void* val_ptr); diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 7d545a1ba6..384d9116fc 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -237,7 +237,7 @@ public: friend class LLNormalTextSegment; friend class LLUICtrlFactory; - struct LineSpacingParams : public LLInitParam::Choice + struct LineSpacingParams : public LLInitParam::ChoiceBlock { Alternative multiple; Alternative pixels; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index caad896a06..d940bed905 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -185,7 +185,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) LLPanel::Params button_panel_p(p.button_panel); button_panel_p.rect = center_panel->getLocalRect(); - button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_LEFT; + button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_LEFT; mButtonPanel = LLUICtrlFactory::create(button_panel_p); center_panel->addChild(mButtonPanel); @@ -558,8 +558,8 @@ BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask) LLToolBar* bar = getParentByType(); if (view) { - view->startDrag(bar->createButton(mId)); - setVisible(FALSE); + //view->startDrag(bar->createButton(mId)); + //setVisible(FALSE); } } } diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index ea3422f04e..dd2bbf0e49 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -65,10 +65,6 @@ public: virtual ~LLToolBarView(); virtual BOOL postBuild(); virtual void draw(); - virtual BOOL handleHover(S32 x, S32 y, MASK mask); - virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); - virtual void onMouseCaptureLost(); - void startDrag(LLToolBarButton*); // Toolbar view interface with the rest of the world // Checks if the commandId is being used somewhere in one of the toolbars bool hasCommand(const LLCommandId& commandId) const; diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 4f129ccfba..76a12e649b 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -2107,7 +2107,7 @@ namespace LLInitParam void ParamValue >::updateValueFromBlock() { - if (control.isProvided()) + if (control.isProvided() && !control().empty()) { updateValue(LLUIColorTable::instance().getColor(control)); } @@ -2264,9 +2264,11 @@ namespace LLInitParam // in this case, that is left+width and bottom+height LLRect& value = getValue(); + right.set(value.mRight, false); left.set(value.mLeft, make_block_authoritative); width.set(value.getWidth(), make_block_authoritative); + top.set(value.mTop, false); bottom.set(value.mBottom, make_block_authoritative); height.set(value.getHeight(), make_block_authoritative); } diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 7801a01ace..3afb7c65a9 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -365,7 +365,7 @@ template LLRegisterWith LLInitClass::sRegister( template LLRegisterWith LLDestroyClass::sRegister(&T::destroyClass); // useful parameter blocks -struct TimeIntervalParam : public LLInitParam::Choice +struct TimeIntervalParam : public LLInitParam::ChoiceBlock { Alternative seconds; Alternative frames; diff --git a/indra/llui/lluicolortable.h b/indra/llui/lluicolortable.h index 76518789ec..6a7a681d57 100644 --- a/indra/llui/lluicolortable.h +++ b/indra/llui/lluicolortable.h @@ -44,7 +44,7 @@ LOG_CLASS(LLUIColorTable); typedef std::map string_color_map_t; public: - struct ColorParams : LLInitParam::Choice + struct ColorParams : LLInitParam::ChoiceBlock { Alternative value; Alternative reference; diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index fc56e5fc35..a8a4e3191d 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -76,14 +76,14 @@ public: Optional function; }; - struct EnableControls : public LLInitParam::Choice + struct EnableControls : public LLInitParam::ChoiceBlock { Alternative enabled; Alternative disabled; EnableControls(); }; - struct ControlVisibility : public LLInitParam::Choice + struct ControlVisibility : public LLInitParam::ChoiceBlock { Alternative visible; Alternative invisible; diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 71c38237c1..d612ad5005 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::BaseBlockWithFlags& get() { return mBaseBlock; } + const LLInitParam::BaseBlock& get() { return mBaseBlock; } private: - LLInitParam::BaseBlockWithFlags mBaseBlock; + LLInitParam::BaseBlock mBaseBlock; }; public: diff --git a/indra/llui/llview.h b/indra/llui/llview.h index f4e31b109a..a1c46f3bf3 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -98,7 +98,7 @@ private: class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElement { public: - struct Follows : public LLInitParam::Choice + struct Follows : public LLInitParam::ChoiceBlock { Alternative string; Alternative flags; -- cgit v1.2.3 From f787208903a4f5a7b641859ba991b8b2e63e2a32 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 30 Sep 2011 17:09:16 -0700 Subject: fix for merge --- indra/llui/lltoolbarview.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 0996577114..12247519ad 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -114,7 +114,7 @@ bool LLToolBarView::addCommand(const LLCommandId& command, LLToolBar* toolbar) } bool LLToolBarView::loadToolbars(bool force_default) -{ +{ LLToolBarView::ToolbarSet toolbar_set; // Load the toolbars.xml file @@ -221,18 +221,19 @@ void LLToolBarView::saveToolbars() const { // Build the parameter tree from the toolbar data LLToolBarView::ToolbarSet toolbar_set; - - // *TODO : factorize that code a bit... if (mToolbarLeft) { + toolbar_set.left_toolbar.button_display_mode = (int)(mToolbarLeft->getButtonType()); addToToolset(mToolbarLeft->getCommandsList(),toolbar_set.left_toolbar); } if (mToolbarRight) { + toolbar_set.right_toolbar.button_display_mode = (int)(mToolbarRight->getButtonType()); addToToolset(mToolbarRight->getCommandsList(),toolbar_set.right_toolbar); } if (mToolbarBottom) { + toolbar_set.bottom_toolbar.button_display_mode = (int)(mToolbarBottom->getButtonType()); addToToolset(mToolbarBottom->getCommandsList(),toolbar_set.bottom_toolbar); } @@ -255,6 +256,19 @@ void LLToolBarView::saveToolbars() const } } +// Enumerate the commands in command_list and add them as Params to the toolbar +void LLToolBarView::addToToolset(command_id_list_t& command_list, Toolbar& toolbar) const +{ + for (command_id_list_t::const_iterator it = command_list.begin(); + it != command_list.end(); + ++it) + { + LLCommandId::Params command; + command.name = it->name(); + toolbar.commands.add(command); + } +} + void LLToolBarView::draw() { static bool debug_print = true; -- cgit v1.2.3 From 63a8fce12b1e1c0d40d97e2f029776fed6e300fb Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 30 Sep 2011 18:51:17 -0700 Subject: made toolbars conform to visual specs added ability to specify clip rects in textures.xml --- indra/llui/lltoolbar.cpp | 17 +++++++---------- indra/llui/lltoolbar.h | 23 +++++++++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 2592fd1229..c62bbe4e71 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -82,9 +82,6 @@ LLToolBar::Params::Params() button_icon_and_text("button_icon_and_text"), read_only("read_only", false), wrap("wrap", true), - min_button_width("min_button_width", 0), - max_button_width("max_button_width", S32_MAX), - button_height("button_height"), pad_left("pad_left"), pad_top("pad_top"), pad_right("pad_right"), @@ -102,9 +99,6 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) mNeedsLayout(false), mButtonPanel(NULL), mCenteringStack(NULL), - mMinButtonWidth(llmin(p.min_button_width(), p.max_button_width())), - mMaxButtonWidth(llmax(p.max_button_width(), p.min_button_width())), - mButtonHeight(p.button_height), mPadLeft(p.pad_left), mPadRight(p.pad_right), mPadTop(p.pad_top), @@ -325,7 +319,7 @@ void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row { if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) { - button->reshape(llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth), max_row_girth); + button->reshape(llclamp(button->getRect().getWidth(), button->mMinWidth, button->mMaxWidth), max_row_girth); } else // VERTICAL { @@ -384,10 +378,10 @@ void LLToolBar::updateLayoutAsNeeded() BOOST_FOREACH(LLToolBarButton* button, mButtons) { - button->reshape(mMinButtonWidth, mButtonHeight); + button->reshape(button->mMinWidth, button->mDesiredHeight); button->autoResize(); - S32 button_clamped_width = llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth); + S32 button_clamped_width = llclamp(button->getRect().getWidth(), button->mMinWidth, button->mMaxWidth); S32 button_length = (orientation == LLLayoutStack::HORIZONTAL) ? button_clamped_width : button->getRect().getHeight(); @@ -402,7 +396,7 @@ void LLToolBar::updateLayoutAsNeeded() { if (orientation == LLLayoutStack::VERTICAL) { // row girth (width in this case) is clamped to allowable button widths - max_row_girth = llclamp(max_row_girth, mMinButtonWidth, mMaxButtonWidth); + max_row_girth = llclamp(max_row_girth, button->mMinWidth, button->mMaxWidth); } // make buttons in current row all same girth @@ -546,6 +540,9 @@ LLToolBarButton::LLToolBarButton(const Params& p) : LLButton(p), mMouseDownX(0), mMouseDownY(0), + mMinWidth(p.min_button_width), + mMaxWidth(p.max_button_width), + mDesiredHeight(p.desired_height), mId("") {} diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 0bb95f4e9c..5d64630fa6 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -37,9 +37,20 @@ class LLToolBarButton : public LLButton { + friend class LLToolBar; public: struct Params : public LLInitParam::Block { + Optional min_button_width, + max_button_width, + desired_height; + + Params() + : min_button_width("min_button_width", 0), + max_button_width("max_button_width", S32_MAX), + desired_height("desired_height", 20) + {} + }; LLToolBarButton(const Params& p); @@ -51,6 +62,9 @@ private: LLCommandId mId; S32 mMouseDownX; S32 mMouseDownY; + S32 mMinWidth; + S32 mMaxWidth; + S32 mDesiredHeight; }; @@ -106,10 +120,6 @@ public: Optional read_only, wrap; - Optional min_button_width, - max_button_width, - button_height; - Optional pad_left, pad_top, pad_right, @@ -171,10 +181,7 @@ private: bool mWrap; bool mNeedsLayout; - S32 mMinButtonWidth, - mMaxButtonWidth, - mButtonHeight, - mPadLeft, + S32 mPadLeft, mPadRight, mPadTop, mPadBottom, -- cgit v1.2.3 From cd467cc34f876920b35d3570f50dbad54ce4a42c Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 3 Oct 2011 16:27:24 -0700 Subject: EXP-1286 : First pass at Drag and Drop of tools. Not functional. Most hooks into the LLToolDragAndDrop system in to support the new AT_WIDGET and SOURCE_VIEWER --- indra/llui/CMakeLists.txt | 5 +- indra/llui/llclipboard.cpp | 6 + indra/llui/llclipboard.h | 9 +- indra/llui/lltoolbar.cpp | 55 ++++++++ indra/llui/lltoolbar.h | 32 ++++- indra/llui/lltoolbarview.cpp | 311 ------------------------------------------- indra/llui/lltoolbarview.h | 96 ------------- 7 files changed, 101 insertions(+), 413 deletions(-) delete mode 100644 indra/llui/lltoolbarview.cpp delete mode 100644 indra/llui/lltoolbarview.h (limited to 'indra/llui') diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 4212812558..dded8ab661 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -5,6 +5,7 @@ project(llui) include(00-Common) include(LLCommon) include(LLImage) +include(LLInventory) include(LLMath) include(LLMessage) include(LLRender) @@ -16,6 +17,7 @@ include(LLXUIXML) include_directories( ${LLCOMMON_INCLUDE_DIRS} ${LLIMAGE_INCLUDE_DIRS} + ${LLINVENTORY_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLRENDER_INCLUDE_DIRS} @@ -101,7 +103,6 @@ set(llui_SOURCE_FILES lltransutil.cpp lltoggleablemenu.cpp lltoolbar.cpp - lltoolbarview.cpp lltooltip.cpp llui.cpp lluicolortable.cpp @@ -205,7 +206,6 @@ set(llui_HEADER_FILES lltimectrl.h lltoggleablemenu.h lltoolbar.h - lltoolbarview.h lltooltip.h lltransutil.h lluicolortable.h @@ -251,6 +251,7 @@ target_link_libraries(llui ${LLRENDER_LIBRARIES} ${LLWINDOW_LIBRARIES} ${LLIMAGE_LIBRARIES} + ${LLINVENTORY_LIBRARIES} ${LLVFS_LIBRARIES} # ugh, just for LLDir ${LLXUIXML_LIBRARIES} ${LLXML_LIBRARIES} diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 984c4ec5fb..6910b962a1 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -40,6 +40,7 @@ LLClipboard gClipboard; LLClipboard::LLClipboard() { + mSourceItem = NULL; } @@ -134,3 +135,8 @@ BOOL LLClipboard::canPastePrimaryString() const { return LLView::getWindow()->isPrimaryTextAvailable(); } + +void LLClipboard::setSourceObject(const LLUUID& source_id, LLAssetType::EType type) +{ + mSourceItem = new LLInventoryObject (source_id, LLUUID::null, type, ""); +} diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 24cb46c3f4..9371b94284 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -30,6 +30,8 @@ #include "llstring.h" #include "lluuid.h" +#include "stdenums.h" +#include "llinventory.h" class LLClipboard @@ -52,9 +54,14 @@ public: BOOL canPastePrimaryString() const; const LLWString& getPastePrimaryWString(LLUUID* source_id = NULL); + // Support clipboard for object known only by their uuid and asset type + void setSourceObject(const LLUUID& source_id, LLAssetType::EType type); + const LLInventoryObject* getSourceObject() { return mSourceItem; } + private: - LLUUID mSourceID; + LLUUID mSourceID; LLWString mString; + LLInventoryObject* mSourceItem; }; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 75c7d91f8a..5300de38a0 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -113,6 +113,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; + mUUID = LLUUID::LLUUID::generateNewID(p.name); } LLToolBar::~LLToolBar() @@ -534,6 +535,8 @@ void LLToolBar::createButton(const LLCommandId& id) cbParam.function_name = commandp->functionName(); cbParam.parameter = commandp->parameter(); button->setCommitCallback(cbParam); + button->setStartDragCallback(mStartDragItemCallback); + button->setHandleDragCallback(mHandleDragItemCallback); } mButtons.push_back(button); @@ -541,3 +544,55 @@ void LLToolBar::createButton(const LLCommandId& id) mNeedsLayout = true; } + +BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) +{ + llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", tooltip = " << tooltip_msg << llendl; + // If we have a drop callback, that means that we can handle the drop + BOOL handled = (mHandleDropCallback ? TRUE : FALSE); + + // if drop, time to call the drop callback to get the operation done + if (handled && drop) + { + handled = mHandleDropCallback(cargo_type,cargo_data,mUUID); + } + + // We accept multi drop by default + *accept = (handled ? ACCEPT_YES_MULTI : ACCEPT_NO); + + // We'll use that flag to change the visual aspect of the target on draw() + mDragAndDropTarget = handled; + + return handled; +} + +LLToolBarButton::LLToolBarButton(const Params& p) : LLButton(p) +{ + mUUID = LLUUID::LLUUID::generateNewID(p.name); +} + +BOOL LLToolBarButton::handleHover( S32 x, S32 y, MASK mask ) +{ +// llinfos << "Merov debug: handleHover, x = " << x << ", y = " << y << ", mouse = " << hasMouseCapture() << llendl; + BOOL handled = FALSE; + + if (hasMouseCapture() && mStartDragItemCallback && mHandleDragItemCallback) + { + if (!mIsDragged) + { + mStartDragItemCallback(x,y,mUUID); + mIsDragged = true; + handled = TRUE; + } + else + { + handled = mHandleDragItemCallback(x,y,mUUID,LLAssetType::AT_WIDGET); + } + } + return handled; +} + diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 03b1756988..6dcf620861 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -33,7 +33,11 @@ #include "lllayoutstack.h" #include "lluictrl.h" #include "llcommandmanager.h" +#include "llassettype.h" +typedef boost::function startdrag_callback_t; +typedef boost::function handledrag_callback_t; +typedef boost::function handledrop_callback_t; class LLToolBarButton : public LLButton { @@ -42,7 +46,17 @@ public: { }; - LLToolBarButton(const Params& p) : LLButton(p) {} + LLToolBarButton(const Params& p); + + virtual BOOL handleHover( S32 x, S32 y, MASK mask ); + + void setStartDragCallback(startdrag_callback_t cb) { mStartDragItemCallback = cb; } + void setHandleDragCallback(handledrag_callback_t cb) { mHandleDragItemCallback = cb; } +protected: + bool mIsDragged; + startdrag_callback_t mStartDragItemCallback; + handledrag_callback_t mHandleDragItemCallback; + LLUUID mUUID; }; @@ -86,7 +100,6 @@ class LLToolBar : public LLUICtrl { public: - struct Params : public LLInitParam::Block { Mandatory button_display_mode; @@ -119,10 +132,18 @@ public: void draw(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); - + virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg); + bool addCommand(const LLCommandId& commandId); bool hasCommand(const LLCommandId& commandId) const; bool enableCommand(const LLCommandId& commandId, bool enabled); + void setStartDragCallback(startdrag_callback_t cb) { mStartDragItemCallback = cb; } + void setHandleDragCallback(handledrag_callback_t cb) { mHandleDragItemCallback = cb; } + void setHandleDropCallback(handledrop_callback_t cb) { mHandleDropCallback = cb; } protected: friend class LLUICtrlFactory; @@ -130,6 +151,10 @@ protected: ~LLToolBar(); void initFromParams(const Params&); + startdrag_callback_t mStartDragItemCallback; + handledrag_callback_t mHandleDragItemCallback; + handledrop_callback_t mHandleDropCallback; + bool mDragAndDropTarget; public: // Methods used in loading and saving toolbar settings @@ -147,6 +172,7 @@ private: BOOL isSettingChecked(const LLSD& userdata); void onSettingEnable(const LLSD& userdata); + LLUUID mUUID; const bool mReadOnly; std::list mButtons; diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp deleted file mode 100644 index 1c6cf3230b..0000000000 --- a/indra/llui/lltoolbarview.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/** - * @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 "lldir.h" -#include "llxmlnode.h" -#include "lltoolbar.h" -#include "llbutton.h" - -#include - -LLToolBarView* gToolBarView = NULL; - -static LLDefaultChildRegistry::Register r("toolbar_view"); - -LLToolBarView::Toolbar::Toolbar() -: button_display_mode("button_display_mode"), - commands("command") -{} - -LLToolBarView::ToolbarSet::ToolbarSet() -: left_toolbar("left_toolbar"), - right_toolbar("right_toolbar"), - bottom_toolbar("bottom_toolbar") -{} - - -LLToolBarView::LLToolBarView(const LLToolBarView::Params& p) -: LLUICtrl(p), - mToolbarLeft(NULL), - mToolbarRight(NULL), - mToolbarBottom(NULL) -{ -} - -void LLToolBarView::initFromParams(const LLToolBarView::Params& p) -{ - // Initialize the base object - LLUICtrl::initFromParams(p); -} - -LLToolBarView::~LLToolBarView() -{ - saveToolbars(); -} - -BOOL LLToolBarView::postBuild() -{ - mToolbarLeft = getChild("toolbar_left"); - mToolbarRight = getChild("toolbar_right"); - mToolbarBottom = getChild("toolbar_bottom"); - - return TRUE; -} - -bool LLToolBarView::hasCommand(const LLCommandId& commandId) const -{ - bool has_command = false; - if (mToolbarLeft && !has_command) - { - has_command = mToolbarLeft->hasCommand(commandId); - } - if (mToolbarRight && !has_command) - { - has_command = mToolbarRight->hasCommand(commandId); - } - if (mToolbarBottom && !has_command) - { - has_command = mToolbarBottom->hasCommand(commandId); - } - return has_command; -} - -bool LLToolBarView::addCommand(const LLCommandId& command, LLToolBar* toolbar) -{ - LLCommandManager& mgr = LLCommandManager::instance(); - if (mgr.getCommand(command)) - { - toolbar->addCommand(command); - } - else - { - llwarns << "Toolbars creation : the command " << command.name() << " cannot be found in the command manager" << llendl; - return false; - } - return true; -} - -bool LLToolBarView::loadToolbars(bool force_default) -{ - LLToolBarView::ToolbarSet toolbar_set; - - // Load the toolbars.xml file - std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml"); - if (force_default) - { - toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); - } - else if (!gDirUtilp->fileExists(toolbar_file)) - { - llwarns << "User toolbars def not found -> use default" << llendl; - toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); - } - - LLXMLNodePtr root; - if(!LLXMLNode::parseFile(toolbar_file, root, NULL)) - { - llerrs << "Unable to load toolbars from file: " << toolbar_file << llendl; - return false; - } - if(!root->hasName("toolbars")) - { - llwarns << toolbar_file << " is not a valid toolbars definition file" << llendl; - return false; - } - - // Parse the toolbar settings - LLXUIParser parser; - parser.readXUI(root, toolbar_set, toolbar_file); - if (!toolbar_set.validateBlock()) - { - llerrs << "Unable to validate toolbars from file: " << toolbar_file << llendl; - return false; - } - - // Clear the toolbars now before adding the loaded commands and settings - if (mToolbarLeft) - { - mToolbarLeft->clearCommandsList(); - } - if (mToolbarRight) - { - mToolbarRight->clearCommandsList(); - } - if (mToolbarBottom) - { - mToolbarBottom->clearCommandsList(); - } - - // Add commands to each toolbar - if (toolbar_set.left_toolbar.isProvided() && mToolbarLeft) - { - if (toolbar_set.left_toolbar.button_display_mode.isProvided()) - { - U32 button_type = toolbar_set.left_toolbar.button_display_mode; - mToolbarLeft->setButtonType((LLToolBarEnums::ButtonType)(button_type)); - } - BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands) - { - addCommand(LLCommandId(command),mToolbarLeft); - } - } - if (toolbar_set.right_toolbar.isProvided() && mToolbarRight) - { - if (toolbar_set.right_toolbar.button_display_mode.isProvided()) - { - U32 button_type = toolbar_set.right_toolbar.button_display_mode; - mToolbarRight->setButtonType((LLToolBarEnums::ButtonType)(button_type)); - } - BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands) - { - addCommand(LLCommandId(command),mToolbarRight); - } - } - if (toolbar_set.bottom_toolbar.isProvided() && mToolbarBottom) - { - if (toolbar_set.bottom_toolbar.button_display_mode.isProvided()) - { - U32 button_type = toolbar_set.bottom_toolbar.button_display_mode; - mToolbarBottom->setButtonType((LLToolBarEnums::ButtonType)(button_type)); - } - BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands) - { - addCommand(LLCommandId(command),mToolbarBottom); - } - } - return true; -} - -void LLToolBarView::saveToolbars() const -{ - // Build the parameter tree from the toolbar data - LLToolBarView::ToolbarSet toolbar_set; - if (mToolbarLeft) - { - toolbar_set.left_toolbar.button_display_mode = (int)(mToolbarLeft->getButtonType()); - addToToolset(mToolbarLeft->getCommandsList(),toolbar_set.left_toolbar); - } - if (mToolbarRight) - { - toolbar_set.right_toolbar.button_display_mode = (int)(mToolbarRight->getButtonType()); - addToToolset(mToolbarRight->getCommandsList(),toolbar_set.right_toolbar); - } - if (mToolbarBottom) - { - toolbar_set.bottom_toolbar.button_display_mode = (int)(mToolbarBottom->getButtonType()); - addToToolset(mToolbarBottom->getCommandsList(),toolbar_set.bottom_toolbar); - } - - // Serialize the parameter tree - LLXMLNodePtr output_node = new LLXMLNode("toolbars", false); - LLXUIParser parser; - parser.writeXUI(output_node, toolbar_set); - - // Write the resulting XML to file - if(!output_node->isNull()) - { - const std::string& filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml"); - LLFILE *fp = LLFile::fopen(filename, "w"); - if (fp != NULL) - { - LLXMLNode::writeHeaderToFile(fp); - output_node->writeToFile(fp); - fclose(fp); - } - } -} - -// Enumerate the commands in command_list and add them as Params to the toolbar -void LLToolBarView::addToToolset(command_id_list_t& command_list, Toolbar& toolbar) const -{ - for (command_id_list_t::const_iterator it = command_list.begin(); - it != command_list.end(); - ++it) - { - LLCommandId::Params command; - command.name = it->name(); - toolbar.commands.add(command); - } -} - -void LLToolBarView::draw() -{ - static bool debug_print = true; - static S32 old_width = 0; - static S32 old_height = 0; - - //LLPanel* sizer_left = getChild("sizer_left"); - - LLRect bottom_rect, left_rect, right_rect; - - if (mToolbarBottom) - { - mToolbarBottom->getParent()->reshape(mToolbarBottom->getParent()->getRect().getWidth(), mToolbarBottom->getRect().getHeight()); - mToolbarBottom->localRectToOtherView(mToolbarBottom->getLocalRect(), &bottom_rect, this); - } - if (mToolbarLeft) - { - mToolbarLeft->getParent()->reshape(mToolbarLeft->getRect().getWidth(), mToolbarLeft->getParent()->getRect().getHeight()); - mToolbarLeft->localRectToOtherView(mToolbarLeft->getLocalRect(), &left_rect, this); - } - if (mToolbarRight) - { - mToolbarRight->getParent()->reshape(mToolbarRight->getRect().getWidth(), mToolbarRight->getParent()->getRect().getHeight()); - mToolbarRight->localRectToOtherView(mToolbarRight->getLocalRect(), &right_rect, this); - } - - if ((old_width != getRect().getWidth()) || (old_height != getRect().getHeight())) - debug_print = true; - if (debug_print) - { - LLRect ctrl_rect = getRect(); - llinfos << "Merov debug : draw control rect = " << ctrl_rect.mLeft << ", " << ctrl_rect.mTop << ", " << ctrl_rect.mRight << ", " << ctrl_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; - old_width = ctrl_rect.getWidth(); - old_height = ctrl_rect.getHeight(); - debug_print = false; - } - // Debug draw - LLColor4 back_color = LLColor4::blue; - LLColor4 back_color_vert = LLColor4::red; - LLColor4 back_color_hori = LLColor4::yellow; - back_color[VALPHA] = 0.5f; - back_color_hori[VALPHA] = 0.5f; - back_color_vert[VALPHA] = 0.5f; - //gl_rect_2d(getLocalRect(), back_color, TRUE); - //gl_rect_2d(bottom_rect, back_color_hori, TRUE); - //gl_rect_2d(left_rect, back_color_vert, TRUE); - //gl_rect_2d(right_rect, back_color_vert, TRUE); - - LLUICtrl::draw(); -} diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h deleted file mode 100644 index efe6920db8..0000000000 --- a/indra/llui/lltoolbarview.h +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @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" -#include "lltoolbar.h" -#include "llcommandmanager.h" - -class LLUICtrlFactory; - -// Parent of all LLToolBar - -class LLToolBarView : public LLUICtrl -{ -public: - // Xui structure of the toolbar panel - struct Params : public LLInitParam::Block {}; - - // Note: valid children for LLToolBarView are stored in this registry - typedef LLDefaultChildRegistry child_registry_t; - - // Xml structure of the toolbars.xml setting - // Those live in a toolbars.xml found in app_settings (for the default) and in - // the user folder for the user specific (saved) settings - struct Toolbar : public LLInitParam::Block - { - Mandatory button_display_mode; - Multiple commands; - Toolbar(); - }; - struct ToolbarSet : public LLInitParam::Block - { - Optional left_toolbar, - right_toolbar, - bottom_toolbar; - ToolbarSet(); - }; - - // Derived methods - virtual ~LLToolBarView(); - virtual BOOL postBuild(); - virtual void draw(); - - // Toolbar view interface with the rest of the world - // Checks if the commandId is being used somewhere in one of the toolbars - bool hasCommand(const LLCommandId& commandId) const; - // Loads the toolbars from the existing user or default settings - bool loadToolbars(bool force_default = false); // return false if load fails - bool loadDefaultToolbars() { return loadToolbars(true); } - -protected: - friend class LLUICtrlFactory; - LLToolBarView(const Params&); - - void initFromParams(const Params&); - -private: - void saveToolbars() const; - bool addCommand(const LLCommandId& commandId, LLToolBar* toolbar); - void addToToolset(command_id_list_t& command_list, Toolbar& toolbar) const; - - // Pointers to the toolbars handled by the toolbar view - LLToolBar* mToolbarLeft; - LLToolBar* mToolbarRight; - LLToolBar* mToolbarBottom; -}; - -extern LLToolBarView* gToolBarView; - -#endif // LL_LLTOOLBARVIEW_H -- cgit v1.2.3 From 2d0dfbca99ffa442025358ece6340b894245d3b0 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 3 Oct 2011 16:37:07 -0700 Subject: * Added tooltips to the toolbar buttons. Reviewed by Richard. --- indra/llui/lltoolbar.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index c62bbe4e71..c0058d534d 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -511,10 +511,13 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) LLCommand* commandp = LLCommandManager::instance().getCommand(id); if (!commandp) return NULL; + std::string label = LLTrans::getString(commandp->labelRef()); + std::string tooltip = label + "\n" + LLTrans::getString(commandp->tooltipRef()); + LLToolBarButton::Params button_p; button_p.name = id.name(); - button_p.label = LLTrans::getString(commandp->labelRef()); - button_p.tool_tip = button_p.label(); + button_p.label = label; + button_p.tool_tip = tooltip; button_p.image_overlay = LLUI::getUIImage(commandp->icon()); button_p.overwriteFrom(mButtonParams[mButtonType]); LLToolBarButton* button = LLUICtrlFactory::create(button_p); -- cgit v1.2.3 From edacb7b3363dca6cd28a4ff7ea27154d6a30702f Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 3 Oct 2011 18:52:22 -0700 Subject: implemented Range and ClampedValue classes to standardize min/max settings fixed not serializing named values when values provided from code --- indra/llui/lltoolbar.cpp | 11 ++-- indra/llui/lltoolbar.h | 11 ++-- indra/llui/lltoolbarview.cpp | 18 +++---- indra/llui/lltoolbarview.h | 4 +- indra/llui/llui.h | 126 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 146 insertions(+), 24 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index c0058d534d..66c2d7ab0b 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -319,7 +319,7 @@ void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row { if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) { - button->reshape(llclamp(button->getRect().getWidth(), button->mMinWidth, button->mMaxWidth), max_row_girth); + button->reshape(button->mWidthRange.clamp(button->getRect().getWidth()), max_row_girth); } else // VERTICAL { @@ -378,10 +378,10 @@ void LLToolBar::updateLayoutAsNeeded() BOOST_FOREACH(LLToolBarButton* button, mButtons) { - button->reshape(button->mMinWidth, button->mDesiredHeight); + button->reshape(button->mWidthRange.getMin(), button->mDesiredHeight); button->autoResize(); - S32 button_clamped_width = llclamp(button->getRect().getWidth(), button->mMinWidth, button->mMaxWidth); + S32 button_clamped_width = button->mWidthRange.clamp(button->getRect().getWidth()); S32 button_length = (orientation == LLLayoutStack::HORIZONTAL) ? button_clamped_width : button->getRect().getHeight(); @@ -396,7 +396,7 @@ void LLToolBar::updateLayoutAsNeeded() { if (orientation == LLLayoutStack::VERTICAL) { // row girth (width in this case) is clamped to allowable button widths - max_row_girth = llclamp(max_row_girth, button->mMinWidth, button->mMaxWidth); + max_row_girth = button->mWidthRange.clamp(max_row_girth); } // make buttons in current row all same girth @@ -543,8 +543,7 @@ LLToolBarButton::LLToolBarButton(const Params& p) : LLButton(p), mMouseDownX(0), mMouseDownY(0), - mMinWidth(p.min_button_width), - mMaxWidth(p.max_button_width), + mWidthRange(p.button_width), mDesiredHeight(p.desired_height), mId("") {} diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 5d64630fa6..48ca6c62b3 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -41,13 +41,11 @@ class LLToolBarButton : public LLButton public: struct Params : public LLInitParam::Block { - Optional min_button_width, - max_button_width, - desired_height; + Optional > button_width; + Optional desired_height; Params() - : min_button_width("min_button_width", 0), - max_button_width("max_button_width", S32_MAX), + : button_width("button_width"), desired_height("desired_height", 20) {} @@ -62,8 +60,7 @@ private: LLCommandId mId; S32 mMouseDownX; S32 mMouseDownY; - S32 mMinWidth; - S32 mMaxWidth; + LLUI::Range mWidthRange; S32 mDesiredHeight; }; diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 12247519ad..49d4bfdc3c 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -169,8 +169,8 @@ bool LLToolBarView::loadToolbars(bool force_default) { if (toolbar_set.left_toolbar.button_display_mode.isProvided()) { - U32 button_type = toolbar_set.left_toolbar.button_display_mode; - mToolbarLeft->setButtonType((LLToolBarEnums::ButtonType)(button_type)); + LLToolBarEnums::ButtonType button_type = toolbar_set.left_toolbar.button_display_mode; + mToolbarLeft->setButtonType(button_type); } BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands) { @@ -181,8 +181,8 @@ bool LLToolBarView::loadToolbars(bool force_default) { if (toolbar_set.right_toolbar.button_display_mode.isProvided()) { - U32 button_type = toolbar_set.right_toolbar.button_display_mode; - mToolbarRight->setButtonType((LLToolBarEnums::ButtonType)(button_type)); + LLToolBarEnums::ButtonType button_type = toolbar_set.right_toolbar.button_display_mode; + mToolbarRight->setButtonType(button_type); } BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands) { @@ -193,8 +193,8 @@ bool LLToolBarView::loadToolbars(bool force_default) { if (toolbar_set.bottom_toolbar.button_display_mode.isProvided()) { - U32 button_type = toolbar_set.bottom_toolbar.button_display_mode; - mToolbarBottom->setButtonType((LLToolBarEnums::ButtonType)(button_type)); + LLToolBarEnums::ButtonType button_type = toolbar_set.bottom_toolbar.button_display_mode; + mToolbarBottom->setButtonType(button_type); } BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands) { @@ -223,17 +223,17 @@ void LLToolBarView::saveToolbars() const LLToolBarView::ToolbarSet toolbar_set; if (mToolbarLeft) { - toolbar_set.left_toolbar.button_display_mode = (int)(mToolbarLeft->getButtonType()); + toolbar_set.left_toolbar.button_display_mode = mToolbarLeft->getButtonType(); addToToolset(mToolbarLeft->getCommandsList(),toolbar_set.left_toolbar); } if (mToolbarRight) { - toolbar_set.right_toolbar.button_display_mode = (int)(mToolbarRight->getButtonType()); + toolbar_set.right_toolbar.button_display_mode = mToolbarRight->getButtonType(); addToToolset(mToolbarRight->getCommandsList(),toolbar_set.right_toolbar); } if (mToolbarBottom) { - toolbar_set.bottom_toolbar.button_display_mode = (int)(mToolbarBottom->getButtonType()); + toolbar_set.bottom_toolbar.button_display_mode = mToolbarBottom->getButtonType(); addToToolset(mToolbarBottom->getCommandsList(),toolbar_set.bottom_toolbar); } diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 20525a22ac..c67b8d9d64 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -50,8 +50,8 @@ public: // the user folder for the user specific (saved) settings struct Toolbar : public LLInitParam::Block { - Mandatory button_display_mode; - Multiple commands; + Mandatory button_display_mode; + Multiple commands; Toolbar(); }; struct ToolbarSet : public LLInitParam::Block diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 3afb7c65a9..9f6fccfef6 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -147,6 +147,132 @@ class LLUI { LOG_CLASS(LLUI); public: + // + // Classes + // + + template + struct Range + { + typedef Range self_t; + + struct Params : public LLInitParam::Block + { + Optional minimum, + maximum; + + Params() + : minimum("min", 0), + maximum("max", S32_MAX) + { + + } + }; + + // correct for inverted params + Range(const Params& p = Params()) + : mMin(p.minimum), + mMax(p.maximum) + { + sanitizeRange(); + } + + Range(T minimum, T maximum) + : mMin(minimum), + mMax(maximum) + { + sanitizeRange(); + } + + S32 clamp(T input) + { + if (input < mMin) return mMin; + if (input > mMax) return mMax; + return input; + } + + void setRange(T minimum, T maximum) + { + mMin = minimum; + mMax = maximum; + sanitizeRange(); + } + + S32 getMin() { return mMin; } + S32 getMax() { return mMax; } + + bool operator==(const self_t& other) const + { + return mMin == other.mMin + && mMax == other.mMax; + } + private: + void sanitizeRange() + { + if (mMin > mMax) + { + llwarns << "Bad interval range (" << mMin << ", " << mMax << ")" << llendl; + // since max is usually the most dangerous one to ignore (buffer overflow, etc), prefer it + // in the case of a malformed range + mMin = mMax; + } + } + + + T mMin, + mMax; + }; + + template + struct ClampedValue : public Range + { + typedef Range range_t; + + struct Params : public LLInitParam::Block + { + Mandatory value; + + Params() + : value("", 0) + { + addSynonym(value, "value"); + } + }; + + ClampedValue(const Params& p) + : range_t(p) + {} + + ClampedValue(const range_t& range) + : range_t(range) + { + // set value here, after range has been sanitized + mValue = clamp(0); + } + + ClampedValue(T value, const range_t& range = range_t()) + : range_t(range) + { + mValue = clamp(value); + } + + T get() + { + return mValue; + } + + void set(T value) + { + mValue = clamp(value); + } + + + private: + T mValue; + }; + + typedef ClampedValue ClampedS32; + // // Methods // -- cgit v1.2.3 From 3689995fcfca3a99038b2aadec638819a63a02c8 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 3 Oct 2011 18:58:30 -0700 Subject: fixed build --- indra/llui/lltoolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 4b7e04b682..efa077ffa1 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -107,7 +107,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; - mUUID = LLUUID::LLUUID::generateNewID(p.name); + mUUID = LLUUID::generateNewID(p.name); } LLToolBar::~LLToolBar() @@ -570,7 +570,7 @@ LLToolBarButton::LLToolBarButton(const Params& p) mDesiredHeight(p.desired_height), mId("") { - mUUID = LLUUID::LLUUID::generateNewID(p.name); + mUUID = LLUUID::generateNewID(p.name); } BOOL LLToolBarButton::handleMouseDown(S32 x, S32 y, MASK mask) -- cgit v1.2.3 From 44e9fb446f3c92c3dfd9b5be8a3e02ec5a44ba00 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 4 Oct 2011 12:04:29 -0700 Subject: another potential gcc fix --- indra/llui/llui.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 9f6fccfef6..8cec1a16f4 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -158,8 +158,8 @@ public: struct Params : public LLInitParam::Block { - Optional minimum, - maximum; + typename Optional minimum, + maximum; Params() : minimum("min", 0), -- cgit v1.2.3 From 50c0447808f7041d5af5017c847a462e9599bdb5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 4 Oct 2011 13:26:54 -0700 Subject: disabled min and max windows macros another attempt at fixing gcc builds --- indra/llui/llui.h | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 8cec1a16f4..af8f239657 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -41,6 +41,7 @@ #include #include "lllazyvalue.h" #include "llframetimer.h" +#include // LLUIFactory #include "llsd.h" @@ -150,27 +151,25 @@ public: // // Classes // + template + struct RangeParams : public LLInitParam::Block > + { + Optional minimum, + maximum; + + RangeParams() + : minimum("min", T()), + maximum("max", std::numeric_limits::max()) + {} + }; template struct Range { typedef Range self_t; - struct Params : public LLInitParam::Block - { - typename Optional minimum, - maximum; - - Params() - : minimum("min", 0), - maximum("max", S32_MAX) - { - - } - }; - // correct for inverted params - Range(const Params& p = Params()) + Range(const RangeParams& p = RangeParams()) : mMin(p.minimum), mMax(p.maximum) { @@ -228,12 +227,12 @@ public: { typedef Range range_t; - struct Params : public LLInitParam::Block + struct Params : public LLInitParam::Block > { - Mandatory value; + Mandatory value; Params() - : value("", 0) + : value("", T()) { addSynonym(value, "value"); } -- cgit v1.2.3 From db2e763ff0537785336a330d03bb9307478cb79a Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 4 Oct 2011 14:09:03 -0700 Subject: * Modified commands to add functions for is_enabled, is_running and is_starting, currently not hooked to any functionality. --- indra/llui/llcommandmanager.cpp | 24 +++++++++++++++++------ indra/llui/llcommandmanager.h | 43 +++++++++++++++++++++++++++++++++++------ indra/llui/lltoolbar.cpp | 4 ++-- 3 files changed, 57 insertions(+), 14 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index b1147134c2..922f243806 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -48,24 +48,36 @@ const LLCommandId LLCommandId::null("null command"); // LLCommand::Params::Params() - : function("function") - , available_in_toybox("available_in_toybox", false) + : available_in_toybox("available_in_toybox", false) , icon("icon") , label_ref("label_ref") , name("name") - , parameter("parameter") , tooltip_ref("tooltip_ref") + , execute_function("execute_function") + , execute_parameters("execute_parameters") + , is_enabled_function("is_enabled_function") + , is_enabled_parameters("is_enabled_parameters") + , is_running_function("is_running_function") + , is_running_parameters("is_running_parameters") + , is_starting_function("is_starting_function") + , is_starting_parameters("is_starting_parameters") { } LLCommand::LLCommand(const LLCommand::Params& p) - : mFunction(p.function) - , mAvailableInToybox(p.available_in_toybox) + : mAvailableInToybox(p.available_in_toybox) , mIcon(p.icon) , mIdentifier(p.name) , mLabelRef(p.label_ref) - , mParameter(p.parameter) , mTooltipRef(p.tooltip_ref) + , mExecuteFunction(p.execute_function) + , mExecuteParameters(p.execute_parameters) + , mIsEnabledFunction(p.is_enabled_function) + , mIsEnabledParameters(p.is_enabled_parameters) + , mIsRunningFunction(p.is_running_function) + , mIsRunningParameters(p.is_running_parameters) + , mIsStartingFunction(p.is_starting_function) + , mIsStartingParameters(p.is_starting_parameters) { } diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 6481a05689..3ac5548a0d 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -83,41 +83,72 @@ private: typedef std::list command_id_list_t; + class LLCommand { public: struct Params : public LLInitParam::Block { Mandatory available_in_toybox; - Mandatory function; Mandatory icon; Mandatory label_ref; Mandatory name; - Optional parameter; Mandatory tooltip_ref; + Mandatory execute_function; + Optional execute_parameters; + + Optional is_enabled_function; + Optional is_enabled_parameters; + + Optional is_running_function; + Optional is_running_parameters; + + Optional is_starting_function; + Optional is_starting_parameters; + Params(); }; LLCommand(const LLCommand::Params& p); const bool availableInToybox() const { return mAvailableInToybox; } - const std::string& functionName() const { return mFunction; } const std::string& icon() const { return mIcon; } const LLCommandId& id() const { return mIdentifier; } const std::string& labelRef() const { return mLabelRef; } - const LLSD& parameter() const { return mParameter; } const std::string& tooltipRef() const { return mTooltipRef; } + const std::string& executeFunctionName() const { return mExecuteFunction; } + const LLSD& executeParameters() const { return mExecuteParameters; } + + const std::string& isEnabledFunctionName() const { return mIsEnabledFunction; } + const LLSD& isEnabledParameters() const { return mIsEnabledParameters; } + + const std::string& isRunningFunctionName() const { return mIsRunningFunction; } + const LLSD& isRunningParameters() const { return mIsRunningParameters; } + + const std::string& isStartingFunctionName() const { return mIsStartingFunction; } + const LLSD& isStartingParameters() const { return mIsStartingParameters; } + private: LLCommandId mIdentifier; bool mAvailableInToybox; - std::string mFunction; std::string mIcon; std::string mLabelRef; - LLSD mParameter; std::string mTooltipRef; + + std::string mExecuteFunction; + LLSD mExecuteParameters; + + std::string mIsEnabledFunction; + LLSD mIsEnabledParameters; + + std::string mIsRunningFunction; + LLSD mIsRunningParameters; + + std::string mIsStartingFunction; + LLSD mIsStartingParameters; }; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index efa077ffa1..a544aa9ec7 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -525,8 +525,8 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) if (!mReadOnly) { LLUICtrl::CommitCallbackParam cbParam; - cbParam.function_name = commandp->functionName(); - cbParam.parameter = commandp->parameter(); + cbParam.function_name = commandp->executeFunctionName(); + cbParam.parameter = commandp->executeParameters(); button->setCommitCallback(cbParam); button->setStartDragCallback(mStartDragItemCallback); button->setHandleDragCallback(mHandleDragItemCallback); -- cgit v1.2.3 From a8fcfc5e19811ce579799d415a9ad63a0f1f6dc7 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 4 Oct 2011 14:11:45 -0700 Subject: removed attempt at templating LLUI::Clamp values in order to get build working again --- indra/llui/lltoolbar.h | 4 +-- indra/llui/llui.h | 72 ++++++++++++++++++++++---------------------------- 2 files changed, 34 insertions(+), 42 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 407cbde7d2..3c317e10a2 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -45,7 +45,7 @@ class LLToolBarButton : public LLButton public: struct Params : public LLInitParam::Block { - Optional > button_width; + Optional button_width; Optional desired_height; Params() @@ -67,7 +67,7 @@ private: LLCommandId mId; S32 mMouseDownX; S32 mMouseDownY; - LLUI::Range mWidthRange; + LLUI::RangeS32 mWidthRange; S32 mDesiredHeight; bool mIsDragged; startdrag_callback_t mStartDragItemCallback; diff --git a/indra/llui/llui.h b/indra/llui/llui.h index af8f239657..28e84fa444 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -151,46 +151,43 @@ public: // // Classes // - template - struct RangeParams : public LLInitParam::Block > - { - Optional minimum, - maximum; - RangeParams() - : minimum("min", T()), - maximum("max", std::numeric_limits::max()) - {} - }; - - template - struct Range + struct RangeS32 { - typedef Range self_t; + struct Params : public LLInitParam::Block + { + Optional minimum, + maximum; + + Params() + : minimum("min", 0), + maximum("max", S32_MAX) + {} + }; // correct for inverted params - Range(const RangeParams& p = RangeParams()) - : mMin(p.minimum), + RangeS32(const Params& p = Params()) + : mMin(p.minimum), mMax(p.maximum) { sanitizeRange(); } - Range(T minimum, T maximum) - : mMin(minimum), + RangeS32(S32 minimum, S32 maximum) + : mMin(minimum), mMax(maximum) { sanitizeRange(); } - S32 clamp(T input) + S32 clamp(S32 input) { if (input < mMin) return mMin; if (input > mMax) return mMax; return input; } - void setRange(T minimum, T maximum) + void setRange(S32 minimum, S32 maximum) { mMin = minimum; mMax = maximum; @@ -200,7 +197,7 @@ public: S32 getMin() { return mMin; } S32 getMax() { return mMax; } - bool operator==(const self_t& other) const + bool operator==(const RangeS32& other) const { return mMin == other.mMin && mMax == other.mMax; @@ -218,60 +215,55 @@ public: } - T mMin, + S32 mMin, mMax; }; - template - struct ClampedValue : public Range + struct ClampedS32 : public RangeS32 { - typedef Range range_t; - - struct Params : public LLInitParam::Block > + struct Params : public LLInitParam::Block { - Mandatory value; + Mandatory value; Params() - : value("", T()) + : value("", 0) { addSynonym(value, "value"); } }; - ClampedValue(const Params& p) - : range_t(p) + ClampedS32(const Params& p) + : RangeS32(p) {} - ClampedValue(const range_t& range) - : range_t(range) + ClampedS32(const RangeS32& range) + : RangeS32(range) { // set value here, after range has been sanitized mValue = clamp(0); } - ClampedValue(T value, const range_t& range = range_t()) - : range_t(range) + ClampedS32(S32 value, const RangeS32& range = RangeS32()) + : RangeS32(range) { mValue = clamp(value); } - T get() + S32 get() { return mValue; } - void set(T value) + void set(S32 value) { mValue = clamp(value); } private: - T mValue; + S32 mValue; }; - typedef ClampedValue ClampedS32; - // // Methods // -- cgit v1.2.3 From 3b3a13707309eb4b7d6ed5d309081c99e5f28eca Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 5 Oct 2011 11:18:17 -0700 Subject: EXP-1286 : DaD is functional though has bugs... Working on it... --- indra/llui/llcommandmanager.cpp | 18 ++++++- indra/llui/llcommandmanager.h | 13 ++++- indra/llui/lltoolbar.cpp | 103 ++++++++++++++++++++++++++++++++++------ indra/llui/lltoolbar.h | 38 ++++++++------- 4 files changed, 137 insertions(+), 35 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index b1147134c2..a8127ab3e3 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -112,9 +112,25 @@ LLCommand * LLCommandManager::getCommand(const LLCommandId& commandId) return command_match; } +LLCommand * LLCommandManager::getCommand(const LLUUID& commandUUID) +{ + LLCommand * command_match = NULL; + + CommandUUIDMap::const_iterator found = mCommandUUIDs.find(commandUUID); + + if (found != mCommandUUIDs.end()) + { + command_match = mCommands[found->second]; + } + + return command_match; +} + void LLCommandManager::addCommand(LLCommand * command) { - mCommandIndices[command->id()] = mCommands.size(); + LLCommandId command_id = command->id(); + mCommandIndices[command_id] = mCommands.size(); + mCommandUUIDs[command_id.uuid()] = mCommands.size(); mCommands.push_back(command); lldebugs << "Successfully added command: " << command->id().name() << llendl; diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 6481a05689..c3d2cccd73 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -52,13 +52,18 @@ public: LLCommandId(const std::string& name) : mName(name) - {} + { + mUUID = LLUUID::LLUUID::generateNewID(name); + } LLCommandId(const Params& p) : mName(p.name) - {} + { + mUUID = LLUUID::LLUUID::generateNewID(p.name); + } const std::string& name() const { return mName; } + const LLUUID& uuid() const { return mUUID; } bool operator!=(const LLCommandId& command) const { @@ -79,6 +84,7 @@ public: private: std::string mName; + LLUUID mUUID; }; typedef std::list command_id_list_t; @@ -141,6 +147,7 @@ public: U32 commandCount() const; LLCommand * getCommand(U32 commandIndex); LLCommand * getCommand(const LLCommandId& commandId); + LLCommand * getCommand(const LLUUID& commandUUID); static bool load(); @@ -148,11 +155,13 @@ protected: void addCommand(LLCommand * command); private: + typedef std::map CommandUUIDMap; typedef std::map CommandIndexMap; typedef std::vector CommandVector; CommandVector mCommands; CommandIndexMap mCommandIndices; + CommandUUIDMap mCommandUUIDs; }; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 199574629f..c349bbcf2e 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -107,7 +107,6 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; - mUUID = LLUUID::LLUUID::generateNewID(p.name); } LLToolBar::~LLToolBar() @@ -193,21 +192,71 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) mNeedsLayout = true; } -bool LLToolBar::addCommand(const LLCommandId& commandId) +bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) { LLCommand * command = LLCommandManager::instance().getCommand(commandId); if (!command) return false; - mButtonCommands.push_back(commandId); + // Create the button and do the things that don't need ordering LLToolBarButton* button = createButton(commandId); - mButtons.push_back(button); mButtonPanel->addChild(button); mButtonMap.insert(std::make_pair(commandId, button)); + + // Insert the command and button in the right place in their respective lists + if ((rank >= mButtonCommands.size()) || (rank < 0)) + { + // In that case, back load + mButtonCommands.push_back(commandId); + mButtons.push_back(button); + } + else + { + // Insert in place: iterate to the right spot... + std::list::iterator it_button = mButtons.begin(); + command_id_list_t::iterator it_command = mButtonCommands.begin(); + while (rank > 0) + { + ++it_button; + ++it_command; + rank--; + } + // ...then insert + mButtonCommands.insert(it_command,commandId); + mButtons.insert(it_button,button); + } + mNeedsLayout = true; return true; } +bool LLToolBar::removeCommand(const LLCommandId& commandId) +{ + if (!hasCommand(commandId)) return false; + + // First erase the map record + command_id_map::iterator it = mButtonMap.find(commandId); + mButtonMap.erase(it); + + // Now iterate on the commands and buttons to identify the relevant records + std::list::iterator it_button = mButtons.begin(); + command_id_list_t::iterator it_command = mButtonCommands.begin(); + while (*it_command != commandId) + { + ++it_button; + ++it_command; + } + + // Delete the button and erase the command and button records + delete (*it_button); + mButtonCommands.erase(it_command); + mButtons.erase(it_button); + + mNeedsLayout = true; + + return true; +} + void LLToolBar::clearCommandsList() { // Clears the commands list @@ -328,6 +377,33 @@ void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row } } +int LLToolBar::getRankFromPosition(S32 x, S32 y) +{ + int rank = 0; + + LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType); + + // Simply compare the passed coord with the buttons outbound box + std::list::iterator it_button = mButtons.begin(); + std::list::iterator end_button = mButtons.end(); + while (it_button != end_button) + { + LLRect button_rect = (*it_button)->getRect(); + if (((orientation == LLLayoutStack::HORIZONTAL) && (button_rect.mRight > x)) || + ((orientation == LLLayoutStack::VERTICAL) && (button_rect.mTop > y)) ) + { + llinfos << "Merov debug : rank compute: orientation = " << orientation << ", x = " << x << ", y = " << y << llendl; + llinfos << "Merov debug : rank compute: rect = " << button_rect.mLeft << ", " << button_rect.mTop << ", " << button_rect.mRight << ", " << button_rect.mBottom << llendl; + break; + } + rank++; + ++it_button; + } + llinfos << "Merov debug : rank = " << rank << llendl; + + return rank; +} + void LLToolBar::updateLayoutAsNeeded() { if (!mNeedsLayout) return; @@ -494,6 +570,7 @@ void LLToolBar::createButtons() delete button; } mButtons.clear(); + mButtonMap.clear(); BOOST_FOREACH(LLCommandId& command_id, mButtonCommands) { @@ -503,7 +580,6 @@ void LLToolBar::createButtons() mButtonMap.insert(std::make_pair(command_id, button)); } mNeedsLayout = true; - } LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) @@ -543,20 +619,20 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EAcceptance* accept, std::string& tooltip_msg) { - llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", tooltip = " << tooltip_msg << llendl; + llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", x = " << x << ", y = " << y << llendl; // If we have a drop callback, that means that we can handle the drop BOOL handled = (mHandleDropCallback ? TRUE : FALSE); - // if drop, time to call the drop callback to get the operation done + // if drop is set, it's time to call the callback to get the operation done if (handled && drop) { - handled = mHandleDropCallback(cargo_type,cargo_data,mUUID); + handled = mHandleDropCallback(cargo_data, x, y ,this); } - // We accept multi drop by default - *accept = (handled ? ACCEPT_YES_MULTI : ACCEPT_NO); + // We accept only single tool drop on toolbars + *accept = (handled ? ACCEPT_YES_SINGLE : ACCEPT_NO); - // We'll use that flag to change the visual aspect of the target on draw() + // We'll use that flag to change the visual aspect of the toolbar target on draw() mDragAndDropTarget = handled; return handled; @@ -571,7 +647,6 @@ LLToolBarButton::LLToolBarButton(const Params& p) mDesiredHeight(p.desired_height), mId("") { - mUUID = LLUUID::LLUUID::generateNewID(p.name); } BOOL LLToolBarButton::handleMouseDown(S32 x, S32 y, MASK mask) @@ -590,13 +665,13 @@ BOOL LLToolBarButton::handleHover( S32 x, S32 y, MASK mask ) { if (!mIsDragged) { - mStartDragItemCallback(x,y,mUUID); + mStartDragItemCallback(x,y,mId.uuid()); mIsDragged = true; handled = TRUE; } else { - handled = mHandleDragItemCallback(x,y,mUUID,LLAssetType::AT_WIDGET); + handled = mHandleDragItemCallback(x,y,mId.uuid(),LLAssetType::AT_WIDGET); } } else diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 10e5f49c0f..ddf2e048b6 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -35,9 +35,11 @@ #include "llcommandmanager.h" #include "llassettype.h" -typedef boost::function startdrag_callback_t; -typedef boost::function handledrag_callback_t; -typedef boost::function handledrop_callback_t; +class LLToolBar; + +typedef boost::function tool_startdrag_callback_t; +typedef boost::function tool_handledrag_callback_t; +typedef boost::function tool_handledrop_callback_t; class LLToolBarButton : public LLButton { @@ -63,8 +65,8 @@ public: BOOL handleHover(S32 x, S32 y, MASK mask); void setCommandId(const LLCommandId& id) { mId = id; } - void setStartDragCallback(startdrag_callback_t cb) { mStartDragItemCallback = cb; } - void setHandleDragCallback(handledrag_callback_t cb) { mHandleDragItemCallback = cb; } + void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; } + void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; } private: LLCommandId mId; S32 mMouseDownX; @@ -72,10 +74,9 @@ private: S32 mMinWidth; S32 mMaxWidth; S32 mDesiredHeight; - bool mIsDragged; - startdrag_callback_t mStartDragItemCallback; - handledrag_callback_t mHandleDragItemCallback; - LLUUID mUUID; + bool mIsDragged; + tool_startdrag_callback_t mStartDragItemCallback; + tool_handledrag_callback_t mHandleDragItemCallback; }; @@ -146,6 +147,7 @@ public: // virtuals void draw(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); + int getRankFromPosition(S32 x, S32 y); BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -153,12 +155,13 @@ public: EAcceptance* accept, std::string& tooltip_msg); - bool addCommand(const LLCommandId& commandId); + bool addCommand(const LLCommandId& commandId, int rank = -1); + bool removeCommand(const LLCommandId& commandId); bool hasCommand(const LLCommandId& commandId) const; bool enableCommand(const LLCommandId& commandId, bool enabled); - void setStartDragCallback(startdrag_callback_t cb) { mStartDragItemCallback = cb; } - void setHandleDragCallback(handledrag_callback_t cb) { mHandleDragItemCallback = cb; } - void setHandleDropCallback(handledrop_callback_t cb) { mHandleDropCallback = cb; } + void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; } + void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; } + void setHandleDropCallback(tool_handledrop_callback_t cb) { mHandleDropCallback = cb; } LLToolBarButton* createButton(const LLCommandId& id); @@ -168,10 +171,10 @@ protected: ~LLToolBar(); void initFromParams(const Params&); - startdrag_callback_t mStartDragItemCallback; - handledrag_callback_t mHandleDragItemCallback; - handledrop_callback_t mHandleDropCallback; - bool mDragAndDropTarget; + tool_startdrag_callback_t mStartDragItemCallback; + tool_handledrag_callback_t mHandleDragItemCallback; + tool_handledrop_callback_t mHandleDropCallback; + bool mDragAndDropTarget; public: // Methods used in loading and saving toolbar settings @@ -188,7 +191,6 @@ private: BOOL isSettingChecked(const LLSD& userdata); void onSettingEnable(const LLSD& userdata); - LLUUID mUUID; const bool mReadOnly; std::list mButtons; -- cgit v1.2.3 From ba60e0906549840b8632d72f17b3f9bcda65e882 Mon Sep 17 00:00:00 2001 From: callum Date: Wed, 5 Oct 2011 12:52:40 -0700 Subject: Fix for typo that broke build. --- indra/llui/llcommandmanager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index b11f905574..8e5abd6461 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -53,13 +53,13 @@ public: LLCommandId(const std::string& name) : mName(name) { - mUUID = LLUUID::LLUUID::generateNewID(name); + mUUID = LLUUID::generateNewID(name); } LLCommandId(const Params& p) : mName(p.name) { - mUUID = LLUUID::LLUUID::generateNewID(p.name); + mUUID = LLUUID::generateNewID(p.name); } const std::string& name() const { return mName; } -- cgit v1.2.3 From 1c4d540afd488c5b64102fc14ea65433855f802a Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 5 Oct 2011 13:03:22 -0700 Subject: * Added function setOpenCallback to match existing setCloseCallback. --- indra/llui/llfloater.cpp | 9 +++++++-- indra/llui/llfloater.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index bc494e97f5..c28bcc2ec9 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1029,7 +1029,7 @@ void LLFloater::setMinimized(BOOL minimize) if (minimize == mMinimized) return; - if(mMinimizeSignal) + if (mMinimizeSignal) { (*mMinimizeSignal)(this, LLSD(minimize)); } @@ -2857,7 +2857,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p) // open callback if (p.open_callback.isProvided()) { - mOpenSignal.connect(initCommitCallback(p.open_callback)); + setOpenCallback(initCommitCallback(p.open_callback)); } // close callback if (p.close_callback.isProvided()) @@ -2872,6 +2872,11 @@ boost::signals2::connection LLFloater::setMinimizeCallback( const commit_signal_ return mMinimizeSignal->connect(cb); } +boost::signals2::connection LLFloater::setOpenCallback( const commit_signal_t::slot_type& cb ) +{ + return mOpenSignal.connect(cb); +} + boost::signals2::connection LLFloater::setCloseCallback( const commit_signal_t::slot_type& cb ) { return mCloseSignal.connect(cb); diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index fba59e82e1..5aff542049 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -144,6 +144,7 @@ public: bool buildFromFile(const std::string &filename, LLXMLNodePtr output_node = NULL); boost::signals2::connection setMinimizeCallback( const commit_signal_t::slot_type& cb ); + boost::signals2::connection setOpenCallback( const commit_signal_t::slot_type& cb ); boost::signals2::connection setCloseCallback( const commit_signal_t::slot_type& cb ); void initFromParams(const LLFloater::Params& p); -- cgit v1.2.3 From 00dc8b3982cf69dbe69b8c1913e701c37f22eba0 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 5 Oct 2011 14:47:50 -0700 Subject: EXP-1286 : DaD works between all toolbars, button drops in correct place, removal of button works too --- indra/llui/lltoolbar.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 07beb147d7..9ffb859053 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -382,6 +382,11 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) int rank = 0; LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType); + S32 button_panel_x = 0; + S32 button_panel_y = 0; + localPointToOtherView(x, y, &button_panel_x, &button_panel_y, mButtonPanel); + + //llinfos << "Merov debug : rank compute: orientation = " << orientation << ", x = " << button_panel_x << ", y = " << button_panel_y << llendl; // Simply compare the passed coord with the buttons outbound box std::list::iterator it_button = mButtons.begin(); @@ -389,17 +394,16 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) while (it_button != end_button) { LLRect button_rect = (*it_button)->getRect(); - if (((orientation == LLLayoutStack::HORIZONTAL) && (button_rect.mRight > x)) || - ((orientation == LLLayoutStack::VERTICAL) && (button_rect.mTop > y)) ) + //llinfos << "Merov debug : rank compute: rect = " << button_rect.mLeft << ", " << button_rect.mTop << ", " << button_rect.mRight << ", " << button_rect.mBottom << llendl; + if (((orientation == LLLayoutStack::HORIZONTAL) && (button_rect.mRight > button_panel_x)) || + ((orientation == LLLayoutStack::VERTICAL) && (button_rect.mBottom < button_panel_y)) ) { - llinfos << "Merov debug : rank compute: orientation = " << orientation << ", x = " << x << ", y = " << y << llendl; - llinfos << "Merov debug : rank compute: rect = " << button_rect.mLeft << ", " << button_rect.mTop << ", " << button_rect.mRight << ", " << button_rect.mBottom << llendl; break; } rank++; ++it_button; } - llinfos << "Merov debug : rank = " << rank << llendl; + //llinfos << "Merov debug : rank = " << rank << llendl; return rank; } @@ -619,7 +623,7 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EAcceptance* accept, std::string& tooltip_msg) { - llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", x = " << x << ", y = " << y << llendl; + //llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", x = " << x << ", y = " << y << llendl; // If we have a drop callback, that means that we can handle the drop BOOL handled = (mHandleDropCallback ? TRUE : FALSE); -- cgit v1.2.3 From 93e3c8e4a51dd60c202bc2e3f11b9ae850b2b6c8 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 5 Oct 2011 16:28:40 -0700 Subject: EXP-1280 FIX -- Minimized floaters associated with toolbar buttons should change the state of their parent button * Toolbar buttons now display green when its corresponding floater is open or minimized. * Made changes to buttons so flash time and rate is configurable * Removed unused "highlight_color" attribute from LLButton * Implemented "isVisible" function for toolbar button floaters. It returns true when the floater is visible or minimized. * Toolbar floater unminimize now also puts focus to the floater * All commands now specify their "is_running_function" for toolbar button state * ButtonFlashCount and ButtonFlashRate have been moved to button.xml settings and are now configurable on the button. Toolbar buttons are set to never flash and this functionality is used to show which buttons have windows open. * All toybox buttons show hover glow even when disabled Reviewed by Richard. --- indra/llui/llbutton.cpp | 24 ++++++------ indra/llui/llbutton.h | 13 +++++-- indra/llui/llfloaterreg.cpp | 23 ++++++++++++ indra/llui/llfloaterreg.h | 1 + indra/llui/lltoolbar.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++--- indra/llui/lltoolbar.h | 12 +++++- indra/llui/llui.cpp | 1 + 7 files changed, 142 insertions(+), 21 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index f259e8027e..c9ee62296f 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -83,7 +83,6 @@ LLButton::Params::Params() label_color_selected("label_color_selected"), // requires is_toggle true label_color_disabled("label_color_disabled"), label_color_disabled_selected("label_color_disabled_selected"), - highlight_color("highlight_color"), image_color("image_color"), image_color_disabled("image_color_disabled"), image_overlay_color("image_overlay_color", LLColor4::white), @@ -99,10 +98,13 @@ LLButton::Params::Params() scale_image("scale_image", true), hover_glow_amount("hover_glow_amount"), commit_on_return("commit_on_return", true), + display_pressed_state("display_pressed_state", true), use_draw_context_alpha("use_draw_context_alpha", true), badge("badge"), handle_right_mouse("handle_right_mouse"), - held_down_delay("held_down_delay") + held_down_delay("held_down_delay"), + button_flash_count("button_flash_count"), + button_flash_rate("button_flash_rate") { addSynonym(is_toggle, "toggle"); changeDefault(initial_value, LLSD(false)); @@ -136,7 +138,6 @@ LLButton::LLButton(const LLButton::Params& p) mSelectedLabelColor(p.label_color_selected()), mDisabledLabelColor(p.label_color_disabled()), mDisabledSelectedLabelColor(p.label_color_disabled_selected()), - mHighlightColor(p.highlight_color()), mImageColor(p.image_color()), mFlashBgColor(p.flash_color()), mDisabledImageColor(p.image_color_disabled()), @@ -159,12 +160,15 @@ LLButton::LLButton(const LLButton::Params& p) mCommitOnReturn(p.commit_on_return), mFadeWhenDisabled(FALSE), mForcePressedState(false), + mDisplayPressedState(p.display_pressed_state), mLastDrawCharsCount(0), mMouseDownSignal(NULL), mMouseUpSignal(NULL), mHeldDownSignal(NULL), mUseDrawContextAlpha(p.use_draw_context_alpha), - mHandleRightMouse(p.handle_right_mouse) + mHandleRightMouse(p.handle_right_mouse), + mButtonFlashCount(p.button_flash_count), + mButtonFlashRate(p.button_flash_rate) { static LLUICachedControl llbutton_orig_h_pad ("UIButtonOrigHPad", 0); static Params default_params(LLUICtrlFactory::getDefaultParams()); @@ -570,15 +574,13 @@ void LLButton::draw() { F32 alpha = mUseDrawContextAlpha ? getDrawContext().mAlpha : getCurrentTransparency(); bool flash = FALSE; - static LLUICachedControl button_flash_rate("ButtonFlashRate", 0); - static LLUICachedControl button_flash_count("ButtonFlashCount", 0); if( mFlashing ) { F32 elapsed = mFlashingTimer.getElapsedTimeF32(); - S32 flash_count = S32(elapsed * button_flash_rate * 2.f); + S32 flash_count = S32(elapsed * mButtonFlashRate * 2.f); // flash on or off? - flash = (flash_count % 2 == 0) || flash_count > S32((F32)button_flash_count * 2.f); + flash = (flash_count % 2 == 0) || flash_count > S32((F32)mButtonFlashCount * 2.f); } bool pressed_by_keyboard = FALSE; @@ -607,7 +609,7 @@ void LLButton::draw() LLColor4 glow_color = LLColor4::white; LLRender::eBlendType glow_type = LLRender::BT_ADD_WITH_ALPHA; LLUIImage* imagep = NULL; - if (pressed) + if (pressed && mDisplayPressedState) { imagep = selected ? mImagePressedSelected : mImagePressed; } @@ -800,7 +802,7 @@ void LLButton::draw() S32 center_y = getLocalRect().getCenterY(); //FUGLY HACK FOR "DEPRESSED" BUTTONS - if (pressed) + if (pressed && mDisplayPressedState) { center_y--; center_x++; @@ -873,7 +875,7 @@ void LLButton::draw() S32 y_offset = 2 + (getRect().getHeight() - 20)/2; - if (pressed) + if (pressed && mDisplayPressedState) { y_offset--; x++; diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 08b45e01b3..14c1d01c7e 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -91,7 +91,6 @@ public: label_color_selected, label_color_disabled, label_color_disabled_selected, - highlight_color, image_color, image_color_disabled, image_overlay_color, @@ -120,7 +119,8 @@ public: // misc Optional is_toggle, scale_image, - commit_on_return; + commit_on_return, + display_pressed_state; Optional hover_glow_amount; Optional held_down_delay; @@ -131,6 +131,9 @@ public: Optional handle_right_mouse; + Optional button_flash_count; + Optional button_flash_rate; + Params(); }; @@ -273,6 +276,9 @@ protected: void getOverlayImageSize(S32& overlay_width, S32& overlay_height); LLFrameTimer mMouseDownTimer; + bool mNeedsHighlight; + S32 mButtonFlashCount; + F32 mButtonFlashRate; private: void drawBorder(LLUIImage* imagep, const LLColor4& color, S32 size); @@ -322,7 +328,6 @@ private: flash icon name is set in attributes(by default it isn't). First way is used otherwise. */ LLPointer mImageFlash; - LLUIColor mHighlightColor; LLUIColor mFlashBgColor; LLUIColor mImageColor; @@ -355,10 +360,10 @@ private: F32 mHoverGlowStrength; F32 mCurGlowStrength; - bool mNeedsHighlight; bool mCommitOnReturn; bool mFadeWhenDisabled; bool mForcePressedState; + bool mDisplayPressedState; LLFrameTimer mFlashingTimer; diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index 27e96856b3..d0ae9413a3 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -478,6 +478,7 @@ void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) if (LLFloater::isMinimized(instance)) { instance->setMinimized(FALSE); + instance->setFocus(TRUE); } else if (!LLFloater::isShown(instance)) { @@ -493,6 +494,28 @@ void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) } } +//static +bool LLFloaterReg::floaterInstanceOpen(const LLSD& sdname) +{ + LLSD key; + std::string name = sdname.asString(); + parse_name_key(name, key); + + bool visible_or_minimized = instanceVisible(name, key); + + if (!visible_or_minimized) + { + LLFloater* instance = findInstance(name, key); + + if (instance != NULL) + { + visible_or_minimized = LLFloater::isMinimized(instance); + } + } + + return visible_or_minimized; +} + //static bool LLFloaterReg::floaterInstanceVisible(const LLSD& sdname) { diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index 6239d98a7d..07ae45cc4c 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -128,6 +128,7 @@ public: static void hideFloaterInstance(const LLSD& sdname); static void toggleFloaterInstance(const LLSD& sdname); static void toggleToolbarFloaterInstance(const LLSD& sdname); + static bool floaterInstanceOpen(const LLSD& sdname); static bool floaterInstanceVisible(const LLSD& sdname); static bool floaterInstanceMinimized(const LLSD& sdname); diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index a544aa9ec7..0ec2eefc19 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -471,7 +471,33 @@ void LLToolBar::updateLayoutAsNeeded() void LLToolBar::draw() { - if (mButtons.empty()) return; + if (mButtons.empty()) + { + return; + } + + // Update enable/disable state and highlight state for editable toolbars + if (!mReadOnly) + { + for (toolbar_button_list::iterator btn_it = mButtons.begin(); btn_it != mButtons.end(); ++btn_it) + { + LLToolBarButton* btn = *btn_it; + LLCommand* command = LLCommandManager::instance().getCommand(btn->mId); + + if (command && btn->mIsEnabledSignal) + { + const bool button_command_enabled = (*btn->mIsEnabledSignal)(btn, command->isEnabledParameters()); + btn->setEnabled(button_command_enabled); + } + + if (command && btn->mIsRunningSignal) + { + const bool button_command_running = (*btn->mIsRunningSignal)(btn, command->isRunningParameters()); + btn->setFlashing(button_command_running); + } + } + } + updateLayoutAsNeeded(); // rect may have shifted during layout LLUI::popMatrix(); @@ -527,14 +553,47 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) LLUICtrl::CommitCallbackParam cbParam; cbParam.function_name = commandp->executeFunctionName(); cbParam.parameter = commandp->executeParameters(); + button->setCommitCallback(cbParam); button->setStartDragCallback(mStartDragItemCallback); button->setHandleDragCallback(mHandleDragItemCallback); + + const std::string& isEnabledFunction = commandp->isEnabledFunctionName(); + if (isEnabledFunction.length() > 0) + { + LLUICtrl::EnableCallbackParam isEnabledParam; + isEnabledParam.function_name = isEnabledFunction; + isEnabledParam.parameter = commandp->isEnabledParameters(); + enable_signal_t::slot_type isEnabledCB = initEnableCallback(isEnabledParam); + + if (NULL == button->mIsEnabledSignal) + { + button->mIsEnabledSignal = new enable_signal_t(); + } + + button->mIsEnabledSignal->connect(isEnabledCB); + } + + const std::string& isRunningFunction = commandp->isRunningFunctionName(); + if (isRunningFunction.length() > 0) + { + LLUICtrl::EnableCallbackParam isRunningParam; + isRunningParam.function_name = isRunningFunction; + isRunningParam.parameter = commandp->isRunningParameters(); + enable_signal_t::slot_type isRunningCB = initEnableCallback(isRunningParam); + + if (NULL == button->mIsRunningSignal) + { + button->mIsRunningSignal = new enable_signal_t(); + } + + button->mIsRunningSignal->connect(isRunningCB); + } } button->setCommandId(id); - return button; + return button; } BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, @@ -568,9 +627,22 @@ LLToolBarButton::LLToolBarButton(const Params& p) mMouseDownY(0), mWidthRange(p.button_width), mDesiredHeight(p.desired_height), - mId("") + mId(""), + mIsEnabledSignal(NULL), + mIsRunningSignal(NULL), + mIsStartingSignal(NULL) { mUUID = LLUUID::generateNewID(p.name); + + mButtonFlashRate = 0.0; + mButtonFlashCount = 0; +} + +LLToolBarButton::~LLToolBarButton() +{ + delete mIsEnabledSignal; + delete mIsRunningSignal; + delete mIsStartingSignal; } BOOL LLToolBarButton::handleMouseDown(S32 x, S32 y, MASK mask) @@ -594,10 +666,10 @@ BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask) handled = TRUE; } else - { + { handled = mHandleDragItemCallback(x,y,mUUID,LLAssetType::AT_WIDGET); - } } + } else { handled = LLButton::handleHover(x, y, mask); @@ -605,3 +677,10 @@ BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask) return handled; } +void LLToolBarButton::onMouseEnter(S32 x, S32 y, MASK mask) +{ + LLUICtrl::onMouseEnter(x, y, mask); + + // Always highlight toolbar buttons, even if they are disabled + mNeedsHighlight = TRUE; +} diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 3c317e10a2..b649ab28ff 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -56,6 +56,7 @@ public: }; LLToolBarButton(const Params& p); + ~LLToolBarButton(); BOOL handleMouseDown(S32 x, S32 y, MASK mask); BOOL handleHover(S32 x, S32 y, MASK mask); @@ -63,6 +64,9 @@ public: void setStartDragCallback(startdrag_callback_t cb) { mStartDragItemCallback = cb; } void setHandleDragCallback(handledrag_callback_t cb) { mHandleDragItemCallback = cb; } + + void onMouseEnter(S32 x, S32 y, MASK mask); + private: LLCommandId mId; S32 mMouseDownX; @@ -73,6 +77,10 @@ private: startdrag_callback_t mStartDragItemCallback; handledrag_callback_t mHandleDragItemCallback; LLUUID mUUID; + + enable_signal_t* mIsEnabledSignal; + enable_signal_t* mIsRunningSignal; + enable_signal_t* mIsStartingSignal; }; @@ -153,6 +161,7 @@ public: bool addCommand(const LLCommandId& commandId); bool hasCommand(const LLCommandId& commandId) const; bool enableCommand(const LLCommandId& commandId, bool enabled); + void setStartDragCallback(startdrag_callback_t cb) { mStartDragItemCallback = cb; } void setHandleDragCallback(handledrag_callback_t cb) { mHandleDragItemCallback = cb; } void setHandleDropCallback(handledrop_callback_t cb) { mHandleDropCallback = cb; } @@ -188,7 +197,8 @@ private: LLUUID mUUID; const bool mReadOnly; - std::list mButtons; + typedef std::list toolbar_button_list; + toolbar_button_list mButtons; command_id_list_t mButtonCommands; typedef std::map command_id_map; command_id_map mButtonMap; diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 76a12e649b..9c0253f074 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -1637,6 +1637,7 @@ 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)); + LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.IsOpen", boost::bind(&LLFloaterReg::floaterInstanceOpen, _2)); // Parse the master list of commands LLCommandManager::load(); -- cgit v1.2.3 From 17c699e4281ffff58e24c5db960a5c33018f1747 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 5 Oct 2011 16:29:12 -0700 Subject: * Updated flash_color to use old LLButton highlight_color default. --- indra/llui/lltooltip.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp index bc6461a0c2..23cdd9ad9a 100644 --- a/indra/llui/lltooltip.cpp +++ b/indra/llui/lltooltip.cpp @@ -200,7 +200,7 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p) icon_params.image_selected(imagep); icon_params.scale_image(true); - icon_params.flash_color(icon_params.highlight_color()); + icon_params.flash_color.control = "ButtonUnselectedFgColor"; mInfoButton = LLUICtrlFactory::create(icon_params); if (p.click_callback.isProvided()) { -- cgit v1.2.3 From 70495f6f2f61687717135f027c224003f5c5360a Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 5 Oct 2011 16:56:49 -0700 Subject: Fixing merge mistakes! --- indra/llui/lltoolbar.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 62217a664a..392e26f496 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -712,8 +712,6 @@ LLToolBarButton::LLToolBarButton(const Params& p) mIsRunningSignal(NULL), mIsStartingSignal(NULL) { - mUUID = LLUUID::generateNewID(p.name); - mButtonFlashRate = 0.0; mButtonFlashCount = 0; } -- cgit v1.2.3 From 64d005bfed6c5adcd29df3ae0774747480a0d839 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 5 Oct 2011 17:04:07 -0700 Subject: EXP-1286 : Add DaD to toybox --- indra/llui/lltoolbar.cpp | 11 ++++++++--- indra/llui/lltoolbar.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 9ffb859053..ef36f426fa 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -103,7 +103,11 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) mPadTop(p.pad_top), mPadBottom(p.pad_bottom), mPadBetween(p.pad_between), - mPopupMenuHandle() + mPopupMenuHandle(), + mStartDragItemCallback(NULL), + mHandleDragItemCallback(NULL), + mHandleDropCallback(NULL), + mDragAndDropTarget(false) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; @@ -608,9 +612,10 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) cbParam.function_name = commandp->executeFunctionName(); cbParam.parameter = commandp->executeParameters(); button->setCommitCallback(cbParam); - button->setStartDragCallback(mStartDragItemCallback); - button->setHandleDragCallback(mHandleDragItemCallback); } + // Drag and drop behavior must work also if provided in the Toybox and, potentially, any read-only toolbar + button->setStartDragCallback(mStartDragItemCallback); + button->setHandleDragCallback(mHandleDragItemCallback); button->setCommandId(id); return button; diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index a35f6d9db1..b630b82d0f 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -159,6 +159,7 @@ public: void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; } void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; } void setHandleDropCallback(tool_handledrop_callback_t cb) { mHandleDropCallback = cb; } + bool isReadOnly() const { return mReadOnly; } LLToolBarButton* createButton(const LLCommandId& id); -- cgit v1.2.3 From fc5030fcfe9d3ffcbb2ad1ae0b1dacd1699a54ce Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 5 Oct 2011 22:46:30 -0700 Subject: EXP-1286 : Clean-up the mess I added to llcommandmanager. All CommandId now have a trusted UUID which is the base for indexing and comparison. --- indra/llui/llcommandmanager.cpp | 19 ++----------------- indra/llui/llcommandmanager.h | 16 ++++++++++------ 2 files changed, 12 insertions(+), 23 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index 2bd50af7af..9ce7533e1b 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -114,7 +114,7 @@ LLCommand * LLCommandManager::getCommand(const LLCommandId& commandId) { LLCommand * command_match = NULL; - CommandIndexMap::const_iterator found = mCommandIndices.find(commandId); + CommandIndexMap::const_iterator found = mCommandIndices.find(commandId.uuid()); if (found != mCommandIndices.end()) { @@ -124,25 +124,10 @@ LLCommand * LLCommandManager::getCommand(const LLCommandId& commandId) return command_match; } -LLCommand * LLCommandManager::getCommand(const LLUUID& commandUUID) -{ - LLCommand * command_match = NULL; - - CommandUUIDMap::const_iterator found = mCommandUUIDs.find(commandUUID); - - if (found != mCommandUUIDs.end()) - { - command_match = mCommands[found->second]; - } - - return command_match; -} - void LLCommandManager::addCommand(LLCommand * command) { LLCommandId command_id = command->id(); - mCommandIndices[command_id] = mCommands.size(); - mCommandUUIDs[command_id.uuid()] = mCommands.size(); + mCommandIndices[command_id.uuid()] = mCommands.size(); mCommands.push_back(command); lldebugs << "Successfully added command: " << command->id().name() << llendl; diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 8e5abd6461..8f9f956ec7 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -62,17 +62,24 @@ public: mUUID = LLUUID::generateNewID(p.name); } + LLCommandId(const LLUUID& uuid) + : mName(""), + mUUID(uuid) + + { + } + const std::string& name() const { return mName; } const LLUUID& uuid() const { return mUUID; } bool operator!=(const LLCommandId& command) const { - return (mName != command.mName); + return (mUUID != command.mUUID); } bool operator==(const LLCommandId& command) const { - return (mName == command.mName); + return (mUUID == command.mUUID); } bool operator<(const LLCommandId& command) const @@ -178,7 +185,6 @@ public: U32 commandCount() const; LLCommand * getCommand(U32 commandIndex); LLCommand * getCommand(const LLCommandId& commandId); - LLCommand * getCommand(const LLUUID& commandUUID); static bool load(); @@ -186,13 +192,11 @@ protected: void addCommand(LLCommand * command); private: - typedef std::map CommandUUIDMap; - typedef std::map CommandIndexMap; + typedef std::map CommandIndexMap; typedef std::vector CommandVector; CommandVector mCommands; CommandIndexMap mCommandIndices; - CommandUUIDMap mCommandUUIDs; }; -- cgit v1.2.3 From adeaf71e3314e44a33864dbe90d93040d4247c67 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Thu, 6 Oct 2011 15:19:15 -0700 Subject: EXP-1300 WIP Visual feedback for Drag and Drop removed hover highlighting of buttons when dragging over them also updated toolbar button art to match spec --- indra/llui/llbutton.cpp | 13 ++++--------- indra/llui/llbutton.h | 1 - indra/llui/lltoolbar.cpp | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index c9ee62296f..68cb5164b6 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -515,15 +515,6 @@ BOOL LLButton::handleRightMouseUp(S32 x, S32 y, MASK mask) return TRUE; } - -void LLButton::onMouseEnter(S32 x, S32 y, MASK mask) -{ - LLUICtrl::onMouseEnter(x, y, mask); - - if (isInEnabledChain()) - mNeedsHighlight = TRUE; -} - void LLButton::onMouseLeave(S32 x, S32 y, MASK mask) { LLUICtrl::onMouseLeave(x, y, mask); @@ -538,6 +529,10 @@ void LLButton::setHighlight(bool b) BOOL LLButton::handleHover(S32 x, S32 y, MASK mask) { + if (isInEnabledChain() + && (!gFocusMgr.getMouseCapture() || gFocusMgr.getMouseCapture() != this)) + mNeedsHighlight = TRUE; + if (!childrenHandleHover(x, y, mask)) { if (mMouseDownTimer.getStarted()) diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 14c1d01c7e..a0a7b4e372 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -160,7 +160,6 @@ public: virtual void draw(); /*virtual*/ BOOL postBuild(); - virtual void onMouseEnter(S32 x, S32 y, MASK mask); virtual void onMouseLeave(S32 x, S32 y, MASK mask); virtual void onMouseCaptureLost(); diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 7fc6a6de8d..63a1706fe4 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -577,7 +577,7 @@ void LLToolBar::draw() if (command && btn->mIsRunningSignal) { const bool button_command_running = (*btn->mIsRunningSignal)(btn, command->isRunningParameters()); - btn->setFlashing(button_command_running); + btn->setToggleState(button_command_running); } } } -- cgit v1.2.3 From 740b3547d6b4685bcd89bb2781ccb423ab935799 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Thu, 6 Oct 2011 16:48:19 -0700 Subject: EXP-1303 FIX Drag and dropping button over viewer area can select objects inworld fixed close button not working on floaters against right edge of window fixed drag and drop only working once per toolbar button reimplemented drag and drop threshold --- indra/llui/lltoolbar.cpp | 20 ++++++++++++++++++-- indra/llui/lltoolbar.h | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 63a1706fe4..c34fbcd4f5 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -177,6 +177,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) center_panel_p.rect = getLocalRect(); center_panel_p.auto_resize = false; center_panel_p.user_resize = false; + center_panel_p.mouse_opaque = false; LLLayoutPanel* center_panel = LLUICtrlFactory::create(center_panel_p); mCenteringStack->addChild(center_panel); @@ -557,7 +558,13 @@ void LLToolBar::draw() { if (mButtons.empty()) { - return; + mButtonPanel->setVisible(FALSE); + mButtonPanel->setMouseOpaque(FALSE); + } + else + { + mButtonPanel->setVisible(TRUE); + mButtonPanel->setMouseOpaque(TRUE); } // Update enable/disable state and highlight state for editable toolbars @@ -741,7 +748,11 @@ BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask) // llinfos << "Merov debug: handleHover, x = " << x << ", y = " << y << ", mouse = " << hasMouseCapture() << llendl; BOOL handled = FALSE; - if (hasMouseCapture() && mStartDragItemCallback && mHandleDragItemCallback) + S32 mouse_distance_squared = (x - mMouseDownX) * (x - mMouseDownX) + (y - mMouseDownY) * (y - mMouseDownY); + S32 drag_threshold = LLUI::sSettingGroups["config"]->getS32("DragAndDropDistanceThreshold"); + if (mouse_distance_squared > drag_threshold * drag_threshold + && hasMouseCapture() && + mStartDragItemCallback && mHandleDragItemCallback) { if (!mIsDragged) { @@ -768,3 +779,8 @@ void LLToolBarButton::onMouseEnter(S32 x, S32 y, MASK mask) // Always highlight toolbar buttons, even if they are disabled mNeedsHighlight = TRUE; } + +void LLToolBarButton::onMouseCaptureLost() +{ + mIsDragged = false; +} diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 3fbe5a7703..4fac081130 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -68,6 +68,7 @@ public: void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; } void onMouseEnter(S32 x, S32 y, MASK mask); + void onMouseCaptureLost(); private: LLCommandId mId; -- cgit v1.2.3 From ea02a6a80d52a030db71100856826eaff43ccce8 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 6 Oct 2011 17:14:54 -0700 Subject: EXP-1301 : Init some members that were not initialized correctly --- indra/llui/lltoolbar.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index c34fbcd4f5..1f5fa5f361 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -723,7 +723,10 @@ LLToolBarButton::LLToolBarButton(const Params& p) mId(""), mIsEnabledSignal(NULL), mIsRunningSignal(NULL), - mIsStartingSignal(NULL) + mIsStartingSignal(NULL), + mIsDragged(false), + mStartDragItemCallback(NULL), + mHandleDragItemCallback(NULL) { mButtonFlashRate = 0.0; mButtonFlashCount = 0; -- cgit v1.2.3 From 35d3fa12ba1b375a55c34680f9c8577ca3c4842c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 7 Oct 2011 10:11:20 -0700 Subject: minor code cleanup --- indra/llui/llcommandmanager.cpp | 2 +- indra/llui/llfloater.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index b1147134c2..42aa9b333b 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -139,7 +139,7 @@ bool LLCommandManager::load() if (!commandsParams.validateBlock()) { - llerrs << "Unable to validate commands param block from file: " << commands_file << llendl; + llerrs << "Invalid commands file: " << commands_file << llendl; return false; } diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index bc494e97f5..177344cde7 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -840,9 +840,9 @@ void LLFloater::applyRectControl() if (mRectControl.size() > 1) { const LLRect& rect = getControlGroup()->getRect(mRectControl); - if (rect.getWidth() > 0 && rect.getHeight() > 0) + if (rect.notEmpty()) { - translate( rect.mLeft - getRect().mLeft, rect.mBottom - getRect().mBottom); + setOrigin(rect.mLeft, rect.mBottom); if (mResizable) { reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight())); -- cgit v1.2.3 From 13a2431cb3ca24be1de51c041a046df6fe641b9e Mon Sep 17 00:00:00 2001 From: Paul ProductEngine Date: Fri, 7 Oct 2011 21:07:03 +0300 Subject: EXP-1255 FIXED (More spillover does not contain separator and "Open Landmarks" menuitem) - Added menu item "Open landmarks" as the last menu item in favorites menu --- indra/llui/lltoolbar.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 4fac081130..e4534dea5f 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -173,6 +173,8 @@ public: LLToolBarButton* createButton(const LLCommandId& id); + bool hasButtons() { return !mButtons.empty(); } + protected: friend class LLUICtrlFactory; LLToolBar(const Params&); -- cgit v1.2.3 From feabe29f356ca2bae5275a5cb0d772614166d2c5 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 7 Oct 2011 18:30:57 -0700 Subject: EXP-1300 : Completed the drawing of drop zones on toolbars when dragging tools --- indra/llui/lltoolbar.cpp | 4 ++++ indra/llui/lltoolbar.h | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 1f5fa5f361..5f7afb07fc 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -86,6 +86,7 @@ LLToolBar::Params::Params() pad_right("pad_right"), pad_bottom("pad_bottom"), pad_between("pad_between"), + min_girth("min_girth"), button_panel("button_panel") {} @@ -103,6 +104,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) mPadTop(p.pad_top), mPadBottom(p.pad_bottom), mPadBetween(p.pad_between), + mMinGirth(p.min_girth), mPopupMenuHandle(), mStartDragItemCallback(NULL), mHandleDragItemCallback(NULL), @@ -517,6 +519,8 @@ void LLToolBar::updateLayoutAsNeeded() S32 total_girth = cur_row // current row position... + max_row_girth // ...incremented by size of final row... + girth_pad_end; // ...plus padding reserved on end + total_girth = llmax(total_girth,mMinGirth); + max_row_length = llmax(max_row_length, row_running_length - mPadBetween + row_pad_end); resizeButtonsInRow(buttons_in_row, max_row_girth); diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 4fac081130..be0589f3c6 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -141,7 +141,8 @@ public: pad_top, pad_right, pad_bottom, - pad_between; + pad_between, + min_girth; // get rid of this Multiple commands; @@ -219,7 +220,8 @@ private: mPadRight, mPadTop, mPadBottom, - mPadBetween; + mPadBetween, + mMinGirth; LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT]; -- cgit v1.2.3 From ec5ea33c8113a63e956c195ccf051b2a03979be9 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sun, 9 Oct 2011 15:52:45 -0700 Subject: EXP-1300 : drop tool animation. First shot. Works but still a bit hacky and with some bugs (tools can be duplicated at times). --- indra/llui/llcommandmanager.cpp | 2 +- indra/llui/llcommandmanager.h | 11 ++++-- indra/llui/lltoolbar.cpp | 83 +++++++++++++++++++++++++++++++++++------ indra/llui/lltoolbar.h | 4 +- 4 files changed, 84 insertions(+), 16 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index 1b87f20d12..d8e035a320 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -41,7 +41,7 @@ // LLCommandId class // -const LLCommandId LLCommandId::null("null command"); +const LLCommandId LLCommandId::null = LLCommandId(); // // LLCommand class diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 8f9f956ec7..fdad7cd1b5 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -50,6 +50,12 @@ public: {} }; + LLCommandId() + : mName("null command") + { + mUUID = LLUUID::generateNewID(mName); + } + LLCommandId(const std::string& name) : mName(name) { @@ -62,10 +68,9 @@ public: mUUID = LLUUID::generateNewID(p.name); } - LLCommandId(const LLUUID& uuid) - : mName(""), + LLCommandId(const std::string& name, const LLUUID& uuid) + : mName(name), mUUID(uuid) - { } diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 5f7afb07fc..6332b2674a 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -33,6 +33,7 @@ #include "llcommandmanager.h" #include "llmenugl.h" #include "lltrans.h" +#include "llinventory.h" // uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit // thanks, MSVC! @@ -113,6 +114,8 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; + mDraggedCommand = LLCommandId::null; + mRank = 0; } LLToolBar::~LLToolBar() @@ -203,17 +206,24 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) { LLCommand * command = LLCommandManager::instance().getCommand(commandId); if (!command) return false; - + llinfos << "Merov debug : addCommand, " << commandId.name() << ", " << commandId.uuid() << llendl; + // Create the button and do the things that don't need ordering LLToolBarButton* button = createButton(commandId); mButtonPanel->addChild(button); - mButtonMap.insert(std::make_pair(commandId, button)); + LLCommandId temp_command = commandId; + if (commandId.name() == "Drag Tool") + { + temp_command = LLCommandId("Drag Tool"); + } + mButtonMap.insert(std::make_pair(temp_command.uuid(), button)); + // Insert the command and button in the right place in their respective lists if ((rank >= mButtonCommands.size()) || (rank < 0)) { // In that case, back load - mButtonCommands.push_back(commandId); + mButtonCommands.push_back(temp_command); mButtons.push_back(button); } else @@ -228,7 +238,7 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) rank--; } // ...then insert - mButtonCommands.insert(it_command,commandId); + mButtonCommands.insert(it_command,temp_command); mButtons.insert(it_button,button); } @@ -241,14 +251,20 @@ bool LLToolBar::removeCommand(const LLCommandId& commandId) { if (!hasCommand(commandId)) return false; + llinfos << "Merov debug : removeCommand, " << commandId.name() << ", " << commandId.uuid() << llendl; // First erase the map record - command_id_map::iterator it = mButtonMap.find(commandId); + LLCommandId temp_command = commandId; + if (commandId.name() == "Drag Tool") + { + temp_command = LLCommandId("Drag Tool"); + } + command_id_map::iterator it = mButtonMap.find(temp_command.uuid()); mButtonMap.erase(it); // Now iterate on the commands and buttons to identify the relevant records std::list::iterator it_button = mButtons.begin(); command_id_list_t::iterator it_command = mButtonCommands.begin(); - while (*it_command != commandId) + while (*it_command != temp_command) { ++it_button; ++it_command; @@ -276,7 +292,12 @@ bool LLToolBar::hasCommand(const LLCommandId& commandId) const { if (commandId != LLCommandId::null) { - command_id_map::const_iterator it = mButtonMap.find(commandId); + LLCommandId temp_command = commandId; + if (commandId.name() == "Drag Tool") + { + temp_command = LLCommandId("Drag Tool"); + } + command_id_map::const_iterator it = mButtonMap.find(temp_command.uuid()); return (it != mButtonMap.end()); } @@ -289,7 +310,12 @@ bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled) if (commandId != LLCommandId::null) { - command_id_map::iterator it = mButtonMap.find(commandId); + LLCommandId temp_command = commandId; + if (commandId.name() == "Drag Tool") + { + temp_command = LLCommandId("Drag Tool"); + } + command_id_map::iterator it = mButtonMap.find(temp_command.uuid()); if (it != mButtonMap.end()) { it->second->setEnabled(enabled); @@ -507,7 +533,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 + mPadBetween; @@ -592,6 +618,12 @@ void LLToolBar::draw() } } } + // HACK!!! + if (!mDragAndDropTarget) + { + removeCommand(mDraggedCommand); + mDraggedCommand = LLCommandId::null; + } updateLayoutAsNeeded(); // rect may have shifted during layout @@ -622,7 +654,12 @@ void LLToolBar::createButtons() LLToolBarButton* button = createButton(command_id); mButtons.push_back(button); mButtonPanel->addChild(button); - mButtonMap.insert(std::make_pair(command_id, button)); + LLCommandId temp_command = command_id; + if (command_id.name() == "Drag Tool") + { + temp_command = LLCommandId("Drag Tool"); + } + mButtonMap.insert(std::make_pair(temp_command.uuid(), button)); } mNeedsLayout = true; } @@ -713,7 +750,31 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, *accept = (handled ? ACCEPT_YES_SINGLE : ACCEPT_NO); // We'll use that flag to change the visual aspect of the toolbar target on draw() - mDragAndDropTarget = handled; + mDragAndDropTarget = false; + + // HACK!!! + if (!isReadOnly() && handled) + { + if (!drop) + { + LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data; + LLAssetType::EType type = inv_item->getType(); + if (type == LLAssetType::AT_WIDGET) + { + mRank = getRankFromPosition(x, y); + mDraggedCommand = LLCommandId("Drag Tool",inv_item->getUUID()); + removeCommand(mDraggedCommand); + addCommand(mDraggedCommand,mRank); + mDragAndDropTarget = true; + } + } + else + { + removeCommand(mDraggedCommand); + mDraggedCommand = LLCommandId::null; + } + + } return handled; } diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index be0589f3c6..9e48dee608 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -184,6 +184,8 @@ protected: tool_handledrag_callback_t mHandleDragItemCallback; tool_handledrop_callback_t mHandleDropCallback; bool mDragAndDropTarget; + int mRank; + LLCommandId mDraggedCommand; public: // Methods used in loading and saving toolbar settings @@ -205,7 +207,7 @@ private: typedef std::list toolbar_button_list; toolbar_button_list mButtons; command_id_list_t mButtonCommands; - typedef std::map command_id_map; + typedef std::map command_id_map; command_id_map mButtonMap; LLToolBarEnums::ButtonType mButtonType; -- cgit v1.2.3 From 9273459251a6c59f8fabc50d9eef0b78e092e6fd Mon Sep 17 00:00:00 2001 From: Seth ProductEngine Date: Mon, 10 Oct 2011 17:09:46 +0300 Subject: EXP-1285 FIXED Chiclets moved to the upper right of the viewer window. - Floaters dock to chiclets at the bottom. - Floaters docking region limited to non-toolbar view. - Chiclet bar is positioned between the right toolbar and the minimized floaters stacked at the top left corner by default. --- indra/llui/lldockcontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/lldockcontrol.cpp b/indra/llui/lldockcontrol.cpp index 6e39fcd714..6397bbd0de 100644 --- a/indra/llui/lldockcontrol.cpp +++ b/indra/llui/lldockcontrol.cpp @@ -92,7 +92,7 @@ void LLDockControl::setDock(LLView* dockWidget) void LLDockControl::getAllowedRect(LLRect& rect) { - rect = mDockableFloater->getRootView()->getRect(); + rect = mDockableFloater->getRootView()->getChild("non_toolbar_panel")->getRect(); } void LLDockControl::repositionDockable() -- cgit v1.2.3 From e61569d71422931e0d1f8d7e2f6e4db13d8b03ba Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 10 Oct 2011 14:08:14 -0700 Subject: added compound LLSD parsing to param blocks reviewed by Leslie --- indra/llui/llnotifications.cpp | 72 ++++------ indra/llui/llsdparam.cpp | 255 ++++++++++++++++++----------------- indra/llui/llsdparam.h | 66 ++++----- indra/llui/tests/llurlentry_stub.cpp | 2 +- indra/llui/tests/llurlentry_test.cpp | 1 - indra/llui/tests/llurlmatch_test.cpp | 4 +- 6 files changed, 201 insertions(+), 199 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index ffe5908a9d..8f7025a9a6 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -46,6 +46,7 @@ #include #include +#include const std::string NOTIFICATION_PERSIST_VERSION = "0.93"; @@ -416,23 +417,17 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par mSoundEffect = LLUUID(LLUI::sSettingGroups["config"]->getString(p.sound)); } - for(LLInitParam::ParamIterator::const_iterator it = p.unique.contexts.begin(), - end_it = p.unique.contexts.end(); - it != end_it; - ++it) + BOOST_FOREACH(const LLNotificationTemplate::UniquenessContext& context, p.unique.contexts) { - mUniqueContext.push_back(it->value); + mUniqueContext.push_back(context.value); } lldebugs << "notification \"" << mName << "\": tag count is " << p.tags.size() << llendl; - for(LLInitParam::ParamIterator::const_iterator it = p.tags.begin(), - end_it = p.tags.end(); - it != end_it; - ++it) + BOOST_FOREACH(const LLNotificationTemplate::Tag& tag, p.tags) { - lldebugs << " tag \"" << std::string(it->value) << "\"" << llendl; - mTags.push_back(it->value); + lldebugs << " tag \"" << std::string(tag.value) << "\"" << llendl; + mTags.push_back(tag.value); } mForm = LLNotificationFormPtr(new LLNotificationForm(p.name, p.form_ref.form)); @@ -1397,14 +1392,12 @@ void replaceFormText(LLNotificationForm::Params& form, const std::string& patter { form.ignore.text = replace; } - for (LLInitParam::ParamIterator::iterator it = form.form_elements.elements.begin(), - end_it = form.form_elements.elements.end(); - it != end_it; - ++it) + + BOOST_FOREACH(LLNotificationForm::FormElement& element, form.form_elements.elements) { - if (it->button.isChosen() && it->button.text() == pattern) + if (element.button.isChosen() && element.button.text() == pattern) { - it->button.text = replace; + element.button.text = replace; } } } @@ -1453,48 +1446,42 @@ bool LLNotifications::loadTemplates() mTemplates.clear(); - for(LLInitParam::ParamIterator::const_iterator it = params.strings.begin(), end_it = params.strings.end(); - it != end_it; - ++it) + BOOST_FOREACH(LLNotificationTemplate::GlobalString& string, params.strings) { - mGlobalStrings[it->name] = it->value; + mGlobalStrings[string.name] = string.value; } std::map form_templates; - for(LLInitParam::ParamIterator::const_iterator it = params.templates.begin(), end_it = params.templates.end(); - it != end_it; - ++it) + BOOST_FOREACH(LLNotificationTemplate::Template& notification_template, params.templates) { - form_templates[it->name] = it->form; + form_templates[notification_template.name] = notification_template.form; } - for(LLInitParam::ParamIterator::iterator it = params.notifications.begin(), end_it = params.notifications.end(); - it != end_it; - ++it) + BOOST_FOREACH(LLNotificationTemplate::Params& notification, params.notifications) { - if (it->form_ref.form_template.isChosen()) + if (notification.form_ref.form_template.isChosen()) { // replace form contents from template - it->form_ref.form = form_templates[it->form_ref.form_template.name]; - if(it->form_ref.form_template.yes_text.isProvided()) + notification.form_ref.form = form_templates[notification.form_ref.form_template.name]; + if(notification.form_ref.form_template.yes_text.isProvided()) { - replaceFormText(it->form_ref.form, "$yestext", it->form_ref.form_template.yes_text); + replaceFormText(notification.form_ref.form, "$yestext", notification.form_ref.form_template.yes_text); } - if(it->form_ref.form_template.no_text.isProvided()) + if(notification.form_ref.form_template.no_text.isProvided()) { - replaceFormText(it->form_ref.form, "$notext", it->form_ref.form_template.no_text); + replaceFormText(notification.form_ref.form, "$notext", notification.form_ref.form_template.no_text); } - if(it->form_ref.form_template.cancel_text.isProvided()) + if(notification.form_ref.form_template.cancel_text.isProvided()) { - replaceFormText(it->form_ref.form, "$canceltext", it->form_ref.form_template.cancel_text); + replaceFormText(notification.form_ref.form, "$canceltext", notification.form_ref.form_template.cancel_text); } - if(it->form_ref.form_template.ignore_text.isProvided()) + if(notification.form_ref.form_template.ignore_text.isProvided()) { - replaceFormText(it->form_ref.form, "$ignoretext", it->form_ref.form_template.ignore_text); + replaceFormText(notification.form_ref.form, "$ignoretext", notification.form_ref.form_template.ignore_text); } } - mTemplates[it->name] = LLNotificationTemplatePtr(new LLNotificationTemplate(*it)); + mTemplates[notification.name] = LLNotificationTemplatePtr(new LLNotificationTemplate(notification)); } return true; @@ -1517,12 +1504,9 @@ bool LLNotifications::loadVisibilityRules() mVisibilityRules.clear(); - for(LLInitParam::ParamIterator::iterator it = params.rules.begin(), - end_it = params.rules.end(); - it != end_it; - ++it) + BOOST_FOREACH(LLNotificationVisibilityRule::Rule& rule, params.rules) { - mVisibilityRules.push_back(LLNotificationVisibilityRulePtr(new LLNotificationVisibilityRule(*it))); + mVisibilityRules.push_back(LLNotificationVisibilityRulePtr(new LLNotificationVisibilityRule(rule))); } return true; diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp index 4b69360e33..83bed3e745 100644 --- a/indra/llui/llsdparam.cpp +++ b/indra/llui/llsdparam.cpp @@ -34,6 +34,7 @@ static LLInitParam::Parser::parser_read_func_map_t sReadFuncs; static LLInitParam::Parser::parser_write_func_map_t sWriteFuncs; static LLInitParam::Parser::parser_inspect_func_map_t sInspectFuncs; +static const LLSD NO_VALUE_MARKER; // // LLParamSDParser @@ -60,29 +61,32 @@ LLParamSDParser::LLParamSDParser() } // special case handling of U32 due to ambiguous LLSD::assign overload -bool LLParamSDParser::writeU32Param(LLParamSDParser::parser_t& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack) +bool LLParamSDParser::writeU32Param(LLParamSDParser::parser_t& parser, const void* val_ptr, parser_t::name_stack_t& name_stack) { LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLSD* sd_to_write = sdparser.getSDWriteNode(name_stack); - if (!sd_to_write) return false; + LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); + sd_to_write.assign((S32)*((const U32*)val_ptr)); - sd_to_write->assign((S32)*((const U32*)val_ptr)); return true; } -bool LLParamSDParser::writeFlag(LLParamSDParser::parser_t& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack) +bool LLParamSDParser::writeFlag(LLParamSDParser::parser_t& parser, const void* val_ptr, parser_t::name_stack_t& name_stack) { LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLSD* sd_to_write = sdparser.getSDWriteNode(name_stack); - if (!sd_to_write) return false; + LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); return true; } +void LLParamSDParser::submit(LLInitParam::BaseBlock& block, const LLSD& sd, LLInitParam::Parser::name_stack_t& name_stack) +{ + mCurReadSD = &sd; + block.submitValue(name_stack, *this); +} void LLParamSDParser::readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool silent) { @@ -90,7 +94,8 @@ void LLParamSDParser::readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool mNameStack.clear(); setParseSilently(silent); - readSDValues(sd, block); + LLParamSDParserUtilities::readSDValues(boost::bind(&LLParamSDParser::submit, this, boost::ref(block), _1, _2), sd, mNameStack); + //readSDValues(sd, block); } void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block) @@ -100,43 +105,6 @@ void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block) block.serializeBlock(*this); } -const LLSD NO_VALUE_MARKER; - -void LLParamSDParser::readSDValues(const LLSD& sd, LLInitParam::BaseBlock& block) -{ - if (sd.isMap()) - { - for (LLSD::map_const_iterator it = sd.beginMap(); - it != sd.endMap(); - ++it) - { - mNameStack.push_back(make_pair(it->first, newParseGeneration())); - readSDValues(it->second, block); - mNameStack.pop_back(); - } - } - else if (sd.isArray()) - { - for (LLSD::array_const_iterator it = sd.beginArray(); - it != sd.endArray(); - ++it) - { - mNameStack.back().second = newParseGeneration(); - readSDValues(*it, block); - } - } - else if (sd.isUndefined()) - { - mCurReadSD = &NO_VALUE_MARKER; - block.submitValue(mNameStack, *this); - } - else - { - mCurReadSD = &sd; - block.submitValue(mNameStack, *this); - } -} - /*virtual*/ std::string LLParamSDParser::getCurrentElementName() { std::string full_name = "sd"; @@ -150,81 +118,6 @@ void LLParamSDParser::readSDValues(const LLSD& sd, LLInitParam::BaseBlock& block return full_name; } -LLSD* LLParamSDParser::getSDWriteNode(const parser_t::name_stack_t& name_stack) -{ - //TODO: implement nested LLSD writing - LLSD* sd_to_write = mWriteRootSD; - bool new_traversal = false; - for (name_stack_t::const_iterator it = name_stack.begin(), prev_it = mNameStack.begin(); - it != name_stack.end(); - ++it) - { - bool new_array_entry = false; - if (prev_it == mNameStack.end()) - { - new_traversal = true; - } - else - { - if (!new_traversal // have not diverged yet from previous trace - && prev_it->first == it->first // names match - && prev_it->second != it->second) // versions differ - { - // name stacks match, but version numbers differ in last place. - // create a different entry at this point using an LLSD array - new_array_entry = true; - } - if (prev_it->first != it->first // names differ - || prev_it->second != it->second) // versions differ - { - // at this point we have diverged from our last trace - // so any elements referenced here are new - new_traversal = true; - } - } - - LLSD* child_sd = it->first.empty() ? sd_to_write : &(*sd_to_write)[it->first]; - - if (child_sd->isArray()) - { - if (new_traversal) - { - // write to new element at end - sd_to_write = &(*child_sd)[child_sd->size()]; - } - else - { - // write to last of existing elements, or first element if empty - sd_to_write = &(*child_sd)[llmax(0, child_sd->size() - 1)]; - } - } - else - { - if (new_array_entry && !child_sd->isArray()) - { - // copy child contents into first element of an array - LLSD new_array = LLSD::emptyArray(); - new_array.append(*child_sd); - // assign array to slot that previously held the single value - *child_sd = new_array; - // return next element in that array - sd_to_write = &((*child_sd)[1]); - } - else - { - sd_to_write = child_sd; - } - } - if (prev_it != mNameStack.end()) - { - ++prev_it; - } - } - mNameStack = name_stack; - - //llinfos << ll_pretty_print_sd(*mWriteRootSD) << llendl; - return sd_to_write; -} bool LLParamSDParser::readFlag(Parser& parser, void* val_ptr) { @@ -312,3 +205,125 @@ bool LLParamSDParser::readSD(Parser& parser, void* val_ptr) *((LLSD*)val_ptr) = *self.mCurReadSD; return true; } + +// static +LLSD& LLParamSDParserUtilities::getSDWriteNode(LLSD& input, LLInitParam::Parser::name_stack_range_t& name_stack_range) +{ + LLSD* sd_to_write = &input; + + for (LLInitParam::Parser::name_stack_t::iterator it = name_stack_range.first; + it != name_stack_range.second; + ++it) + { + bool new_traversal = it->second; + + LLSD* child_sd = it->first.empty() ? sd_to_write : &(*sd_to_write)[it->first]; + + if (child_sd->isArray()) + { + if (new_traversal) + { + // write to new element at end + sd_to_write = &(*child_sd)[child_sd->size()]; + } + else + { + // write to last of existing elements, or first element if empty + sd_to_write = &(*child_sd)[llmax(0, child_sd->size() - 1)]; + } + } + else + { + if (new_traversal + && child_sd->isDefined() + && !child_sd->isArray()) + { + // copy child contents into first element of an array + LLSD new_array = LLSD::emptyArray(); + new_array.append(*child_sd); + // assign array to slot that previously held the single value + *child_sd = new_array; + // return next element in that array + sd_to_write = &((*child_sd)[1]); + } + else + { + sd_to_write = child_sd; + } + } + it->second = false; + } + + return *sd_to_write; +} + +//static +void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack) +{ + if (sd.isMap()) + { + for (LLSD::map_const_iterator it = sd.beginMap(); + it != sd.endMap(); + ++it) + { + stack.push_back(make_pair(it->first, true)); + readSDValues(cb, it->second, stack); + stack.pop_back(); + } + } + else if (sd.isArray()) + { + for (LLSD::array_const_iterator it = sd.beginArray(); + it != sd.endArray(); + ++it) + { + stack.back().second = true; + readSDValues(cb, *it, stack); + } + } + else if (sd.isUndefined()) + { + if (!cb.empty()) + { + cb(NO_VALUE_MARKER, stack); + } + } + else + { + if (!cb.empty()) + { + cb(sd, stack); + } + } +} + +namespace LLInitParam +{ + // LLSD specialization + // block param interface + bool ParamValue, false>::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name) + { + LLSD& sd = LLParamSDParserUtilities::getSDWriteNode(mValue, name_stack); + + LLSD::String string; + + if (p.readValue(string)) + { + sd = string; + return true; + } + return false; + } + + //static + void ParamValue, false>::serializeElement(Parser& p, const LLSD& sd, Parser::name_stack_t& name_stack) + { + p.writeValue(sd.asString(), name_stack); + } + + void ParamValue, false>::serializeBlock(Parser& p, Parser::name_stack_t name_stack, const BaseBlock* diff_block) const + { + // read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc) + LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue); + } +} diff --git a/indra/llui/llsdparam.h b/indra/llui/llsdparam.h index a371c28f68..265993ffb5 100644 --- a/indra/llui/llsdparam.h +++ b/indra/llui/llsdparam.h @@ -29,6 +29,15 @@ #define LL_LLSDPARAM_H #include "llinitparam.h" +#include "boost/function.hpp" + +struct LLParamSDParserUtilities +{ + static LLSD& getSDWriteNode(LLSD& input, LLInitParam::Parser::name_stack_range_t& name_stack_range); + + typedef boost::function read_sd_cb_t; + static void readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack = LLInitParam::Parser::name_stack_t()); +}; class LLParamSDParser : public LLInitParam::Parser @@ -45,25 +54,22 @@ public: /*virtual*/ std::string getCurrentElementName(); private: - void readSDValues(const LLSD& sd, LLInitParam::BaseBlock& block); + void submit(LLInitParam::BaseBlock& block, const LLSD& sd, LLInitParam::Parser::name_stack_t& name_stack); template - static bool writeTypedValue(Parser& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack) + static bool writeTypedValue(Parser& parser, const void* val_ptr, parser_t::name_stack_t& name_stack) { LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLSD* sd_to_write = sdparser.getSDWriteNode(name_stack); - if (!sd_to_write) return false; + LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); - sd_to_write->assign(*((const T*)val_ptr)); + sd_to_write.assign(*((const T*)val_ptr)); return true; } - LLSD* getSDWriteNode(const parser_t::name_stack_t& name_stack); - - static bool writeU32Param(Parser& parser, const void* value_ptr, const parser_t::name_stack_t& name_stack); - static bool writeFlag(Parser& parser, const void* value_ptr, const parser_t::name_stack_t& name_stack); + static bool writeU32Param(Parser& parser, const void* value_ptr, parser_t::name_stack_t& name_stack); + static bool writeFlag(Parser& parser, const void* value_ptr, parser_t::name_stack_t& name_stack); static bool readFlag(Parser& parser, void* val_ptr); static bool readS32(Parser& parser, void* val_ptr); @@ -85,29 +91,29 @@ private: template class LLSDParamAdapter : public T +{ +public: + LLSDParamAdapter() {} + LLSDParamAdapter(const LLSD& sd) { - public: - LLSDParamAdapter() {} - LLSDParamAdapter(const LLSD& sd) - { - LLParamSDParser parser; - parser.readSD(sd, *this); - } - - operator LLSD() const - { - LLParamSDParser parser; - LLSD sd; - parser.writeSD(sd, *this); - return sd; - } + LLParamSDParser parser; + parser.readSD(sd, *this); + } + + operator LLSD() const + { + LLParamSDParser parser; + LLSD sd; + parser.writeSD(sd, *this); + return sd; + } - LLSDParamAdapter(const T& val) - : T(val) - { - T::operator=(val); - } - }; + LLSDParamAdapter(const T& val) + : T(val) + { + T::operator=(val); + } +}; #endif // LL_LLSDPARAM_H diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp index d522123260..c8303bfc89 100644 --- a/indra/llui/tests/llurlentry_stub.cpp +++ b/indra/llui/tests/llurlentry_stub.cpp @@ -124,7 +124,7 @@ namespace LLInitParam { descriptor.mCurrentBlockPtr = this; } - bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation){ return true; } + bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name){ return true; } void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const {} bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_value, S32 max_value) const { return true; } bool BaseBlock::mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; } diff --git a/indra/llui/tests/llurlentry_test.cpp b/indra/llui/tests/llurlentry_test.cpp index 2f814f4200..c1fb050206 100644 --- a/indra/llui/tests/llurlentry_test.cpp +++ b/indra/llui/tests/llurlentry_test.cpp @@ -72,7 +72,6 @@ S32 LLUIImage::getHeight() const namespace LLInitParam { - S32 Parser::sNextParseGeneration = 0; BlockDescriptor::BlockDescriptor() {} ParamDescriptor::ParamDescriptor(param_handle_t p, merge_func_t merge_func, diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp index fb6a2eabf1..9dbccf125a 100644 --- a/indra/llui/tests/llurlmatch_test.cpp +++ b/indra/llui/tests/llurlmatch_test.cpp @@ -66,8 +66,6 @@ namespace LLInitParam BaseBlock::BaseBlock() {} BaseBlock::~BaseBlock() {} - S32 Parser::sNextParseGeneration = 0; - BlockDescriptor::BlockDescriptor() {} ParamDescriptor::ParamDescriptor(param_handle_t p, merge_func_t merge_func, @@ -98,7 +96,7 @@ namespace LLInitParam mEnclosingBlockOffset = 0x7FFFffff & ((U32)(my_addr - block_addr)); } - bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation){ return true; } + bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name){ return true; } void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const {} bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_count, S32 max_count) const { return true; } bool BaseBlock::mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; } -- cgit v1.2.3 From da3c7da7a585ea14a5a494ac7f36e7714bc86ab8 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 10 Oct 2011 15:04:00 -0700 Subject: side toolbar buttons are now squares again --- indra/llui/lltoolbar.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 9e48dee608..84fa7ec0df 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -47,8 +47,8 @@ class LLToolBarButton : public LLButton public: struct Params : public LLInitParam::Block { - Optional button_width; - Optional desired_height; + Optional button_width; + Optional desired_height; Params() : button_width("button_width"), -- cgit v1.2.3 From 0526d673093b2279777dc8be5aae9cc33cb1c822 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 10 Oct 2011 15:31:25 -0700 Subject: EXP-1312 FIX Floaters should appear in region not covered by toolbars moved floater snap region to middle of toolbars and constrained floaters to that snap region also made toybox floater pass all drag and drop events along to toolbar --- indra/llui/llfloater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index cc49238a0b..cba14e21c3 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2549,7 +2549,7 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out } // move window fully onscreen - if (floater->translateIntoRect( getLocalRect(), allow_partial_outside )) + if (floater->translateIntoRect( getSnapRect(), allow_partial_outside )) { floater->clearSnapTarget(); } -- cgit v1.2.3 From a07c3559b6d22ef62e8deab56780d74ac72501e1 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 10 Oct 2011 15:53:44 -0700 Subject: Mac build fix --- indra/llui/llsdparam.cpp | 9 ++++++--- indra/llui/llsdparam.h | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp index 83bed3e745..da50c0ff39 100644 --- a/indra/llui/llsdparam.cpp +++ b/indra/llui/llsdparam.cpp @@ -66,7 +66,8 @@ bool LLParamSDParser::writeU32Param(LLParamSDParser::parser_t& parser, const voi LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); + parser_t::name_stack_range_t range(name_stack.begin(), name_stack.end()); + LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, range); sd_to_write.assign((S32)*((const U32*)val_ptr)); return true; @@ -77,7 +78,8 @@ bool LLParamSDParser::writeFlag(LLParamSDParser::parser_t& parser, const void* v LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); + parser_t::name_stack_range_t range(name_stack.begin(), name_stack.end()); + LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, range); return true; } @@ -324,6 +326,7 @@ namespace LLInitParam void ParamValue, false>::serializeBlock(Parser& p, Parser::name_stack_t name_stack, const BaseBlock* diff_block) const { // read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc) - LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue); + Parser::name_stack_t stack; + LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue, stack); } } diff --git a/indra/llui/llsdparam.h b/indra/llui/llsdparam.h index 265993ffb5..784358d038 100644 --- a/indra/llui/llsdparam.h +++ b/indra/llui/llsdparam.h @@ -62,7 +62,8 @@ private: LLParamSDParser& sdparser = static_cast(parser); if (!sdparser.mWriteRootSD) return false; - LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, std::make_pair(name_stack.begin(), name_stack.end())); + LLInitParam::Parser::name_stack_range_t range(name_stack.begin(), name_stack.end()); + LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, range); sd_to_write.assign(*((const T*)val_ptr)); return true; -- cgit v1.2.3 From fd03ae299bfaf83789e511912d99d204c0833e7f Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Mon, 10 Oct 2011 17:08:51 -0700 Subject: EXP-1274 Create floater for "Avatar Picker" content EXP-1299 Nearby Voice floater can't be closed by clicking the sidebar button again. EXP-1306 Prompt text to "Change your avatar" and "Destinations" floaters get pushed down one line when the floater dialog gets resized to minimum width --- indra/llui/llfloater.cpp | 21 +++++++++++++++------ indra/llui/llfloater.h | 2 +- indra/llui/llresizehandle.cpp | 12 ------------ indra/llui/llresizehandle.h | 7 +------ 4 files changed, 17 insertions(+), 25 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index c28bcc2ec9..f85e46e28d 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -459,15 +459,24 @@ void LLFloater::layoutResizeCtrls() mResizeHandle[3]->setRect(rect); } -void LLFloater::enableResizeCtrls(bool enable) +void LLFloater::enableResizeCtrls(bool enable, bool width, bool height) { + mResizeBar[LLResizeBar::LEFT]->setVisible(enable && width); + mResizeBar[LLResizeBar::LEFT]->setEnabled(enable && width); + + mResizeBar[LLResizeBar::TOP]->setVisible(enable && height); + mResizeBar[LLResizeBar::TOP]->setEnabled(enable && height); + + mResizeBar[LLResizeBar::RIGHT]->setVisible(enable && width); + mResizeBar[LLResizeBar::RIGHT]->setEnabled(enable && width); + + mResizeBar[LLResizeBar::BOTTOM]->setVisible(enable && height); + mResizeBar[LLResizeBar::BOTTOM]->setEnabled(enable && height); + for (S32 i = 0; i < 4; ++i) { - mResizeBar[i]->setVisible(enable); - mResizeBar[i]->setEnabled(enable); - - mResizeHandle[i]->setVisible(enable); - mResizeHandle[i]->setEnabled(enable); + mResizeHandle[i]->setVisible(enable && width && height); + mResizeHandle[i]->setEnabled(enable && width && height); } } diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 5aff542049..af9665e599 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -291,6 +291,7 @@ public: void updateTransparency(ETypeTransparency transparency_type); + void enableResizeCtrls(bool enable, bool width = true, bool height = true); protected: virtual void applySavedVariables(); @@ -340,7 +341,6 @@ private: BOOL offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButton index); void addResizeCtrls(); void layoutResizeCtrls(); - void enableResizeCtrls(bool enable); void addDragHandle(); void layoutDragHandle(); // repair layout diff --git a/indra/llui/llresizehandle.cpp b/indra/llui/llresizehandle.cpp index 942e84eeb6..c3a51c36c9 100644 --- a/indra/llui/llresizehandle.cpp +++ b/indra/llui/llresizehandle.cpp @@ -55,8 +55,6 @@ LLResizeHandle::LLResizeHandle(const LLResizeHandle::Params& p) mImage( NULL ), mMinWidth( p.min_width ), mMinHeight( p.min_height ), - mMaxWidth(S32_MAX), - mMaxHeight(S32_MAX), mCorner( p.corner ) { if( RIGHT_BOTTOM == mCorner) @@ -179,11 +177,6 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) new_width = mMinWidth; delta_x = x_multiple * (mMinWidth - orig_rect.getWidth()); } - else if (new_width > mMaxWidth) - { - new_width = mMaxWidth; - delta_x = x_multiple * (mMaxWidth - orig_rect.getWidth()); - } S32 new_height = orig_rect.getHeight() + y_multiple * delta_y; if( new_height < mMinHeight ) @@ -191,11 +184,6 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) new_height = mMinHeight; delta_y = y_multiple * (mMinHeight - orig_rect.getHeight()); } - else if (new_height > mMaxHeight) - { - new_height = mMaxHeight; - delta_y = y_multiple * (mMaxHeight - orig_rect.getHeight()); - } switch( mCorner ) { diff --git a/indra/llui/llresizehandle.h b/indra/llui/llresizehandle.h index 5cfe3fb63c..7541b9e6c0 100644 --- a/indra/llui/llresizehandle.h +++ b/indra/llui/llresizehandle.h @@ -55,10 +55,7 @@ public: virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); void setResizeLimits( S32 min_width, S32 min_height ) { mMinWidth = min_width; mMinHeight = min_height; } - - void setMaxWidth(S32 width) { mMaxWidth = width;} - void setMaxHeight(S32 height) { mMaxHeight = height;} - + private: BOOL pointInHandle( S32 x, S32 y ); @@ -69,9 +66,7 @@ private: LLCoordGL mLastMouseDir; LLPointer mImage; S32 mMinWidth; - S32 mMaxWidth; S32 mMinHeight; - S32 mMaxHeight; const ECorner mCorner; }; -- cgit v1.2.3 From 6a570a9bdc2660e4db87e8e7a65b724e1ad8d1b2 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 10 Oct 2011 17:52:37 -0700 Subject: fixed icons moving when clicking on icon-only toolbars --- indra/llui/llbutton.cpp | 2 +- indra/llui/lltoolbar.cpp | 5 +++++ indra/llui/lltoolbar.h | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 68cb5164b6..ba3748a573 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -1002,7 +1002,7 @@ void LLButton::resize(LLUIString label) if (mImageOverlay) { S32 overlay_width = mImageOverlay->getWidth(); - F32 scale_factor = getRect().getHeight() / (F32)mImageOverlay->getHeight(); + F32 scale_factor = (getRect().getHeight() - (mImageOverlayBottomPad + mImageOverlayTopPad)) / (F32)mImageOverlay->getHeight(); overlay_width = llround((F32)overlay_width * scale_factor); switch(mImageOverlayAlignment) diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 6332b2674a..5ba54edf1c 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -852,3 +852,8 @@ void LLToolBarButton::onMouseCaptureLost() { mIsDragged = false; } + +void LLToolBarButton::reshape(S32 width, S32 height, BOOL called_from_parent) +{ + LLButton::reshape(mWidthRange.clamp(width), height, called_from_parent); +} diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 84fa7ec0df..a81a5fdb39 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -62,6 +62,8 @@ public: BOOL handleMouseDown(S32 x, S32 y, MASK mask); BOOL handleHover(S32 x, S32 y, MASK mask); + void reshape(S32 width, S32 height, BOOL called_from_parent = true); + void setCommandId(const LLCommandId& id) { mId = id; } void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; } -- cgit v1.2.3 From 1478f22857c24f4f3ecfcf7a08fdd4d5392ee3e6 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 10 Oct 2011 18:00:24 -0700 Subject: EXP-1300 : Simplify and clean up of the DaD which now doesn't duplicate the dragged tool. --- indra/llui/llcommandmanager.h | 4 +-- indra/llui/lltoolbar.cpp | 83 ++++++++++++++----------------------------- indra/llui/lltoolbar.h | 12 +++---- 3 files changed, 35 insertions(+), 64 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index fdad7cd1b5..46e0fe6e69 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -68,8 +68,8 @@ public: mUUID = LLUUID::generateNewID(p.name); } - LLCommandId(const std::string& name, const LLUUID& uuid) - : mName(name), + LLCommandId(const LLUUID& uuid) + : mName(""), mUUID(uuid) { } diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 6332b2674a..776e91b7e5 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -114,8 +114,6 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; - mDraggedCommand = LLCommandId::null; - mRank = 0; } LLToolBar::~LLToolBar() @@ -211,19 +209,14 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) // Create the button and do the things that don't need ordering LLToolBarButton* button = createButton(commandId); mButtonPanel->addChild(button); - LLCommandId temp_command = commandId; - if (commandId.name() == "Drag Tool") - { - temp_command = LLCommandId("Drag Tool"); - } - mButtonMap.insert(std::make_pair(temp_command.uuid(), button)); + mButtonMap.insert(std::make_pair(commandId.uuid(), button)); // Insert the command and button in the right place in their respective lists - if ((rank >= mButtonCommands.size()) || (rank < 0)) + if ((rank >= mButtonCommands.size()) || (rank == RANK_NONE)) { // In that case, back load - mButtonCommands.push_back(temp_command); + mButtonCommands.push_back(commandId); mButtons.push_back(button); } else @@ -238,7 +231,7 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) rank--; } // ...then insert - mButtonCommands.insert(it_command,temp_command); + mButtonCommands.insert(it_command,commandId); mButtons.insert(it_button,button); } @@ -247,27 +240,28 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) return true; } -bool LLToolBar::removeCommand(const LLCommandId& commandId) +// Remove a command from the list +// Returns the rank of the command in the original list so that doing addCommand(id,rank) right after +// a removeCommand(id) would leave the list unchanged. +// Returns RANK_NONE if the command is not found in the list +int LLToolBar::removeCommand(const LLCommandId& commandId) { - if (!hasCommand(commandId)) return false; + if (!hasCommand(commandId)) return RANK_NONE; llinfos << "Merov debug : removeCommand, " << commandId.name() << ", " << commandId.uuid() << llendl; // First erase the map record - LLCommandId temp_command = commandId; - if (commandId.name() == "Drag Tool") - { - temp_command = LLCommandId("Drag Tool"); - } - command_id_map::iterator it = mButtonMap.find(temp_command.uuid()); + command_id_map::iterator it = mButtonMap.find(commandId.uuid()); mButtonMap.erase(it); // Now iterate on the commands and buttons to identify the relevant records + int rank = 0; std::list::iterator it_button = mButtons.begin(); command_id_list_t::iterator it_command = mButtonCommands.begin(); - while (*it_command != temp_command) + while (*it_command != commandId) { ++it_button; ++it_command; + ++rank; } // Delete the button and erase the command and button records @@ -277,7 +271,7 @@ bool LLToolBar::removeCommand(const LLCommandId& commandId) mNeedsLayout = true; - return true; + return rank; } void LLToolBar::clearCommandsList() @@ -292,12 +286,7 @@ bool LLToolBar::hasCommand(const LLCommandId& commandId) const { if (commandId != LLCommandId::null) { - LLCommandId temp_command = commandId; - if (commandId.name() == "Drag Tool") - { - temp_command = LLCommandId("Drag Tool"); - } - command_id_map::const_iterator it = mButtonMap.find(temp_command.uuid()); + command_id_map::const_iterator it = mButtonMap.find(commandId.uuid()); return (it != mButtonMap.end()); } @@ -310,12 +299,7 @@ bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled) if (commandId != LLCommandId::null) { - LLCommandId temp_command = commandId; - if (commandId.name() == "Drag Tool") - { - temp_command = LLCommandId("Drag Tool"); - } - command_id_map::iterator it = mButtonMap.find(temp_command.uuid()); + command_id_map::iterator it = mButtonMap.find(commandId.uuid()); if (it != mButtonMap.end()) { it->second->setEnabled(enabled); @@ -410,6 +394,10 @@ void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row } } +// Returns the position of the coordinates as a rank in the button list. +// The rank is the position a tool dropped in (x,y) would assume in the button list. +// The value returned is between 0 and mButtons.size(), 0 being the first element to the left +// (or top) and mButtons.size() the last one to the right (or bottom). int LLToolBar::getRankFromPosition(S32 x, S32 y) { int rank = 0; @@ -618,12 +606,6 @@ void LLToolBar::draw() } } } - // HACK!!! - if (!mDragAndDropTarget) - { - removeCommand(mDraggedCommand); - mDraggedCommand = LLCommandId::null; - } updateLayoutAsNeeded(); // rect may have shifted during layout @@ -654,12 +636,7 @@ void LLToolBar::createButtons() LLToolBarButton* button = createButton(command_id); mButtons.push_back(button); mButtonPanel->addChild(button); - LLCommandId temp_command = command_id; - if (command_id.name() == "Drag Tool") - { - temp_command = LLCommandId("Drag Tool"); - } - mButtonMap.insert(std::make_pair(temp_command.uuid(), button)); + mButtonMap.insert(std::make_pair(command_id.uuid(), button)); } mNeedsLayout = true; } @@ -736,7 +713,7 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EAcceptance* accept, std::string& tooltip_msg) { - //llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", x = " << x << ", y = " << y << llendl; + llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", x = " << x << ", y = " << y << llendl; // If we have a drop callback, that means that we can handle the drop BOOL handled = (mHandleDropCallback ? TRUE : FALSE); @@ -761,19 +738,13 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, LLAssetType::EType type = inv_item->getType(); if (type == LLAssetType::AT_WIDGET) { - mRank = getRankFromPosition(x, y); - mDraggedCommand = LLCommandId("Drag Tool",inv_item->getUUID()); - removeCommand(mDraggedCommand); - addCommand(mDraggedCommand,mRank); + LLCommandId dragged_command(inv_item->getUUID()); + int rank = getRankFromPosition(x, y); + removeCommand(dragged_command); + addCommand(dragged_command,rank); mDragAndDropTarget = true; } } - else - { - removeCommand(mDraggedCommand); - mDraggedCommand = LLCommandId::null; - } - } return handled; diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 84fa7ec0df..56bc8b9bb3 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -47,8 +47,8 @@ class LLToolBarButton : public LLButton public: struct Params : public LLInitParam::Block { - Optional button_width; - Optional desired_height; + Optional button_width; + Optional desired_height; Params() : button_width("button_width"), @@ -161,9 +161,11 @@ public: void* cargo_data, EAcceptance* accept, std::string& tooltip_msg); + + static const int RANK_NONE = -1; - bool addCommand(const LLCommandId& commandId, int rank = -1); - bool removeCommand(const LLCommandId& commandId); + bool addCommand(const LLCommandId& commandId, int rank = RANK_NONE); + int removeCommand(const LLCommandId& commandId); // Returns the rank the removed command was at, RANK_NONE if not found bool hasCommand(const LLCommandId& commandId) const; bool enableCommand(const LLCommandId& commandId, bool enabled); @@ -184,8 +186,6 @@ protected: tool_handledrag_callback_t mHandleDragItemCallback; tool_handledrop_callback_t mHandleDropCallback; bool mDragAndDropTarget; - int mRank; - LLCommandId mDraggedCommand; public: // Methods used in loading and saving toolbar settings -- cgit v1.2.3 From ec23ec68ea8835e4155e083ec5570245b0aef1ec Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 10 Oct 2011 19:17:38 -0700 Subject: EXP-1310 FIX Profile button should open Web Profile floater removed unused LLWeb functions for opening non-web media moved logic inside floaters and away from auxiliary functions --- indra/llui/llfloaterreg.cpp | 6 +++++- indra/llui/llhelp.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index d0ae9413a3..ae06eb74ac 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -110,7 +110,11 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) int index = list.size(); res = build_func(key); - + if (!res) + { + llwarns << "Failed to build floater type: '" << name << "'." << llendl; + return NULL; + } bool success = res->buildFromFile(xui_file, NULL); if (!success) { diff --git a/indra/llui/llhelp.h b/indra/llui/llhelp.h index 83317bd03c..1726347a78 100644 --- a/indra/llui/llhelp.h +++ b/indra/llui/llhelp.h @@ -32,6 +32,7 @@ class LLHelp { public: virtual void showTopic(const std::string &topic) = 0; + virtual std::string getURL(const std::string &topic) = 0; // return default (fallback) topic name suitable for showTopic() virtual std::string defaultTopic() = 0; // return topic to use before the user logs in -- cgit v1.2.3 From fd1a688f463703ec78a399b35fed19b3d907c91b Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 10 Oct 2011 19:21:01 -0700 Subject: fixed bad merge --- indra/llui/lltoolbar.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index ca04a0e5d5..321064a0fd 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -47,8 +47,8 @@ class LLToolBarButton : public LLButton public: struct Params : public LLInitParam::Block { - Optional button_width; - Optional desired_height; + Optional button_width; + Optional desired_height; Params() : button_width("button_width"), -- cgit v1.2.3 From c845925eebb5cad3049ee0f3b1d0adea3e3a46b5 Mon Sep 17 00:00:00 2001 From: Paul ProductEngine Date: Tue, 11 Oct 2011 17:50:28 +0200 Subject: Fixed Linux build --- indra/llui/llsdparam.cpp | 6 ++++++ indra/llui/llsdparam.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp index da50c0ff39..242b1fca7f 100644 --- a/indra/llui/llsdparam.cpp +++ b/indra/llui/llsdparam.cpp @@ -299,6 +299,12 @@ void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd, LLI } } +//static +void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd) +{ + LLInitParam::Parser::name_stack_t stack = LLInitParam::Parser::name_stack_t(); + readSDValues(cb, sd, stack); +} namespace LLInitParam { // LLSD specialization diff --git a/indra/llui/llsdparam.h b/indra/llui/llsdparam.h index 784358d038..c1cfa98399 100644 --- a/indra/llui/llsdparam.h +++ b/indra/llui/llsdparam.h @@ -36,7 +36,8 @@ struct LLParamSDParserUtilities static LLSD& getSDWriteNode(LLSD& input, LLInitParam::Parser::name_stack_range_t& name_stack_range); typedef boost::function read_sd_cb_t; - static void readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack = LLInitParam::Parser::name_stack_t()); + static void readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack); + static void readSDValues(read_sd_cb_t cb, const LLSD& sd); }; class LLParamSDParser -- cgit v1.2.3 From aec61c579a40687e2696d38a535143d59f771416 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 11 Oct 2011 10:07:19 -0700 Subject: Added 'execute_stop_function' command parameter to handle mouse down/up actions on toolbar buttons --- indra/llui/llbutton.cpp | 18 ++++++++++++++++++ indra/llui/llbutton.h | 5 +++++ indra/llui/llcommandmanager.cpp | 4 ++++ indra/llui/llcommandmanager.h | 9 +++++++++ indra/llui/lltoolbar.cpp | 22 ++++++++++++++++++---- 5 files changed, 54 insertions(+), 4 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index ba3748a573..2e9c7a5d3d 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -296,6 +296,24 @@ void LLButton::onCommit() LLUICtrl::onCommit(); } +boost::signals2::connection LLButton::setClickedCallback(const CommitCallbackParam& cb) +{ + return setClickedCallback(initCommitCallback(cb)); +} +boost::signals2::connection LLButton::setMouseDownCallback(const CommitCallbackParam& cb) +{ + return setMouseDownCallback(initCommitCallback(cb)); +} +boost::signals2::connection LLButton::setMouseUpCallback(const CommitCallbackParam& cb) +{ + return setMouseUpCallback(initCommitCallback(cb)); +} +boost::signals2::connection LLButton::setHeldDownCallback(const CommitCallbackParam& cb) +{ + return setHeldDownCallback(initCommitCallback(cb)); +} + + boost::signals2::connection LLButton::setClickedCallback( const commit_signal_t::slot_type& cb ) { if (!mCommitSignal) mCommitSignal = new commit_signal_t(); diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index a0a7b4e372..ba0345f610 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -170,6 +170,11 @@ public: void setUseEllipses( BOOL use_ellipses ) { mUseEllipses = use_ellipses; } + boost::signals2::connection setClickedCallback(const CommitCallbackParam& cb); + boost::signals2::connection setMouseDownCallback(const CommitCallbackParam& cb); + boost::signals2::connection setMouseUpCallback(const CommitCallbackParam& cb); + boost::signals2::connection setHeldDownCallback(const CommitCallbackParam& cb); + boost::signals2::connection setClickedCallback( const commit_signal_t::slot_type& cb ); // mouse down and up within button boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb ); boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ); // mouse up, EVEN IF NOT IN BUTTON diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index d8e035a320..128ba609cb 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -55,6 +55,8 @@ LLCommand::Params::Params() , tooltip_ref("tooltip_ref") , execute_function("execute_function") , execute_parameters("execute_parameters") + , execute_stop_function("execute_stop_function") + , execute_stop_parameters("execute_stop_parameters") , is_enabled_function("is_enabled_function") , is_enabled_parameters("is_enabled_parameters") , is_running_function("is_running_function") @@ -72,6 +74,8 @@ LLCommand::LLCommand(const LLCommand::Params& p) , mTooltipRef(p.tooltip_ref) , mExecuteFunction(p.execute_function) , mExecuteParameters(p.execute_parameters) + , mExecuteStopFunction(p.execute_stop_function) + , mExecuteStopParameters(p.execute_stop_parameters) , mIsEnabledFunction(p.is_enabled_function) , mIsEnabledParameters(p.is_enabled_parameters) , mIsRunningFunction(p.is_running_function) diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 46e0fe6e69..9b93ab735a 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -116,6 +116,9 @@ public: Mandatory execute_function; Optional execute_parameters; + Optional execute_stop_function; + Optional execute_stop_parameters; + Optional is_enabled_function; Optional is_enabled_parameters; @@ -139,6 +142,9 @@ public: const std::string& executeFunctionName() const { return mExecuteFunction; } const LLSD& executeParameters() const { return mExecuteParameters; } + const std::string& executeStopFunctionName() const { return mExecuteStopFunction; } + const LLSD& executeStopParameters() const { return mExecuteStopParameters; } + const std::string& isEnabledFunctionName() const { return mIsEnabledFunction; } const LLSD& isEnabledParameters() const { return mIsEnabledParameters; } @@ -159,6 +165,9 @@ private: std::string mExecuteFunction; LLSD mExecuteParameters; + std::string mExecuteStopFunction; + LLSD mExecuteStopParameters; + std::string mIsEnabledFunction; LLSD mIsEnabledParameters; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 89184f781f..e74aab6e21 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -659,11 +659,25 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) if (!mReadOnly) { - LLUICtrl::CommitCallbackParam cbParam; - cbParam.function_name = commandp->executeFunctionName(); - cbParam.parameter = commandp->executeParameters(); + LLUICtrl::CommitCallbackParam executeParam; + executeParam.function_name = commandp->executeFunctionName(); + executeParam.parameter = commandp->executeParameters(); - button->setCommitCallback(cbParam); + // If we have a "stop" function then we map the command to mouse down / mouse up otherwise commit + const std::string& executeStopFunction = commandp->executeStopFunctionName(); + if (executeStopFunction.length() > 0) + { + LLUICtrl::CommitCallbackParam executeStopParam; + executeStopParam.function_name = executeStopFunction; + executeStopParam.parameter = commandp->executeStopParameters(); + + button->setMouseDownCallback(executeParam); + button->setMouseUpCallback(executeStopParam); + } + else + { + button->setCommitCallback(executeParam); + } const std::string& isEnabledFunction = commandp->isEnabledFunctionName(); if (isEnabledFunction.length() > 0) -- cgit v1.2.3 From 3596c0f7e139724f31258ffb96157146aeba77b1 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 11 Oct 2011 15:06:16 -0700 Subject: EXP-1300 : Implemented carets for DaD. Works with small bugs but OK for demo. Still in need of some cleanup --- indra/llui/lltoolbar.cpp | 86 +++++++++++++++++++++++++++++++++++------------- indra/llui/lltoolbar.h | 7 ++-- 2 files changed, 68 insertions(+), 25 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 89184f781f..7c1e2017c0 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -34,6 +34,7 @@ #include "llmenugl.h" #include "lltrans.h" #include "llinventory.h" +#include "lliconctrl.h" // uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit // thanks, MSVC! @@ -204,7 +205,6 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) { LLCommand * command = LLCommandManager::instance().getCommand(commandId); if (!command) return false; - llinfos << "Merov debug : addCommand, " << commandId.name() << ", " << commandId.uuid() << llendl; // Create the button and do the things that don't need ordering LLToolBarButton* button = createButton(commandId); @@ -248,7 +248,6 @@ int LLToolBar::removeCommand(const LLCommandId& commandId) { if (!hasCommand(commandId)) return RANK_NONE; - llinfos << "Merov debug : removeCommand, " << commandId.name() << ", " << commandId.uuid() << llendl; // First erase the map record command_id_map::iterator it = mButtonMap.find(commandId.uuid()); mButtonMap.erase(it); @@ -398,7 +397,7 @@ void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row // The rank is the position a tool dropped in (x,y) would assume in the button list. // The value returned is between 0 and mButtons.size(), 0 being the first element to the left // (or top) and mButtons.size() the last one to the right (or bottom). -int LLToolBar::getRankFromPosition(S32 x, S32 y) +int LLToolBar::getRankFromPosition(S32& x, S32& y) { int rank = 0; @@ -406,16 +405,16 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) S32 button_panel_x = 0; S32 button_panel_y = 0; localPointToOtherView(x, y, &button_panel_x, &button_panel_y, mButtonPanel); + S32 dx = x - button_panel_x; + S32 dy = y - button_panel_y; - //llinfos << "Merov debug : rank compute: orientation = " << orientation << ", x = " << button_panel_x << ", y = " << button_panel_y << llendl; - // Simply compare the passed coord with the buttons outbound box std::list::iterator it_button = mButtons.begin(); std::list::iterator end_button = mButtons.end(); + LLRect button_rect; while (it_button != end_button) { - LLRect button_rect = (*it_button)->getRect(); - //llinfos << "Merov debug : rank compute: rect = " << button_rect.mLeft << ", " << button_rect.mTop << ", " << button_rect.mRight << ", " << button_rect.mBottom << llendl; + button_rect = (*it_button)->getRect(); if (((orientation == LLLayoutStack::HORIZONTAL) && (button_rect.mRight > button_panel_x)) || ((orientation == LLLayoutStack::VERTICAL) && (button_rect.mBottom < button_panel_y)) ) { @@ -424,7 +423,16 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) rank++; ++it_button; } - //llinfos << "Merov debug : rank = " << rank << llendl; + if (it_button != end_button) + { + x = button_rect.mRight + dx; + y = button_rect.mTop + dy; + } + else + { + x = button_rect.mLeft + dx; + y = button_rect.mBottom + dy; + } return rank; } @@ -613,7 +621,40 @@ void LLToolBar::draw() LLUI::pushMatrix(); LLUI::translate((F32)getRect().mLeft, (F32)getRect().mBottom, 0.f); + // Position the caret + LLIconCtrl* caret = getChild("caret"); + caret->setVisible(FALSE); + if (mDragAndDropTarget && !mButtonCommands.empty()) + { + LLRect caret_rect = caret->getRect(); + LLRect toolbar_rect = getRect(); + if (mSideType == SIDE_BOTTOM) + { + caret->setRect(LLRect(mDragx-caret_rect.getWidth()/2+1, + toolbar_rect.getHeight()+3, + mDragx+caret_rect.getWidth()/2+1, + toolbar_rect.getHeight()-caret_rect.getHeight()+3)); + } + else if (mSideType == SIDE_LEFT) + { + + caret->setRect(LLRect(toolbar_rect.getWidth()-caret_rect.getWidth()+3, + mDragy+caret_rect.getHeight()/2, + toolbar_rect.getWidth()+3, + mDragy-caret_rect.getHeight()/2)); + } + else + { + caret->setRect(LLRect(-3, + mDragy+caret_rect.getHeight()/2, + caret_rect.getWidth()-3, + mDragy-caret_rect.getHeight()/2)); + } + caret->setVisible(TRUE); + } + LLUICtrl::draw(); + caret->setVisible(FALSE); } void LLToolBar::reshape(S32 width, S32 height, BOOL called_from_parent) @@ -713,7 +754,6 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EAcceptance* accept, std::string& tooltip_msg) { - llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", x = " << x << ", y = " << y << llendl; // If we have a drop callback, that means that we can handle the drop BOOL handled = (mHandleDropCallback ? TRUE : FALSE); @@ -729,21 +769,22 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, // We'll use that flag to change the visual aspect of the toolbar target on draw() mDragAndDropTarget = false; - // HACK!!! - if (!isReadOnly() && handled) + // Convert drag position into insert position and rank + if (!isReadOnly() && handled && !drop) { - if (!drop) + LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data; + LLAssetType::EType type = inv_item->getType(); + if (type == LLAssetType::AT_WIDGET) { - LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data; - LLAssetType::EType type = inv_item->getType(); - if (type == LLAssetType::AT_WIDGET) - { - LLCommandId dragged_command(inv_item->getUUID()); - int rank = getRankFromPosition(x, y); - removeCommand(dragged_command); - addCommand(dragged_command,rank); - mDragAndDropTarget = true; - } + mDragx = x; + mDragy = y; + mDragRank = getRankFromPosition(mDragx, mDragy); + mDragAndDropTarget = true; + /* Do the following if you want to animate the button itself + LLCommandId dragged_command(inv_item->getUUID()); + removeCommand(dragged_command); + addCommand(dragged_command,rank); + */ } } @@ -784,7 +825,6 @@ BOOL LLToolBarButton::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask) { -// llinfos << "Merov debug: handleHover, x = " << x << ", y = " << y << ", mouse = " << hasMouseCapture() << llendl; BOOL handled = FALSE; S32 mouse_distance_squared = (x - mMouseDownX) * (x - mMouseDownX) + (y - mMouseDownY) * (y - mMouseDownY); diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index ca04a0e5d5..f3457028e7 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -156,7 +156,7 @@ public: // virtuals void draw(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); - int getRankFromPosition(S32 x, S32 y); + int getRankFromPosition(S32& x, S32& y); BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -188,6 +188,9 @@ protected: tool_handledrag_callback_t mHandleDragItemCallback; tool_handledrop_callback_t mHandleDropCallback; bool mDragAndDropTarget; + int mDragRank; + S32 mDragx, + mDragy; public: // Methods used in loading and saving toolbar settings @@ -217,7 +220,7 @@ private: LLLayoutStack* mWrapStack; LLPanel* mButtonPanel; LLToolBarEnums::SideType mSideType; - + bool mWrap; bool mNeedsLayout; S32 mPadLeft, -- cgit v1.2.3 From ca9ea840951bcfeaf46f07c9ee0974408c21792a Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 11 Oct 2011 15:54:56 -0700 Subject: * Dimmed overlay color on button image overlays to 0.75*alpha when buttons are unselected. --- indra/llui/llbutton.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 2e9c7a5d3d..0a7584a576 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -828,6 +828,10 @@ void LLButton::draw() { overlay_color.mV[VALPHA] = 0.5f; } + else if (!getToggleState()) + { + overlay_color.mV[VALPHA] = 0.75f; + } overlay_color.mV[VALPHA] *= alpha; switch(mImageOverlayAlignment) -- cgit v1.2.3 From dacfe7b2bdc845640f18db33992924033494e470 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 11 Oct 2011 16:20:02 -0700 Subject: EXP-1300 : Fix caret position in bottom bar, fix misplacement when moving within same toolbar, suppress visible caret in some situations, no caret if toolbar empty --- indra/llui/lltoolbar.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index d4633d7c3b..a1ea4ba18b 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -425,12 +425,12 @@ int LLToolBar::getRankFromPosition(S32& x, S32& y) } if (it_button != end_button) { - x = button_rect.mRight + dx; + x = button_rect.mLeft + dx; y = button_rect.mTop + dy; } else { - x = button_rect.mLeft + dx; + x = button_rect.mRight + dx; y = button_rect.mBottom + dy; } @@ -655,6 +655,7 @@ void LLToolBar::draw() LLUICtrl::draw(); caret->setVisible(FALSE); + mDragAndDropTarget = false; } void LLToolBar::reshape(S32 width, S32 height, BOOL called_from_parent) -- cgit v1.2.3 From f9e900f5ac9002f5ef3b44b02ac300971288e89b Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 11 Oct 2011 17:36:23 -0700 Subject: * New floater positioning code. Better than what's checked in but not great. * Floater updates for positioning and to revert some earlier string changes. --- indra/llui/llfloater.cpp | 76 ++++++++++++++++++++++++++++++++++++--------- indra/llui/llfloater.h | 42 ++++++++++++++++++++----- indra/llui/llfloaterreg.cpp | 35 +++++++++------------ 3 files changed, 110 insertions(+), 43 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 90c41e99dc..0398c0d7eb 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -62,6 +62,17 @@ // use this to control "jumping" behavior when Ctrl-Tabbing const S32 TABBED_FLOATER_OFFSET = 0; +namespace LLInitParam +{ + void TypeValues::declareValues() + { + declare("none", LLFloaterEnums::OPEN_POSITIONING_NONE); + declare("cascading", LLFloaterEnums::OPEN_POSITIONING_CASCADING); + declare("centered", LLFloaterEnums::OPEN_POSITIONING_CENTERED); + declare("specified", LLFloaterEnums::OPEN_POSITIONING_SPECIFIED); + } +} + std::string LLFloater::sButtonNames[BUTTON_COUNT] = { "llfloater_close_btn", //BUTTON_CLOSE @@ -154,7 +165,6 @@ LLFloater::Params::Params() : title("title"), short_title("short_title"), single_instance("single_instance", false), - auto_tile("auto_tile", false), can_resize("can_resize", false), can_minimize("can_minimize", true), can_close("can_close", true), @@ -164,7 +174,7 @@ LLFloater::Params::Params() save_rect("save_rect", false), save_visibility("save_visibility", false), can_dock("can_dock", false), - open_centered("open_centered", false), + open_positioning("open_positioning", LLFloaterEnums::OPEN_POSITIONING_NONE), header_height("header_height", 0), legacy_header_height("legacy_header_height", 0), close_image("close_image"), @@ -227,7 +237,6 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) mShortTitle(p.short_title), mSingleInstance(p.single_instance), mKey(key), - mAutoTile(p.auto_tile), mCanTearOff(p.can_tear_off), mCanMinimize(p.can_minimize), mCanClose(p.can_close), @@ -831,7 +840,7 @@ LLMultiFloater* LLFloater::getHost() return (LLMultiFloater*)mHostHandle.get(); } -void LLFloater::applySavedVariables() +void LLFloater::applySavedVariables() { applyRectControl(); applyDockState(); @@ -839,13 +848,7 @@ void LLFloater::applySavedVariables() void LLFloater::applyRectControl() { - // first, center on screen if requested - if (mOpenCentered) - { - center(); - } - - // override center if we have saved rect control + // If we have a saved rect, use it if (mRectControl.size() > 1) { const LLRect& rect = getControlGroup()->getRect(mRectControl); @@ -867,7 +870,50 @@ void LLFloater::applyDockState() bool dockState = getControlGroup()->getBOOL(mDocStateControl); setDocked(dockState); } +} + +void LLFloater::applyPositioning() +{ + // Otherwise position according to the positioning code + switch (mOpenPositioning) + { + case LLFloaterEnums::OPEN_POSITIONING_CENTERED: + center(); + break; + + case LLFloaterEnums::OPEN_POSITIONING_SPECIFIED: + { + // Translate relative to snap rect + LLRect r = getRect(); + r.mBottom = getSnapRect().getHeight() - r.getHeight() - r.mBottom; + setOrigin(r.mLeft, r.mBottom); + translateIntoRect(getSnapRect(), FALSE); + } + break; + case LLFloaterEnums::OPEN_POSITIONING_CASCADING: + { + static const U32 CASCADING_FLOATER_HOFFSET = 25; + static const U32 CASCADING_FLOATER_VOFFSET = 25; + static const S32 CASCADING_FLOATER_LIMIT = 15; + static S32 cascading_floater_count = 1; + const S32 top = CASCADING_FLOATER_VOFFSET * cascading_floater_count; + const S32 left = CASCADING_FLOATER_HOFFSET * cascading_floater_count; + setOrigin(left, top); + translateIntoRect(getSnapRect(), FALSE); + + if (++cascading_floater_count > CASCADING_FLOATER_LIMIT) + { + cascading_floater_count = 1; + } + } + break; + + case LLFloaterEnums::OPEN_POSITIONING_NONE: + default: + // Do nothing + break; + } } void LLFloater::applyTitle() @@ -2784,7 +2830,6 @@ void LLFloater::setInstanceName(const std::string& name) { mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name); } - } } @@ -2846,9 +2891,9 @@ void LLFloater::initFromParams(const LLFloater::Params& p) mHeaderHeight = p.header_height; mLegacyHeaderHeight = p.legacy_header_height; mSingleInstance = p.single_instance; - mAutoTile = p.auto_tile; - mOpenCentered = p.open_centered; + mOpenPositioning = p.open_positioning; + /* if (p.save_rect && mRectControl.empty()) { mRectControl = "t"; // flag to build mRectControl name once mInstanceName is set @@ -2856,7 +2901,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p) if (p.save_visibility) { mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set - } + }*/ if(p.save_dock_state) { @@ -3008,6 +3053,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str llerrs << "Failed to construct floater " << getName() << llendl; } + applyPositioning(); applyRectControl(); // If we have a saved rect control, apply it gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index af9665e599..b404306e94 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -59,11 +59,35 @@ const BOOL CLOSE_NO = FALSE; const BOOL ADJUST_VERTICAL_YES = TRUE; const BOOL ADJUST_VERTICAL_NO = FALSE; +namespace LLFloaterEnums +{ + enum EOpenPositioning + { + OPEN_POSITIONING_NONE, + OPEN_POSITIONING_CASCADING, + OPEN_POSITIONING_CENTERED, + OPEN_POSITIONING_SPECIFIED, + + OPEN_POSITIONING_COUNT + }; +} + +namespace LLInitParam +{ + template<> + struct TypeValues : public TypeValuesHelper + { + static void declareValues(); + }; +} + + class LLFloater : public LLPanel { -friend class LLFloaterView; -friend class LLFloaterReg; -friend class LLMultiFloater; + friend class LLFloaterView; + friend class LLFloaterReg; + friend class LLMultiFloater; + public: struct KeyCompare { @@ -95,7 +119,6 @@ public: short_title; Optional single_instance, - auto_tile, can_resize, can_minimize, can_close, @@ -104,8 +127,10 @@ public: save_rect, save_visibility, save_dock_state, - can_dock, - open_centered; + can_dock; + + Optional open_positioning; + Optional header_height, legacy_header_height; // HACK see initFromXML() @@ -297,6 +322,7 @@ protected: virtual void applyRectControl(); void applyDockState(); + void applyPositioning(); void storeRectControl(); void storeVisibilityControl(); void storeDockStateControl(); @@ -378,14 +404,14 @@ private: BOOL mSingleInstance; // TRUE if there is only ever one instance of the floater std::string mInstanceName; // Store the instance name so we can remove ourselves from the list - BOOL mAutoTile; // TRUE if placement of new instances tiles BOOL mCanTearOff; BOOL mCanMinimize; BOOL mCanClose; BOOL mDragOnLeft; BOOL mResizable; - bool mOpenCentered; + + LLFloaterEnums::EOpenPositioning mOpenPositioning; S32 mMinWidth; S32 mMinHeight; diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index ae06eb74ac..058223abbd 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -107,7 +107,6 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) if (!groupname.empty()) { instance_list_t& list = sInstanceMap[groupname]; - int index = list.size(); res = build_func(key); if (!res) @@ -121,27 +120,18 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) llwarns << "Failed to build floater type: '" << name << "'." << llendl; return NULL; } - + // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe if (res->mKey.isUndefined()) { - res->mKey = key; + res->mKey = key; } res->setInstanceName(name); res->applySavedVariables(); // Can't apply rect and dock state until setting instance name - if (res->mAutoTile && !res->getHost() && index > 0) - { - LLFloater* last_floater = getLastFloaterInGroup(groupname); - if (last_floater) - { - res->stackWith(*last_floater); - gFloaterView->adjustToFitScreen(res, true); - } - } - else - { - gFloaterView->adjustToFitScreen(res, false); - } + + // apply list.size() and possibly stackWith(getLastFloaterInGroup(groupname)) + gFloaterView->adjustToFitScreen(res, false); + list.push_back(res); } } @@ -477,16 +467,21 @@ void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) std::string name = sdname.asString(); parse_name_key(name, key); - LLFloater* instance = findInstance(name, key); + LLFloater* instance = getInstance(name, key); - if (LLFloater::isMinimized(instance)) + if (!instance) + { + lldebugs << "Unable to get instance of floater '" << name << "'" << llendl; + } + else if (instance->isMinimized()) { instance->setMinimized(FALSE); instance->setFocus(TRUE); } - else if (!LLFloater::isShown(instance)) + else if (!instance->isShown()) { - showInstance(name, key, TRUE); + instance->openFloater(key); + instance->setFocus(TRUE); } else if (!instance->hasFocus() && !instance->getIsChrome()) { -- cgit v1.2.3 From d0cda13235079c6626ebc7bbe4de542784d50fa0 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 11 Oct 2011 22:49:00 -0700 Subject: EXP-1275 FIX A UI element or Keyboard shortcut to clear the viewport Ctrl+Shift+U now toggles UI and hides floaters refactored main_view.xml made all members of llviewerwindow private --- indra/llui/llmenugl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index badba7a416..3ef8d8ff35 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -1731,7 +1731,7 @@ void LLMenuGL::setCanTearOff(BOOL tear_off) { LLMenuItemTearOffGL::Params p; mTearOffItem = LLUICtrlFactory::create(p); - addChildInBack(mTearOffItem); + addChild(mTearOffItem); } else if (!tear_off && mTearOffItem != NULL) { -- cgit v1.2.3 From a1f0101ca293768a37889856b1dde69110b30b7c Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 12 Oct 2011 13:50:20 -0700 Subject: EXP-1275 WIP A UI element or Keyboard shortcut to clear the viewport restores hidden floaters now --- indra/llui/llfloater.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ indra/llui/llfloater.h | 11 +++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 0398c0d7eb..4bcc7c6fe0 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2506,6 +2506,52 @@ void LLFloaterView::closeAllChildren(bool app_quitting) } } +void LLFloaterView::hiddenFloaterClosed(LLFloater* floater) +{ + for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end(); + it != end_it; + ++it) + { + if (it->first.get() == floater) + { + it->second.disconnect(); + mHiddenFloaters.erase(it); + break; + } + } +} + +void LLFloaterView::hideAllFloaters() +{ + child_list_t child_list = *(getChildList()); + + for (child_list_iter_t it = child_list.begin(); it != child_list.end(); ++it) + { + LLFloater* floaterp = dynamic_cast(*it); + if (floaterp && floaterp->getVisible()) + { + floaterp->setVisible(false); + boost::signals2::connection connection = floaterp->mCloseSignal.connect(boost::bind(&LLFloaterView::hiddenFloaterClosed, this, floaterp)); + mHiddenFloaters.push_back(std::make_pair(floaterp->getHandle(), connection)); + } + } +} + +void LLFloaterView::showHiddenFloaters() +{ + for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end(); + it != end_it; + ++it) + { + LLFloater* floaterp = it->first.get(); + if (floaterp) + { + floaterp->setVisible(true); + } + it->second.disconnect(); + } + mHiddenFloaters.clear(); +} BOOL LLFloaterView::allChildrenClosed() { diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index b404306e94..275b508f79 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -35,6 +35,7 @@ #include "lluuid.h" //#include "llnotificationsutil.h" #include +#include class LLDragHandle; class LLResizeHandle; @@ -454,8 +455,6 @@ private: typedef std::map, LLFloater*>::iterator handle_map_iter_t; static handle_map_t sFloaterMap; - std::vector > mMinimizedHiddenChildren; - BOOL mHasBeenDraggedWhileMinimized; S32 mPreviousMinimizedBottom; S32 mPreviousMinimizedLeft; @@ -509,6 +508,10 @@ public: BOOL allChildrenClosed(); void shiftFloaters(S32 x_offset, S32 y_offset); + void hideAllFloaters(); + void showHiddenFloaters(); + + LLFloater* getFrontmost() const; LLFloater* getBackmost() const; LLFloater* getParentFloater(LLView* viewp) const; @@ -523,11 +526,15 @@ public: void setFloaterSnapView(LLHandle snap_view) {mSnapView = snap_view; } private: + void hiddenFloaterClosed(LLFloater* floater); + LLHandle mSnapView; BOOL mFocusCycleMode; S32 mSnapOffsetBottom; S32 mSnapOffsetRight; S32 mMinimizePositionVOffset; + typedef std::vector, boost::signals2::connection> > hidden_floaters_t; + hidden_floaters_t mHiddenFloaters; }; // -- cgit v1.2.3 From 9ca4b8219f1a18b11d457d6f18d3c695aba9aed2 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 12 Oct 2011 15:46:45 -0700 Subject: EXP-1275 WIP A UI element or Keyboard shortcut to clear the viewport added confirmation dialog before hiding UI --- indra/llui/llfloater.cpp | 1 + indra/llui/llfloater.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 4bcc7c6fe0..16fe3b8ca6 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -247,6 +247,7 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) mHeaderHeight(p.header_height), mLegacyHeaderHeight(p.legacy_header_height), mMinimized(FALSE), + mVisibleWhenMinimized(TRUE), mForeground(FALSE), mFirstLook(TRUE), mButtonScale(1.0f), diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 275b508f79..c94aa0207e 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -212,7 +212,7 @@ public: void addDependentFloater(LLFloater* dependent, BOOL reposition = TRUE); void addDependentFloater(LLHandle dependent_handle, BOOL reposition = TRUE); LLFloater* getDependee() { return (LLFloater*)mDependeeHandle.get(); } - void removeDependentFloater(LLFloater* dependent); + void removeDependentFloater(LLFloater* dependent); BOOL isMinimized() const { return mMinimized; } /// isShown() differs from getVisible() in that isShown() also considers /// isMinimized(). isShown() is true only if visible and not minimized. @@ -420,6 +420,7 @@ private: S32 mLegacyHeaderHeight;// HACK see initFloaterXML() BOOL mMinimized; + bool mVisibleWhenMinimized; BOOL mForeground; LLHandle mDependeeHandle; -- cgit v1.2.3 From 3594853d0ef166c98d04c015b1217f2a437f8872 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 12 Oct 2011 16:17:24 -0700 Subject: don't highlight toolbar buttons during drag and drop added mVisibleWhenMinimized to floaters --- indra/llui/llfloater.cpp | 22 ++++++++++++++++++---- indra/llui/llfloater.h | 4 +++- indra/llui/lltoolbar.cpp | 5 ++++- 3 files changed, 25 insertions(+), 6 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 16fe3b8ca6..1e6c8b4a71 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1407,6 +1407,17 @@ void LLFloater::removeDependentFloater(LLFloater* floaterp) floaterp->mDependeeHandle = LLHandle(); } +void LLFloater::setVisibleWhenMinimized(bool visible) +{ + mVisibleWhenMinimized = visible; + if (visible && isMinimized()) + { + // restack in minimized stack + setMinimized(FALSE); + setMinimized(TRUE); + } +} + BOOL LLFloater::offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButton index) { if( mButtonsEnabled[index] ) @@ -1783,11 +1794,14 @@ void LLFloater::draw() } if (isMinimized()) { - for (S32 i = 0; i < BUTTON_COUNT; i++) + if (mVisibleWhenMinimized) { - drawChild(mButtons[i]); + for (S32 i = 0; i < BUTTON_COUNT; i++) + { + drawChild(mButtons[i]); + } + drawChild(mDragHandle); } - drawChild(mDragHandle); } else { @@ -2442,7 +2456,7 @@ void LLFloaterView::getMinimizePosition(S32 *left, S32 *bottom) { // Examine minimized children. LLFloater* floater = (LLFloater*)((LLView*)*child_it); - if(floater->isMinimized()) + if(floater->isMinimized() && floater->getVisibleWhenMinimized()) { LLRect r = floater->getRect(); if((r.mBottom < (row + floater_header_size)) diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index c94aa0207e..5e3d3aefc9 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -213,7 +213,9 @@ public: void addDependentFloater(LLHandle dependent_handle, BOOL reposition = TRUE); LLFloater* getDependee() { return (LLFloater*)mDependeeHandle.get(); } void removeDependentFloater(LLFloater* dependent); - BOOL isMinimized() const { return mMinimized; } + BOOL isMinimized() const { return mMinimized; } + void setVisibleWhenMinimized(bool visible); + bool getVisibleWhenMinimized() const { return mVisibleWhenMinimized;} /// isShown() differs from getVisible() in that isShown() also considers /// isMinimized(). isShown() is true only if visible and not minimized. bool isShown() const; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index a1ea4ba18b..02970bc969 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -871,7 +871,10 @@ void LLToolBarButton::onMouseEnter(S32 x, S32 y, MASK mask) LLUICtrl::onMouseEnter(x, y, mask); // Always highlight toolbar buttons, even if they are disabled - mNeedsHighlight = TRUE; + if (!gFocusMgr.getMouseCapture() || gFocusMgr.getMouseCapture() != this) + { + mNeedsHighlight = TRUE; + } } void LLToolBarButton::onMouseCaptureLost() -- cgit v1.2.3 From d5d7e264ad636a42470772f5e96914327e30eca2 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 12 Oct 2011 16:51:00 -0700 Subject: don't highlight toolbar buttons during drag and drop (for real) --- indra/llui/llbutton.cpp | 2 +- indra/llui/lltoolbar.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 0a7584a576..4f0c0d31bd 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -548,7 +548,7 @@ void LLButton::setHighlight(bool b) BOOL LLButton::handleHover(S32 x, S32 y, MASK mask) { if (isInEnabledChain() - && (!gFocusMgr.getMouseCapture() || gFocusMgr.getMouseCapture() != this)) + && (!gFocusMgr.getMouseCapture() || gFocusMgr.getMouseCapture() == this)) mNeedsHighlight = TRUE; if (!childrenHandleHover(x, y, mask)) diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 02970bc969..a75a1552fc 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -871,7 +871,7 @@ void LLToolBarButton::onMouseEnter(S32 x, S32 y, MASK mask) LLUICtrl::onMouseEnter(x, y, mask); // Always highlight toolbar buttons, even if they are disabled - if (!gFocusMgr.getMouseCapture() || gFocusMgr.getMouseCapture() != this) + if (!gFocusMgr.getMouseCapture() || gFocusMgr.getMouseCapture() == this) { mNeedsHighlight = TRUE; } -- cgit v1.2.3 From 309ebb84a8cf93e03e2594525aa128b3002040bf Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 12 Oct 2011 17:43:47 -0700 Subject: * Floater positioning now based on position of other cascading windows currently open. --- indra/llui/llfloater.cpp | 84 +++++++++++++++++++++++++++++---------------- indra/llui/llfloater.h | 19 ++++++---- indra/llui/llfloaterreg.cpp | 73 ++++++++++++++++++++++++++++++++++++--- indra/llui/llfloaterreg.h | 2 ++ 4 files changed, 139 insertions(+), 39 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 0398c0d7eb..984b710b9d 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -175,6 +175,8 @@ LLFloater::Params::Params() save_visibility("save_visibility", false), can_dock("can_dock", false), open_positioning("open_positioning", LLFloaterEnums::OPEN_POSITIONING_NONE), + specified_left("specified_left"), + specified_bottom("specified_bottom"), header_height("header_height", 0), legacy_header_height("legacy_header_height", 0), close_image("close_image"), @@ -242,6 +244,9 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) mCanClose(p.can_close), mDragOnLeft(p.can_drag_on_left), mResizable(p.can_resize), + mOpenPositioning(p.open_positioning), + mSpecifiedLeft(p.specified_left), + mSpecifiedBottom(p.specified_bottom), mMinWidth(p.min_width), mMinHeight(p.min_height), mHeaderHeight(p.header_height), @@ -678,6 +683,7 @@ void LLFloater::openFloater(const LLSD& key) } else { + applyControlsAndPosition(LLFloaterReg::getLastFloaterCascading()); setMinimized(FALSE); setVisibleAndFrontmost(mAutoFocus); } @@ -840,39 +846,54 @@ LLMultiFloater* LLFloater::getHost() return (LLMultiFloater*)mHostHandle.get(); } -void LLFloater::applySavedVariables() +void LLFloater::applyControlsAndPosition(LLFloater* other) { - applyRectControl(); - applyDockState(); + if (!applyDockState()) + { + if (!applyRectControl()) + { + applyPositioning(other); + } + } } -void LLFloater::applyRectControl() +bool LLFloater::applyRectControl() { + bool saved_rect = false; + // If we have a saved rect, use it if (mRectControl.size() > 1) { const LLRect& rect = getControlGroup()->getRect(mRectControl); - if (rect.notEmpty()) + saved_rect = rect.notEmpty(); + if (saved_rect) { setOrigin(rect.mLeft, rect.mBottom); + if (mResizable) { reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight())); } } } + + return saved_rect; } -void LLFloater::applyDockState() +bool LLFloater::applyDockState() { + bool docked = false; + if (mDocStateControl.size() > 1) { - bool dockState = getControlGroup()->getBOOL(mDocStateControl); - setDocked(dockState); + docked = getControlGroup()->getBOOL(mDocStateControl); + setDocked(docked); } + + return docked; } -void LLFloater::applyPositioning() +void LLFloater::applyPositioning(LLFloater* other) { // Otherwise position according to the positioning code switch (mOpenPositioning) @@ -884,28 +905,33 @@ void LLFloater::applyPositioning() case LLFloaterEnums::OPEN_POSITIONING_SPECIFIED: { // Translate relative to snap rect - LLRect r = getRect(); - r.mBottom = getSnapRect().getHeight() - r.getHeight() - r.mBottom; - setOrigin(r.mLeft, r.mBottom); - translateIntoRect(getSnapRect(), FALSE); + setOrigin(mSpecifiedLeft, mSpecifiedBottom); + const LLRect& snap_rect = gFloaterView->getSnapRect(); + translate(snap_rect.mLeft, snap_rect.mBottom); + translateIntoRect(snap_rect, FALSE); } break; case LLFloaterEnums::OPEN_POSITIONING_CASCADING: + if (other != NULL) { - static const U32 CASCADING_FLOATER_HOFFSET = 25; - static const U32 CASCADING_FLOATER_VOFFSET = 25; - static const S32 CASCADING_FLOATER_LIMIT = 15; - static S32 cascading_floater_count = 1; - const S32 top = CASCADING_FLOATER_VOFFSET * cascading_floater_count; - const S32 left = CASCADING_FLOATER_HOFFSET * cascading_floater_count; - setOrigin(left, top); - translateIntoRect(getSnapRect(), FALSE); + stackWith(*other); + } + else + { + static const U32 CASCADING_FLOATER_HOFFSET = 0; + static const U32 CASCADING_FLOATER_VOFFSET = 0; + + const LLRect& snap_rect = gFloaterView->getSnapRect(); - if (++cascading_floater_count > CASCADING_FLOATER_LIMIT) - { - cascading_floater_count = 1; - } + const S32 horizontal_offset = CASCADING_FLOATER_HOFFSET; + const S32 vertical_offset = snap_rect.getHeight() - CASCADING_FLOATER_VOFFSET; + + S32 rect_height = getRect().getHeight(); + setOrigin(horizontal_offset, vertical_offset - rect_height); + + translate(snap_rect.mLeft, snap_rect.mBottom); + translateIntoRect(snap_rect, FALSE); } break; @@ -2891,9 +2917,11 @@ void LLFloater::initFromParams(const LLFloater::Params& p) mHeaderHeight = p.header_height; mLegacyHeaderHeight = p.legacy_header_height; mSingleInstance = p.single_instance; + mOpenPositioning = p.open_positioning; + mSpecifiedLeft = p.specified_left; + mSpecifiedBottom = p.specified_bottom; - /* if (p.save_rect && mRectControl.empty()) { mRectControl = "t"; // flag to build mRectControl name once mInstanceName is set @@ -2901,8 +2929,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p) if (p.save_visibility) { mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set - }*/ - + } if(p.save_dock_state) { mDocStateControl = "t"; // flag to build mDocStateControl name once mInstanceName is set @@ -3053,7 +3080,6 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str llerrs << "Failed to construct floater " << getName() << llendl; } - applyPositioning(); applyRectControl(); // If we have a saved rect control, apply it gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index b404306e94..b094c76168 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -130,6 +130,9 @@ public: can_dock; Optional open_positioning; + Optional specified_left; + Optional specified_bottom; + Optional header_height, legacy_header_height; // HACK see initFromXML() @@ -291,8 +294,6 @@ public: virtual void setTornOff(bool torn_off) { mTornOff = torn_off; } - void stackWith(LLFloater& other); - // Return a closeable floater, if any, given the current focus. static LLFloater* getClosableFloaterFromFocus(); @@ -317,12 +318,16 @@ public: void updateTransparency(ETypeTransparency transparency_type); void enableResizeCtrls(bool enable, bool width = true, bool height = true); + + bool isPositioning(LLFloaterEnums::EOpenPositioning p) const { return (p == mOpenPositioning); } protected: - virtual void applySavedVariables(); + void applyControlsAndPosition(LLFloater* other); + + void stackWith(LLFloater& other); - virtual void applyRectControl(); - void applyDockState(); - void applyPositioning(); + virtual bool applyRectControl(); + bool applyDockState(); + void applyPositioning(LLFloater* other); void storeRectControl(); void storeVisibilityControl(); void storeDockStateControl(); @@ -412,6 +417,8 @@ private: BOOL mResizable; LLFloaterEnums::EOpenPositioning mOpenPositioning; + S32 mSpecifiedLeft; + S32 mSpecifiedBottom; S32 mMinWidth; S32 mMinHeight; diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index 058223abbd..a148f5a32e 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -59,19 +59,57 @@ void LLFloaterReg::add(const std::string& name, const std::string& filename, con //static LLFloater* LLFloaterReg::getLastFloaterInGroup(const std::string& name) { - LLRect rect; const std::string& groupname = sGroupMap[name]; if (!groupname.empty()) { instance_list_t& list = sInstanceMap[groupname]; if (!list.empty()) { - return list.back(); + for (instance_list_t::reverse_iterator iter = list.rbegin(); iter != list.rend(); ++iter) + { + LLFloater* inst = *iter; + + if (inst->getVisible() && !inst->isMinimized()) + { + return inst; + } + } } } return NULL; } +LLFloater* LLFloaterReg::getLastFloaterCascading() +{ + LLRect candidate_rect; + candidate_rect.mTop = 100000; + LLFloater* candidate_floater = NULL; + + std::map::const_iterator it = sGroupMap.begin(), it_end = sGroupMap.end(); + for( ; it != it_end; ++it) + { + const std::string& group_name = it->second; + + instance_list_t& instances = sInstanceMap[group_name]; + + for (instance_list_t::const_iterator iter = instances.begin(); iter != instances.end(); ++iter) + { + LLFloater* inst = *iter; + + if (inst->getVisible() && inst->isPositioning(LLFloaterEnums::OPEN_POSITIONING_CASCADING)) + { + if (candidate_rect.mTop > inst->getRect().mTop) + { + candidate_floater = inst; + candidate_rect = inst->getRect(); + } + } + } + } + + return candidate_floater; +} + //static LLFloater* LLFloaterReg::findInstance(const std::string& name, const LLSD& key) { @@ -127,9 +165,10 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) res->mKey = key; } res->setInstanceName(name); - res->applySavedVariables(); // Can't apply rect and dock state until setting instance name - // apply list.size() and possibly stackWith(getLastFloaterInGroup(groupname)) + LLFloater *last_floater = (list.empty() ? NULL : list.back()); + res->applyControlsAndPosition(last_floater); + gFloaterView->adjustToFitScreen(res, false); list.push_back(res); @@ -533,3 +572,29 @@ bool LLFloaterReg::floaterInstanceMinimized(const LLSD& sdname) LLFloater* instance = findInstance(name, key); return LLFloater::isShown(instance); } + +// static +U32 LLFloaterReg::getVisibleFloaterInstanceCount() +{ + U32 count = 0; + + std::map::const_iterator it = sGroupMap.begin(), it_end = sGroupMap.end(); + for( ; it != it_end; ++it) + { + const std::string& group_name = it->second; + + instance_list_t& instances = sInstanceMap[group_name]; + + for (instance_list_t::const_iterator iter = instances.begin(); iter != instances.end(); ++iter) + { + LLFloater* inst = *iter; + + if (inst->getVisible() && !inst->isMinimized()) + { + count++; + } + } + } + + return count; +} diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index 07ae45cc4c..817fe2e8c6 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -87,6 +87,7 @@ public: // Helpers static LLFloater* getLastFloaterInGroup(const std::string& name); + static LLFloater* getLastFloaterCascading(); // Find / get (create) / remove / destroy static LLFloater* findInstance(const std::string& name, const LLSD& key = LLSD()); @@ -153,6 +154,7 @@ public: static void blockShowFloaters(bool value) { sBlockShowFloaters = value;} + static U32 getVisibleFloaterInstanceCount(); }; #endif -- cgit v1.2.3 From 20358ea89dc9823ac0b539030fdf03268dbdf4e9 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 12 Oct 2011 17:45:21 -0700 Subject: * Added mModified flag and isModified() query to check it. (currently it is not connect to actual data) --- indra/llui/lltoolbar.cpp | 1 + indra/llui/lltoolbar.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index a1ea4ba18b..1320f03a25 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -99,6 +99,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) mSideType(p.side), mWrap(p.wrap), mNeedsLayout(false), + mModified(false), mButtonPanel(NULL), mCenteringStack(NULL), mPadLeft(p.pad_left), diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 709399c59f..2c66f29c16 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -178,7 +178,8 @@ public: LLToolBarButton* createButton(const LLCommandId& id); - bool hasButtons() { return !mButtons.empty(); } + bool hasButtons() const { return !mButtons.empty(); } + bool isModified() const { return mModified; } protected: friend class LLUICtrlFactory; @@ -225,6 +226,7 @@ private: bool mWrap; bool mNeedsLayout; + bool mModified; S32 mPadLeft, mPadRight, mPadTop, -- cgit v1.2.3 From aa1f0215c764fa346625ace43c467a0e0f803057 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 12 Oct 2011 18:01:50 -0700 Subject: EXP-1331 : Implement new longer caret and make it work on multi lines or columns of tools. EXP-1304 : handle only tools in DaD on toolbars --- indra/llui/lltoolbar.cpp | 92 ++++++++++++++++++++++++++++++++++-------------- indra/llui/lltoolbar.h | 6 ++-- 2 files changed, 69 insertions(+), 29 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index a1ea4ba18b..ce3ef1db97 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -395,12 +395,14 @@ void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row // Returns the position of the coordinates as a rank in the button list. // The rank is the position a tool dropped in (x,y) would assume in the button list. -// The value returned is between 0 and mButtons.size(), 0 being the first element to the left +// The returned value is between 0 and mButtons.size(), 0 being the first element to the left // (or top) and mButtons.size() the last one to the right (or bottom). -int LLToolBar::getRankFromPosition(S32& x, S32& y) +// Various drag data are stored in the toolbar object though are not exposed outside (and shouldn't). +int LLToolBar::getRankFromPosition(S32 x, S32 y) { int rank = 0; + // Convert the toolbar coord into button panel coords LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType); S32 button_panel_x = 0; S32 button_panel_y = 0; @@ -408,32 +410,72 @@ int LLToolBar::getRankFromPosition(S32& x, S32& y) S32 dx = x - button_panel_x; S32 dy = y - button_panel_y; - // Simply compare the passed coord with the buttons outbound box + // Simply compare the passed coord with the buttons outbound box + padding std::list::iterator it_button = mButtons.begin(); std::list::iterator end_button = mButtons.end(); LLRect button_rect; while (it_button != end_button) { button_rect = (*it_button)->getRect(); - if (((orientation == LLLayoutStack::HORIZONTAL) && (button_rect.mRight > button_panel_x)) || - ((orientation == LLLayoutStack::VERTICAL) && (button_rect.mBottom < button_panel_y)) ) + S32 point_x, point_y; + if (orientation == LLLayoutStack::HORIZONTAL) + { + // Horizontal + point_x = (button_rect.mRight + button_rect.mLeft) / 2; + point_y = button_rect.mBottom - mPadBottom; + } + else + { + // Vertical + point_x = button_rect.mRight + mPadRight; + point_y = (button_rect.mTop + button_rect.mBottom) / 2; + } + + if ((button_panel_x < point_x) && (button_panel_y > point_y)) { break; } + mDragCommand = (*it_button)->mId; rank++; ++it_button; } - if (it_button != end_button) + + // Update the passed coordinates to the hit button relevant corner + // (different depending on toolbar orientation) + if (rank < mButtons.size()) { - x = button_rect.mLeft + dx; - y = button_rect.mTop + dy; + mDragx = button_rect.mLeft - mPadLeft; + mDragy = button_rect.mTop + mPadTop; } else { - x = button_rect.mRight + dx; - y = button_rect.mBottom + dy; + // We hit passed the end of the list so put the insertion point at the end + if (orientation == LLLayoutStack::HORIZONTAL) + { + mDragx = button_rect.mRight + mPadRight; + mDragy = button_rect.mTop + mPadTop; + } + else + { + mDragx = button_rect.mLeft - mPadLeft; + mDragy = button_rect.mBottom - mPadBottom; + } + } + + // Update the "girth" of the caret, i.e. the width or height (depending of orientation) + if (orientation == LLLayoutStack::HORIZONTAL) + { + mDragGirth = button_rect.getHeight() + mPadBottom + mPadTop; + } + else + { + mDragGirth = button_rect.getWidth() + mPadLeft + mPadRight; } + // The delta account for the coord model change (i.e. convert back to toolbar coord) + mDragx += dx; + mDragy += dy; + return rank; } @@ -628,26 +670,18 @@ void LLToolBar::draw() { LLRect caret_rect = caret->getRect(); LLRect toolbar_rect = getRect(); - if (mSideType == SIDE_BOTTOM) + if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) { caret->setRect(LLRect(mDragx-caret_rect.getWidth()/2+1, - toolbar_rect.getHeight()+3, + mDragy, mDragx+caret_rect.getWidth()/2+1, - toolbar_rect.getHeight()-caret_rect.getHeight()+3)); - } - else if (mSideType == SIDE_LEFT) - { - - caret->setRect(LLRect(toolbar_rect.getWidth()-caret_rect.getWidth()+3, - mDragy+caret_rect.getHeight()/2, - toolbar_rect.getWidth()+3, - mDragy-caret_rect.getHeight()/2)); + mDragy-mDragGirth)); } else { - caret->setRect(LLRect(-3, + caret->setRect(LLRect(mDragx, mDragy+caret_rect.getHeight()/2, - caret_rect.getWidth()-3, + mDragx+mDragGirth, mDragy-caret_rect.getHeight()/2)); } caret->setVisible(TRUE); @@ -791,16 +825,20 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, LLAssetType::EType type = inv_item->getType(); if (type == LLAssetType::AT_WIDGET) { - mDragx = x; - mDragy = y; - mDragRank = getRankFromPosition(mDragx, mDragy); - mDragAndDropTarget = true; + mDragRank = getRankFromPosition(x, y); + // Don't DaD if we're dragging a command on itself + mDragAndDropTarget = (mDragCommand.uuid() != inv_item->getUUID()); + //llinfos << "Merov debug : DaD, rank = " << mDragRank << ", hit uuid = " << mDragCommand.uuid() << ", dragged uui = " << inv_item->getUUID() << llendl; /* Do the following if you want to animate the button itself LLCommandId dragged_command(inv_item->getUUID()); removeCommand(dragged_command); addCommand(dragged_command,rank); */ } + else + { + handled = FALSE; + } } return handled; diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 709399c59f..8fd509bacc 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -156,7 +156,7 @@ public: // virtuals void draw(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); - int getRankFromPosition(S32& x, S32& y); + int getRankFromPosition(S32 x, S32 y); BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -192,7 +192,9 @@ protected: bool mDragAndDropTarget; int mDragRank; S32 mDragx, - mDragy; + mDragy, + mDragGirth; + LLCommandId mDragCommand; public: // Methods used in loading and saving toolbar settings -- cgit v1.2.3 From 9206226a377c88d34036ebd8a3ac6d9d55bc4146 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 12 Oct 2011 18:16:59 -0700 Subject: tooltips now only show labels for toolbar buttons when label is hidden or truncated tooltips are no longer instantaneous once a tooltip is visible --- indra/llui/llbutton.cpp | 39 +++++++++++++++++++-------------------- indra/llui/llbutton.h | 2 ++ indra/llui/lltoolbar.cpp | 36 +++++++++++++++++++++++++++++------- indra/llui/lltoolbar.h | 4 ++++ indra/llui/llview.cpp | 7 ++++--- indra/llui/llview.h | 2 +- 6 files changed, 59 insertions(+), 31 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 4f0c0d31bd..f40d99c024 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -732,16 +732,7 @@ void LLButton::draw() } // Unselected label assignments - LLWString label; - - if( getToggleState() ) - { - label = mSelectedLabel; - } - else - { - label = mUnselectedLabel; - } + LLWString label = getCurrentLabel(); // overlay with keyboard focus border if (hasFocus()) @@ -988,6 +979,23 @@ void LLButton::setLabelSelected( const LLStringExplicit& label ) mSelectedLabel = label; } +bool LLButton::labelIsTruncated() const +{ + return getCurrentLabel().getString().size() > mLastDrawCharsCount; +} + +const LLUIString& LLButton::getCurrentLabel() const +{ + if( getToggleState() ) + { + return mSelectedLabel; + } + else + { + return mUnselectedLabel; + } +} + void LLButton::setImageUnselected(LLPointer image) { mImageUnselected = image; @@ -999,16 +1007,7 @@ void LLButton::setImageUnselected(LLPointer image) void LLButton::autoResize() { - LLUIString label; - if(getToggleState()) - { - label = mSelectedLabel; - } - else - { - label = mUnselectedLabel; - } - resize(label); + resize(getCurrentLabel()); } void LLButton::resize(LLUIString label) diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index ba0345f610..7d9adcd892 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -242,6 +242,8 @@ public: S32 getLastDrawCharsCount() const { return mLastDrawCharsCount; } + bool labelIsTruncated() const; + const LLUIString& getCurrentLabel() const; void setScaleImage(BOOL scale) { mScaleImage = scale; } BOOL getScaleImage() const { return mScaleImage; } diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index a75a1552fc..fc5ec5ea26 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -193,9 +193,9 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) mCenteringStack->addChild(LLUICtrlFactory::create(border_panel_p)); - BOOST_FOREACH(LLCommandId::Params params, p.commands) + BOOST_FOREACH(LLCommandId id, p.commands) { - addCommand(params); + addCommand(id); } mNeedsLayout = true; @@ -688,13 +688,10 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) LLCommand* commandp = LLCommandManager::instance().getCommand(id); if (!commandp) return NULL; - std::string label = LLTrans::getString(commandp->labelRef()); - std::string tooltip = label + "\n" + LLTrans::getString(commandp->tooltipRef()); - LLToolBarButton::Params button_p; button_p.name = id.name(); - button_p.label = label; - button_p.tool_tip = tooltip; + button_p.label = LLTrans::getString(commandp->labelRef()); + button_p.tool_tip = LLTrans::getString(commandp->tooltipRef()); button_p.image_overlay = LLUI::getUIImage(commandp->icon()); button_p.overwriteFrom(mButtonParams[mButtonType]); LLToolBarButton* button = LLUICtrlFactory::create(button_p); @@ -886,3 +883,28 @@ void LLToolBarButton::reshape(S32 width, S32 height, BOOL called_from_parent) { LLButton::reshape(mWidthRange.clamp(width), height, called_from_parent); } + +const std::string LLToolBarButton::getToolTip() const +{ + std::string tooltip; + if (labelIsTruncated() || getCurrentLabel().empty()) + { + return LLTrans::getString(LLCommandManager::instance().getCommand(mId)->labelRef()) + " -- " + LLView::getToolTip(); + } + else + { + return LLView::getToolTip(); + } +} + + + + + + + + + + + + diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 709399c59f..72fc5630bc 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -72,6 +72,10 @@ public: void onMouseEnter(S32 x, S32 y, MASK mask); void onMouseCaptureLost(); + virtual const std::string getToolTip() const; + + + private: LLCommandId mId; S32 mMouseDownX; diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index e10c2f0d1e..55d053254c 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -708,15 +708,16 @@ BOOL LLView::handleToolTip(S32 x, S32 y, MASK mask) // parents provide tooltips first, which are optionally // overridden by children, in case child is mouse_opaque - if (!mToolTipMsg.empty()) + std::string tooltip = getToolTip(); + if (!tooltip.empty()) { // allow "scrubbing" over ui by showing next tooltip immediately // if previous one was still visible F32 timeout = LLToolTipMgr::instance().toolTipVisible() - ? 0.f + ? LLUI::sSettingGroups["config"]->getF32( "ToolTipFastDelay" ) : LLUI::sSettingGroups["config"]->getF32( "ToolTipDelay" ); LLToolTipMgr::instance().show(LLToolTip::Params() - .message(mToolTipMsg) + .message(tooltip) .sticky_rect(calcScreenRect()) .delay_time(timeout)); diff --git a/indra/llui/llview.h b/indra/llui/llview.h index a1c46f3bf3..5e3387dc98 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -238,7 +238,7 @@ public: ECursorType getHoverCursor() { return mHoverCursor; } - const std::string& getToolTip() const { return mToolTipMsg.getString(); } + virtual const std::string getToolTip() const { return mToolTipMsg.getString(); } void sendChildToFront(LLView* child); void sendChildToBack(LLView* child); -- cgit v1.2.3 From 8affdabac33abbe63bea028dc92620550c06aff4 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 12 Oct 2011 19:17:44 -0700 Subject: removed visiblewhenminimized logic pending redesign --- indra/llui/llfloater.cpp | 23 ++++------------------- indra/llui/llfloater.h | 3 --- 2 files changed, 4 insertions(+), 22 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 81b14aac17..fa533e8153 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -252,7 +252,6 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) mHeaderHeight(p.header_height), mLegacyHeaderHeight(p.legacy_header_height), mMinimized(FALSE), - mVisibleWhenMinimized(TRUE), mForeground(FALSE), mFirstLook(TRUE), mButtonScale(1.0f), @@ -1433,17 +1432,6 @@ void LLFloater::removeDependentFloater(LLFloater* floaterp) floaterp->mDependeeHandle = LLHandle(); } -void LLFloater::setVisibleWhenMinimized(bool visible) -{ - mVisibleWhenMinimized = visible; - if (visible && isMinimized()) - { - // restack in minimized stack - setMinimized(FALSE); - setMinimized(TRUE); - } -} - BOOL LLFloater::offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButton index) { if( mButtonsEnabled[index] ) @@ -1820,14 +1808,11 @@ void LLFloater::draw() } if (isMinimized()) { - if (mVisibleWhenMinimized) + for (S32 i = 0; i < BUTTON_COUNT; i++) { - for (S32 i = 0; i < BUTTON_COUNT; i++) - { - drawChild(mButtons[i]); - } - drawChild(mDragHandle); + drawChild(mButtons[i]); } + drawChild(mDragHandle); } else { @@ -2482,7 +2467,7 @@ void LLFloaterView::getMinimizePosition(S32 *left, S32 *bottom) { // Examine minimized children. LLFloater* floater = (LLFloater*)((LLView*)*child_it); - if(floater->isMinimized() && floater->getVisibleWhenMinimized()) + if(floater->isMinimized()) { LLRect r = floater->getRect(); if((r.mBottom < (row + floater_header_size)) diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 7cfec09e5f..8beb11507e 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -217,8 +217,6 @@ public: LLFloater* getDependee() { return (LLFloater*)mDependeeHandle.get(); } void removeDependentFloater(LLFloater* dependent); BOOL isMinimized() const { return mMinimized; } - void setVisibleWhenMinimized(bool visible); - bool getVisibleWhenMinimized() const { return mVisibleWhenMinimized;} /// isShown() differs from getVisible() in that isShown() also considers /// isMinimized(). isShown() is true only if visible and not minimized. bool isShown() const; @@ -429,7 +427,6 @@ private: S32 mLegacyHeaderHeight;// HACK see initFloaterXML() BOOL mMinimized; - bool mVisibleWhenMinimized; BOOL mForeground; LLHandle mDependeeHandle; -- cgit v1.2.3 From c14aa1b64e1190ff4bd7deef864d5393988e7f91 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 12 Oct 2011 19:48:13 -0700 Subject: EXP-1331 : Avoid showing the caret if the tool is dragged over itself --- indra/llui/lltoolbar.cpp | 29 ++++++++++++++++++++++++++--- indra/llui/lltoolbar.h | 1 + 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 21eeed1d27..5e025f6a45 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -418,6 +418,7 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) while (it_button != end_button) { button_rect = (*it_button)->getRect(); + mDragCommand = (*it_button)->mId; S32 point_x, point_y; if (orientation == LLLayoutStack::HORIZONTAL) { @@ -436,7 +437,6 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) { break; } - mDragCommand = (*it_button)->mId; rank++; ++it_button; } @@ -480,6 +480,27 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) return rank; } +int LLToolBar::getRankFromPosition(const LLCommandId& id) +{ + if (!hasCommand(id)) + { + return RANK_NONE; + } + int rank = 0; + std::list::iterator it_button = mButtons.begin(); + std::list::iterator end_button = mButtons.end(); + while (it_button != end_button) + { + if ((*it_button)->mId == id) + { + break; + } + rank++; + ++it_button; + } + return rank; +} + void LLToolBar::updateLayoutAsNeeded() { if (!mNeedsLayout) return; @@ -826,10 +847,12 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, LLAssetType::EType type = inv_item->getType(); if (type == LLAssetType::AT_WIDGET) { + LLCommandId dragged_command(inv_item->getUUID()); + int orig_rank = getRankFromPosition(dragged_command); mDragRank = getRankFromPosition(x, y); // Don't DaD if we're dragging a command on itself - mDragAndDropTarget = (mDragCommand.uuid() != inv_item->getUUID()); - //llinfos << "Merov debug : DaD, rank = " << mDragRank << ", hit uuid = " << mDragCommand.uuid() << ", dragged uui = " << inv_item->getUUID() << llendl; + mDragAndDropTarget = ((mDragRank == orig_rank) || ((mDragRank-1) == orig_rank) ? false : true); + llinfos << "Merov debug : DaD, rank = " << mDragRank << ", hit uuid = " << mDragCommand.uuid() << ", dragged uui = " << inv_item->getUUID() << llendl; /* Do the following if you want to animate the button itself LLCommandId dragged_command(inv_item->getUUID()); removeCommand(dragged_command); diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 7f8ae4f839..49750a9ac2 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -157,6 +157,7 @@ public: void draw(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); int getRankFromPosition(S32 x, S32 y); + int getRankFromPosition(const LLCommandId& id); BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, -- cgit v1.2.3 From 1a9eaf09b0f36b675732d04c6f10615e2a8a9e05 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 13 Oct 2011 08:58:36 -0700 Subject: EXP-1331 : Fix the drag to position 0 case I broke while fixing the drag on itself case... Aaagh... --- indra/llui/lltoolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 3ea0968bfc..7fcd1da7b1 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -848,7 +848,7 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, int orig_rank = getRankFromPosition(dragged_command); mDragRank = getRankFromPosition(x, y); // Don't DaD if we're dragging a command on itself - mDragAndDropTarget = ((mDragRank == orig_rank) || ((mDragRank-1) == orig_rank) ? false : true); + mDragAndDropTarget = ((orig_rank != RANK_NONE) && ((mDragRank == orig_rank) || ((mDragRank-1) == orig_rank)) ? false : true); llinfos << "Merov debug : DaD, rank = " << mDragRank << ", hit uuid = " << mDragCommand.uuid() << ", dragged uui = " << inv_item->getUUID() << llendl; /* Do the following if you want to animate the button itself LLCommandId dragged_command(inv_item->getUUID()); -- cgit v1.2.3 From 63e4fdfc6498ad8a0af92e89759ae4fdb7035af6 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Thu, 13 Oct 2011 10:49:53 -0700 Subject: cleaned up floater reg, removed extraneous functions --- indra/llui/llbutton.cpp | 2 +- indra/llui/llfloaterreg.cpp | 96 +-------------------------------------------- indra/llui/llfloaterreg.h | 9 +---- indra/llui/llui.cpp | 35 ++++++++--------- 4 files changed, 20 insertions(+), 122 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index f40d99c024..3572d18860 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -1189,7 +1189,7 @@ void LLButton::setFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname) // Set the button control value (toggle state) to the floater visibility control (Sets the value as well) button->setControlVariable(LLFloater::getControlGroup()->getControl(vis_control_name)); // Set the clicked callback to toggle the floater - button->setClickedCallback(boost::bind(&LLFloaterReg::toggleFloaterInstance, sdname)); + button->setClickedCallback(boost::bind(&LLFloaterReg::toggleInstance, sdname, LLSD())); } // static diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index a148f5a32e..0edfc8da2d 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -436,57 +436,8 @@ void LLFloaterReg::registerControlVariables() } } -// Callbacks - -// static -// Call once (i.e use for init callbacks) -void LLFloaterReg::initUICtrlToFloaterVisibilityControl(LLUICtrl* ctrl, const LLSD& sdname) -{ - // Get the visibility control name for the floater - std::string vis_control_name = LLFloaterReg::declareVisibilityControl(sdname.asString()); - // Set the control value to the floater visibility control (Sets the value as well) - ctrl->setControlVariable(LLFloater::getControlGroup()->getControl(vis_control_name)); -} - -// callback args may use "floatername.key" format -static void parse_name_key(std::string& name, LLSD& key) -{ - std::string instname = name; - std::size_t dotpos = instname.find("."); - if (dotpos != std::string::npos) - { - name = instname.substr(0, dotpos); - key = LLSD(instname.substr(dotpos+1, std::string::npos)); - } -} - -//static -void LLFloaterReg::showFloaterInstance(const LLSD& sdname) -{ - LLSD key; - std::string name = sdname.asString(); - parse_name_key(name, key); - showInstance(name, key, TRUE); -} -//static -void LLFloaterReg::hideFloaterInstance(const LLSD& sdname) -{ - LLSD key; - std::string name = sdname.asString(); - parse_name_key(name, key); - hideInstance(name, key); -} //static -void LLFloaterReg::toggleFloaterInstance(const LLSD& sdname) -{ - LLSD key; - std::string name = sdname.asString(); - parse_name_key(name, key); - toggleInstance(name, key); -} - -//static -void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) +void LLFloaterReg::toggleInstanceOrBringToFront(const LLSD& sdname, const LLSD& key) { // // Floaters controlled by the toolbar behave a bit differently from others. @@ -501,11 +452,7 @@ void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) // * Else the target floater is open, close it. // - // First parse the parameter - LLSD key; std::string name = sdname.asString(); - parse_name_key(name, key); - LLFloater* instance = getInstance(name, key); if (!instance) @@ -532,47 +479,6 @@ void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) } } -//static -bool LLFloaterReg::floaterInstanceOpen(const LLSD& sdname) -{ - LLSD key; - std::string name = sdname.asString(); - parse_name_key(name, key); - - bool visible_or_minimized = instanceVisible(name, key); - - if (!visible_or_minimized) - { - LLFloater* instance = findInstance(name, key); - - if (instance != NULL) - { - visible_or_minimized = LLFloater::isMinimized(instance); - } - } - - return visible_or_minimized; -} - -//static -bool LLFloaterReg::floaterInstanceVisible(const LLSD& sdname) -{ - LLSD key; - std::string name = sdname.asString(); - parse_name_key(name, key); - return instanceVisible(name, key); -} - -//static -bool LLFloaterReg::floaterInstanceMinimized(const LLSD& sdname) -{ - LLSD key; - std::string name = sdname.asString(); - parse_name_key(name, key); - LLFloater* instance = findInstance(name, key); - return LLFloater::isShown(instance); -} - // static U32 LLFloaterReg::getVisibleFloaterInstanceCount() { diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index 817fe2e8c6..534cf8b40a 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -124,14 +124,7 @@ public: static void registerControlVariables(); // Callback wrappers - static void initUICtrlToFloaterVisibilityControl(LLUICtrl* ctrl, const LLSD& sdname); - 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 floaterInstanceOpen(const LLSD& sdname); - static bool floaterInstanceVisible(const LLSD& sdname); - static bool floaterInstanceMinimized(const LLSD& sdname); + static void toggleInstanceOrBringToFront(const LLSD& sdname, const LLSD& key = LLSD()); // Typed find / get / show template diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 9c0253f074..79ad99a770 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -89,7 +89,7 @@ std::list gUntranslated; /*static*/ LLUI::remove_popup_t LLUI::sRemovePopupFunc; /*static*/ LLUI::clear_popups_t LLUI::sClearPopupsFunc; -// register filtereditor here +// register filter editor here static LLDefaultChildRegistry::Register register_filter_editor("filter_editor"); static LLDefaultChildRegistry::Register register_flyout_button("flyout_button"); static LLDefaultChildRegistry::Register register_search_editor("search_editor"); @@ -106,7 +106,7 @@ void make_ui_sound(const char* namep) std::string name = ll_safe_string(namep); if (!LLUI::sSettingGroups["config"]->controlExists(name)) { - llwarns << "tried to make ui sound for unknown sound name: " << name << llendl; + llwarns << "tried to make UI sound for unknown sound name: " << name << llendl; } else { @@ -117,12 +117,12 @@ void make_ui_sound(const char* namep) { if (LLUI::sSettingGroups["config"]->getBOOL("UISndDebugSpamToggle")) { - llinfos << "ui sound name: " << name << " triggered but silent (null uuid)" << llendl; + llinfos << "UI sound name: " << name << " triggered but silent (null uuid)" << llendl; } } else { - llwarns << "ui sound named: " << name << " does not translate to a valid uuid" << llendl; + llwarns << "UI sound named: " << name << " does not translate to a valid uuid" << llendl; } } @@ -130,7 +130,7 @@ void make_ui_sound(const char* namep) { if (LLUI::sSettingGroups["config"]->getBOOL("UISndDebugSpamToggle")) { - llinfos << "ui sound name: " << name << llendl; + llinfos << "UI sound name: " << name << llendl; } LLUI::sAudioCallback(uuid); } @@ -474,7 +474,7 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex return; } - // add in offset of current image to current ui translation + // add in offset of current image to current UI translation const LLVector3 ui_scale = gGL.getUIScale(); const LLVector3 ui_translation = (gGL.getUITranslation() + LLVector3(x, y, 0.f)).scaledVec(ui_scale); @@ -1616,17 +1616,16 @@ void LLUI::initClass(const settings_map_t& settings, LLUICtrl::CommitCallbackRegistry::Registrar& reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar(); - // 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)); + // Callbacks for associating controls with floater visibility: + reg.add("Floater.Toggle", boost::bind(&LLFloaterReg::toggleInstance, _2, LLSD())); + reg.add("Floater.ToggleOrBringToFront", boost::bind(&LLFloaterReg::toggleInstanceOrBringToFront, _2, LLSD())); + reg.add("Floater.Show", boost::bind(&LLFloaterReg::showInstance, _2, LLSD(), FALSE)); + reg.add("Floater.Hide", boost::bind(&LLFloaterReg::hideInstance, _2, LLSD())); // Button initialization callback for toggle buttons reg.add("Button.SetFloaterToggle", boost::bind(&LLButton::setFloaterToggle, _1, _2)); - // Button initialization callback for toggle buttons on dockale floaters + // Button initialization callback for toggle buttons on dockable floaters reg.add("Button.SetDockableFloaterToggle", boost::bind(&LLButton::setDockableFloaterToggle, _1, _2)); // Display the help topic for the current context @@ -1635,9 +1634,9 @@ void LLUI::initClass(const settings_map_t& settings, // Currently unused, but kept for reference: reg.add("Button.ToggleFloater", boost::bind(&LLButton::toggleFloaterAndSetToggleState, _1, _2)); - // Used by menus along with Floater.Toggle to display visibility as a checkmark - LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", boost::bind(&LLFloaterReg::floaterInstanceVisible, _2)); - LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.IsOpen", boost::bind(&LLFloaterReg::floaterInstanceOpen, _2)); + // Used by menus along with Floater.Toggle to display visibility as a check-mark + LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD())); + LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.IsOpen", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD())); // Parse the master list of commands LLCommandManager::load(); @@ -2034,12 +2033,12 @@ void LLUI::positionViewNearMouse(LLView* view, S32 spawn_x, S32 spawn_y) CURSOR_HEIGHT + MOUSE_CURSOR_PADDING * 2); S32 local_x, local_y; - // convert screen coordinates to tooltipview-local coordinates + // convert screen coordinates to tooltip view-local coordinates parent->screenPointToLocal(spawn_x, spawn_y, &local_x, &local_y); // Start at spawn position (using left/top) view->setOrigin( local_x, local_y - view->getRect().getHeight()); - // Make sure we're onscreen and not overlapping the mouse + // Make sure we're on-screen and not overlapping the mouse view->translateIntoRectWithExclusion( virtual_window_rect, mouse_rect, FALSE ); } -- cgit v1.2.3 From 1e0a81ad68460f3bf11f4fced84c8832cedc4508 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 13 Oct 2011 14:50:37 -0700 Subject: Build fixes because damn standard doesn't allow binding rvalues to non-const refs. --- indra/llui/llsdparam.cpp | 6 ++++-- indra/llui/tests/llurlentry_stub.cpp | 2 +- indra/llui/tests/llurlmatch_test.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp index 242b1fca7f..6fa90933a4 100644 --- a/indra/llui/llsdparam.cpp +++ b/indra/llui/llsdparam.cpp @@ -104,7 +104,9 @@ void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block) { mNameStack.clear(); mWriteRootSD = &sd; - block.serializeBlock(*this); + + name_stack_t name_stack; + block.serializeBlock(*this, name_stack); } /*virtual*/ std::string LLParamSDParser::getCurrentElementName() @@ -329,7 +331,7 @@ namespace LLInitParam p.writeValue(sd.asString(), name_stack); } - void ParamValue, false>::serializeBlock(Parser& p, Parser::name_stack_t name_stack, const BaseBlock* diff_block) const + void ParamValue, false>::serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block) const { // read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc) Parser::name_stack_t stack; diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp index c8303bfc89..4f251db93b 100644 --- a/indra/llui/tests/llurlentry_stub.cpp +++ b/indra/llui/tests/llurlentry_stub.cpp @@ -125,7 +125,7 @@ namespace LLInitParam descriptor.mCurrentBlockPtr = this; } bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name){ return true; } - void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const {} + void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const LLInitParam::BaseBlock* diff_block) const {} bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_value, S32 max_value) const { return true; } bool BaseBlock::mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; } bool BaseBlock::validateBlock(bool emit_errors) const { return true; } diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp index 9dbccf125a..627f3129e9 100644 --- a/indra/llui/tests/llurlmatch_test.cpp +++ b/indra/llui/tests/llurlmatch_test.cpp @@ -97,7 +97,7 @@ namespace LLInitParam } bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name){ return true; } - void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const {} + void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const LLInitParam::BaseBlock* diff_block) const {} bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_count, S32 max_count) const { return true; } bool BaseBlock::mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; } bool BaseBlock::validateBlock(bool emit_errors) const { return true; } -- cgit v1.2.3 From c224e589d072e733ec5b95f95b3770d5bf0584f0 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 14 Oct 2011 14:23:06 -0700 Subject: EXP-1272 FIX Move "How To" to a separate web floater added missing file and updated size of floater --- indra/llui/llfloater.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index fa533e8153..d1d840729d 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -3048,7 +3048,9 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str return FALSE; } - parser.readXUI(referenced_xml, params, LLUICtrlFactory::getInstance()->getCurFileName()); + Params referenced_params; + parser.readXUI(referenced_xml, referenced_params, LLUICtrlFactory::getInstance()->getCurFileName()); + params.fillFrom(referenced_params); // add children using dimensions from referenced xml for consistent layout setShape(params.rect); -- cgit v1.2.3 From 93b6be6288036681c583e23be3b43ed23732352c Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Fri, 14 Oct 2011 14:46:21 -0700 Subject: New icon love for FUI --- indra/llui/llbutton.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 3572d18860..64fd14ecc9 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -817,7 +817,7 @@ void LLButton::draw() LLColor4 overlay_color = mImageOverlayColor.get(); if (!enabled) { - overlay_color.mV[VALPHA] = 0.5f; + overlay_color.mV[VALPHA] = 0.3f; } else if (!getToggleState()) { -- cgit v1.2.3 From 4c6f04c50225a4a5494974c3a6e13bee76cfbb6f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 14 Oct 2011 16:47:43 -0700 Subject: EXP-1363 : Fix caret position in multiple lines or columns situation --- indra/llui/lltoolbar.cpp | 67 ++++++++++++++++++++++++++++++++---------------- indra/llui/lltoolbar.h | 1 - 2 files changed, 45 insertions(+), 23 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 7fcd1da7b1..97cf583a3c 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -401,6 +401,11 @@ void LLToolBar::resizeButtonsInRow(std::vector& buttons_in_row // Various drag data are stored in the toolbar object though are not exposed outside (and shouldn't). int LLToolBar::getRankFromPosition(S32 x, S32 y) { + if (mButtons.empty()) + { + return RANK_NONE; + } + int rank = 0; // Convert the toolbar coord into button panel coords @@ -417,21 +422,9 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) LLRect button_rect; while (it_button != end_button) { - button_rect = (*it_button)->getRect(); - mDragCommand = (*it_button)->mId; - S32 point_x, point_y; - if (orientation == LLLayoutStack::HORIZONTAL) - { - // Horizontal - point_x = (button_rect.mRight + button_rect.mLeft) / 2; - point_y = button_rect.mBottom - mPadBottom; - } - else - { - // Vertical - point_x = button_rect.mRight + mPadRight; - point_y = (button_rect.mTop + button_rect.mBottom) / 2; - } + button_rect = (*it_button)->getRect(); + S32 point_x = button_rect.mRight + mPadRight; + S32 point_y = button_rect.mBottom - mPadBottom; if ((button_panel_x < point_x) && (button_panel_y > point_y)) { @@ -445,19 +438,49 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) // (different depending on toolbar orientation) if (rank < mButtons.size()) { - mDragx = button_rect.mLeft - mPadLeft; - mDragy = button_rect.mTop + mPadTop; + if (orientation == LLLayoutStack::HORIZONTAL) + { + // Horizontal + S32 mid_point = (button_rect.mRight + button_rect.mLeft) / 2; + if (button_panel_x < mid_point) + { + mDragx = button_rect.mLeft - mPadLeft; + mDragy = button_rect.mTop + mPadTop; + } + else + { + rank++; + mDragx = button_rect.mRight + mPadRight - 1; + mDragy = button_rect.mTop + mPadTop; + } + } + else + { + // Vertical + S32 mid_point = (button_rect.mTop + button_rect.mBottom) / 2; + if (button_panel_y > mid_point) + { + mDragx = button_rect.mLeft - mPadLeft; + mDragy = button_rect.mTop + mPadTop; + } + else + { + rank++; + mDragx = button_rect.mLeft - mPadLeft; + mDragy = button_rect.mBottom - mPadBottom + 1; + } + } } else { // We hit passed the end of the list so put the insertion point at the end if (orientation == LLLayoutStack::HORIZONTAL) - { + { mDragx = button_rect.mRight + mPadRight; mDragy = button_rect.mTop + mPadTop; - } - else - { + } + else + { mDragx = button_rect.mLeft - mPadLeft; mDragy = button_rect.mBottom - mPadBottom; } @@ -849,7 +872,7 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, mDragRank = getRankFromPosition(x, y); // Don't DaD if we're dragging a command on itself mDragAndDropTarget = ((orig_rank != RANK_NONE) && ((mDragRank == orig_rank) || ((mDragRank-1) == orig_rank)) ? false : true); - llinfos << "Merov debug : DaD, rank = " << mDragRank << ", hit uuid = " << mDragCommand.uuid() << ", dragged uui = " << inv_item->getUUID() << llendl; + //llinfos << "Merov debug : DaD, rank = " << mDragRank << ", dragged uui = " << inv_item->getUUID() << llendl; /* Do the following if you want to animate the button itself LLCommandId dragged_command(inv_item->getUUID()); removeCommand(dragged_command); diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 3be252298d..e78c99cb37 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -200,7 +200,6 @@ protected: S32 mDragx, mDragy, mDragGirth; - LLCommandId mDragCommand; public: // Methods used in loading and saving toolbar settings -- cgit v1.2.3 From 0976964f8315aab5879678f07318267b6887ed95 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 14 Oct 2011 18:25:30 -0700 Subject: EXP-1336 FIX Move Notifications to upper right also made toolbar buttons not trigger if enabled callback returns false --- indra/llui/lltoolbar.cpp | 14 +++++++++++--- indra/llui/lltoolbar.h | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 7fcd1da7b1..bd2b55c105 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -668,6 +668,7 @@ void LLToolBar::draw() if (command && btn->mIsEnabledSignal) { const bool button_command_enabled = (*btn->mIsEnabledSignal)(btn, command->isEnabledParameters()); + // TODO: make button appear disabled but have it still respond to drag and drop btn->setEnabled(button_command_enabled); } @@ -941,6 +942,16 @@ void LLToolBarButton::onMouseCaptureLost() mIsDragged = false; } +void LLToolBarButton::onCommit() +{ + LLCommand* command = LLCommandManager::instance().getCommand(mId); + + if (!mIsEnabledSignal || (*mIsEnabledSignal)(this, command->isEnabledParameters())) + { + LLButton::onCommit(); + } +} + void LLToolBarButton::reshape(S32 width, S32 height, BOOL called_from_parent) { LLButton::reshape(mWidthRange.clamp(width), height, called_from_parent); @@ -967,6 +978,3 @@ const std::string LLToolBarButton::getToolTip() const - - - diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 3be252298d..5fac613f50 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -72,9 +72,9 @@ public: void onMouseEnter(S32 x, S32 y, MASK mask); void onMouseCaptureLost(); - virtual const std::string getToolTip() const; - + void onCommit(); + virtual const std::string getToolTip() const; private: LLCommandId mId; -- cgit v1.2.3 From 6d1ae4e0d6668983dc9386903155e426bd2912a3 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 16 Oct 2011 23:37:55 -0700 Subject: wip on dragging disabled toolbar buttons --- indra/llui/llbutton.h | 4 ++-- indra/llui/lltoolbar.cpp | 37 +++++++++++++++++++++++++++++++++++-- indra/llui/lltoolbar.h | 11 +++++++++-- 3 files changed, 46 insertions(+), 6 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 7d9adcd892..1aa58ed9aa 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -94,6 +94,7 @@ public: image_color, image_color_disabled, image_overlay_color, + image_overlay_disabled_color, flash_color; // layout @@ -286,11 +287,9 @@ protected: S32 mButtonFlashCount; F32 mButtonFlashRate; -private: void drawBorder(LLUIImage* imagep, const LLColor4& color, S32 size); void resetMouseDownTimer(); -private: commit_signal_t* mMouseDownSignal; commit_signal_t* mMouseUpSignal; commit_signal_t* mHeldDownSignal; @@ -306,6 +305,7 @@ private: LLPointer mImageOverlay; LLFontGL::HAlign mImageOverlayAlignment; LLUIColor mImageOverlayColor; + LLUIColor mImageOverlayDisabledColor; LLPointer mImageUnselected; LLUIString mUnselectedLabel; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 226a218e47..4d88c37fda 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -692,7 +692,7 @@ void LLToolBar::draw() { const bool button_command_enabled = (*btn->mIsEnabledSignal)(btn, command->isEnabledParameters()); // TODO: make button appear disabled but have it still respond to drag and drop - btn->setEnabled(button_command_enabled); + btn->setEnabled(false);//button_command_enabled); } if (command && btn->mIsRunningSignal) @@ -901,7 +901,14 @@ LLToolBarButton::LLToolBarButton(const Params& p) mIsStartingSignal(NULL), mIsDragged(false), mStartDragItemCallback(NULL), - mHandleDragItemCallback(NULL) + mHandleDragItemCallback(NULL), + mOriginalImageSelected(p.image_selected), + mOriginalImageUnselected(p.image_unselected), + mOriginalImagePressed(p.image_pressed), + mOriginalImagePressedSelected(p.image_pressed_selected), + mOriginalLabelColor(p.label_color), + mOriginalLabelColorSelected(p.label_color_selected), + mOriginalImageOverlayColor(p.image_overlay_color) { mButtonFlashRate = 0.0; mButtonFlashCount = 0; @@ -980,6 +987,32 @@ void LLToolBarButton::reshape(S32 width, S32 height, BOOL called_from_parent) LLButton::reshape(mWidthRange.clamp(width), height, called_from_parent); } +void LLToolBarButton::setEnabled(BOOL enabled) +{ + if (enabled) + { + mImageSelected = mOriginalImageSelected; + mImageUnselected = mOriginalImageUnselected; + mImagePressed = mOriginalImagePressed; + mImagePressedSelected = mOriginalImagePressedSelected; + mUnselectedLabelColor = mOriginalLabelColor; + mSelectedLabelColor = mOriginalLabelColorSelected; + mImageOverlayColor = mOriginalImageOverlayColor; + } + + else + { + mImageSelected = mImageDisabledSelected; + mImageUnselected = mImageDisabled; + mImagePressed = mImageDisabled; + mImagePressedSelected = mImageDisabledSelected; + mUnselectedLabelColor = mDisabledLabelColor; + mSelectedLabelColor = mDisabledSelectedLabelColor; + mImageOverlayColor = mImageOverlayDisabledColor; + } +} + + const std::string LLToolBarButton::getToolTip() const { std::string tooltip; diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index f7ec318652..47af039d52 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -48,7 +48,7 @@ public: struct Params : public LLInitParam::Block { Optional button_width; - Optional desired_height; + Optional desired_height; Params() : button_width("button_width"), @@ -63,7 +63,7 @@ public: BOOL handleMouseDown(S32 x, S32 y, MASK mask); BOOL handleHover(S32 x, S32 y, MASK mask); void reshape(S32 width, S32 height, BOOL called_from_parent = true); - + void setEnabled(BOOL enabled); void setCommandId(const LLCommandId& id) { mId = id; } void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; } @@ -89,6 +89,13 @@ private: enable_signal_t* mIsEnabledSignal; enable_signal_t* mIsRunningSignal; enable_signal_t* mIsStartingSignal; + LLPointer mOriginalImageSelected, + mOriginalImageUnselected, + mOriginalImagePressed, + mOriginalImagePressedSelected; + LLUIColor mOriginalLabelColor, + mOriginalLabelColorSelected, + mOriginalImageOverlayColor; }; -- cgit v1.2.3 From e653e924fe1f080eb4d67d68e24110dba9c64816 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 17 Oct 2011 09:25:07 -0700 Subject: Mac build fix --- indra/llui/lltoolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 4d88c37fda..278e7826b7 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -690,7 +690,7 @@ void LLToolBar::draw() if (command && btn->mIsEnabledSignal) { - const bool button_command_enabled = (*btn->mIsEnabledSignal)(btn, command->isEnabledParameters()); + //const bool button_command_enabled = (*btn->mIsEnabledSignal)(btn, command->isEnabledParameters()); // TODO: make button appear disabled but have it still respond to drag and drop btn->setEnabled(false);//button_command_enabled); } -- cgit v1.2.3 From a2e32429bbe222342c413eb06e2820f6292e251a Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 17 Oct 2011 13:42:35 -0700 Subject: fix for not being able to drag disabled buttons --- indra/llui/llbutton.cpp | 10 ++++++--- indra/llui/llbutton.h | 2 ++ indra/llui/lltoolbar.cpp | 58 +++++++++++++++++++++++++++++++----------------- indra/llui/lltoolbar.h | 5 ++++- 4 files changed, 51 insertions(+), 24 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 64fd14ecc9..2d3007cd5f 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -85,7 +85,9 @@ LLButton::Params::Params() label_color_disabled_selected("label_color_disabled_selected"), image_color("image_color"), image_color_disabled("image_color_disabled"), - image_overlay_color("image_overlay_color", LLColor4::white), + image_overlay_color("image_overlay_color", LLColor4::white % 0.75f), + image_overlay_disabled_color("image_overlay_disabled_color", LLColor4::white % 0.3f), + image_overlay_selected_color("image_overlay_selected_color", LLColor4::white), flash_color("flash_color"), pad_right("pad_right", LLUI::sSettingGroups["config"]->getS32("ButtonHPad")), pad_left("pad_left", LLUI::sSettingGroups["config"]->getS32("ButtonHPad")), @@ -143,6 +145,8 @@ LLButton::LLButton(const LLButton::Params& p) mDisabledImageColor(p.image_color_disabled()), mImageOverlay(p.image_overlay()), mImageOverlayColor(p.image_overlay_color()), + mImageOverlayDisabledColor(p.image_overlay_disabled_color()), + mImageOverlaySelectedColor(p.image_overlay_selected_color()), mImageOverlayAlignment(LLFontGL::hAlignFromName(p.image_overlay_alignment)), mImageOverlayTopPad(p.image_top_pad), mImageOverlayBottomPad(p.image_bottom_pad), @@ -817,11 +821,11 @@ void LLButton::draw() LLColor4 overlay_color = mImageOverlayColor.get(); if (!enabled) { - overlay_color.mV[VALPHA] = 0.3f; + overlay_color = mImageOverlayDisabledColor.get(); } else if (!getToggleState()) { - overlay_color.mV[VALPHA] = 0.75f; + overlay_color = mImageOverlaySelectedColor.get(); } overlay_color.mV[VALPHA] *= alpha; diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 1aa58ed9aa..deaa0823c6 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -94,6 +94,7 @@ public: image_color, image_color_disabled, image_overlay_color, + image_overlay_selected_color, image_overlay_disabled_color, flash_color; @@ -305,6 +306,7 @@ protected: LLPointer mImageOverlay; LLFontGL::HAlign mImageOverlayAlignment; LLUIColor mImageOverlayColor; + LLUIColor mImageOverlaySelectedColor; LLUIColor mImageOverlayDisabledColor; LLPointer mImageUnselected; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 278e7826b7..8faa9b3988 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -690,9 +690,8 @@ void LLToolBar::draw() if (command && btn->mIsEnabledSignal) { - //const bool button_command_enabled = (*btn->mIsEnabledSignal)(btn, command->isEnabledParameters()); - // TODO: make button appear disabled but have it still respond to drag and drop - btn->setEnabled(false);//button_command_enabled); + const bool button_command_enabled = (*btn->mIsEnabledSignal)(btn, command->isEnabledParameters()); + btn->setEnabled(button_command_enabled); } if (command && btn->mIsRunningSignal) @@ -763,6 +762,16 @@ void LLToolBar::createButtons() mNeedsLayout = true; } +void LLToolBarButton::callIfEnabled(LLUICtrl::commit_callback_t commit, LLUICtrl* ctrl, const LLSD& param ) +{ + LLCommand* command = LLCommandManager::instance().getCommand(mId); + + if (!mIsEnabledSignal || (*mIsEnabledSignal)(this, command->isEnabledParameters())) + { + commit(ctrl, param); + } +} + LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) { LLCommand* commandp = LLCommandManager::instance().getCommand(id); @@ -778,6 +787,24 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) if (!mReadOnly) { + enable_callback_t isEnabledCB; + + const std::string& isEnabledFunction = commandp->isEnabledFunctionName(); + if (isEnabledFunction.length() > 0) + { + LLUICtrl::EnableCallbackParam isEnabledParam; + isEnabledParam.function_name = isEnabledFunction; + isEnabledParam.parameter = commandp->isEnabledParameters(); + isEnabledCB = initEnableCallback(isEnabledParam); + + if (NULL == button->mIsEnabledSignal) + { + button->mIsEnabledSignal = new enable_signal_t(); + } + + button->mIsEnabledSignal->connect(isEnabledCB); + } + LLUICtrl::CommitCallbackParam executeParam; executeParam.function_name = commandp->executeFunctionName(); executeParam.parameter = commandp->executeParameters(); @@ -789,30 +816,18 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) LLUICtrl::CommitCallbackParam executeStopParam; executeStopParam.function_name = executeStopFunction; executeStopParam.parameter = commandp->executeStopParameters(); + LLUICtrl::commit_callback_t execute_func = initCommitCallback(executeParam); + LLUICtrl::commit_callback_t stop_func = initCommitCallback(executeStopParam); - button->setMouseDownCallback(executeParam); - button->setMouseUpCallback(executeStopParam); + button->setMouseDownCallback(boost::bind(&LLToolBarButton::callIfEnabled, button, execute_func, _1, _2)); + button->setMouseUpCallback(boost::bind(&LLToolBarButton::callIfEnabled, button, stop_func, _1, _2)); } else { button->setCommitCallback(executeParam); } - const std::string& isEnabledFunction = commandp->isEnabledFunctionName(); - if (isEnabledFunction.length() > 0) - { - LLUICtrl::EnableCallbackParam isEnabledParam; - isEnabledParam.function_name = isEnabledFunction; - isEnabledParam.parameter = commandp->isEnabledParameters(); - enable_signal_t::slot_type isEnabledCB = initEnableCallback(isEnabledParam); - - if (NULL == button->mIsEnabledSignal) - { - button->mIsEnabledSignal = new enable_signal_t(); - } - button->mIsEnabledSignal->connect(isEnabledCB); - } const std::string& isRunningFunction = commandp->isRunningFunctionName(); if (isRunningFunction.length() > 0) @@ -908,7 +923,8 @@ LLToolBarButton::LLToolBarButton(const Params& p) mOriginalImagePressedSelected(p.image_pressed_selected), mOriginalLabelColor(p.label_color), mOriginalLabelColorSelected(p.label_color_selected), - mOriginalImageOverlayColor(p.image_overlay_color) + mOriginalImageOverlayColor(p.image_overlay_color), + mOriginalImageOverlaySelectedColor(p.image_overlay_selected_color) { mButtonFlashRate = 0.0; mButtonFlashCount = 0; @@ -998,6 +1014,7 @@ void LLToolBarButton::setEnabled(BOOL enabled) mUnselectedLabelColor = mOriginalLabelColor; mSelectedLabelColor = mOriginalLabelColorSelected; mImageOverlayColor = mOriginalImageOverlayColor; + mOriginalImageOverlaySelectedColor = mOriginalImageOverlaySelectedColor; } else @@ -1009,6 +1026,7 @@ void LLToolBarButton::setEnabled(BOOL enabled) mUnselectedLabelColor = mDisabledLabelColor; mSelectedLabelColor = mDisabledSelectedLabelColor; mImageOverlayColor = mImageOverlayDisabledColor; + mImageOverlaySelectedColor = mImageOverlayDisabledColor; } } diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 47af039d52..616710ea70 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -77,6 +77,8 @@ public: virtual const std::string getToolTip() const; private: + void callIfEnabled(LLUICtrl::commit_callback_t commit, LLUICtrl* ctrl, const LLSD& param ); + LLCommandId mId; S32 mMouseDownX; S32 mMouseDownY; @@ -95,7 +97,8 @@ private: mOriginalImagePressedSelected; LLUIColor mOriginalLabelColor, mOriginalLabelColorSelected, - mOriginalImageOverlayColor; + mOriginalImageOverlayColor, + mOriginalImageOverlaySelectedColor; }; -- cgit v1.2.3 From ae3b5a4907b4611644d3b21c75ed420bc58593a2 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 17 Oct 2011 15:15:40 -0700 Subject: * Fixed icon opacity on selected and unselected buttons --- indra/llui/llbutton.cpp | 2 +- indra/llui/lltoolbar.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 2d3007cd5f..74b8885e1f 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -823,7 +823,7 @@ void LLButton::draw() { overlay_color = mImageOverlayDisabledColor.get(); } - else if (!getToggleState()) + else if (getToggleState()) { overlay_color = mImageOverlaySelectedColor.get(); } diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 8faa9b3988..629c7d9bc7 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -1014,9 +1014,8 @@ void LLToolBarButton::setEnabled(BOOL enabled) mUnselectedLabelColor = mOriginalLabelColor; mSelectedLabelColor = mOriginalLabelColorSelected; mImageOverlayColor = mOriginalImageOverlayColor; - mOriginalImageOverlaySelectedColor = mOriginalImageOverlaySelectedColor; + mImageOverlaySelectedColor = mOriginalImageOverlaySelectedColor; } - else { mImageSelected = mImageDisabledSelected; -- cgit v1.2.3