You.i Engine
YiAbstractButtonView.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_ABSTRACT_BUTTONVIEW_H_
3 #define _YI_ABSTRACT_BUTTONVIEW_H_
4 
5 #include "signal/YiSignal.h"
6 #include "view/YiSceneView.h"
7 
8 class CYITextSceneNode;
9 
26 {
27 public:
31  enum class EnableState
32  {
34  Disabled = 0,
36  Enabled
37  };
38 
42  enum class PressState
43  {
45  Released = 0,
47  Pressed
48  };
49 
53  enum class OverState
54  {
56  Away = 0,
58  Over
59  };
60 
62  virtual ~CYIAbstractButtonView();
63 
64  virtual bool Init() override;
65 
72  void Enable();
73 
80  void Disable();
81 
88  void SetEnabled(bool enabled);
89 
93  bool IsEnabled() const;
94 
98  bool IsPressed() const;
99 
103  bool IsOver() const;
104 
112  void SetText(const CYIString &text);
113 
123  const CYIString &GetText() const;
124 
132  void SetButtonID(int32_t buttonID);
133 
139  int32_t GetButtonID() const;
140 
141 protected:
145  virtual bool HandleEvent(const std::shared_ptr<CYIEventDispatcher> &pDispatcher, CYIEvent *pEvent) override;
146 
150  virtual void OnEnable() {}
151 
155  virtual void OnDisable() {}
156 
160  virtual void OnPress() {}
161 
165  virtual void OnRelease() {}
166 
170  virtual void OnEnter() {}
171 
175  virtual void OnLeave() {}
176 
180  virtual void OnCancel() {}
181 
187  void StartTimelineForward(CYIAbstractTimeline *pTimeline, const char *pFunctionName = nullptr, const char *pTimelineName = nullptr);
188 
194  void StartTimelineReverse(CYIAbstractTimeline *pTimeline, const char *pFunctionName = nullptr, const char *pTimelineName = nullptr);
195 
199  virtual void FinishAllPlayingTimelines() {}
200 
217  int32_t m_buttonID;
218 
227 
229 };
230 
235 #endif // _YI_ABSTRACT_BUTTONVIEW_H_
EnableState
Definition: YiAbstractButtonView.h:31
void SetEnabled(bool enabled)
The base class for the timeline framework.
Definition: YiAbstractTimeline.h:29
CYITextSceneNode * m_pButtonTextNode
Definition: YiAbstractButtonView.h:222
void StartTimelineReverse(CYIAbstractTimeline *pTimeline, const char *pFunctionName=nullptr, const char *pTimelineName=nullptr)
Provides an abstraction for a button which accepts user interaction in the form of a press...
Definition: YiAbstractButtonView.h:25
virtual void OnEnable()
Definition: YiAbstractButtonView.h:150
bool IsEnabled() const
Base class for events.
Definition: YiEvent.h:27
The base class for all view types. Views are containers of renderable elements that often define inte...
Definition: YiSceneView.h:47
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:36
virtual void OnRelease()
Definition: YiAbstractButtonView.h:165
virtual bool Init() override
EnableState m_enableState
Definition: YiAbstractButtonView.h:204
int32_t m_buttonID
Definition: YiAbstractButtonView.h:217
virtual void OnEnter()
Definition: YiAbstractButtonView.h:170
virtual void OnDisable()
Definition: YiAbstractButtonView.h:155
bool IsPressed() const
virtual void FinishAllPlayingTimelines()
Definition: YiAbstractButtonView.h:199
virtual ~CYIAbstractButtonView()
virtual void OnLeave()
Definition: YiAbstractButtonView.h:175
A scene node type that renders text.
Definition: YiTextSceneNode.h:78
virtual void OnCancel()
Definition: YiAbstractButtonView.h:180
CYITextSceneNode * m_pButtonTextNodePress
Definition: YiAbstractButtonView.h:226
virtual bool HandleEvent(const std::shared_ptr< CYIEventDispatcher > &pDispatcher, CYIEvent *pEvent) override
void StartTimelineForward(CYIAbstractTimeline *pTimeline, const char *pFunctionName=nullptr, const char *pTimelineName=nullptr)
const CYIString & GetText() const
virtual void OnPress()
Definition: YiAbstractButtonView.h:160
void SetButtonID(int32_t buttonID)
int32_t GetButtonID() const
PressState m_pressState
Definition: YiAbstractButtonView.h:208
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:257
PressState
Definition: YiAbstractButtonView.h:42
OverState m_overState
Definition: YiAbstractButtonView.h:212
OverState
Definition: YiAbstractButtonView.h:53
void SetText(const CYIString &text)