From 5ecf5d77656226311ff403107d8a9d8a6b945793 Mon Sep 17 00:00:00 2001 From: ExMix Date: Thu, 20 Mar 2014 18:48:41 +0300 Subject: ruler fix --- map/framework.cpp | 6 +++--- map/information_display.cpp | 8 ++++---- map/navigator.cpp | 10 ---------- map/navigator.hpp | 2 -- map/ruler.cpp | 14 +++++++++++--- map/ruler.hpp | 1 + 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index e93a7d7f35..9f3c31f358 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -777,10 +777,10 @@ void Framework::DrawAdditionalInfo(shared_ptr const & e) m_informationDisplay.setScreen(m_navigator.Screen()); - m_informationDisplay.setDebugInfo(0, GetDrawScale()); + int drawScale = GetDrawScale(); + m_informationDisplay.setDebugInfo(0, drawScale); - m_informationDisplay.enableRuler(m_navigator.InAction() && - (!m_navigator.InDrag() || m_informationDisplay.isRulerEnabled())); + m_informationDisplay.enableRuler(m_navigator.InAction() && drawScale > 5); #ifdef DEBUG m_informationDisplay.enableDebugInfo(true); #endif diff --git a/map/information_display.cpp b/map/information_display.cpp index 1ba9fa323d..795862d4b5 100644 --- a/map/information_display.cpp +++ b/map/information_display.cpp @@ -29,8 +29,8 @@ namespace { - static int const RULLER_X_OFFSET = 65; - static int const RULLER_Y_OFFSET = 15; + static int const RULLER_X_OFFSET = 30; + static int const RULLER_Y_OFFSET = 8; static int const FONT_SIZE = 14; static int const COMPASS_W_OFFSET = 13; static int const COMPASS_H_OFFSET = 71; @@ -67,7 +67,7 @@ void InformationDisplay::InitRuler(Framework * fw) Ruler::Params p; p.m_depth = graphics::rulerDepth; - p.m_position = graphics::EPosAboveRight; + p.m_position = graphics::EPosAboveLeft; p.m_framework = fw; m_ruler.reset(new Ruler(p)); @@ -158,7 +158,7 @@ void InformationDisplay::setDisplayRect(m2::RectI const & rect) { m_displayRect = rect; - m2::PointD pt(m2::PointD(m_displayRect.minX() + RULLER_X_OFFSET * m_visualScale, + m2::PointD pt(m2::PointD(m_displayRect.maxX() - RULLER_X_OFFSET * m_visualScale, m_displayRect.maxY() - RULLER_Y_OFFSET * m_visualScale)); m_ruler->setPivot(pt); diff --git a/map/navigator.cpp b/map/navigator.cpp index 49bc5432a8..d228bbb96a 100644 --- a/map/navigator.cpp +++ b/map/navigator.cpp @@ -29,7 +29,6 @@ namespace Navigator::Navigator(ScalesProcessor const & scales) : m_scales(scales), m_InAction(false), - m_InDrag(false), m_DoSupportRotation(false) { } @@ -310,7 +309,6 @@ void Navigator::StartRotate(double a, double /*timeInSec*/) m_StartAngle = a; m_StartScreen = m_Screen; m_InAction = true; - m_InDrag = false; } void Navigator::DoRotate(double a, double /*timeInSec*/) @@ -339,7 +337,6 @@ void Navigator::StartDrag(m2::PointD const & pt, double /*timeInSec*/) m_StartPt1 = m_LastPt1 = pt; m_StartScreen = m_Screen; m_InAction = true; - m_InDrag = true; } void Navigator::DoDrag(m2::PointD const & pt, double /*timeInSec*/) @@ -378,7 +375,6 @@ void Navigator::StopDrag(m2::PointD const & pt, double timeInSec, bool /*animate { DoDrag(pt, timeInSec); m_InAction = false; - m_InDrag = false; } bool Navigator::InAction() const @@ -386,11 +382,6 @@ bool Navigator::InAction() const return m_InAction; } -bool Navigator::InDrag() const -{ - return m_InDrag; -} - void Navigator::StartScale(m2::PointD const & pt1, m2::PointD const & pt2, double /*timeInSec*/) { m_StartScreen = m_Screen; @@ -400,7 +391,6 @@ void Navigator::StartScale(m2::PointD const & pt1, m2::PointD const & pt2, doubl m_DoCheckRotationThreshold = m_DoSupportRotation; m_IsRotatingDuringScale = false; m_InAction = true; - m_InDrag = false; } void Navigator::ScaleToPoint(m2::PointD const & pt, double factor, double /*timeInSec*/) diff --git a/map/navigator.hpp b/map/navigator.hpp index f79c191453..028517ab1e 100644 --- a/map/navigator.hpp +++ b/map/navigator.hpp @@ -59,7 +59,6 @@ public: bool Update(double timeInSec); bool InAction() const; - bool InDrag() const; /// enabling/disabling screen rotation handling void SetSupportRotation(bool flag); @@ -109,7 +108,6 @@ private: math::Matrix m_DeltaMatrix; // Flag, which indicates, whether we are in the middle of some action. bool m_InAction; - bool m_InDrag; // Does Navigator supports screen rotation. bool m_DoSupportRotation; // Should we check for threshold while scaling by two fingers. diff --git a/map/ruler.cpp b/map/ruler.cpp index 8013f528d8..aeb2302e5b 100644 --- a/map/ruler.cpp +++ b/map/ruler.cpp @@ -109,6 +109,7 @@ namespace // ========================================================= // Ruler::RulerFrame::RulerFrame(Framework & f, const Ruler::RulerFrame::frame_end_fn & fn, double depth) : m_f(f) + , m_textLengthInPx(0) , m_scale(0.0) , m_depth(depth) , m_callback(fn) @@ -121,6 +122,7 @@ Ruler::RulerFrame::RulerFrame(const Ruler::RulerFrame & other, const Ruler::Rule { m_dl = other.m_dl; m_textDL = other.m_textDL; + m_textLengthInPx = other.m_textLengthInPx; m_scale = other.m_scale; m_depth = other.m_depth; m_orgPt = other.m_orgPt; @@ -350,6 +352,7 @@ void Ruler::RulerFrame::Cache(const string & text, graphics::FontDesc const & f) texCoords.push_back(texture->mapPixel(m2::PointF(resourceRect.maxX(), resourceRect.minY()))); } + m_textLengthInPx = lengthFromStart; cs->addTexturedListStrided(coords.data(), sizeof(m2::PointF), normals.data(), sizeof(m2::PointF), texCoords.data(), sizeof(m2::PointF), @@ -407,7 +410,7 @@ void Ruler::RulerFrame::ShowAnimate(bool needPause) void Ruler::RulerFrame::HideAnimate(bool needPause) { - double offset = (needPause == true) ? 0.3 : 0.0; + double offset = (needPause == true) ? 1.0 : 0.0; double timeInterval = (needPause == true) ? 0.3 : 0.15; CreateAnim(1.0, 0.0, timeInterval, offset, false); } @@ -426,7 +429,7 @@ void Ruler::RulerFrame::Draw(graphics::OverlayRenderer * r, const math::MatrixdrawDisplayList(m_textDL.get(), - math::Shift(m, m_orgPt + m2::PointF(0.0, yOffset)), + math::Shift(m, m_orgPt + m2::PointF(CacheLength * m_scale - m_textLengthInPx, yOffset)), &holder); } @@ -589,6 +592,9 @@ void Ruler::layout() void Ruler::UpdateText(const string & text) { RulerFrame * frame = GetMainFrame(); + if (frame->IsAnimActive() && frame->IsHidingAnim()) + return; + if (frame->IsValid()) { delete m_animFrame; @@ -703,7 +709,9 @@ vector const & Ruler::boundRects() const { graphics::FontDesc const & f = font(EActive); RulerFrame * frame = GetMainFrame(); - m2::RectD rect(frame->GetOrgPoint(), m2::PointD(CacheLength * frame->GetScale(), f.m_size * 2)); + m2::PointD org = frame->GetOrgPoint(); + m2::PointD size = m2::PointD(CacheLength * frame->GetScale(), f.m_size * 2); + m2::RectD rect(org - m2::PointD(size.x, 0.0), org + m2::PointD(0.0, size.y)); m_boundRects[0] = m2::AnyRectD(rect); setIsDirtyRect(false); } diff --git a/map/ruler.hpp b/map/ruler.hpp index a93b08f835..995dfd1e6e 100644 --- a/map/ruler.hpp +++ b/map/ruler.hpp @@ -75,6 +75,7 @@ class Ruler : public gui::Element Framework & m_f; shared_ptr m_dl; shared_ptr m_textDL; + int m_textLengthInPx; double m_scale; double m_depth; m2::PointD m_orgPt; -- cgit v1.2.3