FIRE-5317: Fixed size buttons in bottom toolbar are too big

master
Ansariel 2015-11-01 16:33:04 +01:00
parent 2603551b2f
commit b7eb465cdc
7 changed files with 23 additions and 3 deletions

View File

@ -36,6 +36,8 @@
#include "llinventory.h"
#include "lliconctrl.h"
#include "lllayoutstack.h"
// 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");
@ -115,7 +117,8 @@ LLToolBar::Params::Params()
button_panel("button_panel"),
button("button"),
layout_style("layout_style",LLToolBarEnums::LAYOUT_STYLE_NONE),
alignment("alignment",LLToolBarEnums::ALIGN_CENTER)
alignment("alignment",LLToolBarEnums::ALIGN_CENTER),
max_rows("max_rows", 0)
// </FS:Zi>
{}
@ -150,7 +153,8 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p)
//mCenterPanel(NULL)
mCenterPanel(NULL),
mLayoutStyle(p.layout_style),
mAlignment(p.alignment)
mAlignment(p.alignment),
mMaxRows(p.max_rows)
// </FS:Zi>
{
mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text;
@ -779,9 +783,16 @@ void LLToolBar::updateLayoutAsNeeded()
S32 width = button->getInitialWidth();
if (width > equalized_width)
{
equalized_width=width;
equalized_width = width;
}
}
S32 total_button_width = mButtons.size() * equalized_width + (mButtons.size() + 1) * mPadBetween;
if (mMaxRows > 0 && orientation == LLLayoutStack::HORIZONTAL && total_button_width > full_screen_width)
{
S32 buttons_per_row = (S32)ceilf((F32)mButtons.size() / (F32)mMaxRows);
equalized_width = (full_screen_width - mPadBetween * (buttons_per_row + 1)) / buttons_per_row;
}
}
// </FS:Zi>

View File

@ -260,6 +260,8 @@ public:
Optional<LLToolBarEnums::LayoutStyle> layout_style; // <FS:Zi> Add layout style parameter to XUI
Optional<LLToolBarEnums::Alignment> alignment; // <FS:Zi> Add alignment parameter to XUI
Optional<S32> max_rows; // <FS:Ansariel> FIRE-5137: Fix fixed size button layout
Params();
};
@ -345,6 +347,8 @@ private:
mPadBottom,
mPadBetween,
mMinGirth;
// <FS:Ansariel> FIRE-5137: Fix fixed size button layout
const S32 mMaxRows;
// drag and drop state
tool_startdrag_callback_t mStartDragItemCallback;

View File

@ -268,6 +268,7 @@
side="bottom"
follows="left|right|bottom"
button_display_mode="icons_with_text"
max_rows="2"
visible="true">
<icon layout="topleft"
height="28"

View File

@ -267,6 +267,7 @@
side="bottom"
follows="left|right|bottom"
button_display_mode="icons_with_text"
max_rows="2"
visible="true">
<icon layout="topleft"
height="28"

View File

@ -270,6 +270,7 @@
side="bottom"
follows="left|right|bottom"
button_display_mode="icons_with_text"
max_rows="2"
visible="true">
<icon layout="topleft"
height="28"

View File

@ -267,6 +267,7 @@
side="bottom"
follows="left|right|bottom"
button_display_mode="icons_with_text"
max_rows="2"
visible="true">
<icon layout="topleft"
height="28"

View File

@ -267,6 +267,7 @@
side="bottom"
follows="left|right|bottom"
button_display_mode="icons_with_text"
max_rows="2"
visible="true">
<icon layout="topleft"
height="28"