summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/lltoolbar.cpp113
-rw-r--r--indra/llui/lltoolbar.h18
-rw-r--r--indra/newview/app_settings/commands.xml9
-rw-r--r--indra/newview/skins/default/textures/textures.xml1
-rw-r--r--indra/newview/skins/default/xui/en/floater_toybox.xml4
-rw-r--r--indra/newview/skins/default/xui/en/menu_toolbars.xml29
-rw-r--r--indra/newview/skins/default/xui/en/strings.xml2
-rw-r--r--indra/newview/skins/default/xui/en/widgets/toolbar.xml3
8 files changed, 166 insertions, 13 deletions
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<ButtonType>::declareValues()
{
- declare("icons_only", BTNTYPE_ICONS_ONLY);
declare("icons_with_text", BTNTYPE_ICONS_WITH_TEXT);
+ declare("icons_only", BTNTYPE_ICONS_ONLY);
}
void TypeValues<SideType>::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<LLMenuGL>("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<LLToolBarButton*>& buttons_in_row, S32 max_row_girth)
{
// make buttons in current row all same girth
@@ -264,8 +360,8 @@ void LLToolBar::updateLayoutAsNeeded()
std::vector<LLToolBarButton*> buttons_in_row;
- BOOST_FOREACH(LLToolBarButton* button, mButtons)
- {
+ BOOST_FOREACH(LLToolBarButton* button, mButtons)
+ {
button->reshape(mMinButtonWidth, mButtonHeight);
button->autoResize();
@@ -296,11 +392,11 @@ void LLToolBar::updateLayoutAsNeeded()
cur_start = row_pad_start;
cur_row += max_row_girth + mPadBetween;
max_row_girth = 0;
- }
+ }
LLRect button_rect;
if (orientation == LLLayoutStack::HORIZONTAL)
- {
+ {
button_rect.setLeftTopAndSize(cur_start, panel_rect.mTop - cur_row, button_clamped_width, button->getRect().getHeight());
}
else // VERTICAL
@@ -340,8 +436,9 @@ void LLToolBar::updateLayoutAsNeeded()
{ // shift left to maintain right edge
mButtonPanel->translate(mButtonPanel->getRect().getWidth() - total_girth, 0);
}
+
mButtonPanel->reshape(total_girth, max_row_length);
- }
+ }
// re-center toolbar buttons
mCenteringStack->updateLayout();
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 92c289cd3f..5028c39fb8 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -51,8 +51,8 @@ namespace LLToolBarEnums
{
enum ButtonType
{
- BTNTYPE_ICONS_ONLY = 0,
- BTNTYPE_ICONS_WITH_TEXT,
+ BTNTYPE_ICONS_WITH_TEXT = 0,
+ BTNTYPE_ICONS_ONLY,
BTNTYPE_COUNT
};
@@ -96,7 +96,9 @@ public:
Optional<LLToolBarButton::Params> button_icon,
button_icon_and_text;
- Optional<bool> wrap;
+ Optional<bool> read_only,
+ wrap;
+
Optional<S32> min_button_width,
max_button_width,
button_height;
@@ -116,6 +118,7 @@ public:
// virtuals
void draw();
+ BOOL postBuild();
void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
bool addCommand(LLCommand * command);
@@ -123,13 +126,20 @@ public:
protected:
friend class LLUICtrlFactory;
LLToolBar(const Params&);
+ ~LLToolBar();
void initFromParams(const Params&);
+ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
+ BOOL isSettingChecked(const LLSD& userdata);
+ void onSettingEnable(const LLSD& userdata);
+
private:
void updateLayoutAsNeeded();
void resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row, S32 max_row_girth);
+ const bool mReadOnly;
+
std::list<LLToolBarButton*> mButtons;
LLToolBarEnums::ButtonType mButtonType;
LLLayoutStack* mCenteringStack;
@@ -149,6 +159,8 @@ private:
mPadBetween;
LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT];
+
+ LLHandle<LLView> mPopupMenuHandle;
};
diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml
index 5cb8ddffcd..dbb0e8b7ca 100644
--- a/indra/newview/app_settings/commands.xml
+++ b/indra/newview/app_settings/commands.xml
@@ -21,6 +21,7 @@
function="Floater.ToolbarToggle"
param="chat"
/>
+ <!-- Compass it not supported by the viewer yet
<command name="compass"
icon="Command_Compass_Icon"
label_ref="Command_Compass_Label"
@@ -28,6 +29,7 @@
function="Floater.ToolbarToggle"
param="compass"
/>
+ -->
<command name="gestures"
icon="Command_Gestures_Icon"
label_ref="Command_Gestures_Label"
@@ -56,6 +58,13 @@
function="Floater.ToolbarToggle"
param="map"
/>
+ <command name="minimap"
+ icon="Command_MiniMap_Icon"
+ label_ref="Command_MiniMap_Label"
+ tooltip_ref="Command_MiniMap_Tooltip"
+ function="Floater.ToolbarToggle"
+ param="minimap"
+ />
<command name="move"
icon="Command_Move_Icon"
label_ref="Command_Move_Label"
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index d68594097c..8f2194e652 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -133,6 +133,7 @@ with the same filename but different name
<texture name="Command_HowTo_Icon" file_name="icons/SL_Logo.png" preload="true" />
<texture name="Command_Landmarks_Icon" file_name="icons/SL_Logo.png" preload="true" />
<texture name="Command_Map_Icon" file_name="icons/SL_Logo.png" preload="true" />
+ <texture name="Command_MiniMap_Icon" file_name="icons/SL_Logo.png" preload="true" />
<texture name="Command_Move_Icon" file_name="icons/SL_Logo.png" preload="true" />
<texture name="Command_MyLand_Icon" file_name="icons/SL_Logo.png" preload="true" />
<texture name="Command_MyStuff_Icon" file_name="icons/SL_Logo.png" preload="true" />
diff --git a/indra/newview/skins/default/xui/en/floater_toybox.xml b/indra/newview/skins/default/xui/en/floater_toybox.xml
index 5f3a59d964..1c9f20c496 100644
--- a/indra/newview/skins/default/xui/en/floater_toybox.xml
+++ b/indra/newview/skins/default/xui/en/floater_toybox.xml
@@ -45,10 +45,12 @@
</text>
<toolbar
bottom="395"
+ button_display_mode="icons_with_text"
left="40"
max_button_width="140"
- min_button_width="140"
+ min_button_width="70"
name="toybox_toolbar"
+ read_only="true"
right="-40"
side="top"
top="85">
diff --git a/indra/newview/skins/default/xui/en/menu_toolbars.xml b/indra/newview/skins/default/xui/en/menu_toolbars.xml
new file mode 100644
index 0000000000..b3ecd3dcb6
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/menu_toolbars.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<menu bottom="825"
+ layout="topleft"
+ name="Toolbars Popup"
+ visible="false">
+ <menu_item_call label="Choose buttons..."
+ layout="topleft"
+ name="Chose Buttons">
+ <menu_item_call.on_click function="Floater.Show"
+ parameter="toybox" />
+ </menu_item_call>
+ <menu_item_separator layout="topleft" />
+ <menu_item_check label="Icons and labels"
+ layout="topleft"
+ name="icons_and_labels">
+ <on_click function="Toolbars.EnableSetting"
+ parameter="icons_and_labels" />
+ <on_check function="Toolbars.CheckSetting"
+ parameter="icons_and_labels" />
+ </menu_item_check>
+ <menu_item_check label="Icons only"
+ layout="topleft"
+ name="icons_only">
+ <on_click function="Toolbars.EnableSetting"
+ parameter="icons_only" />
+ <on_check function="Toolbars.CheckSetting"
+ parameter="icons_only" />
+ </menu_item_check>
+</menu>
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index d4c2bc50ca..feea555fdc 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -3668,6 +3668,8 @@ Try enclosing path to the editor with double quotes.
<string name="Command_Landmarks_Tooltip"></string>
<string name="Command_Map_Label">Map</string>
<string name="Command_Map_Tooltip"></string>
+ <string name="Command_MiniMap_Label">Mini Map</string>
+ <string name="Command_MiniMap_Tooltip"></string>
<string name="Command_Move_Label">Move</string>
<string name="Command_Move_Tooltip"></string>
<string name="Command_MyLand_Label">My Land</string>
diff --git a/indra/newview/skins/default/xui/en/widgets/toolbar.xml b/indra/newview/skins/default/xui/en/widgets/toolbar.xml
index 45210277b2..7346e5ce2d 100644
--- a/indra/newview/skins/default/xui/en/widgets/toolbar.xml
+++ b/indra/newview/skins/default/xui/en/widgets/toolbar.xml
@@ -4,7 +4,8 @@
pad_right="5"
pad_top="5"
pad_bottom="5"
- pad_between="5">
+ pad_between="5"
+ read_only="false">
<button_panel name="button_panel"
bg_opaque_image="Rounded_Rect"