1 #ifndef __DALI_TOOLKIT_INTERNAL_BUILDER_H__
2 #define __DALI_TOOLKIT_INTERNAL_BUILDER_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
24 #include <boost/property_tree/ptree.hpp>
25 #include <dali/dali.h>
26 #include <dali/integration-api/debug.h>
29 #include <dali-toolkit/public-api/builder/json-parser.h>
30 #include <dali-toolkit/public-api/builder/builder.h>
31 #include <dali-toolkit/internal/builder/builder-declarations.h>
33 // Warning messages usually displayed
34 #define DALI_SCRIPT_WARNING(format, args...) \
35 DALI_LOG_WARNING("Script:" format, ## args)
37 // Info messages are usually debug build
38 #define DALI_SCRIPT_INFO(format, args...) \
39 DALI_LOG_INFO(Dali::Toolkit::Internal::gFilterScript, Debug::General, "Script:" format, ## args)
41 // Info Verbose need to be swiched on in gFilterScript filter constructor (by default set to General)
42 #define DALI_SCRIPT_VERBOSE(format, args...) \
43 DALI_LOG_INFO(Dali::Toolkit::Internal::gFilterScript, Debug::Verbose, "Script:" format, ## args)
59 #if defined(DEBUG_ENABLED)
60 extern Dali::Integration::Log::Filter* gFilterScript;
67 * @copydoc Toolkit::Builder
69 class Builder : public Dali::BaseObject
76 * @copydoc Toolkit::Builder::LoadFromString
78 void LoadFromString( const std::string &data,
79 Dali::Toolkit::Builder::UIFormat rep = Dali::Toolkit::Builder::JSON );
82 * @copydoc Toolkit::Builder::AddConstants
84 void AddConstants( const PropertyValueMap& map );
87 * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName );
89 Animation CreateAnimation( const std::string& animationName );
92 * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map );
94 Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map );
97 * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, Dali::Actor searchRoot );
99 Animation CreateAnimation( const std::string& animationName, Dali::Actor searchRoot );
102 * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor searchRoot );
104 Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor searchRoot );
107 * @copydoc Toolkit::Builder::CreateFromStyle( const std::string& styleName );
109 BaseHandle CreateFromStyle( const std::string& styleName );
112 * @copydoc Toolkit::Builder::CreateFromStyle( const std::string& styleName, const PropertyValueMap& map );
114 BaseHandle CreateFromStyle( const std::string& styleName, const PropertyValueMap& map );
117 * @copydoc Toolkit::Builder::GetFont
119 Font GetFont(const std::string &name) const;
122 * @copydoc Toolkit::Builder::GetTextStyle
124 TextStyle GetTextStyle(const std::string &name) const;
127 * @copydoc Toolkit::Builder::GetImage
129 Image GetImage(const std::string &name) const;
132 * @copydoc Toolkit::Builder::GetActor
134 Actor GetActor( const std::string &name ) const;
137 * @copydoc Toolkit::Builder::ApplyStyle
139 void ApplyStyle( const std::string& styleName, Handle& handle );
142 * @copydoc Toolkit::Builder::AddActors
144 void AddActors( Actor toActor );
147 * @copydoc Toolkit::Builder::AddActors
149 void AddActors( const std::string §ionName, Actor toActor );
152 * @copydoc Toolkit::Builder::GetAnimation
154 Animation GetAnimation( const std::string &name ) const;
157 * @copydoc Toolkit::Builder::CreateRenderTask
159 void CreateRenderTask( const std::string &name );
162 * @copydoc Toolkit::Builder::GetShaderEffect
164 ShaderEffect GetShaderEffect( const std::string &name );
167 * @copydoc Toolkit::Builder::GetShaderEffect
169 ShaderEffect GetShaderEffect( const std::string &name, const Replacement& constant );
172 * @copydoc Toolkit::Builder::GetFrameBufferImage
174 FrameBufferImage GetFrameBufferImage( const std::string &name );
177 * @copydoc Toolkit::Builder::GetFrameBufferImage
179 FrameBufferImage GetFrameBufferImage( const std::string &name, const Replacement& constant );
182 * @copydoc Toolkit::Builder::GetTopLevelActors
184 ActorContainer GetTopLevelActors( void ) const;
192 Builder(const Builder&);
193 Builder& operator=(const Builder& rhs);
195 void SetupTask( RenderTask& task, const Toolkit::TreeNode& node, const Replacement& replacement );
198 Toolkit::JsonParser mParser;
200 typedef std::map<const std::string, FrameBufferImage> ImageLut;
201 ImageLut mFrameBufferImageLut;
203 typedef std::map<const std::string, ShaderEffect> ShaderEffectLut;
204 ShaderEffectLut mShaderEffectLut;
206 SlotDelegate<Builder> mSlotDelegate;
208 PropertyValueMap mReplacementMap;
210 BaseHandle Create( const OptionalChild& optionalStyles, const TreeNode& node, const TreeNode& root, Actor parent,
211 const Replacement& replacement );
213 void LoadConstants();
215 void ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement);
217 Animation CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor searchRoot );
219 BaseHandle CreateFromStyle( const std::string& styleName, const Replacement& replacement );
222 } // namespace Internal
224 inline Internal::Builder& GetImpl(Dali::Toolkit::Builder& obj)
226 DALI_ASSERT_ALWAYS(obj);
228 Dali::BaseObject& handle = obj.GetBaseObject();
230 return static_cast<Internal::Builder&>(handle);
233 inline const Internal::Builder& GetImpl(const Dali::Toolkit::Builder& obj)
235 DALI_ASSERT_ALWAYS(obj);
237 const Dali::BaseObject& handle = obj.GetBaseObject();
239 return static_cast<const Internal::Builder&>(handle);
242 } // namespace Toolkit
246 #endif // __DALI_TOOLKIT_INTERNAL_BUILDER_H__