You.i Engine
YiDevWidget.h
Go to the documentation of this file.
1 #ifndef _YI_DEV_WIDGET_H_
2 #define _YI_DEV_WIDGET_H_
3 
4 #include "debug/YiDevPanel.h"
6 #include "utility/YiRtti.h"
7 #include "utility/YiString.h"
8 #include "utility/YiTimer.h"
9 
10 class CYISceneNode;
11 
37 {
38 public:
42  enum class State
43  {
44  Off = 0,
45  On,
46  Stateless,
47  Disabled
48  };
49 
50  CYIDevWidget(const CYIString &title, const CYIString &subtitle = "");
51  virtual ~CYIDevWidget();
52 
56  bool IsUsingIndicator() const;
57 
63  bool IsUsingSimulatedKeys() const;
64 
70  bool IsCapturingAllEvents() const;
71 
77  bool IsUsingConfigurationItems() const;
78 
82  State GetState() const;
83 
87  virtual const CYIString &GetTitle() const;
88 
92  virtual const CYIString &GetSubtitle() const;
93 
97  void SetParentPanel(CYIDevPanel *pPanel, size_t indexInPanel);
98 
102  size_t GetIndexInPanel() const;
103 
107  void UpdateWidgetState();
108 
114  virtual void OnPanelItemClicked() = 0;
115 
119  virtual void RefreshState(){};
120 
124  virtual void OnConfigureButtonClicked();
125 
129  virtual void OnConfigurationItemClicked(size_t buttonID);
130 
134  virtual void OnConfigurationSubpanelClosed();
135 
139  virtual void OnDraw(){};
140 
144  virtual bool OnUpdate(bool *pSkipUpdate = nullptr);
145 
149  virtual bool OnHandleKeyInputs(const CYIKeyEvent &keyEvent);
150 
154  virtual bool OnHandleActionInputs(int32_t x, int32_t y, int32_t wheelDelta, CYIActionEvent::ButtonType button, CYIEvent::Type eventType, uint8_t pointerID, bool hover);
155 
159  virtual bool OnPreFilterEvent(const std::shared_ptr<CYIEventDispatcher> &pDispatcher, CYIEvent *pEvent, CYIEventHandler *pDestination);
160 
165 
169  bool SimulateKeyPress(const CYIKeyEvent &keyEvent);
170 
175 
176 protected:
180  void SetUseSimulatedKeys(bool useSimulatedKeys);
181 
185  void SetCaptureAllEvents(bool captureAllEvents);
186 
192  void SetUsesConfigurationItems(bool usesConfigurationItems);
193 
201  virtual std::vector<std::pair<CYIString, CYIString>> GetConfigurationButtonTitles();
202 
206  CYISceneNode *GetLogicalRoot() const;
207 
213 
214 private:
215  void OnTimerExpired();
216 
217  CYITimer m_timer;
218  bool m_useSimulatedKeys;
219  bool m_captureAllEvents;
220  bool m_useConfigurationItems;
221  bool m_actionDown;
222  CYIKeyEvent m_lastKeyEvent;
223 
225 };
226 
229 #endif
virtual const CYIString & GetTitle() const
Indicates that the widget is inactive/off.
virtual void OnConfigureButtonClicked()
bool IsCapturingAllEvents() const
Class for key events.
Definition: YiKeyEvent.h:15
Allows registering of event filters which can be used to perform processing on an event before and af...
Definition: YiEventHandler.h:25
virtual std::vector< std::pair< CYIString, CYIString > > GetConfigurationButtonTitles()
bool IsUsingConfigurationItems() const
void SetUsesConfigurationItems(bool usesConfigurationItems)
Base class for events.
Definition: YiEvent.h:27
virtual bool OnHandleKeyInputs(const CYIKeyEvent &keyEvent)
CYISceneNode * GetLogicalRoot() const
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:36
bool IsUsingSimulatedKeys() const
void SetUseSimulatedKeys(bool useSimulatedKeys)
void UpdateWidgetState()
virtual bool OnPreFilterEvent(const std::shared_ptr< CYIEventDispatcher > &pDispatcher, CYIEvent *pEvent, CYIEventHandler *pDestination)
bool SimulateKeyPress(const CYIKeyEvent &keyEvent)
virtual void RefreshState()
Definition: YiDevWidget.h:119
virtual void OnPanelItemClicked()=0
CYIDevPanel * m_pParentPanel
Definition: YiDevWidget.h:208
Indicates that this widget cannot (currently) be activated.
void SimulatedKeyPressesEnded()
virtual void OnConfigurationItemClicked(size_t buttonID)
CYIString m_title
Definition: YiDevWidget.h:211
Indicates that the widget is active/on.
CYIDevWidget(const CYIString &title, const CYIString &subtitle="")
A low-precision timer driven by the update loop.
Definition: YiTimer.h:27
bool IsUsingIndicator() const
State GetState() const
A scene node is the base type for all nodes which are used by the scene manager; it is an integral pa...
Definition: YiSceneNode.h:99
virtual bool OnUpdate(bool *pSkipUpdate=nullptr)
CYIString m_subtitle
Definition: YiDevWidget.h:212
virtual const CYIString & GetSubtitle() const
Definition: YiSignalHandler.h:175
ButtonType
Definition: YiActionEvent.h:21
State
Definition: YiDevWidget.h:42
State m_state
Definition: YiDevWidget.h:210
The base class for all dev widgets.
Definition: YiDevWidget.h:36
void SetParentPanel(CYIDevPanel *pPanel, size_t indexInPanel)
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:257
void SimulatePanelItemClicked()
virtual ~CYIDevWidget()
size_t m_indexInPanel
Definition: YiDevWidget.h:209
size_t GetIndexInPanel() const
This file contains the classes and macros used to implement RTTI in You.i Engine. ...
A class used to manipulate developer utilities.
Definition: YiDevPanel.h:60
virtual bool OnHandleActionInputs(int32_t x, int32_t y, int32_t wheelDelta, CYIActionEvent::ButtonType button, CYIEvent::Type eventType, uint8_t pointerID, bool hover)
void SetCaptureAllEvents(bool captureAllEvents)
Type
The event type of the CYIEvent class instance.
Definition: YiEvent.h:33
Indicates that this widget does not make use of states.
virtual void OnConfigurationSubpanelClosed()
virtual void OnDraw()
Definition: YiDevWidget.h:139