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: 11124360f622b9f42f4d413bc40ab7af76c70c4d (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
#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 = 0,
      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);

    /// invalidate the rendering system to redraw the gui elements.
    void invalidate();
    /// obtain @see VisualScale
    double visualScale() const;

    /// this method is called to cache visual appearance of gui::Element for fast rendering.
    /// it should be called when isDirtyDrawing is set to true(visual parameters of object is changed).
    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();
    /// this method is called after gui::Controller::SetRenderParams to
    /// perform layout calculations which might depends on RenderParams.
    virtual void layout();
    /// set the parent controller for this element.
    virtual void setController(Controller * controller);
    /// check if the layout of element is dirty and re-layout element if needed.
    void checkDirtyLayout() const;

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

    void setTransformation(const math::Matrix<double, 3, 3> & m);
  };
}