Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorrachytski <siarhei.rachytski@gmail.com>2013-02-13 15:36:16 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:50:47 +0300
commit393cd94d36a0aa97fd5ff96b435b3bdcff941121 (patch)
treedd4ab0082dafcdcc4ac32c4dff0ee68ecb1991f1 /gui
parente1bb2b713b9f1305b0ddebea0ccc93f1727b04a5 (diff)
fixed some bugs with gui::Balloon rendering. added "arrow" and "plus" images logic into BookmarkBalloon.
Diffstat (limited to 'gui')
-rw-r--r--gui/balloon.cpp57
-rw-r--r--gui/balloon.hpp1
-rw-r--r--gui/image_view.cpp6
-rw-r--r--gui/image_view.hpp1
4 files changed, 42 insertions, 23 deletions
diff --git a/gui/balloon.cpp b/gui/balloon.cpp
index d0e291d802..d1b5e14c45 100644
--- a/gui/balloon.cpp
+++ b/gui/balloon.cpp
@@ -43,22 +43,22 @@ namespace gui
tp.m_text = m_text;
tp.m_position = graphics::EPosRight;
tp.m_pivot = m2::PointD(0, 0);
- tp.m_depth = depth();
+ tp.m_depth = depth() + 1;
m_textView.reset(new TextView(tp));
- m_textView->setFont(Element::EActive, graphics::FontDesc(20, graphics::Color(0, 0, 0, 255), true));
+ m_textView->setFont(Element::EActive, graphics::FontDesc(20, graphics::Color(255, 255, 255, 255)));
ImageView::Params ip;
ip.m_pivot = m2::PointD(0, 0);
ip.m_position = graphics::EPosRight;
- ip.m_depth = depth();
+ ip.m_depth = depth() + 1;
ip.m_image = m_image;
m_imageView.reset(new ImageView(ip));
- m_arrowHeight = 20;
+ m_arrowHeight = 10;
m_arrowAngle = ang::DegreeToRad(90);
m_arrowWidth = 2 * tan(m_arrowAngle / 2) * m_arrowHeight;
}
@@ -88,13 +88,13 @@ namespace gui
graphics::EPosition pos = position();
if (pos == graphics::EPosAbove)
- r.setMaxY(r.maxY() + m_arrowHeight);
+ r.setMaxY(r.maxY() + m_arrowHeight * k);
else if (pos == graphics::EPosUnder)
- r.setMinY(r.minY() - m_arrowHeight);
+ r.setMinY(r.minY() - m_arrowHeight * k);
else if (pos == graphics::EPosRight)
- r.setMinX(r.minX() - m_arrowHeight);
+ r.setMinX(r.minX() - m_arrowHeight * k);
else if (pos == graphics::EPosLeft)
- r.setMaxX(r.maxX() + m_arrowHeight);
+ r.setMaxX(r.maxX() + m_arrowHeight * k);
m_boundRects[0] = m2::AnyRectD(r);
@@ -122,6 +122,8 @@ namespace gui
double imt = m_imageMarginTop * k;
double imb = m_imageMarginBottom * k;
+ double arrowHeight = m_arrowHeight * k;
+
double w = tml + tr.SizeX() + tmr
+ iml + ir.SizeX() + imr;
@@ -134,29 +136,29 @@ namespace gui
if (pos == graphics::EPosAbove)
{
m_textView->setPivot(m2::PointD(pv.x - w / 2 + tml,
- pv.y - h / 2 - m_arrowHeight));
+ pv.y - h / 2 - arrowHeight));
m_imageView->setPivot(m2::PointD(pv.x + w / 2 - imr - ir.SizeX(),
- pv.y - h / 2 - m_arrowHeight));
+ pv.y - h / 2 - arrowHeight));
}
else if (pos == graphics::EPosUnder)
{
m_textView->setPivot(m2::PointD(pv.x - w / 2 + tml,
- pv.y + h / 2 + m_arrowHeight));
+ pv.y + h / 2 + arrowHeight));
m_imageView->setPivot(m2::PointD(pv.x + w / 2 - imr - ir.SizeX(),
- pv.y + h / 2 + m_arrowHeight));
+ pv.y + h / 2 + arrowHeight));
}
else if (pos == graphics::EPosLeft)
{
- m_textView->setPivot(m2::PointD(pv.x - w - m_arrowHeight + tml,
+ m_textView->setPivot(m2::PointD(pv.x - w - arrowHeight + tml,
pv.y));
- m_imageView->setPivot(m2::PointD(pv.x - m_arrowHeight - imr - ir.SizeX(),
+ m_imageView->setPivot(m2::PointD(pv.x - arrowHeight - imr - ir.SizeX(),
pv.y));
}
else if (pos == graphics::EPosRight)
{
- m_textView->setPivot(m2::PointD(pv.x + m_arrowHeight + tml,
+ m_textView->setPivot(m2::PointD(pv.x + arrowHeight + tml,
pv.y));
- m_imageView->setPivot(m2::PointD(pv.x + m_arrowHeight + tml + tr.SizeX() + tmr + imr,
+ m_imageView->setPivot(m2::PointD(pv.x + arrowHeight + tml + tr.SizeX() + tmr + imr,
pv.y));
}
@@ -182,17 +184,19 @@ namespace gui
m2::RectD const & r = roughBoundRect();
+ double k = visualScale();
+
double bw = r.SizeX();
double bh = r.SizeY();
- double aw = m_arrowWidth;
- double ah = m_arrowHeight;
+ double aw = m_arrowWidth * k;
+ double ah = m_arrowHeight * k;
graphics::EPosition pos = position();
graphics::Path<float> p;
if (pos & graphics::EPosAbove)
{
- bh -= m_arrowHeight;
+ bh -= ah;
p.reset(m2::PointF(-aw / 2, -ah));
p.lineRel(m2::PointF(-bw / 2 + aw / 2, 0));
@@ -205,7 +209,7 @@ namespace gui
}
else if (pos & graphics::EPosUnder)
{
- bh -= m_arrowHeight;
+ bh -= ah;
p.reset(m2::PointF(aw / 2, ah));
p.lineRel(m2::PointF(bw / 2 - aw / 2, 0));
@@ -248,9 +252,9 @@ namespace gui
{
checkDirtyLayout();
-// r->drawRectangle(roughBoundRect(), graphics::Color(0, 0, 255, 128), depth());
-// r->drawRectangle(m_textView->roughBoundRect(), graphics::Color(0, 255, 255, 128), depth());
-// r->drawRectangle(m_imageView->roughBoundRect(), graphics::Color(0, 255, 0, 128), depth());
+// r->drawRectangle(roughBoundRect(), graphics::Color(0, 0, 255, 128), depth() + 1);
+// r->drawRectangle(m_textView->roughBoundRect(), graphics::Color(0, 255, 255, 128), depth() + 1);
+// r->drawRectangle(m_imageView->roughBoundRect(), graphics::Color(0, 255, 0, 128), depth() + 1);
math::Matrix<double, 3, 3> drawM = math::Shift(
math::Identity<double, 3>(),
@@ -303,4 +307,11 @@ namespace gui
setIsDirtyLayout(true);
invalidate();
}
+
+ void Balloon::setImage(graphics::Image::Info const & info)
+ {
+ m_imageView->setImage(info);
+ setIsDirtyLayout(true);
+ invalidate();
+ }
}
diff --git a/gui/balloon.hpp b/gui/balloon.hpp
index 16e0c8adf4..8f8283b3f0 100644
--- a/gui/balloon.hpp
+++ b/gui/balloon.hpp
@@ -85,6 +85,7 @@ namespace gui
void setOnClickListener(TOnClickListener const & fn);
void setText(string const & s);
+ void setImage(graphics::Image::Info const & info);
bool onTapStarted(m2::PointD const & pt);
bool onTapMoved(m2::PointD const & pt);
diff --git a/gui/image_view.cpp b/gui/image_view.cpp
index 4fc1ade780..802ea03aa8 100644
--- a/gui/image_view.cpp
+++ b/gui/image_view.cpp
@@ -84,4 +84,10 @@ namespace gui
r->drawDisplayList(m_displayList.get(), drawM * m);
}
}
+ void ImageView::setImage(graphics::Image::Info const & info)
+ {
+ m_image = info;
+ setIsDirtyLayout(true);
+ invalidate();
+ }
}
diff --git a/gui/image_view.hpp b/gui/image_view.hpp
index 607e9ed364..936d1093d9 100644
--- a/gui/image_view.hpp
+++ b/gui/image_view.hpp
@@ -42,5 +42,6 @@ namespace gui
vector<m2::AnyRectD> const & boundRects() const;
void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
+ void setImage(graphics::Image::Info const & info);
};
}