Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-api / controls / page-turn-view / page-factory.h
1 #ifndef __DALI_TOOLKIT_PAGE_FACTORY_H__
2 #define __DALI_TOOLKIT_PAGE_FACTORY_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //     http://floralicense.org/license/
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19
20 // INTERNAL INCLUDES
21 #include <dali/dali.h>
22
23 namespace Dali DALI_IMPORT_API
24 {
25
26 namespace Toolkit
27 {
28
29 /**
30  * PageFactory is an abstract interface for providing image actors to PageTurnView
31  * Each image actor is identified by a unique ID, and has a linear order from 0 to GetNumberOfPages()-1
32  */
33 class PageFactory
34 {
35 public:
36   // Property Names
37   static const std::string ACTOR_HITTABLE; ///< name "actor-hittable", type bool
38
39 public:
40
41   /**
42    * Constructor
43    * By default, the off screen rendering is disabled
44    * Is off screen rendering is required to create the page image,
45    * call EnableOffscreenRendering() before pass it as parameter to the PageTurnView
46    */
47   PageFactory();
48
49   /**
50    * Virtual destructor
51    */
52   virtual ~PageFactory();
53
54   /**
55    * Enable the off screen rendering to create the page image from actor tree
56    */
57   void EnableOffscreenRendering( );
58
59   /**
60    * Query whether offscreen rendering is needed to create the page image
61    * @return
62    */
63   bool IsOffscreenRenderingNeeded();
64
65   /**
66    * Query the number of pages available from the factory.
67    * The maximum available page has an ID of GetNumberOfPages()-1.
68    */
69   virtual unsigned int GetNumberOfPages() = 0;
70
71   /**
72    * Create an actor to represent the page content.
73    * @param[in] pageId The ID of the page to create.
74    * @return An actor, or an uninitialized pointer if the ID is out of range.
75    */
76   virtual Actor NewPage( unsigned int pageId ) = 0;
77
78 public: //Signal
79   /**
80    * Signal type for notification
81    */
82   typedef SignalV2< void ( int ) > RefreshSignal;
83
84   /**
85    * Signal emitted when the Actor tree is ready for rendering into the page image.
86    * The signal is connected to the page refresh function inside PageTurnView.
87    */
88   RefreshSignal& PageRefreshSignal();
89
90   /**
91    * Emit the page ready singal. The PageTurn view will be notified to refresh the given page accordingly.
92    * @param[in] pageId the index of the page which is ready for refreshing.
93    */
94   void EmitPageRefreshSignal( int pageId );
95
96 protected:
97
98   /**
99    * Sets whether an actor should be hittable for the PageTurnView::GetHitActor().
100    * It is useful when a sub-tree should be hit instead of the 'leaf' actor in the actor tree.
101    * By default, actors are not hittable for PageTurnView::GetHitActor()
102    * @param[in] actor The actor to be set with the hittablity
103    * @param[in] hittable True to be hittable, false otherwise.
104    */
105   void SetActorHittability( Actor actor, bool hittable );
106
107   /**
108    * Query whether an actor is hittable for the PageTurnView::GetHitActor().
109    */
110   bool GetActorHittability( Actor actor );
111
112 private:
113
114   bool mNeedOffscreenRendering;
115
116   RefreshSignal mPageRefreshSignal;
117 };
118
119 } // namespace Toolkit
120
121 } // namespace Dali
122 #endif /* __DALI_TOOLKIT_PAGE_FACTORY_H__ */