Fix boost includes
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / internal / builder / builder-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_BUILDER_H__
2 #define __DALI_TOOLKIT_INTERNAL_BUILDER_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 // EXTERNAL INCLUDES
21 #include <string>
22 #include <list>
23 #include <map>
24 #include <dali/dali.h>
25 #include <dali/integration-api/debug.h>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/public-api/builder/json-parser.h>
29 #include <dali-toolkit/public-api/builder/builder.h>
30 #include <dali-toolkit/internal/builder/builder-declarations.h>
31
32 // Warning messages usually displayed
33 #define DALI_SCRIPT_WARNING(format, args...) \
34   DALI_LOG_WARNING("Script:" format, ## args)
35
36 // Info messages are usually debug build
37 #define DALI_SCRIPT_INFO(format, args...) \
38   DALI_LOG_INFO(Dali::Toolkit::Internal::gFilterScript, Debug::General, "Script:" format, ## args)
39
40 // Info Verbose need to be swiched on in gFilterScript filter constructor (by default set to General)
41 #define DALI_SCRIPT_VERBOSE(format, args...) \
42   DALI_LOG_INFO(Dali::Toolkit::Internal::gFilterScript, Debug::Verbose, "Script:" format, ## args)
43
44 namespace Dali
45 {
46
47 namespace Toolkit
48 {
49   class TreeNode;
50 }
51
52 namespace Toolkit
53 {
54
55 namespace Internal
56 {
57
58 #if defined(DEBUG_ENABLED)
59 extern Dali::Integration::Log::Filter* gFilterScript;
60 #endif
61
62 class Builder;
63 class Replacement;
64
65 /**
66  * @copydoc Toolkit::Builder
67  */
68 class Builder : public Dali::BaseObject
69 {
70 public:
71
72   Builder();
73
74   /**
75    * @copydoc Toolkit::Builder::LoadFromString
76    */
77   void LoadFromString( const std::string &data,
78                        Dali::Toolkit::Builder::UIFormat rep = Dali::Toolkit::Builder::JSON );
79
80   /**
81    * @copydoc Toolkit::Builder::AddConstants
82    */
83   void AddConstants( const PropertyValueMap& map );
84
85   /**
86    * @copydoc Toolkit::Builder::AddConstant
87    */
88   void AddConstant( const std::string& key, const Property::Value& value );
89
90   /**
91    * @copydoc Toolkit::Builder::GetConstants
92    */
93   const PropertyValueMap& GetConstants() const;
94
95   /**
96    * @copydoc Toolkit::Builder::GetConstant
97    */
98   const Property::Value& GetConstant( const std::string& key ) const;
99
100   /**
101    * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName );
102    */
103   Animation CreateAnimation( const std::string& animationName );
104
105   /**
106    * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map );
107    */
108   Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map );
109
110   /**
111    * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,Dali::Actor);
112    */
113   Animation CreateAnimation( const std::string& animationName, Dali::Actor sourceActor );
114
115   /**
116    * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,const PropertyValueMap&,Dali::Actor);
117    */
118   Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor );
119
120   /**
121    * @copydoc Toolkit::Builder::Create( const std::string& templateName );
122    */
123   BaseHandle Create( const std::string& templateName );
124
125   /**
126    * @copydoc Toolkit::Builder::Create( const std::string& templateName, const PropertyValueMap& map );
127    */
128   BaseHandle Create( const std::string& templateName, const PropertyValueMap& map );
129
130  /**
131    * @copydoc Toolkit::Builder::GetFont
132    */
133   Font GetFont(const std::string &name) const;
134
135   /**
136    * @copydoc Toolkit::Builder::GetTextStyle
137    */
138   TextStyle GetTextStyle(const std::string &name) const;
139
140   /**
141    * @copydoc Toolkit::Builder::GetImage
142    */
143   Image GetImage(const std::string &name) const;
144
145   /**
146    * @copydoc Toolkit::Builder::GetActor
147    */
148   Actor GetActor( const std::string &name ) const;
149
150   /**
151    * @copydoc Toolkit::Builder::ApplyStyle
152    */
153   void ApplyStyle( const std::string& styleName, Handle& handle );
154
155   void AnimateTo( const std::string& styleName, Handle& handle );
156
157   /**
158    * @copydoc Toolkit::Builder::AddActors
159    */
160   void AddActors( Actor toActor );
161
162   /**
163    * @copydoc Toolkit::Builder::AddActors
164    */
165   void AddActors( const std::string &sectionName, Actor toActor );
166
167   /**
168    * @copydoc Toolkit::Builder::GetAnimation
169    */
170   Animation GetAnimation( const std::string &name ) const;
171
172   /**
173    * @copydoc Toolkit::Builder::CreateRenderTask
174    */
175   void CreateRenderTask( const std::string &name );
176
177   /**
178    * @copydoc Toolkit::Builder::GetShaderEffect
179    */
180   ShaderEffect GetShaderEffect( const std::string &name );
181
182   /**
183    * @copydoc Toolkit::Builder::GetShaderEffect
184    */
185   ShaderEffect GetShaderEffect( const std::string &name, const Replacement& constant );
186
187   /**
188    * @copydoc Toolkit::Builder::GetFrameBufferImage
189    */
190   FrameBufferImage GetFrameBufferImage( const std::string &name );
191
192   /**
193    * @copydoc Toolkit::Builder::GetFrameBufferImage
194    */
195   FrameBufferImage GetFrameBufferImage( const std::string &name, const Replacement& constant );
196
197   /**
198    * @copydoc Toolkit::Builder::GetTopLevelActors
199    */
200   ActorContainer GetTopLevelActors( void ) const;
201
202 protected:
203
204   virtual ~Builder();
205
206 private:
207   // Undefined
208   Builder(const Builder&);
209   Builder& operator=(const Builder& rhs);
210
211   void SetupTask( RenderTask& task, const Toolkit::TreeNode& node, const Replacement& replacement );
212
213 private:
214   Toolkit::JsonParser mParser;
215
216   typedef std::map<const std::string, FrameBufferImage> ImageLut;
217   ImageLut mFrameBufferImageLut;
218
219   typedef std::map<const std::string, ShaderEffect> ShaderEffectLut;
220   ShaderEffectLut mShaderEffectLut;
221
222   SlotDelegate<Builder> mSlotDelegate;
223
224   PropertyValueMap mReplacementMap;
225
226   BaseHandle Create( const std::string& templateName, const Replacement& constant );
227
228   BaseHandle DoCreate( const TreeNode& root, const TreeNode& node, Actor parent, const Replacement& replacements );
229
230   void LoadConstants( const TreeNode& root, PropertyValueMap& intoMap );
231
232   void LoadIncludes( const std::string& data );
233
234   void ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement);
235
236   Animation CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor );
237
238   void ApplyProperties( const TreeNode& root, const TreeNode& node,
239                         Dali::Handle& handle, const Replacement& constant );
240
241   void ApplyStylesByActor( const TreeNode& root, const TreeNode& node,
242                            Dali::Handle& handle, const Replacement& constant );
243
244   void ApplyAllStyleProperties( const TreeNode& root, const TreeNode& node,
245                                 Dali::Handle& handle, const Replacement& constant );
246
247   void SetProperties( const TreeNode& node, Handle& handle, const Replacement& constant );
248
249 };
250
251 } // namespace Internal
252
253 inline Internal::Builder& GetImpl(Dali::Toolkit::Builder& obj)
254 {
255   DALI_ASSERT_ALWAYS(obj);
256
257   Dali::BaseObject& handle = obj.GetBaseObject();
258
259   return static_cast<Internal::Builder&>(handle);
260 }
261
262 inline const Internal::Builder& GetImpl(const Dali::Toolkit::Builder& obj)
263 {
264   DALI_ASSERT_ALWAYS(obj);
265
266   const Dali::BaseObject& handle = obj.GetBaseObject();
267
268   return static_cast<const Internal::Builder&>(handle);
269 }
270
271 } // namespace Toolkit
272
273 } // namespace Dali
274
275 #endif // __DALI_TOOLKIT_INTERNAL_BUILDER_H__