diff --git a/map/framework.hpp b/map/framework.hpp index 2da94da193..437219b2b0 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -100,6 +100,9 @@ class FrameWork m2::PointD m_position; double m_confidenceRadius; + /// is AddRedrawCommand enabled? + bool m_isRedrawEnabled; + void Invalidate() { m_windowHandle->invalidate(); @@ -113,7 +116,7 @@ class FrameWork void AddRedrawCommand() { yg::gl::RenderState const state = m_renderQueue.CopyState(); - if (state.m_currentScreen != m_navigator.Screen()) + if ((state.m_currentScreen != m_navigator.Screen()) && (m_isRedrawEnabled)) AddRedrawCommandSure(); } @@ -163,7 +166,8 @@ public: : m_windowHandle(windowHandle), m_renderQueue(GetPlatform().SkinName(), GetPlatform().IsMultiSampled()), m_isHeadingEnabled(false), - m_isPositionEnabled(false) + m_isPositionEnabled(false), + m_isRedrawEnabled(true) { m_renderQueue.AddWindowHandle(m_windowHandle); } @@ -223,6 +227,13 @@ public: UpdateNow(); } + /// enabling/disabling AddRedrawCommand + void SetRedrawEnabled(bool isRedrawEnabled) + { + m_isRedrawEnabled = isRedrawEnabled; + AddRedrawCommand(); + } + /// respond to device orientation changes void SetOrientation(EOrientation orientation) { diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index d1f04854fc..5708405339 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -17,9 +17,12 @@ namespace qt m_handle(new handle_t(this)), m_framework(m_handle), m_isDrag(false), - m_pScale(0) + m_pScale(0), + m_redrawInterval(100) { m_framework.Init(storage); + m_timer = new QTimer(this); + connect(m_timer, SIGNAL(timeout()), this, SLOT(ScaleTimerElapsed())); } void DrawWidget::SetScaleControl(QSlider * pScale) @@ -149,6 +152,7 @@ namespace qt if (e->button() == Qt::LeftButton) { + m_framework.SetRedrawEnabled(false); m_framework.StartDrag(get_drag_event(e)); setCursor(Qt::CrossCursor); @@ -163,6 +167,7 @@ namespace qt { if (m_isDrag) { + m_framework.SetRedrawEnabled(true); m_framework.StopDrag(get_drag_event(e)); setCursor(Qt::ArrowCursor); m_isDrag = false; @@ -186,6 +191,7 @@ namespace qt if (m_isDrag && e->button() == Qt::LeftButton) { + m_framework.SetRedrawEnabled(true); m_framework.StopDrag(get_drag_event(e)); setCursor(Qt::ArrowCursor); @@ -193,10 +199,22 @@ namespace qt } } + void DrawWidget::ScaleTimerElapsed() + { + m_framework.SetRedrawEnabled(true); + m_timer->stop(); + } + void DrawWidget::wheelEvent(QWheelEvent * e) { if (!m_isDrag) { + /// if we are inside the timer, cancel it + if (m_timer->isActive()) + m_timer->stop(); + + m_framework.SetRedrawEnabled(false); + m_timer->start(m_redrawInterval); //m_framework.Scale(exp(e->delta() / 360.0)); m_framework.ScaleToPoint(ScaleToPointEvent(e->pos().x(), e->pos().y(), exp(e->delta() / 360.0))); UpdateScaleControl(); diff --git a/qt/draw_widget.hpp b/qt/draw_widget.hpp index 01207daa10..23fa3b3b15 100644 --- a/qt/draw_widget.hpp +++ b/qt/draw_widget.hpp @@ -7,6 +7,7 @@ #include "../map/framework.hpp" #include "../map/navigator.hpp" +#include class FileReader; template class ReaderSource; @@ -35,6 +36,9 @@ namespace qt bool m_isDrag; + QTimer * m_timer; + size_t m_redrawInterval; + Q_OBJECT public Q_SLOTS: @@ -47,6 +51,7 @@ namespace qt void ShowAll(); void Repaint(); void ScaleChanged(int action); + void ScaleTimerElapsed(); public: DrawWidget(QWidget * pParent, storage::Storage & storage);