Added an optional val_width to slider and multi_slider_bar. When using this be sure it isn't truncating, as setting this value sets the textbox to a fixed width, with no consideration to the actual value it can contain.

This commit is contained in:
Shyotl
2012-01-13 01:02:46 -06:00
parent ad3a16fd3b
commit c371b82900
3 changed files with 44 additions and 23 deletions

View File

@@ -543,22 +543,32 @@ LLView* LLMultiSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFa
S32 max_sliders = 1;
node->getAttributeS32("max_sliders", max_sliders);
S32 value_width = 0;
node->getAttributeS32("val_width", value_width);
S32 text_left = 0;
if (show_text)
{
// calculate the size of the text box (log max_value is number of digits - 1 so plus 1)
if ( max_value )
text_left = font->getWidth(std::string("0")) * ( static_cast < S32 > ( log10 ( max_value ) ) + precision + 1 );
if(value_width > 0)
{
//Fixed width. Be wary of precision and sign causing text to take more space than expected!
text_left = value_width;
}
else
{
// calculate the size of the text box (log max_value is number of digits - 1 so plus 1)
if ( max_value )
text_left = font->getWidth(std::string("0")) * ( static_cast < S32 > ( log10 ( max_value ) ) + precision + 1 );
if ( increment < 1.0f )
text_left += font->getWidth(std::string(".")); // (mostly) take account of decimal point in value
if ( increment < 1.0f )
text_left += font->getWidth(std::string(".")); // (mostly) take account of decimal point in value
if ( min_value < 0.0f || max_value < 0.0f )
text_left += font->getWidth(std::string("-")); // (mostly) take account of minus sign
if ( min_value < 0.0f || max_value < 0.0f )
text_left += font->getWidth(std::string("-")); // (mostly) take account of minus sign
// padding to make things look nicer
text_left += 8;
// padding to make things look nicer
text_left += 8;
}
}
LLUICtrlCallback callback = NULL;