From 0b795f3d7dffc320762176285eb16f7a238ab405 Mon Sep 17 00:00:00 2001 From: rachytski Date: Thu, 24 Jan 2013 17:21:42 +0300 Subject: [PATCH] renamed OverlayElement::tieRect into OverlayElement::computeTopLeft. --- graphics/circle_element.cpp | 12 +++++++++--- graphics/overlay_element.cpp | 24 +++++++++++++----------- graphics/overlay_element.hpp | 7 ++++--- graphics/symbol_element.cpp | 16 ++++++++++++---- gui/button.cpp | 6 +++++- 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/graphics/circle_element.cpp b/graphics/circle_element.cpp index b0ffa3f2f4..b6a564599c 100644 --- a/graphics/circle_element.cpp +++ b/graphics/circle_element.cpp @@ -35,9 +35,13 @@ namespace graphics texRect.Inflate(-1, -1); - m2::PointD posPt = tieRect(m2::RectD(texRect), math::Identity()); + m2::PointD sz(texRect.SizeX(), texRect.SizeY()); - return m2::AnyRectD(m2::RectD(posPt, posPt + m2::PointD(texRect.SizeX(), texRect.SizeY()))); + m2::PointD posPt = computeTopLeft(sz, + pivot(), + position()); + + return m2::AnyRectD(m2::RectD(posPt, posPt + sz)); } void CircleElement::draw(OverlayRenderer * r, math::Matrix const & m) const @@ -53,7 +57,9 @@ namespace graphics m2::RectI texRect(res->m_texRect); texRect.Inflate(-1, -1); - m2::PointD posPt = tieRect(m2::RectD(texRect), m); + m2::PointD posPt = computeTopLeft(m2::PointD(texRect.SizeX(), texRect.SizeY()), + pivot() * m, + position()); r->drawTexturedPolygon(m2::PointD(0.0, 0.0), 0.0, texRect.minX(), texRect.minY(), texRect.maxX(), texRect.maxY(), diff --git a/graphics/overlay_element.cpp b/graphics/overlay_element.cpp index 21aa25cd8e..474f0e2ddd 100644 --- a/graphics/overlay_element.cpp +++ b/graphics/overlay_element.cpp @@ -7,7 +7,9 @@ namespace graphics {} OverlayElement::Params::Params() - : m_pivot(), m_position(graphics::EPosAboveRight), m_depth(graphics::maxDepth) + : m_pivot(), + m_position(EPosAboveRight), + m_depth(maxDepth) {} OverlayElement::OverlayElement(Params const & p) @@ -24,26 +26,25 @@ namespace graphics m_isDirtyRoughRect(true) {} - m2::PointD const OverlayElement::tieRect(m2::RectD const & r, math::Matrix const & m) const + m2::PointD const OverlayElement::computeTopLeft(m2::PointD const & sz, + m2::PointD const & pv, + EPosition pos) { m2::PointD res; - graphics::EPosition pos = position(); - m2::PointD pt = pivot() * m; - if (pos & EPosLeft) - res.x = pt.x - r.SizeX(); + res.x = pv.x - sz.x; else if (pos & EPosRight) - res.x = pt.x; + res.x = pv.x; else - res.x = pt.x - r.SizeX() / 2; + res.x = pv.x - sz.x / 2; if (pos & EPosAbove) - res.y = pt.y - r.SizeY(); + res.y = pv.y - sz.y; else if (pos & EPosUnder) - res.y = pt.y; + res.y = pv.y; else - res.y = pt.y - r.SizeY() / 2; + res.y = pv.y - sz.y / 2; return res; } @@ -205,6 +206,7 @@ namespace graphics return res; } + bool OverlayElement::hasSharpGeometry() const { return false; diff --git a/graphics/overlay_element.hpp b/graphics/overlay_element.hpp index 0a2a262941..b1f61fbd71 100644 --- a/graphics/overlay_element.hpp +++ b/graphics/overlay_element.hpp @@ -46,8 +46,9 @@ namespace graphics public: UserInfo m_userInfo; - - m2::PointD const tieRect(m2::RectD const & r, math::Matrix const & m) const; + static m2::PointD const computeTopLeft(m2::PointD const & sz, + m2::PointD const & pv, + EPosition pos); struct Params { @@ -72,7 +73,7 @@ namespace graphics m2::PointD const & pivot() const; virtual void setPivot(m2::PointD const & pv); - virtual m2::PointD const point(EPosition pos) const; + m2::PointD const point(EPosition pos) const; void offset(m2::PointD const & offs); diff --git a/graphics/symbol_element.cpp b/graphics/symbol_element.cpp index e1a79ca839..608057bb6c 100644 --- a/graphics/symbol_element.cpp +++ b/graphics/symbol_element.cpp @@ -48,9 +48,13 @@ namespace graphics m2::RectI texRect(m_symbolRect); texRect.Inflate(-1, -1); - m2::PointD posPt = tieRect(m2::RectD(texRect), math::Identity()); + m2::PointD sz(texRect.SizeX(), texRect.SizeY()); - return m2::AnyRectD(m2::RectD(posPt, posPt + m2::PointD(texRect.SizeX(), texRect.SizeY()))); + m2::PointD const posPt = computeTopLeft(sz, + pivot(), + position()); + + return m2::AnyRectD(m2::RectD(posPt, posPt + sz)); } void SymbolElement::draw(OverlayRenderer * r, math::Matrix const & m) const @@ -76,13 +80,17 @@ namespace graphics m2::RectI texRect(res->m_texRect); texRect.Inflate(-1, -1); - m2::PointD posPt = tieRect(m2::RectD(texRect), m); + m2::PointD sz(texRect.SizeX(), texRect.SizeY()); + + m2::PointD posPt = computeTopLeft(sz, + pivot() * m, + position()); posPt -= pivot(); r->drawStraightTexturedPolygon(pivot(), texRect.minX(), texRect.minY(), texRect.maxX(), texRect.maxY(), - posPt.x, posPt.y, posPt.x + texRect.SizeX(), posPt.y + texRect.SizeY(), + posPt.x, posPt.y, posPt.x + sz.x, posPt.y + sz.y, depth(), res->m_pipelineID); } diff --git a/gui/button.cpp b/gui/button.cpp index 17549bbeb5..82e6cbb41a 100644 --- a/gui/button.cpp +++ b/gui/button.cpp @@ -120,7 +120,11 @@ namespace gui rc.Inflate(dx, dy); rc.Offset(-rc.minX(), -rc.minY()); - rc.Offset(tieRect(rc, math::Identity())); + m2::PointD pt = computeTopLeft(m2::PointD(rc.SizeX(), rc.SizeY()), + pivot(), + position()); + + rc.Offset(pt); m_boundRects.push_back(m2::AnyRectD(rc)); setIsDirtyRect(false); }