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-01-24 19:52:10 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:49:17 +0300
commitf6c85b65f4fe6ad784c9a37f909c7e8109193515 (patch)
tree2fe0466a56ffcdcec567ac6433625f8a6a670fb4 /gui
parent8650c6cd814d6ac04d754689fd15b23701fc7776 (diff)
added gui::ImageView element.
Diffstat (limited to 'gui')
-rw-r--r--gui/gui.pro2
-rw-r--r--gui/image_view.cpp87
-rw-r--r--gui/image_view.hpp45
3 files changed, 134 insertions, 0 deletions
diff --git a/gui/gui.pro b/gui/gui.pro
index 19d0ba2661..092abd6b2e 100644
--- a/gui/gui.pro
+++ b/gui/gui.pro
@@ -14,9 +14,11 @@ HEADERS += \
element.hpp \
button.hpp \
text_view.hpp \
+ image_view.hpp \
SOURCES += \
controller.cpp \
element.cpp \
button.cpp \
text_view.cpp \
+ image_view.cpp \
diff --git a/gui/image_view.cpp b/gui/image_view.cpp
new file mode 100644
index 0000000000..4fc1ade780
--- /dev/null
+++ b/gui/image_view.cpp
@@ -0,0 +1,87 @@
+#include "image_view.hpp"
+#include "controller.hpp"
+
+#include "../graphics/screen.hpp"
+#include "../graphics/display_list.hpp"
+
+#include "../base/matrix.hpp"
+
+#include "../geometry/transformations.hpp"
+
+namespace gui
+{
+ ImageView::Params::Params()
+ {}
+
+ ImageView::ImageView(Params const & p)
+ : base_t(p),
+ m_boundRects(1)
+ {
+ m_image = p.m_image;
+ }
+
+ void ImageView::cache()
+ {
+ graphics::Screen * cs = m_controller->GetCacheScreen();
+
+ m_displayList.reset();
+ m_displayList.reset(cs->createDisplayList());
+
+ cs->beginFrame();
+ cs->setDisplayList(m_displayList.get());
+
+ math::Matrix<double, 3, 3> m =
+ math::Shift(
+ math::Identity<double, 3>(),
+ -(int)m_image.m_size.x / 2, -(int)m_image.m_size.y / 2);
+
+ uint32_t imageResID = cs->mapInfo(m_image);
+ cs->drawImage(m, imageResID, depth());
+
+ cs->setDisplayList(0);
+ cs->endFrame();
+ }
+
+ void ImageView::purge()
+ {
+ m_displayList.reset();
+ }
+
+ vector<m2::AnyRectD> const & ImageView::boundRects() const
+ {
+ if (isDirtyRect())
+ {
+ m2::PointD sz(m_image.m_size);
+
+ m2::PointD pt = computeTopLeft(sz,
+ pivot(),
+ position());
+
+
+ m_boundRects[0] = m2::AnyRectD(m2::RectD(pt, pt + sz));
+
+ setIsDirtyRect(false);
+ }
+
+ return m_boundRects;
+ }
+
+ void ImageView::draw(graphics::OverlayRenderer * r,
+ math::Matrix<double, 3, 3> const & m) const
+ {
+ if (isVisible())
+ {
+ checkDirtyLayout();
+
+ m2::PointD pt = computeTopLeft(m_image.m_size,
+ pivot() * m,
+ position());
+
+ math::Matrix<double, 3, 3> drawM = math::Shift(math::Identity<double, 3>(),
+ pt.x + m_image.m_size.x / 2,
+ pt.y + m_image.m_size.y / 2);
+
+ r->drawDisplayList(m_displayList.get(), drawM * m);
+ }
+ }
+}
diff --git a/gui/image_view.hpp b/gui/image_view.hpp
new file mode 100644
index 0000000000..d2542831e9
--- /dev/null
+++ b/gui/image_view.hpp
@@ -0,0 +1,45 @@
+#pragma once
+
+#include "element.hpp"
+
+#include "../graphics/image.hpp"
+#include "../std/shared_ptr.hpp"
+
+namespace graphics
+{
+ class DisplayList;
+ class OverlayRenderer;
+}
+
+namespace gui
+{
+ class ImageView : public Element
+ {
+ private:
+
+ mutable vector<m2::AnyRectD> m_boundRects;
+
+ graphics::Image::Info m_image;
+ m2::RectU m_margin;
+ shared_ptr<graphics::DisplayList> m_displayList;
+
+ public:
+
+ void cache();
+ void purge();
+
+ typedef Element base_t;
+
+ struct Params : public base_t::Params
+ {
+ graphics::Image::Info m_image;
+ Params();
+ };
+
+ ImageView(Params const & p);
+
+ vector<m2::AnyRectD> const & boundRects() const;
+
+ void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
+ };
+}