diff options
author | Richard Linden <none@none> | 2011-09-22 17:36:04 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2011-09-22 17:36:04 -0700 |
commit | 0c5d69b662b97d7716c2b00baccd112eb1c6ec98 (patch) | |
tree | 111520a9d87a1d5af866f30c4a78d104da2747ff | |
parent | 565483ee1f2ea7b8d525c6d89700452216481c5e (diff) | |
parent | c155483fc206768e21d180fac9ccdd85db8f582e (diff) |
Automated merge with ssh://hg.lindenlab.com/richard/viewer-experience-fui
-rw-r--r-- | indra/llui/lltoolbar.cpp | 74 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 7 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_test_toolbar.xml | 10 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/widgets/toolbar.xml | 23 |
4 files changed, 65 insertions, 49 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index bbd7706a11..b2cf7e6554 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -62,6 +62,7 @@ LLToolBar::Params::Params() wrap("wrap", true), min_button_width("min_button_width", 0), max_button_width("max_button_width", S32_MAX), + button_height("button_height"), background_image("background_image") {} @@ -75,6 +76,7 @@ LLToolBar::LLToolBar(const Params& p) mCenteringStack(NULL), mMinButtonWidth(p.min_button_width), mMaxButtonWidth(p.max_button_width), + mButtonHeight(p.button_height), mBackgroundImage(p.background_image) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; @@ -123,11 +125,11 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) { // remove any offset from button if (orientation == LLLayoutStack::HORIZONTAL) { - button_rect.setOriginAndSize(0, 0, mMinButtonWidth, button_rect.getHeight()); + button_rect.setOriginAndSize(0, 0, mMinButtonWidth, mButtonHeight); } else // VERTICAL { - button_rect.setOriginAndSize(0, 0, mMinButtonWidth, button_rect.getHeight()); + button_rect.setOriginAndSize(0, 0, mMinButtonWidth, mButtonHeight); } } @@ -142,6 +144,22 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) } } +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()); + } + } +} + bool LLToolBar::addCommand(LLCommand * command) { // @@ -193,14 +211,17 @@ void LLToolBar::updateLayoutAsNeeded() if (!mNeedsLayout) return; 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_total_girth = (orientation == LLLayoutStack::HORIZONTAL) + ? getRect().getHeight() + : getRect().getWidth(); S32 max_row_girth = 0; S32 cur_start = 0; S32 cur_row = 0; @@ -209,8 +230,8 @@ void LLToolBar::updateLayoutAsNeeded() std::vector<LLToolBarButton*> buttons_in_row; - BOOST_FOREACH(LLToolBarButton* button, mButtons) - { + BOOST_FOREACH(LLToolBarButton* button, mButtons) + { S32 button_clamped_width = llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth); S32 button_length = (orientation == LLLayoutStack::HORIZONTAL) ? button_clamped_width @@ -219,38 +240,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 != 0) // ...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_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 @@ -258,7 +270,7 @@ void LLToolBar::updateLayoutAsNeeded() button_rect.setLeftTopAndSize(cur_row, panel_rect.mTop - cur_start, button_clamped_width, button->getRect().getHeight()); } button->setShape(button_rect); - + buttons_in_row.push_back(button); row_running_length += button_length; @@ -267,9 +279,11 @@ void LLToolBar::updateLayoutAsNeeded() } // 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 + resizeButtonsInRow(buttons_in_row, max_row_girth); - // grow and optionally shift toolbar to accomodate buttons + // grow and optionally shift toolbar to accommodate buttons if (orientation == LLLayoutStack::HORIZONTAL) { if (mSideType == SIDE_TOP) @@ -286,9 +300,9 @@ void LLToolBar::updateLayoutAsNeeded() translate(getRect().getWidth() - total_girth, 0); } reshape(total_girth, getRect().getHeight()); - } + } - // 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 diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 85cd6d5170..9b08b26ce4 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -99,7 +99,8 @@ public: Optional<bool> wrap; Optional<S32> min_button_width, - max_button_width; + max_button_width, + button_height; // get rid of this Multiple<LLToolBarButton::Params> buttons; @@ -122,6 +123,7 @@ protected: private: void updateLayoutAsNeeded(); + void resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row, S32 max_row_girth); std::list<LLToolBarButton*> mButtons; LLToolBarEnums::ButtonType mButtonType; @@ -133,7 +135,8 @@ private: bool mWrap; bool mNeedsLayout; S32 mMinButtonWidth, - mMaxButtonWidth; + mMaxButtonWidth, + mButtonHeight; LLUIImagePtr mBackgroundImage; diff --git a/indra/newview/skins/default/xui/en/floater_test_toolbar.xml b/indra/newview/skins/default/xui/en/floater_test_toolbar.xml index 85f0f104fc..da964b88e2 100644 --- a/indra/newview/skins/default/xui/en/floater_test_toolbar.xml +++ b/indra/newview/skins/default/xui/en/floater_test_toolbar.xml @@ -13,13 +13,16 @@ width="500" left="0" top="20" - min_width="100" + min_button_width="0" + max_button_width="100" side="top"> <button auto_resize="true" + use_ellipses="true" label="Button"/> <button auto_resize="true" label="Button with long label"/> <button auto_resize="true" + use_ellipses="true" label="Button with longest label of all"/> </toolbar> <toolbar name="test_toolbar_left" @@ -28,7 +31,7 @@ width="100" left="0" top="70" - min_width="100" + min_button_width="100" side="left"> <button height="30" label="Button"/> @@ -43,7 +46,6 @@ width="100" right="500" top="70" - min_width="100" side="right"> <button auto_resize="true" label="Button 1"/> @@ -58,7 +60,7 @@ width="500" left="0" bottom="500" - min_width="100" + min_button_width="100" side="bottom"> <button auto_resize="true" label="Button"/> diff --git a/indra/newview/skins/default/xui/en/widgets/toolbar.xml b/indra/newview/skins/default/xui/en/widgets/toolbar.xml index a7f73c0c7c..f9cc9b7c69 100644 --- a/indra/newview/skins/default/xui/en/widgets/toolbar.xml +++ b/indra/newview/skins/default/xui/en/widgets/toolbar.xml @@ -1,15 +1,12 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> -<toolbar background_image = "Rounded_Rect"> - <button_icon_and_text - follows="none" - height="30" - chrome="true" - auto_resize="true" - /> - <button_icon - follows="none" - height="30" - chrome="true" - auto_resize="true" - /> +<toolbar background_image = "Rounded_Rect" + button_height="30"> + <button_icon_and_text follows="none" + chrome="true" + use_ellipses="true" + auto_resize="true"/> + <button_icon follows="none" + chrome="true" + use_ellipses="true" + auto_resize="true"/> </toolbar> |