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

element.cpp « gui - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9c464652ed79fdceaa2f011635f0a01e0a1f73e3 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "element.hpp"
#include "controller.hpp"

#include "../graphics/overlay_renderer.hpp"

#include "../base/logging.hpp"

namespace gui
{
  Element::Element(Params const & p)
    : OverlayElement(p),
      m_controller(0),
      m_state(EActive)
  {}

  void Element::setState(EState state)
  {
    m_state = state;
  }

  Element::EState Element::state() const
  {
    return m_state;
  }

  void Element::setFont(EState state, graphics::FontDesc const & font)
  {
    m_fonts[state] = font;
  }

  graphics::FontDesc const & Element::font(EState state) const
  {
    return m_fonts[state];
  }

  void Element::setColor(EState state, graphics::Color const & c)
  {
    m_colors[state] = c;
  }

  graphics::Color const & Element::color(EState state) const
  {
    return m_colors[state];
  }

  void Element::invalidate()
  {
    if (m_controller)
      m_controller->Invalidate();
    else
      LOG(LWARNING, ("unattached gui::Element couldn't be invalidated!"));
  }

  double Element::visualScale() const
  {
    if (m_controller)
      return m_controller->GetVisualScale();
    else
    {
      LOG(LWARNING, ("unattached gui::Elements shouldn't call gui::Element::visualScale function"));
      return 0.0;
    }
  }

  void Element::cache()
  {}

  void Element::purge()
  {}

  void Element::update()
  {}

  void Element::layout()
  {}

  void Element::checkDirtyLayout() const
  {
    if (isDirtyLayout())
    {
      const_cast<Element*>(this)->layout();
      const_cast<Element*>(this)->cache();
      setIsDirtyLayout(false);
    }
  }

  void Element::draw(graphics::OverlayRenderer *r, math::Matrix<double, 3, 3> const & m) const
  {
    for (unsigned i = 0; i < boundRects().size(); ++i)
      r->drawRectangle(boundRects()[i], color(state()), depth());
  }

  double Element::priority() const
  {
    return 0;
  }

  bool Element::onTapStarted(m2::PointD const & pt)
  {
    return false;
  }

  bool Element::onTapMoved(m2::PointD const & pt)
  {
    return false;
  }

  bool Element::onTapEnded(m2::PointD const & pt)
  {
    return false;
  }

  bool Element::onTapCancelled(m2::PointD const & pt)
  {
    return false;
  }

  void Element::setController(Controller * controller)
  {
    m_controller = controller;
  }

  void Element::setTransformation(const math::Matrix<double, 3, 3> & /*m*/)
  {
  }
}