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/YiActionEvent.h"
5 #include "event/YiEventFilter.h"
6 #include "event/YiKeyEvent.h"
8 #include "signal/YiSignal.h"
10 
11 #include <glm/vec2.hpp>
12 
14 class CYIApp;
15 class CYIDevPanelItemView;
16 class CYIDevWidget;
17 class CYIGeoList;
18 class CYIGeoScene;
19 class CYIGeoView;
20 class CYISceneManager;
21 class CYISceneView;
22 
61 {
62 public:
63  enum class InsertPosition
64  {
65  Top,
66  Bottom
67  };
68 
73 
74  CYIDevPanel(CYISceneManager *pSceneManager, CYIApp *pApp);
75  ~CYIDevPanel();
76 
80  void Open();
81 
85  void Close();
86 
90  void ToggleVisibility();
91 
97  bool IsActive() const;
98 
102  bool IsVisible() const;
103 
107  bool IsConfigurationSubpanelOpen() const;
108 
114  void AddWidget(std::unique_ptr<CYIDevWidget> pWidget, InsertPosition insertPosition = InsertPosition::Top);
115 
119  void UpdateWidget(size_t indexInPanel);
120 
126  template<class T>
127  T *GetWidget() const;
128 
132  std::vector<CYIDevWidget *> GetWidgets() const;
133 
137  CYIApp *GetApp() const;
138 
145 
150 
156  void SimulatePanelItemClicked(size_t index);
157 
163  void SimulateConfigurationItemClicked(size_t widgetIndex, size_t itemIndex);
164 
170  void OpenConfigurationSubpanel(CYIDevWidget *pWidget, const std::vector<std::pair<CYIString, CYIString>> &items);
171 
176 
183 
187  bool Update(bool *pSkipUpdate = nullptr);
188 
192  void Draw();
193 
200 
210 
211 private:
212  void CreateStartupSystemWidgets();
213  void CreateSystemWidgets();
214  void AddWidgetInternal(std::unique_ptr<CYIDevWidget> pWidget, InsertPosition insertPosition);
215  void Initialize();
216  void CreateViews();
217  void AddViewForWidget(size_t widgetIndex);
218  void UpdatePanelItems();
219  void UpdatePanelItem(const std::shared_ptr<CYIDevPanelItemView> &pPanelItem, CYIDevWidget *pWidget);
220  void OnPanelItemClicked(size_t buttonID);
221  void OnConfigureButtonClicked(size_t buttonID);
222  void OpenConfigurationSubpanel(size_t widgetID);
223  void ConfigureConfigureArrows(CYIDevWidget *pConfiguringWidget);
224  void OnAnimationComplete();
225  void OnConfigureSubpanelAnimationComplete();
226  bool IsTouchActivation(int32_t x, int32_t y);
227  bool IsKeyActivation(const CYIKeyEvent &keyEvent);
228  bool HandleSimulatedKeys(int32_t x, int32_t y, CYIEvent::Type eventType, CYIDevWidget *pWidget);
229  void UpdatePanelScale();
230  bool HandleTrackpadEvent(const CYITrackpadEvent *pEvent);
231  bool HandleKeyInputs(const CYIKeyEvent &keyEvent);
232  bool HandleActionInputs(int32_t x, int32_t y, int32_t wheelDelta, CYIActionEvent::ButtonType button, CYIEvent::Type eventType, uint8_t pointerID, bool hover);
233  bool SimulateTrackpadKeyEvent(CYIKeyEvent::KeyCode keyCode);
234 
235  // CYIBackButtonHandler::Listener functions
236  virtual bool OnBackButtonPressed() override;
237 
238  // CYIEventFilter functions
239  virtual bool PreFilterEvent(const std::shared_ptr<CYIEventDispatcher> &pDispatcher, CYIEvent *pEvent, CYIEventHandler *pDestination) override;
240  virtual bool PostFilterEvent(const std::shared_ptr<CYIEventDispatcher> &pDispatcher, CYIEvent *pEvent, CYIEventHandler *pDestination) override;
241 
242  std::shared_ptr<CYIAssetTextureBase> m_pLogoTexture;
243  std::vector<std::unique_ptr<CYIDevWidget>> m_widgets;
244  CYISceneView *m_pPanelView;
245  CYISceneView *m_pWidgetsContainer;
246  bool m_panelActive;
247 
248  bool m_systemWidgetsCreated;
249 
250  CYIDevWidget *m_pConfiguringWidget;
251  bool m_subconfigurationPanelActive;
252 
253  uint8_t m_touchesCount;
254  int64_t m_lastTouchTime;
255 
256  class KeySequence
257  {
258  const CYIKeyEvent::KeyCode *m_pKeyCode;
259  uint8_t m_validKeyCount;
260  int64_t m_lastKeyEventTime;
261  size_t m_totalKeyCount;
262 
263  public:
264  template<size_t totalKeyCount>
265  KeySequence(const CYIKeyEvent::KeyCode (&keyCode)[totalKeyCount])
266  : m_pKeyCode(keyCode)
267  , m_validKeyCount(0)
268  , m_lastKeyEventTime(0)
269  , m_totalKeyCount(totalKeyCount)
270  {
271  }
272 
273  bool IsCodeActivation(const CYIKeyEvent &keyEvent);
274  };
275  std::vector<KeySequence> m_keySequences;
276 
277  bool m_suppressNextKeyUpEvent;
278  bool m_renderNextFrame;
279  uint64_t m_panelAnimationDurationMs;
280 
281  bool m_inTrackpadGesture;
282  glm::vec2 m_lastProcessedGestureLocation;
283 
284  CYISceneManager *m_pSceneManager;
285  CYIApp *m_pApp;
286 
287  std::shared_ptr<CYIGeoScene> m_pDevPanel;
288  std::shared_ptr<CYIGeoView> m_pListContainer;
289  std::shared_ptr<CYIGeoList> m_pList;
290  std::shared_ptr<CYIGeoView> m_pSubListContainer;
291  std::shared_ptr<CYIGeoList> m_pSubList;
292  std::vector<std::shared_ptr<CYIDevPanelItemView>> m_panelItems;
293 };
294 
297 #include "debug/YiDevPanel.inl"
298 
299 #endif
Stores data related to trackpad input.
Definition: YiTrackpadEvent.h:22
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
CYISceneManager * GetSceneManager() const
void SimulatePanelItemClicked(size_t index)
Scene trees composed of CYISceneNode objects are registered with the scene manager in order for them ...
Definition: YiSceneManager.h:75
CYIDevPanel(CYISceneManager *pSceneManager, CYIApp *pApp)
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
bool IsActive() const
bool Update(bool *pSkipUpdate=nullptr)
Insert at the top of the widgets list.
Implement this interface to provide custom behaviour when the system back button is pressed...
Definition: YiBackButtonHandler.h:30
static const CYIString DEV_PANEL_ASSETS_PREFIX
Definition: YiDevPanel.h:72
T * GetWidget() const
CYISceneView * GetWidgetsContainer() const
void CloseConfigurationSubpanel()
void ReconfigureConfigurationSubpanel(CYIDevWidget *pWidget)
CYISignal UserDeactivated
Definition: YiDevPanel.h:209
void Close()
void AddWidget(std::unique_ptr< CYIDevWidget > pWidget, InsertPosition insertPosition=InsertPosition::Top)
void OpenConfigurationSubpanel(CYIDevWidget *pWidget, const std::vector< std::pair< CYIString, CYIString >> &items)
Definition: YiSignalHandler.h:175
ButtonType
Definition: YiActionEvent.h:21
CYISignal UserActivated
Definition: YiDevPanel.h:199
CYIApp * GetApp() const
bool IsVisible() const
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:36
KeyCode
Key code for CYIKeyEvent events.
Definition: YiKeyEvent.h:34
void UpdateWidget(size_t indexInPanel)
Allows children that inherit from this class to implement processing before and after events are hand...
Definition: YiEventFilter.h:24
std::vector< CYIDevWidget * > GetWidgets() const
Insert at the bottom of the widgets list.
bool IsConfigurationSubpanelOpen() const
A class used to manipulate developer utilities.
Definition: YiDevPanel.h:60
Signals and slots are a thread-safe and flexible communication framework that will allow various obje...
Definition: YiSignal.h:168
InsertPosition
Definition: YiDevPanel.h:63
The base class for all applications.
Definition: YiApp.h:45
Type
The event type of the CYIEvent class instance.
Definition: YiEvent.h:33
void SimulateConfigurationItemClicked(size_t widgetIndex, size_t itemIndex)
void ToggleVisibility()