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 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 indra/llui/lltoolbar.cpp (limited to 'indra/llui/lltoolbar.cpp') 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); + } +} -- 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/lltoolbar.cpp | 121 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 101 insertions(+), 20 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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(); +} + -- 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 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 9 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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); + } +} -- 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 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 135 insertions(+), 61 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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); } } -- 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 +++++++++++++++++++++++++---------------------- 1 file changed, 104 insertions(+), 92 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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); -- 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/lltoolbar.cpp') 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/lltoolbar.cpp | 77 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 14 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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(); -- 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 +++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 23 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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 -- 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 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; -- 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 +++++++++++++++++++++++++---------------------- 1 file changed, 125 insertions(+), 110 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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); - } -} -- 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/lltoolbar.cpp') 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 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 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 105 insertions(+), 8 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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(); -- 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 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'indra/llui/lltoolbar.cpp') 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; -- 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/lltoolbar.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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(); -- 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/lltoolbar.cpp | 71 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 21 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; -- 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/lltoolbar.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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); } } -- 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/lltoolbar.cpp | 79 ++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 36 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; +} + -- 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/lltoolbar.cpp') 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 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; } -- 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/lltoolbar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llui/lltoolbar.cpp') 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/lltoolbar.cpp | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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/lltoolbar.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; } - -- 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 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 29 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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); } -- 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/lltoolbar.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/llui/lltoolbar.cpp') 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); -- 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 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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(); } -- 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/lltoolbar.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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); } } } -- 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 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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("") {} -- 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/lltoolbar.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'indra/llui/lltoolbar.cpp') 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; +} + -- 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/lltoolbar.cpp') 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 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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("") {} -- 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/lltoolbar.cpp') 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 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/lltoolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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 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/lltoolbar.cpp | 103 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 89 insertions(+), 14 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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 -- 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/lltoolbar.cpp') 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/lltoolbar.cpp | 89 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 5 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; +} -- 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/lltoolbar.cpp') 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 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; -- 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/lltoolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/lltoolbar.cpp') 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 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; +} -- 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/lltoolbar.cpp') 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 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 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llui/lltoolbar.cpp') 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); -- 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/lltoolbar.cpp | 83 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 72 insertions(+), 11 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; } -- 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/lltoolbar.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llui/lltoolbar.cpp') 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); +} -- 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/lltoolbar.cpp | 83 ++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 56 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; -- 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/lltoolbar.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 23 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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); -- 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/lltoolbar.cpp') 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 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/lltoolbar.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/llui/lltoolbar.cpp') 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/lltoolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/lltoolbar.cpp') 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 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 + 1 file changed, 1 insertion(+) (limited to 'indra/llui/lltoolbar.cpp') 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), -- 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 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 27 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; -- 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/lltoolbar.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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(); + } +} + + + + + + + + + + + + -- 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 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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); -- 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/lltoolbar.cpp') 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 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 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 22 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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); -- 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 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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 - - - -- 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/lltoolbar.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; -- 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/lltoolbar.cpp') 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/lltoolbar.cpp | 58 +++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 20 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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; } } -- 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/lltoolbar.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llui/lltoolbar.cpp') 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