forked from organicmaps/organicmaps
renamed OverlayElement::tieRect into OverlayElement::computeTopLeft.
This commit is contained in:
parent
ff587a1087
commit
0b795f3d7d
5 changed files with 43 additions and 22 deletions
|
@ -35,9 +35,13 @@ namespace graphics
|
|||
|
||||
texRect.Inflate(-1, -1);
|
||||
|
||||
m2::PointD posPt = tieRect(m2::RectD(texRect), math::Identity<double, 3>());
|
||||
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<double, 3, 3> 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(),
|
||||
|
|
|
@ -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<double, 3, 3> 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;
|
||||
|
|
|
@ -46,8 +46,9 @@ namespace graphics
|
|||
public:
|
||||
|
||||
UserInfo m_userInfo;
|
||||
|
||||
m2::PointD const tieRect(m2::RectD const & r, math::Matrix<double, 3, 3> 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);
|
||||
|
||||
|
|
|
@ -48,9 +48,13 @@ namespace graphics
|
|||
m2::RectI texRect(m_symbolRect);
|
||||
texRect.Inflate(-1, -1);
|
||||
|
||||
m2::PointD posPt = tieRect(m2::RectD(texRect), math::Identity<double, 3>());
|
||||
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<double, 3, 3> 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);
|
||||
}
|
||||
|
|
|
@ -120,7 +120,11 @@ namespace gui
|
|||
rc.Inflate(dx, dy);
|
||||
rc.Offset(-rc.minX(), -rc.minY());
|
||||
|
||||
rc.Offset(tieRect(rc, math::Identity<double, 3>()));
|
||||
m2::PointD pt = computeTopLeft(m2::PointD(rc.SizeX(), rc.SizeY()),
|
||||
pivot(),
|
||||
position());
|
||||
|
||||
rc.Offset(pt);
|
||||
m_boundRects.push_back(m2::AnyRectD(rc));
|
||||
setIsDirtyRect(false);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue