diff options
author | Jacek Antonelli | 2008-09-06 18:24:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-09-06 18:25:07 -0500 |
commit | 798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch) | |
tree | 1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llui/llsliderctrl.cpp | |
parent | Second Life viewer sources 1.20.15 (diff) | |
download | meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2 meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz |
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llui/llsliderctrl.cpp')
-rw-r--r-- | linden/indra/llui/llsliderctrl.cpp | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/linden/indra/llui/llsliderctrl.cpp b/linden/indra/llui/llsliderctrl.cpp index d3dc35f..a47f133 100644 --- a/linden/indra/llui/llsliderctrl.cpp +++ b/linden/indra/llui/llsliderctrl.cpp | |||
@@ -34,7 +34,6 @@ | |||
34 | #include "llsliderctrl.h" | 34 | #include "llsliderctrl.h" |
35 | 35 | ||
36 | #include "audioengine.h" | 36 | #include "audioengine.h" |
37 | #include "sound_ids.h" | ||
38 | 37 | ||
39 | #include "llmath.h" | 38 | #include "llmath.h" |
40 | #include "llfontgl.h" | 39 | #include "llfontgl.h" |
@@ -54,8 +53,8 @@ const U32 MAX_STRING_LENGTH = 10; | |||
54 | 53 | ||
55 | static LLRegisterWidget<LLSliderCtrl> r("slider"); | 54 | static LLRegisterWidget<LLSliderCtrl> r("slider"); |
56 | 55 | ||
57 | LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, | 56 | LLSliderCtrl::LLSliderCtrl(const std::string& name, const LLRect& rect, |
58 | const LLString& label, | 57 | const std::string& label, |
59 | const LLFontGL* font, | 58 | const LLFontGL* font, |
60 | S32 label_width, | 59 | S32 label_width, |
61 | S32 text_left, | 60 | S32 text_left, |
@@ -65,7 +64,7 @@ LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, | |||
65 | void (*commit_callback)(LLUICtrl*, void*), | 64 | void (*commit_callback)(LLUICtrl*, void*), |
66 | void* callback_user_data, | 65 | void* callback_user_data, |
67 | F32 initial_value, F32 min_value, F32 max_value, F32 increment, | 66 | F32 initial_value, F32 min_value, F32 max_value, F32 increment, |
68 | const LLString& control_which) | 67 | const std::string& control_which) |
69 | : LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data ), | 68 | : LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data ), |
70 | mFont(font), | 69 | mFont(font), |
71 | mShowText( show_text ), | 70 | mShowText( show_text ), |
@@ -94,7 +93,7 @@ LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, | |||
94 | label_width = font->getWidth(label); | 93 | label_width = font->getWidth(label); |
95 | } | 94 | } |
96 | LLRect label_rect( left, top, label_width, bottom ); | 95 | LLRect label_rect( left, top, label_width, bottom ); |
97 | mLabelBox = new LLTextBox( "SliderCtrl Label", label_rect, label.c_str(), font ); | 96 | mLabelBox = new LLTextBox( std::string("SliderCtrl Label"), label_rect, label, font ); |
98 | addChild(mLabelBox); | 97 | addChild(mLabelBox); |
99 | } | 98 | } |
100 | 99 | ||
@@ -106,12 +105,11 @@ LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, | |||
106 | 105 | ||
107 | S32 slider_left = label_width ? label_width + SLIDERCTRL_SPACING : 0; | 106 | S32 slider_left = label_width ? label_width + SLIDERCTRL_SPACING : 0; |
108 | LLRect slider_rect( slider_left, top, slider_right, bottom ); | 107 | LLRect slider_rect( slider_left, top, slider_right, bottom ); |
109 | mSlider = new LLSlider( | 108 | mSlider = new LLSlider(std::string("slider"), |
110 | "slider", | 109 | slider_rect, |
111 | slider_rect, | 110 | LLSliderCtrl::onSliderCommit, this, |
112 | LLSliderCtrl::onSliderCommit, this, | 111 | initial_value, min_value, max_value, increment, volume, |
113 | initial_value, min_value, max_value, increment, volume, | 112 | control_which ); |
114 | control_which ); | ||
115 | addChild( mSlider ); | 113 | addChild( mSlider ); |
116 | 114 | ||
117 | if( show_text ) | 115 | if( show_text ) |
@@ -119,11 +117,11 @@ LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, | |||
119 | LLRect text_rect( text_left, top, getRect().getWidth(), bottom ); | 117 | LLRect text_rect( text_left, top, getRect().getWidth(), bottom ); |
120 | if( can_edit_text ) | 118 | if( can_edit_text ) |
121 | { | 119 | { |
122 | mEditor = new LLLineEditor( "SliderCtrl Editor", text_rect, | 120 | mEditor = new LLLineEditor( std::string("SliderCtrl Editor"), text_rect, |
123 | "", font, | 121 | LLStringUtil::null, font, |
124 | MAX_STRING_LENGTH, | 122 | MAX_STRING_LENGTH, |
125 | &LLSliderCtrl::onEditorCommit, NULL, NULL, this, | 123 | &LLSliderCtrl::onEditorCommit, NULL, NULL, this, |
126 | &LLLineEditor::prevalidateFloat ); | 124 | &LLLineEditor::prevalidateFloat ); |
127 | mEditor->setFollowsLeft(); | 125 | mEditor->setFollowsLeft(); |
128 | mEditor->setFollowsBottom(); | 126 | mEditor->setFollowsBottom(); |
129 | mEditor->setFocusReceivedCallback( &LLSliderCtrl::onEditorGainFocus, this ); | 127 | mEditor->setFocusReceivedCallback( &LLSliderCtrl::onEditorGainFocus, this ); |
@@ -135,7 +133,7 @@ LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, | |||
135 | } | 133 | } |
136 | else | 134 | else |
137 | { | 135 | { |
138 | mTextBox = new LLTextBox( "SliderCtrl Text", text_rect, "", font); | 136 | mTextBox = new LLTextBox( std::string("SliderCtrl Text"), text_rect, LLStringUtil::null, font); |
139 | mTextBox->setFollowsLeft(); | 137 | mTextBox->setFollowsLeft(); |
140 | mTextBox->setFollowsBottom(); | 138 | mTextBox->setFollowsBottom(); |
141 | addChild(mTextBox); | 139 | addChild(mTextBox); |
@@ -163,7 +161,7 @@ void LLSliderCtrl::setValue(F32 v, BOOL from_event) | |||
163 | updateText(); | 161 | updateText(); |
164 | } | 162 | } |
165 | 163 | ||
166 | BOOL LLSliderCtrl::setLabelArg( const LLString& key, const LLStringExplicit& text ) | 164 | BOOL LLSliderCtrl::setLabelArg( const std::string& key, const LLStringExplicit& text ) |
167 | { | 165 | { |
168 | BOOL res = FALSE; | 166 | BOOL res = FALSE; |
169 | if (mLabelBox) | 167 | if (mLabelBox) |
@@ -193,11 +191,11 @@ void LLSliderCtrl::clear() | |||
193 | setValue(0.0f); | 191 | setValue(0.0f); |
194 | if( mEditor ) | 192 | if( mEditor ) |
195 | { | 193 | { |
196 | mEditor->setText( LLString::null ); | 194 | mEditor->setText( LLStringUtil::null ); |
197 | } | 195 | } |
198 | if( mTextBox ) | 196 | if( mTextBox ) |
199 | { | 197 | { |
200 | mTextBox->setText( LLString::null ); | 198 | mTextBox->setText( LLStringUtil::null ); |
201 | } | 199 | } |
202 | 200 | ||
203 | } | 201 | } |
@@ -211,8 +209,8 @@ void LLSliderCtrl::updateText() | |||
211 | // Don't display very small negative values as -0.000 | 209 | // Don't display very small negative values as -0.000 |
212 | F32 displayed_value = (F32)(floor(getValueF32() * pow(10.0, (F64)mPrecision) + 0.5) / pow(10.0, (F64)mPrecision)); | 210 | F32 displayed_value = (F32)(floor(getValueF32() * pow(10.0, (F64)mPrecision) + 0.5) / pow(10.0, (F64)mPrecision)); |
213 | 211 | ||
214 | LLString format = llformat("%%.%df", mPrecision); | 212 | std::string format = llformat("%%.%df", mPrecision); |
215 | LLString text = llformat(format.c_str(), displayed_value); | 213 | std::string text = llformat(format.c_str(), displayed_value); |
216 | if( mEditor ) | 214 | if( mEditor ) |
217 | { | 215 | { |
218 | mEditor->setText( text ); | 216 | mEditor->setText( text ); |
@@ -234,7 +232,7 @@ void LLSliderCtrl::onEditorCommit( LLUICtrl* caller, void *userdata ) | |||
234 | F32 val = self->mValue; | 232 | F32 val = self->mValue; |
235 | F32 saved_val = self->mValue; | 233 | F32 saved_val = self->mValue; |
236 | 234 | ||
237 | LLString text = self->mEditor->getText(); | 235 | std::string text = self->mEditor->getText(); |
238 | if( LLLineEditor::postvalidateFloat( text ) ) | 236 | if( LLLineEditor::postvalidateFloat( text ) ) |
239 | { | 237 | { |
240 | LLLocale locale(LLLocale::USER_LOCALE); | 238 | LLLocale locale(LLLocale::USER_LOCALE); |
@@ -451,10 +449,10 @@ LLXMLNodePtr LLSliderCtrl::getXML(bool save_children) const | |||
451 | 449 | ||
452 | LLView* LLSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) | 450 | LLView* LLSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) |
453 | { | 451 | { |
454 | LLString name("slider"); | 452 | std::string name("slider"); |
455 | node->getAttributeString("name", name); | 453 | node->getAttributeString("name", name); |
456 | 454 | ||
457 | LLString label; | 455 | std::string label; |
458 | node->getAttributeString("label", label); | 456 | node->getAttributeString("label", label); |
459 | 457 | ||
460 | LLRect rect; | 458 | LLRect rect; |
@@ -500,13 +498,13 @@ LLView* LLSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory | |||
500 | { | 498 | { |
501 | // calculate the size of the text box (log max_value is number of digits - 1 so plus 1) | 499 | // calculate the size of the text box (log max_value is number of digits - 1 so plus 1) |
502 | if ( max_value ) | 500 | if ( max_value ) |
503 | text_left = font->getWidth("0") * ( static_cast < S32 > ( log10 ( max_value ) ) + precision + 1 ); | 501 | text_left = font->getWidth(std::string("0")) * ( static_cast < S32 > ( log10 ( max_value ) ) + precision + 1 ); |
504 | 502 | ||
505 | if ( increment < 1.0f ) | 503 | if ( increment < 1.0f ) |
506 | text_left += font->getWidth("."); // (mostly) take account of decimal point in value | 504 | text_left += font->getWidth(std::string(".")); // (mostly) take account of decimal point in value |
507 | 505 | ||
508 | if ( min_value < 0.0f || max_value < 0.0f ) | 506 | if ( min_value < 0.0f || max_value < 0.0f ) |
509 | text_left += font->getWidth("-"); // (mostly) take account of minus sign | 507 | text_left += font->getWidth(std::string("-")); // (mostly) take account of minus sign |
510 | 508 | ||
511 | // padding to make things look nicer | 509 | // padding to make things look nicer |
512 | text_left += 8; | 510 | text_left += 8; |