From 12a05922687cddcef06ed84e15ad43683fba5b7f Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Fri, 25 Nov 2016 16:09:55 +0300 Subject: [PATCH] Show the ruler only during scaling. --- drape_frontend/gui/ruler.cpp | 2 +- drape_frontend/gui/ruler_helper.cpp | 14 +++++++++++++- drape_frontend/gui/ruler_helper.hpp | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drape_frontend/gui/ruler.cpp b/drape_frontend/gui/ruler.cpp index 541ccb8733..e24bfd5cdb 100644 --- a/drape_frontend/gui/ruler.cpp +++ b/drape_frontend/gui/ruler.cpp @@ -51,7 +51,7 @@ public: : TBase(id, anchor, pivot) , m_isAppearing(isAppearing) , m_isVisibleAtEnd(true) - , m_animation(false, 0.4) + , m_animation(false, 0.2) { } diff --git a/drape_frontend/gui/ruler_helper.cpp b/drape_frontend/gui/ruler_helper.cpp index e3bdbe0b54..e60a50fe9c 100644 --- a/drape_frontend/gui/ruler_helper.cpp +++ b/drape_frontend/gui/ruler_helper.cpp @@ -29,6 +29,8 @@ static int const MinUnitValue = -1; static int const MaxUnitValue = numeric_limits::max() - 1; static int const InvalidUnitValue = MaxUnitValue + 1; +static double const kHideDelaySeconds = 1.0; + struct UnitValue { char const * m_s; @@ -113,6 +115,14 @@ RulerHelper::RulerHelper() void RulerHelper::Update(ScreenBase const & screen) { + if (m_lastScale != screen.GetScale()) + { + if (!IsVisible(screen)) + SetTextDirty(); + m_lastScale = screen.GetScale(); + m_hideTimer.Reset(); + } + m2::PointD pivot = screen.PixelRect().Center(); int const minPxWidth = my::rounds(MinPixelWidth * df::VisualParams::Instance().GetVisualScale()); m2::PointD pt1 = screen.PtoG(pivot); @@ -150,7 +160,9 @@ void RulerHelper::Update(ScreenBase const & screen) bool RulerHelper::IsVisible(ScreenBase const & screen) const { DrapeGui & gui = DrapeGui::Instance(); - return !gui.IsCopyrightActive() && df::GetDrawTileScale(screen) >= VISIBLE_RULER_BOTTOM_SCALE; + return !gui.IsCopyrightActive() && + (df::GetDrawTileScale(screen) >= VISIBLE_RULER_BOTTOM_SCALE) && + (m_hideTimer.ElapsedSeconds() < kHideDelaySeconds); } void RulerHelper::Invalidate() diff --git a/drape_frontend/gui/ruler_helper.hpp b/drape_frontend/gui/ruler_helper.hpp index 5ed7fa2111..a30d6f0db6 100644 --- a/drape_frontend/gui/ruler_helper.hpp +++ b/drape_frontend/gui/ruler_helper.hpp @@ -2,6 +2,8 @@ #include "drape_frontend/animation/show_hide_animation.hpp" +#include "base/timer.hpp" + #include "std/string.hpp" class ScreenBase; @@ -38,6 +40,8 @@ private: bool m_isTextDirty; mutable bool m_dirtyTextRequested; int m_currentDrawScale = 0; + my::Timer m_hideTimer; + double m_lastScale = 0.0; }; }