[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-toolkit.git] / 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 <boost/property_tree/ptree.hpp>
25 #include <dali/dali.h>
26 #include <dali/integration-api/debug.h>
27
28 // INTERNAL INCLUDES
29 #include <dali-toolkit/public-api/builder/json-parser.h>
30 #include <dali-toolkit/public-api/builder/builder.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
64 /**
65  * @copydoc Toolkit::Builder
66  */
67 class Builder : public Dali::BaseObject
68 {
69 public:
70
71   Builder();
72
73   /**
74    * @copydoc Toolkit::Builder::LoadFromString
75    */
76   void LoadFromString( const std::string &data,
77                        Dali::Toolkit::Builder::UIFormat rep = Dali::Toolkit::Builder::JSON );
78
79   /**
80    * @copydoc Toolkit::Builder::CreateAnimation
81    */
82   Animation CreateAnimation( const std::string& animationName );
83
84   /**
85    * @copydoc Toolkit::Builder::CreateFromStyle
86    */
87   BaseHandle CreateFromStyle( const std::string& styleName );
88
89   /**
90    * @copydoc Toolkit::Builder::GetFont
91    */
92   Font GetFont(const std::string &name) const;
93
94   /**
95    * @copydoc Toolkit::Builder::GetTextStyle
96    */
97   TextStyle GetTextStyle(const std::string &name) const;
98
99   /**
100    * @copydoc Toolkit::Builder::GetImage
101    */
102   Image GetImage(const std::string &name) const;
103
104   /**
105    * @copydoc Toolkit::Builder::GetActor
106    */
107   Actor GetActor( const std::string &name ) const;
108
109   /**
110    * @copydoc Toolkit::Builder::ApplyStyle
111    */
112   void ApplyStyle( const std::string& styleName, Handle& handle );
113
114   /**
115    * @copydoc Toolkit::Builder::AddActors
116    */
117   void AddActors( Actor toActor );
118
119   /**
120    * @copydoc Toolkit::Builder::AddActors
121    */
122   void AddActors( const std::string &sectionName, Actor toActor );
123
124   /**
125    * @copydoc Toolkit::Builder::GetAnimation
126    */
127   Animation GetAnimation( const std::string &name ) const;
128
129   /**
130    * @copydoc Toolkit::Builder::CreateRenderTask
131    */
132   void CreateRenderTask( const std::string &name );
133
134   /**
135    * @copydoc Toolkit::Builder::GetShaderEffect
136    */
137   ShaderEffect GetShaderEffect( const std::string &name );
138
139   /**
140    * @copydoc Toolkit::Builder::GetFrameBufferImage
141    */
142   FrameBufferImage GetFrameBufferImage( const std::string &name );
143
144   /**
145    * @copydoc Toolkit::Builder::GetTopLevelActors
146    */
147   ActorContainer GetTopLevelActors( void ) const;
148
149 protected:
150
151   virtual ~Builder();
152
153 private:
154   // Undefined
155   Builder(const Builder&);
156   Builder& operator=(const Builder& rhs);
157
158   void SetupTask( RenderTask& task, const Toolkit::TreeNode& node );
159
160 private:
161   Toolkit::JsonParser mParser;
162
163   typedef std::map<const std::string, FrameBufferImage> ImageLut;
164   ImageLut mFrameBufferImageLut;
165
166   typedef std::map<const std::string, ShaderEffect> ShaderEffectLut;
167   ShaderEffectLut mShaderEffectLut;
168
169   SlotDelegate<Builder> mSlotDelegate;
170 };
171
172 } // namespace Internal
173
174 inline Internal::Builder& GetImpl(Dali::Toolkit::Builder& obj)
175 {
176   DALI_ASSERT_ALWAYS(obj);
177
178   Dali::BaseObject& handle = obj.GetBaseObject();
179
180   return static_cast<Internal::Builder&>(handle);
181 }
182
183 inline const Internal::Builder& GetImpl(const Dali::Toolkit::Builder& obj)
184 {
185   DALI_ASSERT_ALWAYS(obj);
186
187   const Dali::BaseObject& handle = obj.GetBaseObject();
188
189   return static_cast<const Internal::Builder&>(handle);
190 }
191
192 } // namespace Toolkit
193
194 } // namespace Dali
195
196 #endif // __DALI_TOOLKIT_INTERNAL_BUILDER_H__