You.i Engine
YiDevPanel.h
Go to the documentation of this file.
1 #ifndef _YI_DEV_PANEL_H_
2 #define _YI_DEV_PANEL_H_
3 
4 #include "event/YiEventFilter.h"
5 #include "event/YiKeyEvent.h"
7 #include "signal/YiSignal.h"
9 
10 #include <glm/vec2.hpp>
11 
13 class CYIApp;
14 class CYIDevPanelItemView;
15 class CYIDevWidget;
16 class CYIGeoList;
17 class CYIGeoScene;
18 class CYIGeoView;
19 class CYISceneManager;
20 class CYISceneView;
21 
53 {
54 public:
56  {
57  TOP,
59  };
60 
65 
66  CYIDevPanel(CYISceneManager *pSceneManager, CYIApp *pApp);
67  ~CYIDevPanel();
68 
72  void Open();
73 
77  void Close();
78 
82  void ToggleVisibility();
83 
89  bool IsActive() const;
90 
94  bool IsVisible() const;
95 
99  bool IsConfigurationSubpanelOpen() const;
100 
101 
107  void AddWidget(std::unique_ptr<CYIDevWidget> pWidget, INSERT_POSITION eInsertPosition = TOP);
108  std::vector<CYIDevWidget *> GetWidgets() const;
109 
113  void UpdateWidget(uint32_t uIndexInPanel);
114 
120  template<class T>
121  T *GetWidget() const;
122 
126  CYIApp *GetApp() const;
127 
134 
139 
145  void SimulatePanelItemClicked(uint32_t uIndex);
146 
152  void SimulateConfigurationItemClicked(uint32_t uWidgetIndex, uint32_t uItemIndex);
153 
159  void OpenConfigurationSubpanel(CYIDevWidget *pWidget, const std::vector<std::pair<CYIString, CYIString> > &items);
160 
165 
172 
173 
174  bool HandleKeyInputs(const CYIKeyEvent &keyEvent);
175  bool HandleActionInputs(int32_t nX, int32_t nY, int32_t nWheelDelta, uint8_t uButton, YI_EVENT_TYPE eEventType, uint8_t uPointerID, bool bHover);
176 
180  bool Update(bool *pbSkipUpdate = nullptr);
181 
185  void Draw();
186 
193 
203 
204 private:
205  void CreateSystemWidgets();
206  void Initialize();
207  void CreateViews();
208  void AddViewForWidget(uint32_t uWidgetIndex);
209  void UpdatePanelItems();
210  void UpdatePanelItem(const std::shared_ptr<CYIDevPanelItemView> &pPanelItem, CYIDevWidget *pWidget);
211  void OnPanelItemClicked(int32_t nButtonID);
212  void OnConfigureButtonClicked(int32_t nButtonID);
213  void OpenConfigurationSubpanel(int32_t nWidgetID);
214  void ConfigureConfigureArrows(CYIDevWidget *pConfiguringWidget);
215  void OnAnimationComplete();
216  void OnConfigureSubpanelAnimationComplete();
217  bool IsTouchActivation(int32_t nX, int32_t nY);
218  bool IsKeyActivation(const CYIKeyEvent &keyEvent);
219  bool IsPlayPauseActivation(const CYIKeyEvent &keyEvent);
220  bool IsKonamiCodeActivation(const CYIKeyEvent &keyEvent);
221  bool HandleSimulatedKeys(int32_t nX, int32_t nY, YI_EVENT_TYPE eEventType, CYIDevWidget *pWidget);
222  void UpdatePanelScale();
223  bool HandleTrackpadEvent(const CYITrackpadEvent *pEvent);
224  bool SimulateTrackpadKeyEvent(YI_KEY_CODE eKeyCode);
225 
226  // CYIBackButtonHandler::Listener functions
227  virtual bool OnBackButtonPressed() override;
228 
229  // CYIEventFilter functions
230  virtual bool PreFilterEvent(const std::shared_ptr<CYIEventDispatcher> &pDispatcher, CYIEvent *pEvent, CYIEventHandler *pDestination) override;
231  virtual bool PostFilterEvent(const std::shared_ptr<CYIEventDispatcher> &pDispatcher, CYIEvent *pEvent, CYIEventHandler *pDestination) override;
232 
233  std::shared_ptr<CYIAssetTextureBase> m_pLogoTexture;
234  std::vector<std::unique_ptr<CYIDevWidget>> m_widgets;
235  CYISceneView *m_pPanelView;
236  CYISceneView *m_pWidgetsContainer;
237  bool m_bPanelActive;
238 
239  bool m_bSystemWidgetsCreated;
240 
241  CYIDevWidget *m_pConfiguringWidget;
242  bool m_bSubconfigurationPanelActive;
243 
244  uint8_t m_uTouchesCount;
245  int64_t m_nLastTouchTime;
246 
247  uint8_t m_uValidPlayPauseKeyCount;
248  int64_t m_nLastPlayPauseKeyEventTime;
249 
250  uint8_t m_uValidKonamiKeyCount;
251  int64_t m_nLastKonamiKeyEventTime;
252 
253  bool m_bSuppressNextKeyUpEvent;
254  bool m_bRenderNextFrame;
255 
256  bool m_bInTrackpadGesture;
257  glm::vec2 m_lastProcessedGestureLocation;
258 
259  CYISceneManager *m_pSceneManager;
260  CYIApp *m_pApp;
261 
262  std::shared_ptr<CYIGeoScene> m_pDevPanel;
263  std::shared_ptr<CYIGeoView> m_pListContainer;
264  std::shared_ptr<CYIGeoList> m_pList;
265  std::shared_ptr<CYIGeoView> m_pSubListContainer;
266  std::shared_ptr<CYIGeoList> m_pSubList;
267  std::vector<std::shared_ptr<CYIDevPanelItemView>> m_panelItems;
268 };
269 
272 #include "debug/YiDevPanel.inl"
273 
274 #endif
void AddWidget(std::unique_ptr< CYIDevWidget > pWidget, INSERT_POSITION eInsertPosition=TOP)
bool HandleKeyInputs(const CYIKeyEvent &keyEvent)
void OpenConfigurationSubpanel(CYIDevWidget *pWidget, const std::vector< std::pair< CYIString, CYIString > > &items)
void SimulateConfigurationItemClicked(uint32_t uWidgetIndex, uint32_t uItemIndex)
Stores data related to trackpad input.
Definition: YiTrackpadEvent.h:22
void SimulatePanelItemClicked(uint32_t uIndex)
bool IsVisible() const
Class for key events.
Definition: YiKeyEvent.h:15
bool IsConfigurationSubpanelOpen() const
Allows registering of event filters which can be used to perform processing on an event before and af...
Definition: YiEventHandler.h:25
Scene trees composed of CYISceneNode objects are registered with the scene manager in order for them ...
Definition: YiSceneManager.h:73
bool Update(bool *pbSkipUpdate=nullptr)
CYIDevPanel(CYISceneManager *pSceneManager, CYIApp *pApp)
Base class for events.
Definition: YiEvent.h:489
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:35
T * GetWidget() const
bool HandleActionInputs(int32_t nX, int32_t nY, int32_t nWheelDelta, uint8_t uButton, YI_EVENT_TYPE eEventType, uint8_t uPointerID, bool bHover)
YI_EVENT_TYPE
The event type of the CYIEvent class instance.
Definition: YiEvent.h:23
Implement this interface to provide custom behaviour when the system back button is pressed...
Definition: YiBackButtonHandler.h:32
The base class for an object accessible from script source code.
Definition: YiScriptableObject.h:28
static const CYIString DEV_PANEL_ASSETS_PREFIX
Definition: YiDevPanel.h:64
void CloseConfigurationSubpanel()
CYISceneManager * GetSceneManager() const
void ReconfigureConfigurationSubpanel(CYIDevWidget *pWidget)
CYISignal UserDeactivated
Definition: YiDevPanel.h:202
void UpdateWidget(uint32_t uIndexInPanel)
CYIApp * GetApp() const
YI_KEY_CODE
Key code for CYIKeyEvent events.
Definition: YiEvent.h:81
CYISceneView * GetWidgetsContainer() const
Insert at the bottom of the widgets list.
Definition: YiDevPanel.h:58
void Close()
Definition: YiSignalHandler.h:174
CYISignal UserActivated
Definition: YiDevPanel.h:192
bool IsActive() const
Insert at the top of the widgets list.
Definition: YiDevPanel.h:57
This asset represents the base class for POT (Power Of Two) and NPOT (Non-Power Of Two) textures...
Definition: YiAssetTextureBase.h:24
The base class for all dev widgets.
Definition: YiDevWidget.h:37
Allows children that inherit from this class to implement processing before and after events are hand...
Definition: YiEventFilter.h:24
A class used to manipulate developer utilities.
Definition: YiDevPanel.h:52
Signals and slots are a thread-safe and flexible communication framework that will allow various obje...
Definition: YiSignal.h:164
std::vector< CYIDevWidget * > GetWidgets() const
INSERT_POSITION
Definition: YiDevPanel.h:55
The base class for all applications.
Definition: YiApp.h:43
void ToggleVisibility()