Merge remote-tracking branch 'origin/tizen' into devel/new_mesh
[platform/core/uifw/dali-toolkit.git] / 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) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 /**
31  * PageFactory is an abstract interface for providing image actors to PageTurnView
32  * Each image actor is identified by a unique ID, and has a linear order from 0 to GetNumberOfPages()-1
33  */
34 class DALI_IMPORT_API PageFactory
35 {
36 public:
37   // Property Names
38   static const std::string ACTOR_HITTABLE; ///< name "actor-hittable", type bool
39
40 public:
41
42   /**
43    * Constructor
44    * By default, the off screen rendering is disabled
45    * Is off screen rendering is required to create the page image,
46    * call EnableOffscreenRendering() before pass it as parameter to the PageTurnView
47    */
48   PageFactory();
49
50   /**
51    * Virtual destructor
52    */
53   virtual ~PageFactory();
54
55   /**
56    * Enable the off screen rendering to create the page image from actor tree
57    */
58   void EnableOffscreenRendering( );
59
60   /**
61    * Query whether offscreen rendering is needed to create the page image
62    * @return
63    */
64   bool IsOffscreenRenderingNeeded();
65
66   /**
67    * Query the number of pages available from the factory.
68    * The maximum available page has an ID of GetNumberOfPages()-1.
69    */
70   virtual unsigned int GetNumberOfPages() = 0;
71
72   /**
73    * Create an actor to represent the page content.
74    * @param[in] pageId The ID of the page to create.
75    * @return An actor, or an uninitialized pointer if the ID is out of range.
76    */
77   virtual Actor NewPage( unsigned int pageId ) = 0;
78
79 public: //Signal
80   /**
81    * Signal type for notification
82    */
83   typedef Signal< void ( int ) > RefreshSignal;
84
85   /**
86    * Signal emitted when the Actor tree is ready for rendering into the page image.
87    * The signal is connected to the page refresh function inside PageTurnView.
88    */
89   RefreshSignal& PageRefreshSignal();
90
91   /**
92    * Emit the page ready singal. The PageTurn view will be notified to refresh the given page accordingly.
93    * @param[in] pageId the index of the page which is ready for refreshing.
94    */
95   void EmitPageRefreshSignal( int pageId );
96
97 protected:
98
99   /**
100    * Sets whether an actor should be hittable for the PageTurnView::GetHitActor().
101    * It is useful when a sub-tree should be hit instead of the 'leaf' actor in the actor tree.
102    * By default, actors are not hittable for PageTurnView::GetHitActor()
103    * @param[in] actor The actor to be set with the hittablity
104    * @param[in] hittable True to be hittable, false otherwise.
105    */
106   void SetActorHittability( Actor actor, bool hittable );
107
108   /**
109    * Query whether an actor is hittable for the PageTurnView::GetHitActor().
110    */
111   bool GetActorHittability( Actor actor );
112
113 private:
114
115   bool mNeedOffscreenRendering;
116
117   RefreshSignal mPageRefreshSignal;
118 };
119
120 } // namespace Toolkit
121
122 } // namespace Dali
123 #endif /* __DALI_TOOLKIT_PAGE_FACTORY_H__ */