diff options
-rw-r--r-- | indra/llui/llbutton.cpp | 18 | ||||
-rw-r--r-- | indra/llui/llbutton.h | 5 | ||||
-rw-r--r-- | indra/llui/llcommandmanager.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llcommandmanager.h | 9 | ||||
-rw-r--r-- | indra/llui/lltoolbar.cpp | 22 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 6 | ||||
-rw-r--r-- | indra/newview/app_settings/commands.xml | 2 | ||||
-rw-r--r-- | indra/newview/llfavoritesbar.cpp | 197 | ||||
-rw-r--r-- | indra/newview/llfavoritesbar.h | 14 | ||||
-rw-r--r-- | indra/newview/skins/default/textures/toolbar_icons/picks.png | bin | 1368 -> 1396 bytes | |||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_navigation_bar.xml | 18 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/strings.xml | 2 |
12 files changed, 219 insertions, 78 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index ba3748a573..2e9c7a5d3d 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -296,6 +296,24 @@ void LLButton::onCommit() LLUICtrl::onCommit(); } +boost::signals2::connection LLButton::setClickedCallback(const CommitCallbackParam& cb) +{ + return setClickedCallback(initCommitCallback(cb)); +} +boost::signals2::connection LLButton::setMouseDownCallback(const CommitCallbackParam& cb) +{ + return setMouseDownCallback(initCommitCallback(cb)); +} +boost::signals2::connection LLButton::setMouseUpCallback(const CommitCallbackParam& cb) +{ + return setMouseUpCallback(initCommitCallback(cb)); +} +boost::signals2::connection LLButton::setHeldDownCallback(const CommitCallbackParam& cb) +{ + return setHeldDownCallback(initCommitCallback(cb)); +} + + boost::signals2::connection LLButton::setClickedCallback( const commit_signal_t::slot_type& cb ) { if (!mCommitSignal) mCommitSignal = new commit_signal_t(); diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index a0a7b4e372..ba0345f610 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -170,6 +170,11 @@ public: void setUseEllipses( BOOL use_ellipses ) { mUseEllipses = use_ellipses; } + boost::signals2::connection setClickedCallback(const CommitCallbackParam& cb); + boost::signals2::connection setMouseDownCallback(const CommitCallbackParam& cb); + boost::signals2::connection setMouseUpCallback(const CommitCallbackParam& cb); + boost::signals2::connection setHeldDownCallback(const CommitCallbackParam& cb); + boost::signals2::connection setClickedCallback( const commit_signal_t::slot_type& cb ); // mouse down and up within button boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb ); boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ); // mouse up, EVEN IF NOT IN BUTTON diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index d8e035a320..128ba609cb 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -55,6 +55,8 @@ LLCommand::Params::Params() , tooltip_ref("tooltip_ref") , execute_function("execute_function") , execute_parameters("execute_parameters") + , execute_stop_function("execute_stop_function") + , execute_stop_parameters("execute_stop_parameters") , is_enabled_function("is_enabled_function") , is_enabled_parameters("is_enabled_parameters") , is_running_function("is_running_function") @@ -72,6 +74,8 @@ LLCommand::LLCommand(const LLCommand::Params& p) , mTooltipRef(p.tooltip_ref) , mExecuteFunction(p.execute_function) , mExecuteParameters(p.execute_parameters) + , mExecuteStopFunction(p.execute_stop_function) + , mExecuteStopParameters(p.execute_stop_parameters) , mIsEnabledFunction(p.is_enabled_function) , mIsEnabledParameters(p.is_enabled_parameters) , mIsRunningFunction(p.is_running_function) diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 46e0fe6e69..9b93ab735a 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -116,6 +116,9 @@ public: Mandatory<std::string> execute_function; Optional<LLSD> execute_parameters; + Optional<std::string> execute_stop_function; + Optional<LLSD> execute_stop_parameters; + Optional<std::string> is_enabled_function; Optional<LLSD> is_enabled_parameters; @@ -139,6 +142,9 @@ public: const std::string& executeFunctionName() const { return mExecuteFunction; } const LLSD& executeParameters() const { return mExecuteParameters; } + const std::string& executeStopFunctionName() const { return mExecuteStopFunction; } + const LLSD& executeStopParameters() const { return mExecuteStopParameters; } + const std::string& isEnabledFunctionName() const { return mIsEnabledFunction; } const LLSD& isEnabledParameters() const { return mIsEnabledParameters; } @@ -159,6 +165,9 @@ private: std::string mExecuteFunction; LLSD mExecuteParameters; + std::string mExecuteStopFunction; + LLSD mExecuteStopParameters; + std::string mIsEnabledFunction; LLSD mIsEnabledParameters; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 89184f781f..e74aab6e21 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -659,11 +659,25 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) if (!mReadOnly) { - LLUICtrl::CommitCallbackParam cbParam; - cbParam.function_name = commandp->executeFunctionName(); - cbParam.parameter = commandp->executeParameters(); + LLUICtrl::CommitCallbackParam executeParam; + executeParam.function_name = commandp->executeFunctionName(); + executeParam.parameter = commandp->executeParameters(); - button->setCommitCallback(cbParam); + // If we have a "stop" function then we map the command to mouse down / mouse up otherwise commit + const std::string& executeStopFunction = commandp->executeStopFunctionName(); + if (executeStopFunction.length() > 0) + { + LLUICtrl::CommitCallbackParam executeStopParam; + executeStopParam.function_name = executeStopFunction; + executeStopParam.parameter = commandp->executeStopParameters(); + + button->setMouseDownCallback(executeParam); + button->setMouseUpCallback(executeStopParam); + } + else + { + button->setCommitCallback(executeParam); + } const std::string& isEnabledFunction = commandp->isEnabledFunctionName(); if (isEnabledFunction.length() > 0) diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 321064a0fd..d9ea0f57d3 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -48,7 +48,7 @@ public: struct Params : public LLInitParam::Block<Params, LLButton::Params> { Optional<LLUI::RangeS32::Params> button_width; - Optional<S32> desired_height; + Optional<S32> desired_height; Params() : button_width("button_width"), @@ -163,7 +163,7 @@ public: void* cargo_data, EAcceptance* accept, std::string& tooltip_msg); - + static const int RANK_NONE = -1; bool addCommand(const LLCommandId& commandId, int rank = RANK_NONE); @@ -178,6 +178,8 @@ public: LLToolBarButton* createButton(const LLCommandId& id); + bool hasButtons() { return !mButtons.empty(); } + protected: friend class LLUICtrlFactory; LLToolBar(const Params&); diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index d758647d3a..296d992b34 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -217,6 +217,8 @@ tooltip_ref="Command_Speak_Tooltip" execute_function="Agent.ToggleMicrophone" execute_parameters="speak" + execute_stop_function="" + execute_stop_parameters="speak" is_enabled_function="Agent.IsActionAllowed" is_enabled_parameters="speak" is_running_function="Agent.IsMicrophoneOn" diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 6dcfa95a0e..98de418878 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -31,6 +31,7 @@ #include "llfocusmgr.h" #include "llinventory.h" #include "lllandmarkactions.h" +#include "lltoolbarview.h" #include "lltrans.h" #include "lluictrlfactory.h" #include "llmenugl.h" @@ -54,6 +55,7 @@ static LLDefaultChildRegistry::Register<LLFavoritesBarCtrl> r("favorites_bar"); const S32 DROP_DOWN_MENU_WIDTH = 250; +const S32 DROP_DOWN_MENU_TOP_PAD = 13; /** * Helper for LLFavoriteLandmarkButton and LLFavoriteLandmarkMenuItem. @@ -893,84 +895,155 @@ void LLFavoritesBarCtrl::showDropDownMenu() { if (mOverflowMenuHandle.isDead()) { - LLToggleableMenu::Params menu_p; - menu_p.name("favorites menu"); - menu_p.can_tear_off(false); - menu_p.visible(false); - menu_p.scrollable(true); - menu_p.max_scrollable_items = 10; - menu_p.preferred_width = DROP_DOWN_MENU_WIDTH; - - LLToggleableMenu* menu = LLUICtrlFactory::create<LLFavoriteLandmarkToggleableMenu>(menu_p); - mOverflowMenuHandle = menu->getHandle(); + createOverflowMenu(); } LLToggleableMenu* menu = (LLToggleableMenu*)mOverflowMenuHandle.get(); + if (menu && menu->toggleVisibility()) + { + if (mUpdateDropDownItems) + { + updateMenuItems(menu); + } + + menu->buildDrawLabels(); + menu->updateParent(LLMenuGL::sMenuContainer); + menu->setButtonRect(mMoreTextBox->getRect(), this); + positionAndShowMenu(menu); + } +} + +void LLFavoritesBarCtrl::createOverflowMenu() +{ + LLToggleableMenu::Params menu_p; + menu_p.name("favorites menu"); + menu_p.can_tear_off(false); + menu_p.visible(false); + menu_p.scrollable(true); + menu_p.max_scrollable_items = 10; + menu_p.preferred_width = DROP_DOWN_MENU_WIDTH; + + LLToggleableMenu* menu = LLUICtrlFactory::create<LLFavoriteLandmarkToggleableMenu>(menu_p); + mOverflowMenuHandle = menu->getHandle(); +} - if (menu) +void LLFavoritesBarCtrl::updateMenuItems(LLToggleableMenu* menu) +{ + menu->empty(); + + U32 widest_item = 0; + + for (S32 i = mFirstDropDownItem; i < mItems.count(); i++) { - if (!menu->toggleVisibility()) - return; + LLViewerInventoryItem* item = mItems.get(i); + const std::string& item_name = item->getName(); - U32 max_width = llmin(DROP_DOWN_MENU_WIDTH, getRect().getWidth()); - if (mUpdateDropDownItems) + LLFavoriteLandmarkMenuItem::Params item_params; + item_params.name(item_name); + item_params.label(item_name); + item_params.on_click.function(boost::bind(&LLFavoritesBarCtrl::onButtonClick, this, item->getUUID())); + + LLFavoriteLandmarkMenuItem *menu_item = LLUICtrlFactory::create<LLFavoriteLandmarkMenuItem>(item_params); + menu_item->initFavoritesBarPointer(this); + menu_item->setRightMouseDownCallback(boost::bind(&LLFavoritesBarCtrl::onButtonRightClick, this, item->getUUID(), _1, _2, _3, _4)); + menu_item->LLUICtrl::setMouseDownCallback(boost::bind(&LLFavoritesBarCtrl::onButtonMouseDown, this, item->getUUID(), _1, _2, _3, _4)); + menu_item->LLUICtrl::setMouseUpCallback(boost::bind(&LLFavoritesBarCtrl::onButtonMouseUp, this, item->getUUID(), _1, _2, _3, _4)); + menu_item->setLandmarkID(item->getUUID()); + + fitLabelWidth(menu_item); + + widest_item = llmax(widest_item, menu_item->getNominalWidth()); + + menu->addChild(menu_item); + } + + addOpenLandmarksMenuItem(menu); + mUpdateDropDownItems = false; +} + +void LLFavoritesBarCtrl::fitLabelWidth(LLMenuItemCallGL* menu_item) +{ + U32 max_width = llmin(DROP_DOWN_MENU_WIDTH, getRect().getWidth()); + std::string item_name = menu_item->getName(); + + // Check whether item name wider than menu + if (menu_item->getNominalWidth() > max_width) + { + S32 chars_total = item_name.length(); + S32 chars_fitted = 1; + menu_item->setLabel(LLStringExplicit("")); + S32 label_space = max_width - menu_item->getFont()->getWidth("...") - + menu_item->getNominalWidth();// This returns width of menu item with empty label (pad pixels) + + while (chars_fitted < chars_total + && menu_item->getFont()->getWidth(item_name, 0, chars_fitted) < label_space) { - menu->empty(); + chars_fitted++; + } + chars_fitted--; // Rolling back one char, that doesn't fit - U32 widest_item = 0; + menu_item->setLabel(item_name.substr(0, chars_fitted) + "..."); + } +} - for (S32 i = mFirstDropDownItem; i < mItems.count(); i++) - { - LLViewerInventoryItem* item = mItems.get(i); - const std::string& item_name = item->getName(); - - LLFavoriteLandmarkMenuItem::Params item_params; - item_params.name(item_name); - item_params.label(item_name); - - item_params.on_click.function(boost::bind( - &LLFavoritesBarCtrl::onButtonClick, this, - item->getUUID())); - LLFavoriteLandmarkMenuItem *menu_item = LLUICtrlFactory::create<LLFavoriteLandmarkMenuItem>(item_params); - menu_item->initFavoritesBarPointer(this); - menu_item->setRightMouseDownCallback(boost::bind(&LLFavoritesBarCtrl::onButtonRightClick, this, item->getUUID(), _1, _2, _3, _4)); - menu_item->LLUICtrl::setMouseDownCallback(boost::bind(&LLFavoritesBarCtrl::onButtonMouseDown, this, item->getUUID(), _1, _2, _3, _4)); - menu_item->LLUICtrl::setMouseUpCallback(boost::bind(&LLFavoritesBarCtrl::onButtonMouseUp, this, item->getUUID(), _1, _2, _3, _4)); - menu_item->setLandmarkID(item->getUUID()); - - // Check whether item name wider than menu - if (menu_item->getNominalWidth() > max_width) - { - S32 chars_total = item_name.length(); - S32 chars_fitted = 1; - menu_item->setLabel(LLStringExplicit("")); - S32 label_space = max_width - menu_item->getFont()->getWidth("...") - - menu_item->getNominalWidth();// This returns width of menu item with empty label (pad pixels) - - while (chars_fitted < chars_total - && menu_item->getFont()->getWidth(item_name, 0, chars_fitted) < label_space) - { - chars_fitted++; - } - chars_fitted--; // Rolling back one char, that doesn't fit +void LLFavoritesBarCtrl::addOpenLandmarksMenuItem(LLToggleableMenu* menu) +{ + std::string label_untrans = "Open landmarks"; + std::string label_transl; + bool translated = LLTrans::findString(label_transl, label_untrans); + + LLMenuItemCallGL::Params item_params; + item_params.name("open_my_landmarks"); + item_params.label(translated ? label_transl: label_untrans); + item_params.on_click.function(boost::bind(&LLFloaterSidePanelContainer::showPanel, "places", LLSD())); + LLMenuItemCallGL* menu_item = LLUICtrlFactory::create<LLMenuItemCallGL>(item_params); + + fitLabelWidth(menu_item); + + LLMenuItemSeparatorGL::Params sep_params; + sep_params.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor"); + sep_params.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor"); + sep_params.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor"); + sep_params.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor"); + LLMenuItemSeparatorGL* separator = LLUICtrlFactory::create<LLMenuItemSeparatorGL>(sep_params); + + menu->addChild(separator); + menu->addChild(menu_item); +} - menu_item->setLabel(item_name.substr(0, chars_fitted) - + "..."); - } - widest_item = llmax(widest_item, menu_item->getNominalWidth()); +void LLFavoritesBarCtrl::positionAndShowMenu(LLToggleableMenu* menu) +{ + U32 max_width = llmin(DROP_DOWN_MENU_WIDTH, getRect().getWidth()); - menu->addChild(menu_item); - } - mUpdateDropDownItems = false; + S32 menu_x = getRect().getWidth() - max_width; + S32 menu_y = getParent()->getRect().mBottom - DROP_DOWN_MENU_TOP_PAD; + + // the menu should be offset of the right edge of the window + // so it's no covered by buttons in the right-side toolbar. + LLToolBar* right_toolbar = gToolBarView->getChild<LLToolBar>("toolbar_right"); + if (right_toolbar && right_toolbar->hasButtons()) + { + S32 toolbar_top = 0; + + if (LLView* top_border_panel = right_toolbar->getChild<LLView>("button_panel")) + { + toolbar_top = top_border_panel->calcScreenRect().mTop; } - menu->buildDrawLabels(); - menu->updateParent(LLMenuGL::sMenuContainer); + // Calculating the bottom (in screen coord) of the drop down menu + S32 menu_top = getParent()->getRect().mBottom - DROP_DOWN_MENU_TOP_PAD; + S32 menu_bottom = menu_top - menu->getRect().getHeight(); + S32 menu_bottom_screen = 0; - menu->setButtonRect(mMoreTextBox->getRect(), this); + localPointToScreen(0, menu_bottom, &menu_top, &menu_bottom_screen); - LLMenuGL::showPopup(this, menu, getRect().getWidth() - max_width, 0); + if (menu_bottom_screen < toolbar_top) + { + menu_x -= right_toolbar->getRect().getWidth(); + } } + + LLMenuGL::showPopup(this, menu, menu_x, menu_y); } void LLFavoritesBarCtrl::onButtonClick(LLUUID item_id) diff --git a/indra/newview/llfavoritesbar.h b/indra/newview/llfavoritesbar.h index a41795a080..1b11d6196e 100644 --- a/indra/newview/llfavoritesbar.h +++ b/indra/newview/llfavoritesbar.h @@ -34,6 +34,9 @@ #include "llinventoryobserver.h" #include "llinventorymodel.h" +class LLMenuItemCallGL; +class LLToggleableMenu; + class LLFavoritesBarCtrl : public LLUICtrl, public LLInventoryObserver { public: @@ -132,6 +135,17 @@ private: // finds an item by it's UUID in the items array LLInventoryModel::item_array_t::iterator findItemByUUID(LLInventoryModel::item_array_t& items, const LLUUID& id); + void createOverflowMenu(); + + void updateMenuItems(LLToggleableMenu* menu); + + // Fits menu item label width with favorites menu width + void fitLabelWidth(LLMenuItemCallGL* menu_item); + + void addOpenLandmarksMenuItem(LLToggleableMenu* menu); + + void positionAndShowMenu(LLToggleableMenu* menu); + BOOL mShowDragMarker; LLUICtrl* mLandingTab; LLUICtrl* mLastTab; diff --git a/indra/newview/skins/default/textures/toolbar_icons/picks.png b/indra/newview/skins/default/textures/toolbar_icons/picks.png Binary files differindex 4499bf562b..befda04b42 100644 --- a/indra/newview/skins/default/textures/toolbar_icons/picks.png +++ b/indra/newview/skins/default/textures/toolbar_icons/picks.png diff --git a/indra/newview/skins/default/xui/en/panel_navigation_bar.xml b/indra/newview/skins/default/xui/en/panel_navigation_bar.xml index 21c9eb7437..bf9eeb6d26 100644 --- a/indra/newview/skins/default/xui/en/panel_navigation_bar.xml +++ b/indra/newview/skins/default/xui/en/panel_navigation_bar.xml @@ -60,9 +60,9 @@ layout="topleft" auto_resize="true" user_resize="true" - min_width="340" + min_width="480" name="navigation_layout_panel" - width="340"> + width="480"> <panel background_visible="false" follows="left|top|right" @@ -71,7 +71,7 @@ layout="topleft" left="0" name="navigation_panel" - width="340"> + width="480"> <pull_button follows="left|top" direction="down" @@ -118,7 +118,7 @@ mouse_opaque="false" name="location_combo" top_delta="0" - width="215"> + width="355"> <combo_list mouse_wheel_opaque="true"/> </location_input> @@ -149,9 +149,9 @@ layout="topleft" auto_resize="true" user_resize="true" - min_width="335" + min_width="315" name="favorites_layout_panel" - width="335"> + width="315"> <favorites_bar follows="left|right|top" font="SansSerifSmall" @@ -161,7 +161,7 @@ name="favorite" image_drag_indication="Accordion_ArrowOpened_Off" tool_tip="Drag Landmarks here for quick access to your favorite places in Second Life!" - width="331"> + width="311"> <label follows="left|top" height="15" @@ -177,14 +177,12 @@ <!-- More button actually is a text box. --> <more_button follows="left|bottom" - font.name="SansSerifSmall" - font.style="UNDERLINE" name=">>" tab_stop="false" tool_tip="Show more of My Favorites" top="15" width="50"> - More... + More ▼ </more_button> </favorites_bar> </layout_panel> diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index d12dda88be..f19cfa19f2 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -2051,6 +2051,8 @@ Returns a string with the requested data about the region <string name="Marketplace Error Unsellable Item">Error: This item can not be sold on the marketplace.</string> <string name="Marketplace Error Internal Import">Error: There was a problem with this item. Try again later.</string> + <string name="Open landmarks">Open landmarks</string> + <!-- use value="" because they have preceding spaces --> <string name="no_transfer" value=" (no transfer)" /> <string name="no_modify" value=" (no modify)" /> |