You.i Engine
YiListView.h
Go to the documentation of this file.
1 // © You i Labs Inc. All rights reserved.
2 #ifndef _YI_LIST_VIEW_H_
3 #define _YI_LIST_VIEW_H_
4 
5 #include "streamer/YiStreamer.h"
6 #include "view/YiScrollingView.h"
7 
35 class CYIListView : public CYIScrollingView, private CYIStreamer
36 {
37 public:
46  {
47  public:
48  friend class CYIListView;
49 
51 
52  protected:
53  /*
54  \details Gets the number of streamable items in the list. Implementing classes may use this member when implementing paging functions.
55  */
56  size_t GetItemCount() const;
57 
58  /*
59  \details Get the index of the streamed item found by the list to use as a reference to determine the current page. Implementing classes may use this member when implementing paging functions.
60  */
61  size_t GetPageReferenceItemIndex() const;
62 
63  private:
64  size_t m_itemCount;
65  size_t m_pageReferenceItemIndex;
66  };
67 
68  CYIListView();
69  virtual ~CYIListView();
70 
71  virtual bool Init() override;
72 
76  void SetAdapter(std::unique_ptr<CYINodeAdapter> pAdapter);
77 
81  const CYINodeAdapter *GetAdapter() const;
82 
87 
92 
96  bool IsStreamedIn(size_t index) const;
97 
101  CYISceneNode *GetStreamedNode(size_t index) const;
102 
108  size_t GetItemIndex(CYISceneNode *pStreamedItem) const;
109 
113  size_t GetFocusedItemIndex() const;
114 
122  void SetStreamingRegionFactor(float factor);
123 
127  float GetStreamingRegionFactor() const;
128 
139  void SetItemProperties(const CYIString &viewTemplateName, std::unique_ptr<IYIPropertiesSource> pProperties);
140 
147  IYIPropertiesSource *GetItemProperties(const CYIString &viewTemplateName) const;
148 
154  virtual void RevealItem(size_t index, uint32_t duration, CYITimeInterpolator *pInterpolator = nullptr);
155 
161  bool IsInVisibleRegion(size_t index) const;
162 
165  CYISignal<size_t /* index */, CYISceneNode *> ItemGainedFocus;
166  CYISignal<size_t /* index */, CYISceneNode *> ItemLostFocus;
168  size_t GetChildIndex(size_t itemIndex) const;
169 
170 protected:
176  virtual std::unique_ptr<CYILayout> CreateDefaultLayoutInstance() const;
177 
178  virtual void OnStreamedIn(size_t index, CYISceneNode *pStreamedItem) override;
179  virtual void OnStreamedOut(size_t index, CYISceneNode *pStreamedItem) override;
180 
181  virtual void FocusGainedForItem(size_t index) override;
182 
186  virtual void OnFocusGainedForItem(size_t index) override;
187 
188  virtual void FocusLostForItem(size_t index) override;
189 
193  virtual void OnFocusLostForItem(size_t index) override;
194 
195  // CYISceneNode functions
196  virtual void WorldBoundingBoxUpdated() override;
197  virtual void ApplyMeasurements() override;
198 
199  // CYIStreamer functions
201 
202  // CYIScrollingView functions
203  virtual void ParseProperties() override;
204  virtual void ChildVisibilityInVisibleRegionChanged(CYISceneNode *pChild, bool isInVisibleRegion) override;
205  virtual void ChildMovedInVisibleRegion(CYISceneNode *pChild, const glm::vec2 &normalizedPosition) override;
206  virtual CYIAbstractTimeline *GetCascadeTimelineFor(TimelineType type, CYISceneView *pView) override;
207 
208  virtual void UpdateHorizontalPagingStrategyImpl() override;
209  virtual void UpdateVerticalPagingStrategyImpl() override;
210 
211 private:
212  // CYIStreamer functions
213  virtual void InsertItem(size_t index, std::unique_ptr<CYISceneNode> pItem) override;
214  virtual std::unique_ptr<CYISceneNode> RemoveItem(size_t index, CYISceneNode *pItem) override;
215  virtual void ReorderItem(size_t fromIndex, size_t toIndex, CYISceneNode *pItem) override;
216  virtual bool IsItemInStreamingRegion(CYISceneNode *pItem) const override;
217  virtual CYISceneNode *GetItem(size_t index) const override;
218  virtual bool CanBeStreamedOut(size_t index, CYISceneNode *pNode) const override;
219 
220  void HandlePlaceholderItems();
221  virtual const std::vector<std::shared_ptr<CYIAssetViewTemplate>> &GetReferenceNodeViewTemplates() const;
222  virtual void StreamedIn(size_t index, CYISceneNode *pStreamedItem) override;
223  virtual void StreamedOut(size_t index, CYISceneNode *pStreamedItem) override;
224 
225  void InitializeItemInsertIndex();
226 
227  virtual void UpdateStreamedStateOfAllItems(bool triggeredByLayout);
228  void RemoveCascadeTimelineFor(TimelineType type, CYISceneNode *pNode, CYITimelineGroup *pCascadeGroup);
229 
230  virtual void CarouselStatusChanged(Direction direction, bool isCarousel) override;
231 
232  void OnViewWithFocusChanged(CYISceneView *pView);
233 
234  void OnHorizontalPositionChanged(float position);
235  void OnVerticalPositionChanged(float position);
236  size_t GetPageReferenceItem(Direction direction) const;
237 
238  size_t m_itemInsertIndex;
239  size_t m_streamingItemsCount;
240  float m_streamingRegionFactor;
241 
242  std::map<CYIString, std::unique_ptr<IYIPropertiesSource>> m_itemProperties;
243 
244  std::vector<std::shared_ptr<CYIAssetViewTemplate>> m_referenceNodeViewTemplates;
245 
246  CYISceneNode *m_pFocusedStreamableView;
247 
249 };
250 
255 #endif // _YI_LIST_VIEW_H_
virtual void ChildVisibilityInVisibleRegionChanged(CYISceneNode *pChild, bool isInVisibleRegion) override
The base class for the timeline framework.
Definition: YiAbstractTimeline.h:29
Container for basic interpolator functions.
Definition: YiTimeInterpolator.h:20
A class that implements a scene node streamer.
Definition: YiStreamer.h:36
size_t GetChildIndex(size_t itemIndex) const
virtual void FocusLostForItem(size_t index) override
bool RequestFocusOnItem(size_t index, CYIFocus::Direction direction=CYIFocus::Direction::Forward, CYIFocus::FocusRootRule focusRootRule=CYIFocus::FocusRootRule::DescendantsUpdateContext, const CYIAABB &previousFocusRect=CYIAABB())
CYISignal< size_t, CYISceneNode * > ItemLostFocus
Definition: YiListView.h:166
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:32
virtual void ParseProperties() override
void SetAdapter(std::unique_ptr< CYINodeAdapter > pAdapter)
The base class for types of timeline groups.
Definition: YiTimelineGroup.h:25
virtual void UpdateHorizontalPagingStrategyImpl() override
virtual void WorldBoundingBoxUpdated() override
Direction
Definition: YiScrollingView.h:851
virtual void ApplyMeasurements() override
Direction
Definition: YiFocus.h:44
virtual void UpdateVerticalPagingStrategyImpl() override
virtual bool Init() override
virtual ~CYIListView()
IYIPropertiesSource * GetItemProperties(const CYIString &viewTemplateName) const
virtual std::unique_ptr< CYILayout > CreateDefaultLayoutInstance() const
Definition: YiScrollingView.h:254
A class that provides streaming functionality in a scrolling view.
Definition: YiListView.h:35
virtual void OnFocusGainedForItem(size_t index) override
size_t GetItemIndex(CYISceneNode *pStreamedItem) const
TimelineType
Definition: YiScrollingView.h:172
CYISignal< size_t, CYISceneNode * > ItemLeftVisibleRegion
Definition: YiListView.h:164
Definition: YiListView.h:45
virtual void RevealItem(size_t index, uint32_t duration, CYITimeInterpolator *pInterpolator=nullptr)
Provides an interface for supplying and reclaiming nodes to and from CYIStreamer. ...
Definition: YiNodeAdapter.h:32
size_t GetPageReferenceItemIndex() const
void SetStreamingRegionFactor(float factor)
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:105
virtual void OnStreamedIn(size_t index, CYISceneNode *pStreamedItem) override
CYISignal< size_t, CYISceneNode * > ItemEnteredVisibleRegion
Definition: YiListView.h:163
FocusRootRule
Definition: YiFocus.h:60
virtual void OnStreamedOut(size_t index, CYISceneNode *pStreamedItem) override
CYISignal< size_t, CYISceneNode * > ItemGainedFocus
Definition: YiListView.h:165
void UpdateStreamedStateOfAllItems()
float GetStreamingRegionFactor() const
friend class CYIListView
Definition: YiListView.h:48
An interface to a class that provides key-value properties.
Definition: YiPropertiesSource.h:21
This class represents an Axis-Aligned Bounding Box.
Definition: YiAABB.h:22
CYISceneNode * GetStreamedNode(size_t index) const
const CYINodeAdapter * GetAdapter() const
Allows users to scroll and pan through content inside.
Definition: YiScrollingView.h:147
virtual void ChildMovedInVisibleRegion(CYISceneNode *pChild, const glm::vec2 &normalizedPosition) override
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:259
void SetItemProperties(const CYIString &viewTemplateName, std::unique_ptr< IYIPropertiesSource > pProperties)
virtual void OnFocusLostForItem(size_t index) override
size_t GetFocusedItemIndex() const
Signals and slots are a thread-safe and flexible communication framework that will allow various obje...
Definition: YiSignal.h:169
bool IsInVisibleRegion(size_t index) const
virtual CYIAbstractTimeline * GetCascadeTimelineFor(TimelineType type, CYISceneView *pView) override
bool IsStreamedIn(size_t index) const
virtual void FocusGainedForItem(size_t index) override