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 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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::AddConstant
89 void AddConstant( const std::string& key, const Property::Value& value );
92 * @copydoc Toolkit::Builder::GetConstants
94 const PropertyValueMap& GetConstants() const;
97 * @copydoc Toolkit::Builder::GetConstant
99 const Property::Value& GetConstant( const std::string& key ) const;
102 * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName );
104 Animation CreateAnimation( const std::string& animationName );
107 * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map );
109 Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map );
112 * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,Dali::Actor);
114 Animation CreateAnimation( const std::string& animationName, Dali::Actor sourceActor );
117 * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,const PropertyValueMap&,Dali::Actor);
119 Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor );
122 * @copydoc Toolkit::Builder::Create( const std::string& templateName );
124 BaseHandle Create( const std::string& templateName );
127 * @copydoc Toolkit::Builder::Create( const std::string& templateName, const PropertyValueMap& map );
129 BaseHandle Create( const std::string& templateName, const PropertyValueMap& map );
132 * @copydoc Toolkit::Builder::CreateFromJson( const std::string& json );
134 BaseHandle CreateFromJson( const std::string& json );
137 * @copydoc Toolkit::Builder::ApplyFromJson( Handle& handle, const std::string& json );
139 bool ApplyFromJson( Handle& handle, const std::string& json );
142 * @copydoc Toolkit::Builder::ApplyStyle
144 bool ApplyStyle( const std::string& styleName, Handle& handle );
147 * @copydoc Toolkit::Builder::AddActors
149 void AddActors( Actor toActor );
152 * @copydoc Toolkit::Builder::AddActors
154 void AddActors( const std::string §ionName, Actor toActor );
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::QuitSignal
184 Toolkit::Builder::Signal& QuitSignal();
187 * Emits the quit signal
189 void EmitQuitSignal();
197 Builder(const Builder&);
198 Builder& operator=(const Builder& rhs);
200 void SetupTask( RenderTask& task, const Toolkit::TreeNode& node, const Replacement& replacement );
203 Toolkit::JsonParser mParser;
205 typedef std::map<const std::string, FrameBufferImage> ImageLut;
206 ImageLut mFrameBufferImageLut;
208 typedef std::map<const std::string, ShaderEffect> ShaderEffectLut;
209 ShaderEffectLut mShaderEffectLut;
211 SlotDelegate<Builder> mSlotDelegate;
213 PropertyValueMap mReplacementMap;
215 BaseHandle Create( const std::string& templateName, const Replacement& constant );
217 BaseHandle DoCreate( const TreeNode& root, const TreeNode& node, Actor parent, const Replacement& replacements );
219 void LoadConstants( const TreeNode& root, PropertyValueMap& intoMap );
221 void LoadIncludes( const std::string& data );
223 bool ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement);
225 Animation CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor );
227 void ApplyProperties( const TreeNode& root, const TreeNode& node,
228 Dali::Handle& handle, const Replacement& constant );
230 void ApplyStylesByActor( const TreeNode& root, const TreeNode& node,
231 Dali::Handle& handle, const Replacement& constant );
233 void ApplyAllStyleProperties( const TreeNode& root, const TreeNode& node,
234 Dali::Handle& handle, const Replacement& constant );
236 void SetProperties( const TreeNode& node, Handle& handle, const Replacement& constant );
238 Toolkit::Builder::Signal mQuitSignal;
241 } // namespace Internal
243 inline Internal::Builder& GetImpl(Dali::Toolkit::Builder& obj)
245 DALI_ASSERT_ALWAYS(obj);
247 Dali::BaseObject& handle = obj.GetBaseObject();
249 return static_cast<Internal::Builder&>(handle);
252 inline const Internal::Builder& GetImpl(const Dali::Toolkit::Builder& obj)
254 DALI_ASSERT_ALWAYS(obj);
256 const Dali::BaseObject& handle = obj.GetBaseObject();
258 return static_cast<const Internal::Builder&>(handle);
261 } // namespace Toolkit
265 #endif // __DALI_TOOLKIT_INTERNAL_BUILDER_H__