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

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

#include "element.hpp"
#include "text_view.hpp"

#include "../std/function.hpp"
#include "../std/string.hpp"
#include "../std/scoped_ptr.hpp"

namespace graphics
{
  class OverlayElement;

  namespace gl
  {
    class OverlayRenderer;
  }
}

namespace gui
{
  class Button : public Element
  {
  public:

    typedef function<void (Element const *)> TOnClickListener;

  private:

    TOnClickListener m_OnClickListener;

    unsigned m_minWidth;
    unsigned m_minHeight;

    scoped_ptr<TextView> m_textView;
    map<EState, shared_ptr<graphics::DisplayList> > m_dls;

    void cacheButtonBody(EState state);

    mutable vector<m2::AnyRectD> m_boundRects;

    void cache();

  public:

    struct Params : Element::Params
    {
      unsigned m_minWidth;
      unsigned m_minHeight;
      string m_text;
      Params();
    };

    Button(Params const & p);

    bool onTapStarted(m2::PointD const & pt);
    bool onTapMoved(m2::PointD const & pt);
    bool onTapEnded(m2::PointD const & pt);
    bool onTapCancelled(m2::PointD const & pt);

    void setOnClickListener(TOnClickListener const & l);

    void setPivot(m2::PointD const & pv);
    void setFont(EState state, graphics::FontDesc const & font);
    void setColor(EState state, graphics::Color const & c);

    void setText(string const & text);
    string const & text() const;

    void setMinWidth(unsigned minWidthInDIP);
    unsigned minWidth() const;

    void setMinHeight(unsigned minHeightInDIP);
    unsigned minHeight() const;

    void setController(Controller * controller);

    /// Inherited from OverlayElement
    /// @{

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

    void purge();
    void layout();

    /// @}
  };
}