You.i Engine
YiDrawerView.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_DRAWER_VIEW_H
3 #define _YI_DRAWER_VIEW_H
4 
5 #include "signal/YiSignal.h"
6 #include "view/YiSceneView.h"
7 
29 class CYIDrawerView : public CYISceneView, public CYISceneNode::PropertyAnimation::Listener
30 {
31 public:
35  enum class Direction
36  {
37  BottomToTop,
38  TopToBottom,
39  LeftToRight,
41  };
42 
46  enum class State
47  {
48  Closed,
49  Opened,
50  Opening,
51  Closing,
52  ClosedHidden,
53  OpenedHidden
54  };
55 
56  CYIDrawerView();
57 
64 
71 
78 
85 
86  virtual bool Init() override;
87 
88  virtual bool HandleEvent(const std::shared_ptr<CYIEventDispatcher> &pDispatcher, CYIEvent *pEvent) override;
89 
91 
96  virtual void Open();
97 
102  virtual void Close();
103 
112  virtual void ShowDrawer();
113 
121  virtual void HideDrawer();
122 
127 
135  void SetDrawerOpenDirection(Direction direction, float drawerLength);
136 
142  State GetDrawerState() const;
143 
147  float GetDrawerThreshold() const;
148 
158  void SetDrawerThreshold(float drawerThresholdPercentage);
159 
163  uint32_t GetDrawerDelay() const;
164 
170  void SetDrawerDelay(uint32_t drawerDelayMs);
171 
177  void SetDrawerOpenInterpolator(CYITimeInterpolator *pInterpolator);
178 
184  void SetDrawerCloseInterpolator(CYITimeInterpolator *pInterpolator);
185 
186 protected:
190  void SetDrawerState(State state);
191 
196 
200  float GetDrawerPosition() const;
201 
205  bool IsInversed() const;
209  bool IsHorizontal() const;
210 
213 
220  uint32_t m_drawerDelayMs;
221 
224 
225 private:
226  bool m_mouseDown;
227 
229 };
230 
234 {
235  return m_drawerOpenDirection;
236 }
237 
239 {
240  return m_drawerState;
241 }
242 
244 {
245  return m_drawerThreshold;
246 }
247 
248 inline void CYIDrawerView::SetDrawerThreshold(float drawerThresholdPercentage)
249 {
250  m_drawerThreshold = drawerThresholdPercentage;
251 }
252 
253 inline uint32_t CYIDrawerView::GetDrawerDelay() const
254 {
255  return m_drawerDelayMs;
256 }
257 
258 inline void CYIDrawerView::SetDrawerDelay(uint32_t drawerDelayMs)
259 {
260  m_drawerDelayMs = drawerDelayMs;
261 }
262 
264 {
265  m_pDrawerOpenInterpolator = pInterpolator;
266 }
267 
269 {
270  m_pDrawerCloseInterpolator = pInterpolator;
271 }
272 
273 #endif // _YI_DRAWER_VIEW_H
State
Possible states the drawer can be in.
Definition: YiDrawerView.h:46
Container for basic interpolator functions.
Definition: YiTimeInterpolator.h:20
Direction m_drawerOpenDirection
Definition: YiDrawerView.h:211
Direction GetDrawerOpenDirection() const
Definition: YiDrawerView.h:233
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
Type
Definition: YiSceneNode.h:170
bool IsHorizontal() const
float m_drawerHiddenPos
Definition: YiDrawerView.h:218
Direction used for bottom edge drawers that will open from bottom to top.
virtual void ShowDrawer()
virtual void HideDrawer()
CYISignal< State > DrawerStateChanged
Definition: YiDrawerView.h:84
State GetDrawerState() const
Definition: YiDrawerView.h:238
CYISignal< float > OpenedPercentage
Definition: YiDrawerView.h:63
Direction used for top edge drawers that will open from top to bottom.
void SetDrawerThreshold(float drawerThresholdPercentage)
Definition: YiDrawerView.h:248
float GetDrawerThreshold() const
Definition: YiDrawerView.h:243
State m_drawerState
Definition: YiDrawerView.h:212
Direction used for right edge drawers that will open from right to left.
float m_drawerClosePos
Definition: YiDrawerView.h:216
void SetDrawerDelay(uint32_t drawerDelayMs)
Definition: YiDrawerView.h:258
CYITimeInterpolator * m_pDrawerCloseInterpolator
Definition: YiDrawerView.h:223
CYITimeInterpolator * m_pDrawerOpenInterpolator
Definition: YiDrawerView.h:222
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
float m_drawerOpenPos
Definition: YiDrawerView.h:217
float m_pointerStartPos
Definition: YiDrawerView.h:214
void SetDrawerOpenDirection(Direction direction, float drawerLength)
bool IsInversed() const
float GetDrawerPosition() const
float m_drawerThreshold
Definition: YiDrawerView.h:219
float m_drawerStartPos
Definition: YiDrawerView.h:215
uint32_t GetDrawerDelay() const
Definition: YiDrawerView.h:253
void SetDrawerCloseInterpolator(CYITimeInterpolator *pInterpolator)
Definition: YiDrawerView.h:268
uint32_t m_drawerDelayMs
Definition: YiDrawerView.h:220
virtual bool Init() override
virtual void Open()
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:257
virtual void Close()
CYISignal Closed
Definition: YiDrawerView.h:77
virtual void OnPropertyAnimationComplete(CYISceneNode *pNode, PropertyAnimation::Type propType)
Direction used for left edge drawers that will open from left to right.
PropertyAnimation::Type GetDrawerPropertyType() const
The CYIDrawerView can be placed around the edges of a view, making it possible for the user to swipe ...
Definition: YiDrawerView.h:29
Direction
The direction the drawer will open. The direction is relative to the parent&#39;s local space...
Definition: YiDrawerView.h:35
CYISignal Opened
Definition: YiDrawerView.h:70
virtual bool HandleEvent(const std::shared_ptr< CYIEventDispatcher > &pDispatcher, CYIEvent *pEvent) override
void SetDrawerOpenInterpolator(CYITimeInterpolator *pInterpolator)
Definition: YiDrawerView.h:263
void SetDrawerState(State state)