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: 1e3416e1e09a0ce8fd14f8dc67fee6d8c2c9499e (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
#pragma once

#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 after layout() is calculated properly.
    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.
    /// It should be called when isDirtyLayout is set to true (visual parameters of object is changed).
    virtual void layout();
    /// Set the parent controller for this element. Should be called for all inner Elemen's too.
    virtual void setController(Controller * controller);

    /// Check if the layout of element is dirty and re-layout element if needed.
    /// Used in a "lazy" layout/cache strategy (called before actual drawing).
    void checkDirtyLayout() const;

    /// @name Override from OverlayElement.
    //@{
    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);
    //@}
  };
}