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 +++++++++-- indra/newview/CMakeLists.txt | 2 + indra/newview/llfloatertoybox.cpp | 103 +++++++++++++++++++++ indra/newview/llfloatertoybox.h | 58 ++++++++++++ indra/newview/llviewerfloaterreg.cpp | 2 + .../skins/default/xui/en/floater_toybox.xml | 63 +++++++++++++ indra/newview/skins/default/xui/en/menu_login.xml | 2 +- indra/newview/skins/default/xui/en/menu_viewer.xml | 14 ++- 9 files changed, 336 insertions(+), 21 deletions(-) create mode 100644 indra/newview/llfloatertoybox.cpp create mode 100644 indra/newview/llfloatertoybox.h create mode 100644 indra/newview/skins/default/xui/en/floater_toybox.xml (limited to 'indra') 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; }; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 7351144765..18e092eb4a 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -237,6 +237,7 @@ set(viewer_SOURCE_FILES llfloatertools.cpp llfloatertopobjects.cpp llfloatertos.cpp + llfloatertoybox.cpp llfloateruipreview.cpp llfloaterurlentry.cpp llfloatervoiceeffect.cpp @@ -800,6 +801,7 @@ set(viewer_HEADER_FILES llfloatertools.h llfloatertopobjects.h llfloatertos.h + llfloatertoybox.h llfloateruipreview.h llfloaterurlentry.h llfloatervoiceeffect.h diff --git a/indra/newview/llfloatertoybox.cpp b/indra/newview/llfloatertoybox.cpp new file mode 100644 index 0000000000..b4fb2e45ab --- /dev/null +++ b/indra/newview/llfloatertoybox.cpp @@ -0,0 +1,103 @@ +/** + * @file llfloatertoybox.cpp + * @brief The toybox for flexibilizing the UI. + * + * $LicenseInfo:firstyear=2002&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 "llviewerprecompiledheaders.h" + +#include "llfloatertoybox.h" + +#include "llbutton.h" +#include "llpanel.h" + + +LLFloaterToybox::LLFloaterToybox(const LLSD& key) + : LLFloater(key) + , mBtnRestoreDefaults(NULL) +{ + mCommitCallbackRegistrar.add("Toybox.RestoreDefaults", boost::bind(&LLFloaterToybox::onBtnRestoreDefaults, this)); +} + +LLFloaterToybox::~LLFloaterToybox() +{ +} + +BOOL LLFloaterToybox::postBuild() +{ + center(); + + mBtnRestoreDefaults = getChild("btn_restore_defaults"); + + // + // Create Buttons + // +/* + LLToyboxButtons::load(); + + for (size_t i = 0; i < LLToyboxButtons::buttonCount(); i++) + { + LLToyboxButton * button = LLToyboxButtons::get(i); + + // Panel opacity depends on whether or not button position is established + LLPanel * buttonPanel = createPanelForButton(button); + + mToolBar->add(buttonPanel); + } +*/ + + return TRUE; +} + +void LLFloaterToybox::onOpen(const LLSD& key) +{ + +} + +BOOL LLFloaterToybox::canClose() +{ + return TRUE; +} + +void LLFloaterToybox::onClose(bool app_quitting) +{ + +} + +void LLFloaterToybox::draw() +{ + LLFloater::draw(); +} + +void LLFloaterToybox::onFocusReceived() +{ + +} + +void LLFloaterToybox::onBtnRestoreDefaults() +{ + +} + + +// eof diff --git a/indra/newview/llfloatertoybox.h b/indra/newview/llfloatertoybox.h new file mode 100644 index 0000000000..bb9392a0e3 --- /dev/null +++ b/indra/newview/llfloatertoybox.h @@ -0,0 +1,58 @@ +/** + * @file llfloatertoybox.h + * @brief The toybox for flexibilizing the UI. + * + * $LicenseInfo:firstyear=2002&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_LLFLOATERTOYBOX_H +#define LL_LLFLOATERTOYBOX_H + +#include "llfloater.h" + + +class LLButton; + + +class LLFloaterToybox +: public LLFloater +{ +public: + LLFloaterToybox(const LLSD& key); + virtual ~LLFloaterToybox(); + + // virtuals + BOOL postBuild(); + void onOpen(const LLSD& key); + BOOL canClose(); + void onClose(bool app_quitting); + void draw(); + void onFocusReceived(); + +protected: + void onBtnRestoreDefaults(); + +public: + LLButton * mBtnRestoreDefaults; +}; + +#endif // LL_LLFLOATERTOYBOX_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 4af5fdd9f3..375ee3ad33 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -103,6 +103,7 @@ #include "llfloatertools.h" #include "llfloatertos.h" #include "llfloatertopobjects.h" +#include "llfloatertoybox.h" #include "llfloateruipreview.h" #include "llfloatervoiceeffect.h" #include "llfloaterwhitelistentry.h" @@ -255,6 +256,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("test_text_editor", "floater_test_text_editor.xml", &LLFloaterReg::build); LLFloaterReg::add("test_widgets", "floater_test_widgets.xml", &LLFloaterReg::build); LLFloaterReg::add("top_objects", "floater_top_objects.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("toybox", "floater_toybox.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("reporter", "floater_report_abuse.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("reset_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/skins/default/xui/en/floater_toybox.xml b/indra/newview/skins/default/xui/en/floater_toybox.xml new file mode 100644 index 0000000000..1951497309 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_toybox.xml @@ -0,0 +1,63 @@ + + + + Add or remove buttons by dragging them to or from the toolbars. + + + Buttons will appear as shown or as icon-only depending on each toolbar's settings. + + + + + diff --git a/indra/newview/skins/default/xui/en/menu_login.xml b/indra/newview/skins/default/xui/en/menu_login.xml index 4c4ff3e5c4..bb58dd500f 100644 --- a/indra/newview/skins/default/xui/en/menu_login.xml +++ b/indra/newview/skins/default/xui/en/menu_login.xml @@ -13,7 +13,7 @@ tear_off="true" name="File"> - + + + --> -