diff options
author | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
commit | ce28e056c20bf2723f565bbf464b87781ec248a2 (patch) | |
tree | ef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/llui/llslider.cpp | |
parent | Second Life viewer sources 1.19.1.4b (diff) | |
download | meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2 meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz |
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/llui/llslider.cpp')
-rw-r--r-- | linden/indra/llui/llslider.cpp | 134 |
1 files changed, 54 insertions, 80 deletions
diff --git a/linden/indra/llui/llslider.cpp b/linden/indra/llui/llslider.cpp index 02841ee..12d794c 100644 --- a/linden/indra/llui/llslider.cpp +++ b/linden/indra/llui/llslider.cpp | |||
@@ -41,6 +41,10 @@ | |||
41 | #include "llcontrol.h" | 41 | #include "llcontrol.h" |
42 | #include "llimagegl.h" | 42 | #include "llimagegl.h" |
43 | 43 | ||
44 | static LLRegisterWidget<LLSlider> r1("slider_bar"); | ||
45 | static LLRegisterWidget<LLSlider> r2("volume_slider"); | ||
46 | |||
47 | |||
44 | LLSlider::LLSlider( | 48 | LLSlider::LLSlider( |
45 | const LLString& name, | 49 | const LLString& name, |
46 | const LLRect& rect, | 50 | const LLRect& rect, |
@@ -68,9 +72,9 @@ LLSlider::LLSlider( | |||
68 | mMouseDownCallback( NULL ), | 72 | mMouseDownCallback( NULL ), |
69 | mMouseUpCallback( NULL ) | 73 | mMouseUpCallback( NULL ) |
70 | { | 74 | { |
71 | mThumbImage = LLUI::sImageProvider->getImageByID(LLUUID(LLUI::sAssetsGroup->getString("icn_slide-thumb_dark.tga"))); | 75 | mThumbImage = LLUI::sImageProvider->getUIImage("icn_slide-thumb_dark.tga"); |
72 | mTrackImage = LLUI::sImageProvider->getImageByID(LLUUID(LLUI::sAssetsGroup->getString("icn_slide-groove_dark.tga"))); | 76 | mTrackImage = LLUI::sImageProvider->getUIImage("icn_slide-groove_dark.tga"); |
73 | mTrackHighlightImage = LLUI::sImageProvider->getImageByID(LLUUID(LLUI::sAssetsGroup->getString("icn_slide-highlight.tga"))); | 77 | mTrackHighlightImage = LLUI::sImageProvider->getUIImage("icn_slide-highlight.tga"); |
74 | 78 | ||
75 | // properly handle setting the starting thumb rect | 79 | // properly handle setting the starting thumb rect |
76 | // do it this way to handle both the operating-on-settings | 80 | // do it this way to handle both the operating-on-settings |
@@ -217,98 +221,68 @@ BOOL LLSlider::handleMouseDown(S32 x, S32 y, MASK mask) | |||
217 | return TRUE; | 221 | return TRUE; |
218 | } | 222 | } |
219 | 223 | ||
220 | BOOL LLSlider::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) | 224 | BOOL LLSlider::handleKeyHere(KEY key, MASK mask) |
221 | { | 225 | { |
222 | BOOL handled = FALSE; | 226 | BOOL handled = FALSE; |
223 | if( getVisible() && getEnabled() && !called_from_parent ) | 227 | switch(key) |
224 | { | 228 | { |
225 | switch(key) | 229 | case KEY_UP: |
226 | { | 230 | case KEY_DOWN: |
227 | case KEY_UP: | 231 | // eat up and down keys to be consistent |
228 | case KEY_DOWN: | 232 | handled = TRUE; |
229 | // eat up and down keys to be consistent | 233 | break; |
230 | handled = TRUE; | 234 | case KEY_LEFT: |
231 | break; | 235 | setValueAndCommit(getValueF32() - getIncrement()); |
232 | case KEY_LEFT: | 236 | handled = TRUE; |
233 | setValueAndCommit(getValueF32() - getIncrement()); | 237 | break; |
234 | handled = TRUE; | 238 | case KEY_RIGHT: |
235 | break; | 239 | setValueAndCommit(getValueF32() + getIncrement()); |
236 | case KEY_RIGHT: | 240 | handled = TRUE; |
237 | setValueAndCommit(getValueF32() + getIncrement()); | 241 | break; |
238 | handled = TRUE; | 242 | default: |
239 | break; | 243 | break; |
240 | default: | ||
241 | break; | ||
242 | } | ||
243 | } | 244 | } |
244 | return handled; | 245 | return handled; |
245 | } | 246 | } |
246 | 247 | ||
247 | void LLSlider::draw() | 248 | void LLSlider::draw() |
248 | { | 249 | { |
249 | if( getVisible() ) | 250 | // since thumb image might still be decoding, need thumb to accomodate image size |
250 | { | 251 | updateThumbRect(); |
251 | // since thumb image might still be decoding, need thumb to accomodate image size | ||
252 | updateThumbRect(); | ||
253 | |||
254 | // Draw background and thumb. | ||
255 | |||
256 | // drawing solids requires texturing be disabled | ||
257 | LLGLSNoTexture no_texture; | ||
258 | |||
259 | LLRect rect(mDragStartThumbRect); | ||
260 | |||
261 | F32 opacity = getEnabled() ? 1.f : 0.3f; | ||
262 | LLColor4 center_color = (mThumbCenterColor % opacity); | ||
263 | LLColor4 track_color = (mTrackColor % opacity); | ||
264 | |||
265 | // Track | ||
266 | LLRect track_rect(mThumbImage->getWidth() / 2, | ||
267 | getLocalRect().getCenterY() + (mTrackImage->getHeight() / 2), | ||
268 | getRect().getWidth() - mThumbImage->getWidth() / 2, | ||
269 | getLocalRect().getCenterY() - (mTrackImage->getHeight() / 2) ); | ||
270 | |||
271 | gl_draw_scaled_image_with_border(track_rect.mLeft, track_rect.mBottom, 3, 3, track_rect.getWidth(), track_rect.getHeight(), | ||
272 | mTrackImage, track_color); | ||
273 | gl_draw_scaled_image_with_border(track_rect.mLeft, track_rect.mBottom, 3, 3, mThumbRect.mLeft, track_rect.getHeight(), | ||
274 | mTrackHighlightImage, track_color); | ||
275 | 252 | ||
253 | // Draw background and thumb. | ||
276 | 254 | ||
277 | // Thumb | 255 | // drawing solids requires texturing be disabled |
278 | if( hasMouseCapture() ) | 256 | LLGLSNoTexture no_texture; |
279 | { | ||
280 | gl_draw_scaled_image(mDragStartThumbRect.mLeft, mDragStartThumbRect.mBottom, mDragStartThumbRect.getWidth(), mDragStartThumbRect.getHeight(), | ||
281 | mThumbImage, mThumbCenterColor % 0.3f); | ||
282 | 257 | ||
283 | if (hasFocus()) | 258 | F32 opacity = getEnabled() ? 1.f : 0.3f; |
284 | { | 259 | LLColor4 center_color = (mThumbCenterColor % opacity); |
285 | F32 lerp_amt = gFocusMgr.getFocusFlashAmt(); | 260 | LLColor4 track_color = (mTrackColor % opacity); |
286 | LLRect highlight_rect = mThumbRect; | ||
287 | highlight_rect.stretch(llround(lerp(1.f, 3.f, lerp_amt))); | ||
288 | gl_draw_scaled_image_with_border(highlight_rect.mLeft, highlight_rect.mBottom, 0, 0, highlight_rect.getWidth(), highlight_rect.getHeight(), | ||
289 | mThumbImage, gFocusMgr.getFocusColor(), TRUE); | ||
290 | } | ||
291 | 261 | ||
292 | gl_draw_scaled_image(mThumbRect.mLeft, mThumbRect.mBottom, mThumbRect.getWidth(), mThumbRect.getHeight(), | 262 | // Track |
293 | mThumbImage, mThumbOutlineColor); | 263 | LLRect track_rect(mThumbImage->getWidth() / 2, |
264 | getLocalRect().getCenterY() + (mTrackImage->getHeight() / 2), | ||
265 | getRect().getWidth() - mThumbImage->getWidth() / 2, | ||
266 | getLocalRect().getCenterY() - (mTrackImage->getHeight() / 2) ); | ||
267 | LLRect highlight_rect(track_rect.mLeft, track_rect.mTop, mThumbRect.getCenterX(), track_rect.mBottom); | ||
268 | mTrackImage->draw(track_rect); | ||
269 | mTrackHighlightImage->draw(highlight_rect); | ||
294 | 270 | ||
295 | } | 271 | // Thumb |
296 | else | 272 | if( hasMouseCapture() ) |
297 | { | 273 | { |
298 | if (hasFocus()) | 274 | // Show ghost where thumb was before dragging began. |
299 | { | 275 | mThumbImage->draw(mDragStartThumbRect, mThumbCenterColor % 0.3f); |
300 | F32 lerp_amt = gFocusMgr.getFocusFlashAmt(); | ||
301 | LLRect highlight_rect = mThumbRect; | ||
302 | highlight_rect.stretch(llround(lerp(1.f, 3.f, lerp_amt))); | ||
303 | gl_draw_scaled_image_with_border(highlight_rect.mLeft, highlight_rect.mBottom, 0, 0, highlight_rect.getWidth(), highlight_rect.getHeight(), | ||
304 | mThumbImage, gFocusMgr.getFocusColor(), TRUE); | ||
305 | } | ||
306 | |||
307 | gl_draw_scaled_image(mThumbRect.mLeft, mThumbRect.mBottom, mThumbRect.getWidth(), mThumbRect.getHeight(), | ||
308 | mThumbImage, center_color); | ||
309 | } | ||
310 | LLUICtrl::draw(); | ||
311 | } | 276 | } |
277 | if (hasFocus()) | ||
278 | { | ||
279 | // Draw focus highlighting. | ||
280 | mThumbImage->drawBorder(mThumbRect, gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth()); | ||
281 | } | ||
282 | // Fill in the thumb. | ||
283 | mThumbImage->draw(mThumbRect, hasMouseCapture() ? mThumbOutlineColor : center_color); | ||
284 | |||
285 | LLUICtrl::draw(); | ||
312 | } | 286 | } |
313 | 287 | ||
314 | // virtual | 288 | // virtual |