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

element.hpp « gui - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 51791017359d29971258937fbbce49dc08ad4cf2 (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
#pragma once

#include "../geometry/point2d.hpp"

#include "../graphics/overlay_element.hpp"
#include "../graphics/color.hpp"
#include "../graphics/font_desc.hpp"

#include "../std/map.hpp"

namespace graphics
{
  namespace gl
  {
    class OverlayRenderer;
  }
}

namespace gui
{
  class Controller;

  class Element : public graphics::OverlayElement
  {
  public:

    enum EState
    {
      EInactive,
      EActive,
      EPressed,
      ESelected
    };

  protected:

    Controller * m_controller;

  private:

    EState m_state;

    mutable map<EState, graphics::FontDesc> m_fonts;
    mutable map<EState, graphics::Color> m_colors;

  public:

    typedef OverlayElement::Params Params;

    Element(Params const & p);

    void setState(EState state);
    EState state() const;

    virtual void setFont(EState state, graphics::FontDesc const & font);
    graphics::FontDesc const & font(EState state) const;

    virtual void setColor(EState state, graphics::Color const & c);
    graphics::Color const & color(EState state) const;

    /// Implement this method to handle single tap on the GUI element.
    virtual bool onTapStarted(m2::PointD const & pt);
    virtual bool onTapMoved(m2::PointD const & pt);
    virtual bool onTapEnded(m2::PointD const & pt);
    virtual bool onTapCancelled(m2::PointD const & pt);

    void invalidate();
    double visualScale() const;

    graphics::OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const;
    void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
    int visualRank() const;

    virtual void cache();
    /// this method is called upon renderPolicy destruction and should clean
    /// all rendering-related resources, p.e. displayLists.
    virtual void purge();
    /// this method is called in each frame and should be overriden if the
    /// element wants to update it's internal state.
    virtual void update();

    virtual void setController(Controller * controller);

    void checkDirtyDrawing() const;
  };
}