Joystick.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <etk/types.hpp>
9 #include <etk/Color.hpp>
10 #include <ewol/debug.hpp>
11 #include <ewol/widget/Widget.hpp>
12 #include <esignal/Signal.hpp>
13 
14 // TODO : Rework ==> use property and shaper ...
15 
16 namespace ewol {
17  namespace widget {
18  class Joystick;
19  using JoystickShared = ememory::SharedPtr<ewol::widget::Joystick>;
20  using JoystickWeak = ememory::WeakPtr<ewol::widget::Joystick>;
24  class Joystick :public ewol::Widget {
25  public:
26  // Event list of properties
27  esignal::Signal<> signalEnable;
28  esignal::Signal<> signalDisable;
29  esignal::Signal<vec2> signalMove;
30  public:
31  enum joystickMode {
32  modeNormal,
33  modeArrow,
34  };
35  private:
36  etk::Color<> m_colorFg;
37  etk::Color<> m_colorBg;
38  vec2 m_displayPos;
39  float m_distance;
40  float m_angle;
41  bool m_lock;
42  enum joystickMode m_displayMode;
43  private:
44  // generic property of the joystick:
45  bool m_displayBackground;
46  std::string m_background;
47  std::string m_foreground;
48  float m_ratio;
49  protected:
50  Joystick();
51  public:
52  DECLARE_WIDGET_FACTORY(Joystick, "Joystick");
53  virtual ~Joystick();
54  public:
55  void setLockMode(bool _lockWhenOut) {
56  m_lock = _lockWhenOut;
57  };
58  void setDisplayMode(enum joystickMode _newMode) {
59  m_displayMode = _newMode;
60  };
65  void ratio(float _newRatio);
71  void background(std::string _imageNameInData, bool _display=true);
76  void foreground(std::string _imageNameInData);
82  void getProperty(float& _distance, float& _angle);
83 
84  public:
85  virtual void onRegenerateDisplay() override;
86  virtual bool onEventInput(const ewol::event::Input& _event) override;
87  };
88  };
89 };
90 
void getProperty(float &_distance, float &_angle)
get the property of the joystick
Definition: Input.hpp:12
void foreground(std::string _imageNameInData)
set the Foreground of the widget joystick
virtual void onRegenerateDisplay() override
Event generated when a redraw is needed.
Definition: Area.hpp:16
void background(std::string _imageNameInData, bool _display=true)
set the Background of the widget joystick
Definition: Joystick.hpp:24
void ratio(float _newRatio)
set the ratio of the widget joystick
Widget class is the main widget interface, it hase some generic properties: :** known his parent :** ...
Definition: Widget.hpp:73
virtual bool onEventInput(const ewol::event::Input &_event) override
Event on an input of this Widget (finger, mouse, stilet)