diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2012-06-02 21:21:26 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:39:18 +0300 |
commit | 36c49f0e317b063f2c614d635d033cfaede10929 (patch) | |
tree | fee3346218b60ffe5e7e9d43fd682a4a28e64aa9 /gui/text_view.cpp | |
parent | 3be82073ef66412c383fd89b8899c9c92a033e68 (diff) |
implemented mechanism for drawable resources caching. this will allow us to use display lists in future for fast rendering of GUI elements in the main loop.
Diffstat (limited to 'gui/text_view.cpp')
-rw-r--r-- | gui/text_view.cpp | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/gui/text_view.cpp b/gui/text_view.cpp new file mode 100644 index 0000000000..17f960b9f5 --- /dev/null +++ b/gui/text_view.cpp @@ -0,0 +1,91 @@ +#include "text_view.hpp" +#include "controller.hpp" + +namespace gui +{ + TextView::TextView(Params const & p) + : Element(p) + { + setText(p.m_text); + + setFont(EActive, yg::FontDesc(12, yg::Color(0, 0, 0, 255))); + setFont(EPressed, yg::FontDesc(12, yg::Color(0, 0, 0, 255))); + + setColor(EActive, yg::Color(yg::Color(192, 192, 192, 255))); + setColor(EPressed, yg::Color(yg::Color(64, 64, 64, 255))); + } + + void TextView::setText(string const & text) + { + m_text = text; + setIsDirtyDrawing(true); + } + + string const & TextView::text() const + { + return m_text; + } + + void TextView::cache() + { + yg::StraightTextElement::Params params; + params.m_depth = depth(); + params.m_fontDesc = font(state()); + params.m_fontDesc.m_size *= visualScale(); + params.m_log2vis = true; + params.m_pivot = pivot(); + params.m_position = position(); + params.m_glyphCache = m_controller->GetGlyphCache(); + params.m_logText = strings::MakeUniString(m_text); + params.m_doSplit = true; + params.m_delimiters = "\n"; + params.m_useAllParts = true; + + m_elem.reset(new yg::StraightTextElement(params)); + } + + yg::OverlayElement * TextView::clone(math::Matrix<double, 3, 3> const & m) const + { + return new TextView(*this); + } + + void TextView::draw(yg::gl::OverlayRenderer *r, const math::Matrix<double, 3, 3> &m) + { + checkDirtyDrawing(); + m_elem->draw(r, m); + } + + vector<m2::AnyRectD> const & TextView::boundRects() const + { + if (isDirtyRect()) + { + setIsDirtyDrawing(true); + checkDirtyDrawing(); + m_boundRects.clear(); + m_boundRects.push_back(m2::AnyRectD(m_elem->roughBoundRect())); + setIsDirtyRect(false); + } + + return m_boundRects; + } + + bool TextView::onTapStarted(m2::PointD const & pt) + { + return false; + } + + bool TextView::onTapMoved(m2::PointD const & pt) + { + return false; + } + + bool TextView::onTapEnded(m2::PointD const & pt) + { + return false; + } + + bool TextView::onTapCancelled(m2::PointD const & pt) + { + return false; + } +} |