From c585602380659ac2af054bba438d5b8e1300fcd9 Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Mon, 5 Oct 2015 14:58:53 +0300 Subject: [PATCH] Tuned constants in kinetic scroll and color of GPS area --- drape_frontend/kinetic_scroller.cpp | 20 +++++++++----- drape_frontend/my_position.cpp | 4 +-- drape_frontend/my_position_controller.cpp | 2 +- drape_frontend/user_event_stream.cpp | 33 +++++++++++------------ drape_frontend/user_event_stream.hpp | 8 +++--- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/drape_frontend/kinetic_scroller.cpp b/drape_frontend/kinetic_scroller.cpp index 2201bb6ab8..135e0ebe4f 100644 --- a/drape_frontend/kinetic_scroller.cpp +++ b/drape_frontend/kinetic_scroller.cpp @@ -12,9 +12,9 @@ double const kKineticDuration = 0.375; double const kKineticFeedbackStart = 0.1; double const kKineticFeedbackEnd = 0.5; double const kKineticFadeoff = 5.0; -double const kKineticThreshold = 10.0; -double const kKineticInertia = 0.8; -double const kKineticMaxSpeed = 2000.0; // pixels per second +double const kKineticThreshold = 50.0; +double const kKineticInertia = 0.5; +double const kKineticMaxSpeed = 1500.0; // pixels per second double CalculateKineticFeedback(ScreenBase const & modelView) { @@ -91,13 +91,19 @@ void KineticScroller::GrabViewRect(ScreenBase const & modelView, double timeStam double pxDeltaLength = (modelView.GtoP(currentCenter) - modelView.GtoP(lastCenter)).Length(); m2::PointD delta = (currentCenter - lastCenter); if (!delta.IsAlmostZero()) + { delta = delta.Normalize(); - // velocity on pixels - double v = min(pxDeltaLength / elapsed, kKineticMaxSpeed); + // velocity on pixels + double v = min(pxDeltaLength / elapsed, kKineticMaxSpeed); - // at this point length(m_direction) already in pixel space, and delta normalized - m_direction = delta * kKineticInertia * v + m_direction * (1.0 - kKineticInertia); + // at this point length(m_direction) already in pixel space, and delta normalized + m_direction = delta * kKineticInertia * v + m_direction * (1.0 - kKineticInertia); + } + else + { + m_direction = m2::PointD::Zero(); + } m_lastTimestamp = timeStamp; m_lastRect = modelView.GlobalRect(); diff --git a/drape_frontend/my_position.cpp b/drape_frontend/my_position.cpp index 23989aadbd..996edbd21a 100644 --- a/drape_frontend/my_position.cpp +++ b/drape_frontend/my_position.cpp @@ -118,12 +118,10 @@ void MyPosition::CacheAccuracySector(ref_ptr mng) float const etalonSector = math::twicePi / static_cast(TriangleCount); dp::TextureManager::ColorRegion color; - mng->GetColorRegion(dp::Color(0x51, 0xA3, 0xDC, 0x46), color); + mng->GetColorRegion(dp::Color(30, 150, 240, 20), color); glsl::vec2 colorCoord = glsl::ToVec2(color.GetTexRect().Center()); buffer_vector buffer; - //buffer.emplace_back(glsl::vec2(0.0f, 0.0f), colorCoord); - glsl::vec2 startNormal(0.0f, 1.0f); for (size_t i = 0; i < TriangleCount + 1; ++i) diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp index b61b6c6146..eb2d563653 100644 --- a/drape_frontend/my_position_controller.cpp +++ b/drape_frontend/my_position_controller.cpp @@ -14,7 +14,7 @@ namespace df namespace { -int const POSITION_Y_OFFSET = 120; +int const POSITION_Y_OFFSET = 75; double const GPS_BEARING_LIFETIME_S = 5.0; double const MIN_SPEED_THRESHOLD_MPS = 1.0; diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index 8691f89553..b8fd5e0d02 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -139,25 +139,25 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool & { case UserEvent::EVENT_SCALE: breakAnim = SetScale(e.m_scaleEvent.m_pxPoint, e.m_scaleEvent.m_factor, e.m_scaleEvent.m_isAnim); - TouchCancel(m_touches, 0.0); + TouchCancel(m_touches); break; case UserEvent::EVENT_RESIZE: m_navigator.OnSize(e.m_resize.m_width, e.m_resize.m_height); viewportChanged = true; breakAnim = true; - TouchCancel(m_touches, 0.0); + TouchCancel(m_touches); break; case UserEvent::EVENT_SET_ANY_RECT: breakAnim = SetRect(e.m_anyRect.m_rect, e.m_anyRect.m_isAnim); - TouchCancel(m_touches, 0.0); + TouchCancel(m_touches); break; case UserEvent::EVENT_SET_RECT: breakAnim = SetRect(e.m_rectEvent.m_rect, e.m_rectEvent.m_zoom, e.m_rectEvent.m_applyRotation, e.m_rectEvent.m_isAnim); - TouchCancel(m_touches, 0.0); + TouchCancel(m_touches); break; case UserEvent::EVENT_SET_CENTER: breakAnim = SetCenter(e.m_centerEvent.m_center, e.m_centerEvent.m_zoom, e.m_centerEvent.m_isAnim); - TouchCancel(m_touches, 0.0); + TouchCancel(m_touches); break; case UserEvent::EVENT_TOUCH: breakAnim = ProcessTouch(e.m_touchEvent); @@ -173,7 +173,7 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool & breakAnim = SetFollowAndRotate(e.m_followAndRotate.m_targetRect, e.m_followAndRotate.m_userPos, e.m_followAndRotate.m_newCenterOffset,e.m_followAndRotate.m_oldCenterOffset, e.m_followAndRotate.m_azimuth, e.m_followAndRotate.m_isAnim); - TouchCancel(m_touches, 0.0); + TouchCancel(m_touches); break; default: ASSERT(false, ()); @@ -338,16 +338,16 @@ bool UserEventStream::ProcessTouch(TouchEvent const & touch) switch (touchEvent.m_type) { case TouchEvent::TOUCH_DOWN: - isMapTouch |= TouchDown(touchEvent.m_touches, touch.m_timeStamp); + isMapTouch |= TouchDown(touchEvent.m_touches); break; case TouchEvent::TOUCH_MOVE: isMapTouch |= TouchMove(touchEvent.m_touches, touch.m_timeStamp); break; case TouchEvent::TOUCH_CANCEL: - isMapTouch |= TouchCancel(touchEvent.m_touches, touch.m_timeStamp); + isMapTouch |= TouchCancel(touchEvent.m_touches); break; case TouchEvent::TOUCH_UP: - isMapTouch |= TouchUp(touchEvent.m_touches, touch.m_timeStamp); + isMapTouch |= TouchUp(touchEvent.m_touches); break; default: ASSERT(false, ()); @@ -357,7 +357,7 @@ bool UserEventStream::ProcessTouch(TouchEvent const & touch) return isMapTouch; } -bool UserEventStream::TouchDown(array const & touches, double timestamp) +bool UserEventStream::TouchDown(array const & touches) { size_t touchCount = GetValidTouchesCount(touches); bool isMapTouch = true; @@ -392,7 +392,7 @@ bool UserEventStream::TouchDown(array const & touches, double timestam CancelTapDetector(); break; case STATE_DRAG: - isMapTouch = EndDrag(touches[0], timestamp, true /* cancelled */); + isMapTouch = EndDrag(touches[0], true /* cancelled */); break; default: break; @@ -445,7 +445,7 @@ bool UserEventStream::TouchMove(array const & touches, double timestam return isMapTouch; } -bool UserEventStream::TouchCancel(array const & touches, double timestamp) +bool UserEventStream::TouchCancel(array const & touches) { size_t touchCount = GetValidTouchesCount(touches); bool isMapTouch = true; @@ -466,7 +466,7 @@ bool UserEventStream::TouchCancel(array const & touches, double timest break; case STATE_DRAG: ASSERT_EQUAL(touchCount, 1, ()); - isMapTouch = EndDrag(touches[0], timestamp, true /* cancelled */); + isMapTouch = EndDrag(touches[0], true /* cancelled */); break; case STATE_SCALE: ASSERT_EQUAL(touchCount, 2, ()); @@ -480,7 +480,7 @@ bool UserEventStream::TouchCancel(array const & touches, double timest return isMapTouch; } -bool UserEventStream::TouchUp(array const & touches, double timestamp) +bool UserEventStream::TouchUp(array const & touches) { size_t touchCount = GetValidTouchesCount(touches); bool isMapTouch = true; @@ -501,7 +501,7 @@ bool UserEventStream::TouchUp(array const & touches, double timestamp) break; case STATE_DRAG: ASSERT_EQUAL(touchCount, 1, ()); - isMapTouch = EndDrag(touches[0], timestamp, false /* cancelled */); + isMapTouch = EndDrag(touches[0], false /* cancelled */); break; case STATE_SCALE: ASSERT_EQUAL(touchCount, 2, ()); @@ -545,7 +545,7 @@ void UserEventStream::Drag(Touch const & t, double timestamp) m_scroller.GrabViewRect(m_navigator.Screen(), timestamp); } -bool UserEventStream::EndDrag(Touch const & t, double timestamp, bool cancelled) +bool UserEventStream::EndDrag(Touch const & t, bool cancelled) { TEST_CALL(END_DRAG); ASSERT_EQUAL(m_state, STATE_DRAG, ()); @@ -564,7 +564,6 @@ bool UserEventStream::EndDrag(Touch const & t, double timestamp, bool cancelled) if (m_kineticTimer.TimeElapsedAs().count() >= kKineticDelayMs) { - m_scroller.GrabViewRect(m_navigator.Screen(), timestamp); m_animation = m_scroller.CreateKineticAnimation(m_navigator.Screen()); m_scroller.CancelGrab(); return false; diff --git a/drape_frontend/user_event_stream.hpp b/drape_frontend/user_event_stream.hpp index 1d1259b998..311f475944 100644 --- a/drape_frontend/user_event_stream.hpp +++ b/drape_frontend/user_event_stream.hpp @@ -261,16 +261,16 @@ private: bool ProcessTouch(TouchEvent const & touch); - bool TouchDown(array const & touches, double timestamp); + bool TouchDown(array const & touches); bool TouchMove(array const & touches, double timestamp); - bool TouchCancel(array const & touches, double timestamp); - bool TouchUp(array const & touches, double timestamp); + bool TouchCancel(array const & touches); + bool TouchUp(array const & touches); void UpdateTouches(array const & touches); void BeginDrag(Touch const & t, double timestamp); void Drag(Touch const & t, double timestamp); // EndDrag returns false in case of kinetic moving after dragging has begun. - bool EndDrag(Touch const & t, double timestamp, bool cancelled); + bool EndDrag(Touch const & t, bool cancelled); void BeginScale(Touch const & t1, Touch const & t2); void Scale(Touch const & t1, Touch const & t2);