summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llresizehandle.cpp12
-rw-r--r--indra/llui/llresizehandle.h5
-rw-r--r--indra/llui/lltoolbar.cpp29
-rw-r--r--indra/llui/lltoolbarview.cpp99
-rw-r--r--indra/llui/lltoolbarview.h32
5 files changed, 161 insertions, 16 deletions
diff --git a/indra/llui/llresizehandle.cpp b/indra/llui/llresizehandle.cpp
index c3a51c36c9..942e84eeb6 100644
--- a/indra/llui/llresizehandle.cpp
+++ b/indra/llui/llresizehandle.cpp
@@ -55,6 +55,8 @@ LLResizeHandle::LLResizeHandle(const LLResizeHandle::Params& p)
mImage( NULL ),
mMinWidth( p.min_width ),
mMinHeight( p.min_height ),
+ mMaxWidth(S32_MAX),
+ mMaxHeight(S32_MAX),
mCorner( p.corner )
{
if( RIGHT_BOTTOM == mCorner)
@@ -177,6 +179,11 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask)
new_width = mMinWidth;
delta_x = x_multiple * (mMinWidth - orig_rect.getWidth());
}
+ else if (new_width > mMaxWidth)
+ {
+ new_width = mMaxWidth;
+ delta_x = x_multiple * (mMaxWidth - orig_rect.getWidth());
+ }
S32 new_height = orig_rect.getHeight() + y_multiple * delta_y;
if( new_height < mMinHeight )
@@ -184,6 +191,11 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask)
new_height = mMinHeight;
delta_y = y_multiple * (mMinHeight - orig_rect.getHeight());
}
+ else if (new_height > mMaxHeight)
+ {
+ new_height = mMaxHeight;
+ delta_y = y_multiple * (mMaxHeight - orig_rect.getHeight());
+ }
switch( mCorner )
{
diff --git a/indra/llui/llresizehandle.h b/indra/llui/llresizehandle.h
index 531eb1db61..5cfe3fb63c 100644
--- a/indra/llui/llresizehandle.h
+++ b/indra/llui/llresizehandle.h
@@ -56,6 +56,9 @@ public:
void setResizeLimits( S32 min_width, S32 min_height ) { mMinWidth = min_width; mMinHeight = min_height; }
+ void setMaxWidth(S32 width) { mMaxWidth = width;}
+ void setMaxHeight(S32 height) { mMaxHeight = height;}
+
private:
BOOL pointInHandle( S32 x, S32 y );
@@ -66,7 +69,9 @@ private:
LLCoordGL mLastMouseDir;
LLPointer<LLUIImage> mImage;
S32 mMinWidth;
+ S32 mMaxWidth;
S32 mMinHeight;
+ S32 mMaxHeight;
const ECorner mCorner;
};
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 9ca5a0f480..677d50a0c7 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -124,12 +124,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<LLContextMenu>("menu_toolbars.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance());
if (menu)
@@ -142,6 +146,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");
}
}
@@ -188,12 +196,6 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p)
mCenteringStack->addChild(LLUICtrlFactory::create<LLLayoutPanel>(border_panel_p));
- BOOST_FOREACH (const LLCommandId::Params& command_id, p.commands)
- {
- mButtonCommands.push_back(command_id);
- }
- createButtons();
-
mNeedsLayout = true;
}
@@ -203,8 +205,11 @@ bool LLToolBar::addCommand(const LLCommandId& commandId)
bool add_command = (command != NULL);
+ if (add_command)
+ {
mButtonCommands.push_back(commandId);
createButtons();
+ }
return add_command;
}
@@ -254,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);
}
}
@@ -371,8 +378,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();
@@ -405,8 +412,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());
}
@@ -451,7 +458,7 @@ void LLToolBar::updateLayoutAsNeeded()
reshape(total_girth, getRect().getHeight());
mButtonPanel->reshape(total_girth, max_row_length);
- }
+ }
// re-center toolbar buttons
mCenteringStack->updateLayout();
diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp
index 9df6f4946f..7047cca948 100644
--- a/indra/llui/lltoolbarview.cpp
+++ b/indra/llui/lltoolbarview.cpp
@@ -29,13 +29,108 @@
#include "lltoolbarview.h"
+#include "lldir.h"
+#include "llxmlnode.h"
#include "lltoolbar.h"
#include "llbutton.h"
+#include <boost/foreach.hpp>
+
LLToolBarView* gToolBarView = NULL;
static LLDefaultChildRegistry::Register<LLToolBarView> r("toolbar_view");
+LLToolBarView::Toolbar::Toolbar()
+: commands("command")
+{}
+
+LLToolBarView::ToolbarSet::ToolbarSet()
+: left_toolbar("left_toolbar"),
+ right_toolbar("right_toolbar"),
+ bottom_toolbar("bottom_toolbar")
+{}
+
+bool LLToolBarView::load()
+{
+ LLToolBarView::ToolbarSet toolbar_set;
+
+ // Load the default toolbars.xml file
+ // *TODO : pick up the user's toolbar setting if existing
+ std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml");
+
+ LLXMLNodePtr root;
+ if(!LLXMLNode::parseFile(toolbar_file, root, NULL))
+ {
+ llerrs << "Unable to load toolbars from file: " << toolbar_file << llendl;
+ return false;
+ }
+ if(!root->hasName("toolbars"))
+ {
+ llwarns << toolbar_file << " is not a valid toolbars definition file" << llendl;
+ return false;
+ }
+
+ // Parse the toolbar settings
+ LLXUIParser parser;
+ parser.readXUI(root, toolbar_set, toolbar_file);
+ if (!toolbar_set.validateBlock())
+ {
+ llerrs << "Unable to validate toolbars from file: " << toolbar_file << llendl;
+ return false;
+ }
+
+ // Add commands to each toolbar
+ // *TODO: factorize that code : tricky with Blocks though, simple lexical approach fails
+ LLCommandManager& mgr = LLCommandManager::instance();
+
+ if (toolbar_set.left_toolbar.isProvided() && mToolbarLeft)
+ {
+ BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands)
+ {
+ LLCommandId* commandId = new LLCommandId(command);
+ if (mgr.getCommand(*commandId))
+ {
+ mToolbarLeft->addCommand(*commandId);
+ }
+ else
+ {
+ llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl;
+ }
+ }
+ }
+ if (toolbar_set.right_toolbar.isProvided() && mToolbarRight)
+ {
+ BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands)
+ {
+ LLCommandId* commandId = new LLCommandId(command);
+ if (mgr.getCommand(*commandId))
+ {
+ mToolbarRight->addCommand(*commandId);
+ }
+ else
+ {
+ llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl;
+ }
+ }
+ }
+ if (toolbar_set.bottom_toolbar.isProvided() && mToolbarBottom)
+ {
+ BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands)
+ {
+ LLCommandId* commandId = new LLCommandId(command);
+ if (mgr.getCommand(*commandId))
+ {
+ mToolbarBottom->addCommand(*commandId);
+ }
+ else
+ {
+ llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl;
+ }
+ }
+ }
+ return true;
+}
+
LLToolBarView::LLToolBarView(const LLToolBarView::Params& p)
: LLUICtrl(p),
mToolbarLeft(NULL),
@@ -59,6 +154,10 @@ BOOL LLToolBarView::postBuild()
mToolbarLeft = getChild<LLToolBar>("toolbar_left");
mToolbarRight = getChild<LLToolBar>("toolbar_right");
mToolbarBottom = getChild<LLToolBar>("toolbar_bottom");
+
+ // Load the toolbars from the settings
+ load();
+
return TRUE;
}
diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h
index 2e7885f391..0f16b89ecc 100644
--- a/indra/llui/lltoolbarview.h
+++ b/indra/llui/lltoolbarview.h
@@ -39,18 +39,36 @@ class LLUICtrlFactory;
class LLToolBarView : public LLUICtrl
{
public:
+ // Xui structure of the toolbar panel
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> {};
+
+ // Note: valid children for LLToolBarView are stored in this registry
+ typedef LLDefaultChildRegistry child_registry_t;
- virtual ~LLToolBarView();
- /*virtual*/ BOOL postBuild();
+ // Xml structure of the toolbars.xml setting
+ // Those live in a toolbars.xml found in app_settings (for the default) and in
+ // the user folder for the user specific (saved) settings
+ struct Toolbar : public LLInitParam::Block<Toolbar>
+ {
+ Multiple<LLCommandId::Params> commands;
+ Toolbar();
+ };
+ struct ToolbarSet : public LLInitParam::Block<ToolbarSet>
+ {
+ Optional<Toolbar> left_toolbar,
+ right_toolbar,
+ bottom_toolbar;
+ ToolbarSet();
+ };
+ // Derived methods
+ virtual ~LLToolBarView();
+ virtual BOOL postBuild();
virtual void draw();
+ // Toolbar view interface with the rest of the world
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&);
@@ -58,6 +76,10 @@ protected:
void initFromParams(const Params&);
private:
+ // Loads the toolbars from the existing user or default settings
+ bool load(); // return false if load fails
+
+ // Pointers to the toolbars handled by the toolbar view
LLToolBar* mToolbarLeft;
LLToolBar* mToolbarRight;
LLToolBar* mToolbarBottom;