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

text_view.cpp « gui - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 61be3de297eecae89875d3949963e7e0957dc097 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "text_view.hpp"
#include "controller.hpp"

namespace gui
{
  TextView::TextView(Params const & p)
    : Element(p)
  {
    setText(p.m_text);

    setFont(EActive, graphics::FontDesc(12, graphics::Color(0, 0, 0, 255)));
    setFont(EPressed, graphics::FontDesc(12, graphics::Color(0, 0, 0, 255)));

    setColor(EActive, graphics::Color(graphics::Color(192, 192, 192, 255)));
    setColor(EPressed, graphics::Color(graphics::Color(64, 64, 64, 255)));
  }

  void TextView::setText(string const & text)
  {
    if (m_text != text)
    {
      m_text = text;
      setIsDirtyDrawing(true);
      setIsDirtyRect(true);
    }
  }

  string const & TextView::text() const
  {
    return m_text;
  }

  void TextView::cache()
  {
    graphics::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 graphics::StraightTextElement(params));
  }

  void TextView::draw(graphics::OverlayRenderer *r, math::Matrix<double, 3, 3> const & m) const
  {
    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;
  }
}