From 9382433931a9266bafa8dcd797d6f98cb80a7eaf Mon Sep 17 00:00:00 2001 From: Andrew Dyukov Date: Tue, 8 Jun 2010 23:02:54 +0300 Subject: EXT-5629 FIXED Made sensitivity of +/- zoom buttons from camera floater consistent with viewer 1.23 - Changed actions happening when minus or plus are held- now onSliderValueChanged() is not used for zoom via buttons. Zooming in and out now happens as it did in 1.23 in LLJoystickCameraZoom::onHeldDown(), but only "Zoom in slow" and Zoom out slow" were borrowed from there, because fast versions are not needed- they do not happen in 1.23. - Removed LLJoystickCameraZoom class, because it's not used anywhere. If need for it ever rises, it can be easily restored. Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/530/ --HG-- branch : product-engine --- indra/newview/llfloatercamera.cpp | 33 ++++++-- indra/newview/llfloatercamera.h | 1 - indra/newview/lljoystickbutton.cpp | 153 ------------------------------------- indra/newview/lljoystickbutton.h | 40 ---------- 4 files changed, 25 insertions(+), 202 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index ca346138fb..d6effb2b21 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -49,6 +49,9 @@ static LLDefaultChildRegistry::Register r("panel_camera_item"); +const F32 NUDGE_TIME = 0.25f; // in seconds +const F32 ORBIT_NUDGE_RATE = 0.05f; // fraction of normal speed + // Constants const F32 CAMERA_BUTTON_DELAY = 0.0f; @@ -75,6 +78,7 @@ protected: void onZoomPlusHeldDown(); void onZoomMinusHeldDown(); void onSliderValueChanged(); + F32 getOrbitRate(F32 time); private: LLButton* mPlusBtn; @@ -155,8 +159,8 @@ LLPanelCameraZoom::LLPanelCameraZoom() mMinusBtn( NULL ), mSlider( NULL ) { - mCommitCallbackRegistrar.add("Zoom.minus", boost::bind(&LLPanelCameraZoom::onZoomPlusHeldDown, this)); - mCommitCallbackRegistrar.add("Zoom.plus", boost::bind(&LLPanelCameraZoom::onZoomMinusHeldDown, this)); + mCommitCallbackRegistrar.add("Zoom.minus", boost::bind(&LLPanelCameraZoom::onZoomMinusHeldDown, this)); + mCommitCallbackRegistrar.add("Zoom.plus", boost::bind(&LLPanelCameraZoom::onZoomPlusHeldDown, this)); mCommitCallbackRegistrar.add("Slider.value_changed", boost::bind(&LLPanelCameraZoom::onSliderValueChanged, this)); } @@ -179,9 +183,9 @@ void LLPanelCameraZoom::onZoomPlusHeldDown() F32 val = mSlider->getValueF32(); F32 inc = mSlider->getIncrement(); mSlider->setValue(val - inc); - // commit only if value changed - if (val != mSlider->getValueF32()) - mSlider->onCommit(); + F32 time = mPlusBtn->getHeldDownTime(); + gAgentCamera.unlockView(); + gAgentCamera.setOrbitInKey(getOrbitRate(time)); } void LLPanelCameraZoom::onZoomMinusHeldDown() @@ -189,9 +193,22 @@ void LLPanelCameraZoom::onZoomMinusHeldDown() F32 val = mSlider->getValueF32(); F32 inc = mSlider->getIncrement(); mSlider->setValue(val + inc); - // commit only if value changed - if (val != mSlider->getValueF32()) - mSlider->onCommit(); + F32 time = mMinusBtn->getHeldDownTime(); + gAgentCamera.unlockView(); + gAgentCamera.setOrbitOutKey(getOrbitRate(time)); +} + +F32 LLPanelCameraZoom::getOrbitRate(F32 time) +{ + if( time < NUDGE_TIME ) + { + F32 rate = ORBIT_NUDGE_RATE + time * (1 - ORBIT_NUDGE_RATE)/ NUDGE_TIME; + return rate; + } + else + { + return 1; + } } void LLPanelCameraZoom::onSliderValueChanged() diff --git a/indra/newview/llfloatercamera.h b/indra/newview/llfloatercamera.h index 8fa7a53996..564e38d02d 100644 --- a/indra/newview/llfloatercamera.h +++ b/indra/newview/llfloatercamera.h @@ -39,7 +39,6 @@ #include "llflatlistview.h" class LLJoystickCameraRotate; -class LLJoystickCameraZoom; class LLJoystickCameraTrack; class LLFloaterReg; class LLPanelCameraZoom; diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index 9e1dc3a4b0..c2a1923dfe 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -53,7 +53,6 @@ static LLDefaultChildRegistry::Register r1("joystick_slide"); static LLDefaultChildRegistry::Register r2("joystick_turn"); static LLDefaultChildRegistry::Register r3("joystick_rotate"); -static LLDefaultChildRegistry::Register r4("joystick_zoom"); static LLDefaultChildRegistry::Register r5("joystick_track"); @@ -647,155 +646,3 @@ void LLJoystickCameraTrack::onHeldDown() gAgentCamera.setPanDownKey(getOrbitRate()); } } - - - -//------------------------------------------------------------------------------- -// LLJoystickCameraZoom -//------------------------------------------------------------------------------- - -LLJoystickCameraZoom::LLJoystickCameraZoom(const LLJoystickCameraZoom::Params& p) -: LLJoystick(p), - mInTop( FALSE ), - mInBottom( FALSE ), - mPlusInImage(p.plus_image), - mMinusInImage(p.minus_image) -{ -} - -BOOL LLJoystickCameraZoom::handleMouseDown(S32 x, S32 y, MASK mask) -{ - BOOL handled = LLJoystick::handleMouseDown(x, y, mask); - - if( handled ) - { - if (mFirstMouse.mY > getRect().getHeight() / 2) - { - mInitialQuadrant = JQ_UP; - } - else - { - mInitialQuadrant = JQ_DOWN; - } - } - return handled; -} - - -void LLJoystickCameraZoom::onHeldDown() -{ - updateSlop(); - - const F32 FAST_RATE = 2.5f; // two and a half times the normal rate - - S32 dy = mLastMouse.mY - mFirstMouse.mY + mInitialOffset.mY; - - if (dy > mVertSlopFar) - { - // Zoom in fast - gAgentCamera.unlockView(); - gAgentCamera.setOrbitInKey(FAST_RATE); - } - else if (dy > mVertSlopNear) - { - // Zoom in slow - gAgentCamera.unlockView(); - gAgentCamera.setOrbitInKey(getOrbitRate()); - } - else if (dy < -mVertSlopFar) - { - // Zoom out fast - gAgentCamera.unlockView(); - gAgentCamera.setOrbitOutKey(FAST_RATE); - } - else if (dy < -mVertSlopNear) - { - // Zoom out slow - gAgentCamera.unlockView(); - gAgentCamera.setOrbitOutKey(getOrbitRate()); - } -} - -// Only used for drawing -void LLJoystickCameraZoom::setToggleState( BOOL top, BOOL bottom ) -{ - mInTop = top; - mInBottom = bottom; -} - -void LLJoystickCameraZoom::draw() -{ - if( mInTop ) - { - mPlusInImage->draw(0,0); - } - else - if( mInBottom ) - { - mMinusInImage->draw(0,0); - } - else - { - getImageUnselected()->draw( 0, 0 ); - } -} - -void LLJoystickCameraZoom::updateSlop() -{ - mVertSlopNear = getRect().getHeight() / 4; - mVertSlopFar = getRect().getHeight() / 2; - - mHorizSlopNear = getRect().getWidth() / 4; - mHorizSlopFar = getRect().getWidth() / 2; - - // Compute initial mouse offset based on initial quadrant. - // Place the mouse evenly between the near and far zones. - switch (mInitialQuadrant) - { - case JQ_ORIGIN: - mInitialOffset.set(0, 0); - break; - - case JQ_UP: - mInitialOffset.mX = 0; - mInitialOffset.mY = (mVertSlopNear + mVertSlopFar) / 2; - break; - - case JQ_DOWN: - mInitialOffset.mX = 0; - mInitialOffset.mY = - (mVertSlopNear + mVertSlopFar) / 2; - break; - - case JQ_LEFT: - mInitialOffset.mX = - (mHorizSlopNear + mHorizSlopFar) / 2; - mInitialOffset.mY = 0; - break; - - case JQ_RIGHT: - mInitialOffset.mX = (mHorizSlopNear + mHorizSlopFar) / 2; - mInitialOffset.mY = 0; - break; - - default: - llerrs << "LLJoystick::LLJoystick() - bad switch case" << llendl; - break; - } - - return; -} - - -F32 LLJoystickCameraZoom::getOrbitRate() -{ - F32 time = getElapsedHeldDownTime(); - if( time < NUDGE_TIME ) - { - F32 rate = ORBIT_NUDGE_RATE + time * (1 - ORBIT_NUDGE_RATE)/ NUDGE_TIME; -// llinfos << "rate " << rate << " time " << time << llendl; - return rate; - } - else - { - return 1; - } -} diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h index 2b071a8999..1dd30036ab 100644 --- a/indra/newview/lljoystickbutton.h +++ b/indra/newview/lljoystickbutton.h @@ -183,44 +183,4 @@ public: virtual void onHeldDown(); }; - -// Zoom the camera in and out -class LLJoystickCameraZoom -: public LLJoystick -{ -public: - struct Params - : public LLInitParam::Block - { - Optional plus_image; - Optional minus_image; - - Params() - : plus_image ("plus_image", NULL), - minus_image ("minus_image", NULL) - { - held_down_delay.seconds(0.0); - } - }; - LLJoystickCameraZoom(const Params&); - - virtual void setToggleState( BOOL top, BOOL bottom ); - - virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); - virtual void onHeldDown(); - virtual void draw(); - -protected: - virtual void updateSlop(); - F32 getOrbitRate(); - -protected: - BOOL mInTop; - BOOL mInBottom; - LLUIImagePtr mPlusInImage; - LLUIImagePtr mMinusInImage; -}; - - - #endif // LL_LLJOYSTICKBUTTON_H -- cgit v1.2.3