summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/lltoolbar.cpp58
-rw-r--r--indra/llui/lltoolbar.h55
2 files changed, 96 insertions, 17 deletions
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<LLToolBar> 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<LLToolBarEnums::ButtonType>::declareValues()
+ {
+ declare("icons_only", LLToolBarEnums::BTNTYPE_ICONS_ONLY);
+ declare("icons_with_text", LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT);
+ }
+
+ void TypeValues<LLToolBarEnums::SideType>::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);
+ }
+}
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index fb03095c56..60a848a6e3 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -32,6 +32,7 @@
#include "lllayoutstack.h"
#include "llbutton.h"
+
class LLToolBarButton : public LLButton
{
public:
@@ -40,9 +41,44 @@ public:
};
LLToolBarButton(const Params& p) : LLButton(p) {}
-
};
+
+namespace LLToolBarEnums
+{
+ enum ButtonType
+ {
+ BTNTYPE_ICONS_ONLY = 0,
+ BTNTYPE_ICONS_WITH_TEXT,
+ };
+
+ enum SideType
+ {
+ SIDE_NONE = 0,
+ SIDE_BOTTOM,
+ SIDE_LEFT,
+ SIDE_RIGHT,
+ SIDE_TOP,
+ };
+}
+
+// NOTE: This needs to occur before Param block declaration for proper compilation.
+namespace LLInitParam
+{
+ template<>
+ struct TypeValues<LLToolBarEnums::ButtonType> : public TypeValuesHelper<LLToolBarEnums::ButtonType>
+ {
+ static void declareValues();
+ };
+
+ template<>
+ struct TypeValues<LLToolBarEnums::SideType> : public TypeValuesHelper<LLToolBarEnums::SideType>
+ {
+ static void declareValues();
+ };
+}
+
+
class LLToolBar
: public LLUICtrl
{
@@ -50,26 +86,29 @@ public:
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
{
- Mandatory<LLLayoutStack::ELayoutOrientation,
- LLLayoutStack::OrientationNames> orientation;
- Multiple<LLToolBarButton::Params> buttons;
+ Mandatory<LLToolBarEnums::ButtonType> button_display_mode;
+ Multiple<LLToolBarButton::Params> buttons;
+ Mandatory<LLToolBarEnums::SideType> side;
Params();
};
- /*virtual*/ void draw();
+ // virtuals
+ void draw();
protected:
friend class LLUICtrlFactory;
LLToolBar(const Params&);
+
void initFromParams(const Params&);
void addButton(LLToolBarButton* buttonp);
void updateLayout();
private:
- LLLayoutStack::ELayoutOrientation mOrientation;
- LLLayoutStack* mStack;
- std::list<LLToolBarButton*> mButtons;
+ std::list<LLToolBarButton*> mButtons;
+ LLToolBarEnums::ButtonType mButtonType;
+ LLToolBarEnums::SideType mSideType;
+ LLLayoutStack* mStack;
};