BOOL LLSlider::handleMouseDown(S32 x, S32 y, MASK mask) { // only do sticky-focus on non-chrome widgets if (!getIsChrome()) { setFocus(TRUE); } if (mMouseDownSignal) (*mMouseDownSignal)( this, getValueF32() ); if (MASK_CONTROL & mask) // if CTRL is modifying { setValueAndCommit(mInitialValue); } else { // Find the offset of the actual mouse location from the center of the thumb. if (mThumbRect.pointInRect(x,y)) { mMouseOffset = (mThumbRect.mLeft + mThumbImage->getWidth()/2) - x; } else { mMouseOffset = 0; } // Start dragging the thumb // No handler needed for focus lost since this class has no state that depends on it. gFocusMgr.setMouseCapture( this ); mDragStartThumbRect = mThumbRect; } make_ui_sound("UISndClick"); return TRUE; }
BOOL LLSlider::handleScrollWheel(S32 x, S32 y, S32 clicks) { if ( mOrientation == VERTICAL ) { F32 new_val = getValueF32() - clicks * getIncrement(); setValueAndCommit(new_val); return TRUE; } return LLF32UICtrl::handleScrollWheel(x,y,clicks); }
BOOL LLSlider::handleKeyHere(KEY key, MASK mask) { BOOL handled = FALSE; switch(key) { case KEY_DOWN: case KEY_LEFT: setValueAndCommit(getValueF32() - getIncrement()); handled = TRUE; break; case KEY_UP: case KEY_RIGHT: setValueAndCommit(getValueF32() + getIncrement()); handled = TRUE; break; default: break; } return handled; }
BOOL LLSlider::handleHover(S32 x, S32 y, MASK mask) { if( hasMouseCapture() ) { if ( mOrientation == HORIZONTAL ) { S32 thumb_half_width = mThumbImage->getWidth()/2; S32 left_edge = thumb_half_width; S32 right_edge = getRect().getWidth() - (thumb_half_width); x += mMouseOffset; x = llclamp( x, left_edge, right_edge ); F32 t = F32(x - left_edge) / (right_edge - left_edge); setValueAndCommit(t * (mMaxValue - mMinValue) + mMinValue ); } else // mOrientation == VERTICAL { S32 thumb_half_height = mThumbImage->getHeight()/2; S32 top_edge = thumb_half_height; S32 bottom_edge = getRect().getHeight() - (thumb_half_height); y += mMouseOffset; y = llclamp(y, top_edge, bottom_edge); F32 t = F32(y - top_edge) / (bottom_edge - top_edge); setValueAndCommit(t * (mMaxValue - mMinValue) + mMinValue ); } getWindow()->setCursor(UI_CURSOR_ARROW); LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (active)" << LL_ENDL; } else { getWindow()->setCursor(UI_CURSOR_ARROW); LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (inactive)" << LL_ENDL; } return TRUE; }
BOOL LLSlider::handleHover(S32 x, S32 y, MASK mask) { if( hasMouseCapture() ) { S32 thumb_half_width = mThumbImage->getWidth()/2; S32 left_edge = thumb_half_width; S32 right_edge = getRect().getWidth() - (thumb_half_width); x += mMouseOffset; x = llclamp( x, left_edge, right_edge ); F32 t = F32(x - left_edge) / (right_edge - left_edge); setValueAndCommit(t * (mMaxValue - mMinValue) + mMinValue ); getWindow()->setCursor(UI_CURSOR_ARROW); lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; } else { getWindow()->setCursor(UI_CURSOR_ARROW); lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; } return TRUE; }