summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llbutton.cpp22
-rw-r--r--indra/llui/llcommandmanager.cpp24
-rw-r--r--indra/llui/llcommandmanager.h62
-rw-r--r--indra/llui/lldockcontrol.cpp3
-rw-r--r--indra/llui/llmenugl.cpp2
-rw-r--r--indra/llui/lltoolbar.cpp390
-rw-r--r--indra/llui/lltoolbar.h59
-rw-r--r--indra/llui/lltoolbarview.cpp59
-rw-r--r--indra/llui/lltoolbarview.h14
-rw-r--r--indra/llui/llui.cpp1
-rw-r--r--indra/llui/llview.cpp7
-rw-r--r--indra/llui/llview.h1
12 files changed, 474 insertions, 170 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 6c08ec7431..06781f1bdf 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -989,11 +989,27 @@ void LLButton::resize(LLUIString label)
// get current btn length
S32 btn_width =getRect().getWidth();
// check if it need resize
- if (mAutoResize == TRUE)
+ if (mAutoResize)
{
- if (btn_width - (mRightHPad + mLeftHPad) < label_width)
+ S32 min_width = label_width + mLeftHPad + mRightHPad;
+ if (mImageOverlay)
{
- setRect(LLRect( getRect().mLeft, getRect().mTop, getRect().mLeft + label_width + mLeftHPad + mRightHPad , getRect().mBottom));
+ switch(mImageOverlayAlignment)
+ {
+ case LLFontGL::LEFT:
+ case LLFontGL::RIGHT:
+ min_width += mImageOverlay->getWidth() + mImgOverlayLabelSpace;
+ break;
+ case LLFontGL::HCENTER:
+ break;
+ default:
+ // draw nothing
+ break;
+ }
+ }
+ if (btn_width < min_width)
+ {
+ reshape(min_width, getRect().getHeight());
}
}
}
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp
index 6be616b980..783990780b 100644
--- a/indra/llui/llcommandmanager.cpp
+++ b/indra/llui/llcommandmanager.cpp
@@ -38,11 +38,18 @@
//
+// LLCommandId class
+//
+
+const LLCommandId LLCommandId::null("null command");
+
+//
// LLCommand class
//
LLCommand::Params::Params()
: function("function")
+ , available_in_toybox("available_in_toybox", false)
, icon("icon")
, label_ref("label_ref")
, name("name")
@@ -53,9 +60,10 @@ LLCommand::Params::Params()
LLCommand::LLCommand(const LLCommand::Params& p)
: mFunction(p.function)
+ , mAvailableInToybox(p.available_in_toybox)
, mIcon(p.icon)
+ , mIdentifier(p.name)
, mLabelRef(p.label_ref)
- , mName(p.name)
, mParam(p.param)
, mTooltipRef(p.tooltip_ref)
{
@@ -90,26 +98,26 @@ LLCommand * LLCommandManager::getCommand(U32 commandIndex)
return mCommands[commandIndex];
}
-LLCommand * LLCommandManager::getCommand(const std::string& commandName)
+LLCommand * LLCommandManager::getCommand(const LLCommandId& commandId)
{
- LLCommand * command_name_match = NULL;
+ LLCommand * command_match = NULL;
- CommandIndexMap::const_iterator found = mCommandIndices.find(commandName);
+ CommandIndexMap::const_iterator found = mCommandIndices.find(commandId);
if (found != mCommandIndices.end())
{
- command_name_match = mCommands[found->second];
+ command_match = mCommands[found->second];
}
- return command_name_match;
+ return command_match;
}
void LLCommandManager::addCommand(LLCommand * command)
{
- mCommandIndices[command->name()] = mCommands.size();
+ mCommandIndices[command->id()] = mCommands.size();
mCommands.push_back(command);
- llinfos << "Successfully added command: " << command->name() << llendl;
+ lldebugs << "Successfully added command: " << command->id().name() << llendl;
}
//static
diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h
index 24378ecd62..8435d915f3 100644
--- a/indra/llui/llcommandmanager.h
+++ b/indra/llui/llcommandmanager.h
@@ -31,11 +31,62 @@
#include "llsingleton.h"
+class LLCommand;
+class LLCommandManager;
+
+
+class LLCommandId
+{
+public:
+ friend class LLCommand;
+ friend class LLCommandManager;
+
+ struct Params : public LLInitParam::Block<Params>
+ {
+ Mandatory<std::string> name;
+
+ Params()
+ : name("name")
+ {}
+ };
+
+ LLCommandId(const std::string& name)
+ : mName(name)
+ {}
+
+ LLCommandId(const Params& p)
+ : mName(p.name)
+ {}
+
+ const std::string& name() const { return mName; }
+
+ bool operator!=(const LLCommandId& command) const
+ {
+ return (mName != command.mName);
+ }
+
+ bool operator==(const LLCommandId& command) const
+ {
+ return (mName == command.mName);
+ }
+
+ bool operator<(const LLCommandId& command) const
+ {
+ return (mName < command.mName);
+ }
+
+ static const LLCommandId null;
+
+private:
+ std::string mName;
+};
+
class LLCommand
{
public:
struct Params : public LLInitParam::Block<Params>
{
+ Mandatory<bool> available_in_toybox;
Mandatory<std::string> function;
Mandatory<std::string> icon;
Mandatory<std::string> label_ref;
@@ -48,18 +99,21 @@ public:
LLCommand(const LLCommand::Params& p);
+ const bool availableInToybox() const { return mAvailableInToybox; }
const std::string& functionName() const { return mFunction; }
const std::string& icon() const { return mIcon; }
+ const LLCommandId& id() const { return mIdentifier; }
const std::string& labelRef() const { return mLabelRef; }
- const std::string& name() const { return mName; }
const std::string& param() const { return mParam; }
const std::string& tooltipRef() const { return mTooltipRef; }
private:
+ LLCommandId mIdentifier;
+
+ bool mAvailableInToybox;
std::string mFunction;
std::string mIcon;
std::string mLabelRef;
- std::string mName;
std::string mParam;
std::string mTooltipRef;
};
@@ -84,7 +138,7 @@ public:
U32 commandCount() const;
LLCommand * getCommand(U32 commandIndex);
- LLCommand * getCommand(const std::string& commandName);
+ LLCommand * getCommand(const LLCommandId& commandId);
static bool load();
@@ -92,7 +146,7 @@ protected:
void addCommand(LLCommand * command);
private:
- typedef std::map<std::string, U32> CommandIndexMap;
+ typedef std::map<LLCommandId, U32> CommandIndexMap;
typedef std::vector<LLCommand *> CommandVector;
CommandVector mCommands;
diff --git a/indra/llui/lldockcontrol.cpp b/indra/llui/lldockcontrol.cpp
index b1c27126d9..6e39fcd714 100644
--- a/indra/llui/lldockcontrol.cpp
+++ b/indra/llui/lldockcontrol.cpp
@@ -97,6 +97,7 @@ void LLDockControl::getAllowedRect(LLRect& rect)
void LLDockControl::repositionDockable()
{
+ if (!mDockWidget) return;
LLRect dockRect = mDockWidget->calcScreenRect();
LLRect rootRect;
mGetAllowedRectCallback(rootRect);
@@ -160,7 +161,7 @@ bool LLDockControl::isDockVisible()
case TOP:
{
// check is dock inside parent rect
- // assume that parent for all dockable flaoters
+ // assume that parent for all dockable floaters
// is the root view
LLRect dockParentRect =
mDockWidget->getRootView()->calcScreenRect();
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 6cac841cde..badba7a416 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -947,7 +947,7 @@ LLMenuItemBranchGL::LLMenuItemBranchGL(const LLMenuItemBranchGL::Params& p)
LLMenuItemBranchGL::~LLMenuItemBranchGL()
{
- LLView::deleteViewByHandle(mBranchHandle);
+ delete mBranchHandle.get();
}
// virtual
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index e052c1c876..2fb9f249d4 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -30,10 +30,12 @@
#include <boost/foreach.hpp>
#include "lltoolbar.h"
-#include "llcommandmanager.h"
+#include "llmenugl.h"
#include "lltrans.h"
-static LLDefaultChildRegistry::Register<LLToolBar> r1("toolbar");
+// uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit
+// thanks, MSVC!
+//static LLDefaultChildRegistry::Register<LLToolBar> r1("toolbar");
namespace LLToolBarEnums
{
@@ -49,34 +51,97 @@ namespace LLToolBarEnums
return orientation;
}
}
+
using namespace LLToolBarEnums;
+
+namespace LLInitParam
+{
+ void TypeValues<ButtonType>::declareValues()
+ {
+ declare("icons_with_text", BTNTYPE_ICONS_WITH_TEXT);
+ declare("icons_only", BTNTYPE_ICONS_ONLY);
+ }
+
+ void TypeValues<SideType>::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"),
+ commands("command"),
+ 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),
- background_image("background_image")
+ button_height("button_height"),
+ 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 LLToolBar::Params& p)
: LLUICtrl(p),
+ mReadOnly(p.read_only),
mButtonType(p.button_display_mode),
mSideType(p.side),
mWrap(p.wrap),
mNeedsLayout(false),
- mCenterPanel(NULL),
+ mButtonPanel(NULL),
mCenteringStack(NULL),
- mMinButtonWidth(p.min_button_width),
- mMaxButtonWidth(p.max_button_width),
- mBackgroundImage(p.background_image)
+ 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),
+ mPadBottom(p.pad_bottom),
+ 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()
+{
+ delete mPopupMenuHandle.get();
+}
+
+void LLToolBar::createContextMenu()
+{
+ if (!mPopupMenuHandle.get())
+ {
+ 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));
+
+ LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile<LLContextMenu>("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;
+ }
+ }
}
void LLToolBar::initFromParams(const LLToolBar::Params& p)
@@ -91,6 +156,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<LLLayoutStack>(centering_stack_p);
addChild(mCenteringStack);
@@ -100,6 +166,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<LLLayoutPanel>(border_panel_p));
@@ -109,84 +176,148 @@ 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<LLLayoutPanel>(center_panel_p);
- mCenteringStack->addChild(mCenterPanel);
+ LLLayoutPanel* center_panel = LLUICtrlFactory::create<LLLayoutPanel>(center_panel_p);
+ mCenteringStack->addChild(center_panel);
+
+ LLPanel::Params button_panel_p(p.button_panel);
+ button_panel_p.rect = center_panel->getLocalRect();
+ button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_LEFT;
+ mButtonPanel = LLUICtrlFactory::create<LLPanel>(button_panel_p);
+ center_panel->addChild(mButtonPanel);
mCenteringStack->addChild(LLUICtrlFactory::create<LLLayoutPanel>(border_panel_p));
- BOOST_FOREACH (LLToolBarButton::Params button_p, p.buttons)
+ BOOST_FOREACH (const LLCommandId::Params& command_id, p.commands)
{
- // buttons always follow left and top, for all orientations
- button_p.follows.flags = FOLLOWS_LEFT|FOLLOWS_TOP;
- button_p.fillFrom(mButtonParams[mButtonType]);
+ mButtonCommands.push_back(command_id);
+ }
+ createButtons();
- LLRect button_rect(button_p.rect);
- { // remove any offset from button
- if (orientation == LLLayoutStack::HORIZONTAL)
- {
- button_rect.setOriginAndSize(0, 0, mMinButtonWidth, button_rect.getHeight());
- }
- else // VERTICAL
+ mNeedsLayout = true;
+}
+
+bool LLToolBar::addCommand(const LLCommandId& commandId)
+{
+ LLCommand * command = LLCommandManager::instance().getCommand(commandId);
+
+ bool add_command = (command != NULL);
+
+ mButtonCommands.push_back(commandId);
+ createButtons();
+
+ return add_command;
+}
+
+bool LLToolBar::hasCommand(const LLCommandId& commandId) const
+{
+ bool has_command = false;
+
+ if (commandId != LLCommandId::null)
+ {
+ for (std::list<LLCommandId>::const_iterator cmd = mButtonCommands.begin(); cmd != mButtonCommands.end(); ++cmd)
+ {
+ if ((*cmd) == commandId)
{
- button_rect.setOriginAndSize(0, 0, mMinButtonWidth, button_rect.getHeight());
+ has_command = true;
+ break;
}
}
+ }
- // use our calculated rect
- button_p.rect = button_rect;
- LLToolBarButton* buttonp = LLUICtrlFactory::create<LLToolBarButton>(button_p);
+ return has_command;
+}
- mButtons.push_back(buttonp);
- mCenterPanel->addChild(buttonp);
+bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled)
+{
+ LLButton * command_button = NULL;
+
+ if (commandId != LLCommandId::null)
+ {
+ command_button = mButtonPanel->findChild<LLButton>(commandId.name());
- mNeedsLayout = true;
+ if (command_button)
+ {
+ command_button->setEnabled(enabled);
+ }
}
+
+ return (command_button != NULL);
}
-bool LLToolBar::addCommand(LLCommand * command)
+BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
- //
- // Init basic toolbar button params
- //
+ BOOL handle_it_here = !mReadOnly;
- LLToolBarButton::Params button_p;
- button_p.fillFrom(mButtonParams[mButtonType]);
+ if (handle_it_here)
+ {
+ createContextMenu();
+ LLContextMenu * menu = (LLContextMenu *) mPopupMenuHandle.get();
- button_p.name = command->name();
- button_p.label = LLTrans::getString(command->labelRef());
- button_p.tool_tip = LLTrans::getString(command->tooltipRef());
+ if (menu)
+ {
+ menu->show(x, y);
+ LLMenuGL::showPopup(this, menu, x, y);
+ }
+ }
- //
- // Set up the button rectangle
- //
+ return handle_it_here;
+}
- S32 btn_width = mMinButtonWidth;
- S32 btn_height = mButtonParams[mButtonType].rect.height;
+BOOL LLToolBar::isSettingChecked(const LLSD& userdata)
+{
+ BOOL retval = FALSE;
- if ((mSideType == LLToolBarEnums::SIDE_BOTTOM) || (mSideType == LLToolBarEnums::SIDE_TOP))
+ const std::string setting_name = userdata.asString();
+
+ if (setting_name == "icons_and_labels")
{
- btn_height = getRect().getHeight();
+ retval = (mButtonType == BTNTYPE_ICONS_WITH_TEXT);
+ }
+ else if (setting_name == "icons_only")
+ {
+ retval = (mButtonType == BTNTYPE_ICONS_ONLY);
}
- LLRect button_rect;
- button_rect.setOriginAndSize(0, 0, btn_width, btn_height);
-
- button_p.rect = button_rect;
+ return retval;
+}
- //
- // Add it to the list of buttons
- //
+void LLToolBar::onSettingEnable(const LLSD& userdata)
+{
+ llassert(!mReadOnly);
- LLToolBarButton * toolbar_button = LLUICtrlFactory::create<LLToolBarButton>(button_p);
+ const std::string setting_name = userdata.asString();
- toolbar_button->reshape(llclamp(toolbar_button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth), toolbar_button->getRect().getHeight());
+ const ButtonType current_button_type = mButtonType;
- mButtons.push_back(toolbar_button);
- mCenterPanel->addChild(toolbar_button);
+ if (setting_name == "icons_and_labels")
+ {
+ mButtonType = BTNTYPE_ICONS_WITH_TEXT;
+ }
+ else if (setting_name == "icons_only")
+ {
+ mButtonType = BTNTYPE_ICONS_ONLY;
+ }
- mNeedsLayout = true;
+ if(current_button_type != mButtonType)
+ {
+ createButtons();
+ }
+}
- return true;
+void LLToolBar::resizeButtonsInRow(std::vector<LLToolBarButton*>& 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()
@@ -195,23 +326,53 @@ void LLToolBar::updateLayoutAsNeeded()
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_row_girth = 0;
- S32 cur_start = 0;
- S32 cur_row = 0;
+ S32 max_row_length = 0;
+
+ 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_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_pad_end = mPadBottom;
+ cur_row = mPadLeft;
+ girth_pad_end = mPadRight;
+ }
+
+ row_running_length = row_pad_start;
+ cur_start = row_pad_start;
+
- LLRect panel_rect = mCenterPanel->getLocalRect();
+ LLRect panel_rect = mButtonPanel->getLocalRect();
std::vector<LLToolBarButton*> buttons_in_row;
- BOOST_FOREACH(LLToolBarButton* button, mButtons)
- {
+ 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
@@ -220,37 +381,29 @@ 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 != row_pad_start) // ...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;
- 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;
}
- 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());
}
@@ -262,15 +415,20 @@ 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 + 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...
+ + girth_pad_end; // ...plus padding reserved on end
+ max_row_length = llmax(max_row_length, row_running_length - mPadBetween + row_pad_end);
- // grow and optionally shift toolbar to accomodate buttons
+ resizeButtonsInRow(buttons_in_row, max_row_girth);
+
+ // grow and optionally shift toolbar to accommodate buttons
if (orientation == LLLayoutStack::HORIZONTAL)
{
if (mSideType == SIDE_TOP)
@@ -279,6 +437,7 @@ void LLToolBar::updateLayoutAsNeeded()
}
reshape(getRect().getWidth(), total_girth);
+ mButtonPanel->reshape(max_row_length, total_girth);
}
else // VERTICAL
{
@@ -286,10 +445,12 @@ void LLToolBar::updateLayoutAsNeeded()
{ // shift left to maintain right edge
translate(getRect().getWidth() - total_girth, 0);
}
+
reshape(total_girth, getRect().getHeight());
- }
+ mButtonPanel->reshape(total_girth, max_row_length);
+ }
- // 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
@@ -300,12 +461,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();
}
@@ -315,20 +470,29 @@ void LLToolBar::reshape(S32 width, S32 height, BOOL called_from_parent)
mNeedsLayout = true;
}
-namespace LLInitParam
+void LLToolBar::createButtons()
{
- void TypeValues<ButtonType>::declareValues()
+ BOOST_FOREACH(LLToolBarButton* button, mButtons)
{
- declare("icons_only", BTNTYPE_ICONS_ONLY);
- declare("icons_with_text", BTNTYPE_ICONS_WITH_TEXT);
+ delete button;
}
-
- void TypeValues<SideType>::declareValues()
+ mButtons.clear();
+
+ BOOST_FOREACH(LLCommandId& command_id, mButtonCommands)
{
- declare("none", SIDE_NONE);
- declare("bottom", SIDE_BOTTOM);
- declare("left", SIDE_LEFT);
- declare("right", SIDE_RIGHT);
- declare("top", SIDE_TOP);
+ 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<LLToolBarButton>(button_p);
+
+ mButtons.push_back(button);
+ mButtonPanel->addChild(button);
}
+
+ mNeedsLayout = true;
}
+
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 85cd6d5170..75ae499a3d 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -28,12 +28,11 @@
#ifndef LL_LLTOOLBAR_H
#define LL_LLTOOLBAR_H
-#include "lluictrl.h"
-#include "lllayoutstack.h"
#include "llbutton.h"
-
-
-class LLCommand;
+#include "llcommandmanager.h"
+#include "lllayoutstack.h"
+#include "lluictrl.h"
+#include "llcommandmanager.h"
class LLToolBarButton : public LLButton
@@ -51,15 +50,14 @@ namespace LLToolBarEnums
{
enum ButtonType
{
- BTNTYPE_ICONS_ONLY = 0,
- BTNTYPE_ICONS_WITH_TEXT,
+ BTNTYPE_ICONS_WITH_TEXT = 0,
+ BTNTYPE_ICONS_ONLY,
BTNTYPE_COUNT
};
enum SideType
{
- SIDE_NONE = 0,
SIDE_BOTTOM,
SIDE_LEFT,
SIDE_RIGHT,
@@ -97,13 +95,22 @@ 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;
+ max_button_width,
+ button_height;
+
+ Optional<S32> pad_left,
+ pad_top,
+ pad_right,
+ pad_bottom,
+ pad_between;
// get rid of this
- Multiple<LLToolBarButton::Params> buttons;
+ Multiple<LLCommandId::Params> commands;
- Optional<LLUIImage*> background_image;
+ Optional<LLPanel::Params> button_panel;
Params();
};
@@ -111,33 +118,51 @@ public:
// virtuals
void draw();
void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
+ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
- bool addCommand(LLCommand * command);
+ bool addCommand(const LLCommandId& commandId);
+ bool hasCommand(const LLCommandId& commandId) const;
+ bool enableCommand(const LLCommandId& commandId, bool enabled);
protected:
friend class LLUICtrlFactory;
LLToolBar(const Params&);
+ ~LLToolBar();
void initFromParams(const Params&);
private:
+ void createContextMenu();
void updateLayoutAsNeeded();
+ void createButtons();
+ void resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row, S32 max_row_girth);
+ BOOL isSettingChecked(const LLSD& userdata);
+ void onSettingEnable(const LLSD& userdata);
+
+ const bool mReadOnly;
std::list<LLToolBarButton*> mButtons;
+ std::list<LLCommandId> mButtonCommands;
LLToolBarEnums::ButtonType mButtonType;
LLLayoutStack* mCenteringStack;
LLLayoutStack* mWrapStack;
- LLLayoutPanel* mCenterPanel;
+ LLPanel* mButtonPanel;
LLToolBarEnums::SideType mSideType;
bool mWrap;
bool mNeedsLayout;
S32 mMinButtonWidth,
- mMaxButtonWidth;
-
- LLUIImagePtr mBackgroundImage;
+ mMaxButtonWidth,
+ mButtonHeight,
+ mPadLeft,
+ mPadRight,
+ mPadTop,
+ mPadBottom,
+ mPadBetween;
LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT];
+
+ LLHandle<class LLContextMenu> mPopupMenuHandle;
};
diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp
index 590cd4ffca..9df6f4946f 100644
--- a/indra/llui/lltoolbarview.cpp
+++ b/indra/llui/lltoolbarview.cpp
@@ -37,7 +37,10 @@ LLToolBarView* gToolBarView = NULL;
static LLDefaultChildRegistry::Register<LLToolBarView> r("toolbar_view");
LLToolBarView::LLToolBarView(const LLToolBarView::Params& p)
-: LLUICtrl(p)
+: LLUICtrl(p),
+ mToolbarLeft(NULL),
+ mToolbarRight(NULL),
+ mToolbarBottom(NULL)
{
}
@@ -51,21 +54,46 @@ LLToolBarView::~LLToolBarView()
{
}
+BOOL LLToolBarView::postBuild()
+{
+ mToolbarLeft = getChild<LLToolBar>("toolbar_left");
+ mToolbarRight = getChild<LLToolBar>("toolbar_right");
+ mToolbarBottom = getChild<LLToolBar>("toolbar_bottom");
+ return TRUE;
+}
+
+bool LLToolBarView::hasCommand(const LLCommandId& commandId) const
+{
+ bool has_command = false;
+ if (mToolbarLeft && !has_command)
+ {
+ has_command = mToolbarLeft->hasCommand(commandId);
+ }
+ if (mToolbarRight && !has_command)
+ {
+ has_command = mToolbarRight->hasCommand(commandId);
+ }
+ if (mToolbarBottom && !has_command)
+ {
+ has_command = mToolbarBottom->hasCommand(commandId);
+ }
+ return has_command;
+}
+
void LLToolBarView::draw()
{
static bool debug_print = true;
static S32 old_width = 0;
static S32 old_height = 0;
- LLToolBar* toolbar_bottom = getChild<LLToolBar>("toolbar_bottom");
- LLToolBar* toolbar_left = getChild<LLToolBar>("toolbar_left");
- LLToolBar* toolbar_right = getChild<LLToolBar>("toolbar_right");
- LLPanel* sizer_left = getChild<LLPanel>("sizer_left");
+ //LLPanel* sizer_left = getChild<LLPanel>("sizer_left");
+
+ LLRect bottom_rect, left_rect, right_rect;
+
+ if (mToolbarBottom) mToolbarBottom->localRectToOtherView(mToolbarBottom->getLocalRect(), &bottom_rect, this);
+ if (mToolbarLeft) mToolbarLeft->localRectToOtherView(mToolbarLeft->getLocalRect(), &left_rect, this);
+ if (mToolbarRight) mToolbarRight->localRectToOtherView(mToolbarRight->getLocalRect(), &right_rect, this);
- LLRect bottom_rect = toolbar_bottom->getRect();
- LLRect left_rect = toolbar_left->getRect();
- LLRect right_rect = toolbar_right->getRect();
- LLRect sizer_left_rect = sizer_left->getRect();
if ((old_width != getRect().getWidth()) || (old_height != getRect().getHeight()))
debug_print = true;
@@ -76,18 +104,21 @@ void LLToolBarView::draw()
llinfos << "Merov debug : draw bottom rect = " << bottom_rect.mLeft << ", " << bottom_rect.mTop << ", " << bottom_rect.mRight << ", " << bottom_rect.mBottom << llendl;
llinfos << "Merov debug : draw left rect = " << left_rect.mLeft << ", " << left_rect.mTop << ", " << left_rect.mRight << ", " << left_rect.mBottom << llendl;
llinfos << "Merov debug : draw right rect = " << right_rect.mLeft << ", " << right_rect.mTop << ", " << right_rect.mRight << ", " << right_rect.mBottom << llendl;
- llinfos << "Merov debug : draw s left rect = " << sizer_left_rect.mLeft << ", " << sizer_left_rect.mTop << ", " << sizer_left_rect.mRight << ", " << sizer_left_rect.mBottom << llendl;
old_width = ctrl_rect.getWidth();
old_height = ctrl_rect.getHeight();
debug_print = false;
}
// Debug draw
LLColor4 back_color = LLColor4::blue;
+ LLColor4 back_color_vert = LLColor4::red;
+ LLColor4 back_color_hori = LLColor4::yellow;
back_color[VALPHA] = 0.5f;
-// gl_rect_2d(getLocalRect(), back_color, TRUE);
-// gl_rect_2d(bottom_rect, LLColor4::red, TRUE);
-// gl_rect_2d(left_rect, LLColor4::green, TRUE);
-// gl_rect_2d(right_rect, LLColor4::yellow, TRUE);
+ back_color_hori[VALPHA] = 0.5f;
+ back_color_vert[VALPHA] = 0.5f;
+ //gl_rect_2d(getLocalRect(), back_color, TRUE);
+ gl_rect_2d(bottom_rect, back_color_hori, TRUE);
+ gl_rect_2d(left_rect, back_color_vert, TRUE);
+ gl_rect_2d(right_rect, back_color_vert, TRUE);
LLUICtrl::draw();
}
diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h
index 73278e226b..2e7885f391 100644
--- a/indra/llui/lltoolbarview.h
+++ b/indra/llui/lltoolbarview.h
@@ -29,6 +29,8 @@
#define LL_LLTOOLBARVIEW_H
#include "lluictrl.h"
+#include "lltoolbar.h"
+#include "llcommandmanager.h"
class LLUICtrlFactory;
@@ -38,9 +40,17 @@ class LLToolBarView : public LLUICtrl
{
public:
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> {};
+
virtual ~LLToolBarView();
+ /*virtual*/ BOOL postBuild();
+
virtual void draw();
+ bool hasCommand(const LLCommandId& commandId) const;
+
+ // valid children for LLToolBarView are stored in this registry
+ typedef LLDefaultChildRegistry child_registry_t;
+
protected:
friend class LLUICtrlFactory;
LLToolBarView(const Params&);
@@ -48,7 +58,9 @@ protected:
void initFromParams(const Params&);
private:
- LLHandle<LLView> mSnapView;
+ LLToolBar* mToolbarLeft;
+ LLToolBar* mToolbarRight;
+ LLToolBar* mToolbarBottom;
};
extern LLToolBarView* gToolBarView;
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index a4303780fd..4f129ccfba 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -96,6 +96,7 @@ static LLDefaultChildRegistry::Register<LLSearchEditor> register_search_editor("
// register other widgets which otherwise may not be linked in
static LLDefaultChildRegistry::Register<LLLoadingIndicator> register_loading_indicator("loading_indicator");
+static LLDefaultChildRegistry::Register<LLToolBar> register_toolbar("toolbar");
//
// Functions
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 60452b9ae4..e10c2f0d1e 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -1826,13 +1826,6 @@ LLView* LLView::findNextSibling(LLView* child)
return (next_it != mChildList.end()) ? *next_it : NULL;
}
-void LLView::deleteViewByHandle(LLHandle<LLView> handle)
-{
- LLView* viewp = handle.get();
-
- delete viewp;
-}
-
LLCoordGL getNeededTranslation(const LLRect& input, const LLRect& constraint, BOOL allow_partial_outside)
{
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 594a5eec6b..7a1b2e4ba0 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -482,7 +482,6 @@ public:
// return query for iterating over focus roots in tab order
static const LLCtrlQuery & getFocusRootsQuery();
- static void deleteViewByHandle(LLHandle<LLView> handle);
static LLWindow* getWindow(void) { return LLUI::sWindow; }
// Set up params after XML load before calling new(),