X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fbuilder%2Fbuilder-impl.h;h=0a76c7b0f6c15bdfe463b6e88d1389b1f6dd70a8;hb=b1e8521ad77e7b4e62b59613b2edef64429130e9;hp=a5d6f0663725277193e54d37bf105b766a8aa7bf;hpb=12b5da1b6e2e4b88f3cdb24b81d1b54b68b5f4f1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/builder/builder-impl.h b/dali-toolkit/internal/builder/builder-impl.h index a5d6f06..0a76c7b 100644 --- a/dali-toolkit/internal/builder/builder-impl.h +++ b/dali-toolkit/internal/builder/builder-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_BUILDER_H__ -#define __DALI_TOOLKIT_INTERNAL_BUILDER_H__ +#ifndef DALI_TOOLKIT_INTERNAL_BUILDER_H +#define DALI_TOOLKIT_INTERNAL_BUILDER_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -33,18 +33,19 @@ #include #include #include +#include // Warning messages usually displayed -#define DALI_SCRIPT_WARNING(format, args...) \ - DALI_LOG_WARNING("Script:" format, ## args) +#define DALI_SCRIPT_WARNING(format, ...) \ + DALI_LOG_WARNING("Script:" format, ## __VA_ARGS__) // Info messages are usually debug build -#define DALI_SCRIPT_INFO(format, args...) \ - DALI_LOG_INFO(Dali::Toolkit::Internal::gFilterScript, Debug::General, "Script:" format, ## args) +#define DALI_SCRIPT_INFO(format, ...) \ + DALI_LOG_INFO(Dali::Toolkit::Internal::gFilterScript, Debug::General, "Script:" format, ## __VA_ARGS__) // Info Verbose need to be swiched on in gFilterScript filter constructor (by default set to General) -#define DALI_SCRIPT_VERBOSE(format, args...) \ - DALI_LOG_INFO(Dali::Toolkit::Internal::gFilterScript, Debug::Verbose, "Script:" format, ## args) +#define DALI_SCRIPT_VERBOSE(format, ...) \ + DALI_LOG_INFO(Dali::Toolkit::Internal::gFilterScript, Debug::Verbose, "Script:" format, ## __VA_ARGS__) namespace Dali { @@ -93,6 +94,11 @@ public: void AddConstant( const std::string& key, const Property::Value& value ); /** + * @copydoc Toolkit::Builder::GetConfigurations + */ + const Property::Map& GetConfigurations() const; + + /** * @copydoc Toolkit::Builder::GetConstants */ const Property::Map& GetConstants() const; @@ -148,39 +154,37 @@ public: bool ApplyStyle( const std::string& styleName, Handle& handle ); /** - * @copydoc Toolkit::Builder::AddActors - */ - void AddActors( Actor toActor ); - - /** - * @copydoc Toolkit::Builder::AddActors + * Lookup the stylename in builder. If it's found in the parse tree, + * then return true. + * @param[in] styleName The style name to search for + * @return true if the stylename exists */ - void AddActors( const std::string §ionName, Actor toActor ); + bool LookupStyleName( const std::string& styleName ); /** - * @copydoc Toolkit::Builder::CreateRenderTask - */ - void CreateRenderTask( const std::string &name ); + * Lookup the stylename in the recorded Styles - if it exists, + * performs a shallow copy to the passed in style and returns true. + * Otherwise it returns false. - /** - * @copydoc Toolkit::Builder::GetShaderEffect + * @param[in] styleName The stylename to search for + * @return A const pointer to the style object */ - ShaderEffect GetShaderEffect( const std::string &name ); + const StylePtr GetStyle( const std::string& styleName ); /** - * @copydoc Toolkit::Builder::GetShaderEffect + * @copydoc Toolkit::Builder::AddActors */ - ShaderEffect GetShaderEffect( const std::string &name, const Replacement& constant ); + void AddActors( Actor toActor ); /** - * @copydoc Toolkit::Builder::GetFrameBufferImage + * @copydoc Toolkit::Builder::AddActors */ - FrameBufferImage GetFrameBufferImage( const std::string &name ); + void AddActors( const std::string §ionName, Actor toActor ); /** - * @copydoc Toolkit::Builder::GetFrameBufferImage + * @copydoc Toolkit::Builder::CreateRenderTask */ - FrameBufferImage GetFrameBufferImage( const std::string &name, const Replacement& constant ); + void CreateRenderTask( const std::string &name ); /** * @copydoc Toolkit::Builder::GetPath @@ -223,100 +227,160 @@ public: */ void EmitQuitSignal(); + protected: virtual ~Builder(); private: + typedef std::vector KeyStack; + typedef std::vector< TreeNode::KeyNodePair > MappingsLut; + typedef struct{ std::string name; Dali::LinearConstrainer linearConstrainer; } LinearConstrainerEntry; + typedef std::vector LinearConstrainerLut; + typedef struct{ std::string name; Dali::PathConstrainer pathConstrainer; } PathConstrainerEntry; + typedef std::vector PathConstrainerLut; + typedef std::map PathLut; + +private: // Undefined Builder(const Builder&); + + // Undefined Builder& operator=(const Builder& rhs); - void SetupTask( RenderTask& task, const Toolkit::TreeNode& node, const Replacement& replacement ); + void LoadConstants( const TreeNode& root, Property::Map& intoMap ); -private: - Toolkit::JsonParser mParser; + void LoadConfiguration( const TreeNode& root, Property::Map& intoMap ); - typedef std::map ImageLut; - ImageLut mFrameBufferImageLut; + Animation CreateAnimation( const std::string& animationName, + const Replacement& replacement, + Dali::Actor sourceActor ); - typedef std::map ShaderEffectLut; - ShaderEffectLut mShaderEffectLut; + BaseHandle Create( const std::string& templateName, + const Replacement& constant ); - typedef std::map PathLut; - PathLut mPathLut; + BaseHandle DoCreate( const TreeNode& root, + const TreeNode& node, + Actor parent, + const Replacement& replacements ); - typedef struct{ std::string name; Dali::PathConstrainer pathConstrainer; } PathConstrainerEntry; - typedef std::vector PathConstrainerLut; - PathConstrainerLut mPathConstrainerLut; + void SetupTask( RenderTask& task, + const Toolkit::TreeNode& node, + const Replacement& replacement ); - typedef struct{ std::string name; Dali::LinearConstrainer linearConstrainer; } LinearConstrainerEntry; - typedef std::vector LinearConstrainerLut; - LinearConstrainerLut mLinearConstrainerLut; + bool ApplyStyle( const std::string& styleName, + Handle& handle, + const Replacement& replacement); - SlotDelegate mSlotDelegate; + void ApplyAllStyleProperties( const TreeNode& root, + const TreeNode& node, + Dali::Handle& handle, + const Replacement& constant ); - Property::Map mReplacementMap; + void RecordStyles( const char* styleName, + const TreeNode& node, + Dali::Handle& handle, + const Replacement& replacements ); - typedef std::vector< TreeNode::KeyNodePair > MappingsLut; - MappingsLut mCompleteMappings; + void RecordStyle( StylePtr style, + const TreeNode& node, + Dali::Handle& handle, + const Replacement& replacements ); - BaseHandle Create( const std::string& templateName, const Replacement& constant ); + void RecordTransitions( const TreeNode::KeyNodePair& keyValue, + Property::Array& transitions, + const Replacement& replacements ); - BaseHandle DoCreate( const TreeNode& root, const TreeNode& node, Actor parent, const Replacement& replacements ); + void RecordTransitionData( const TreeNode::KeyNodePair& keyNode, + Toolkit::TransitionData& transitionData, + const Replacement& replacements ); - void LoadConstants( const TreeNode& root, Property::Map& intoMap ); + void ApplyProperties( const TreeNode& root, + const TreeNode& node, + Dali::Handle& handle, + const Replacement& constant ); - void LoadIncludes( const std::string& data ); + void ApplySignals( const TreeNode& root, + const TreeNode& node, + Dali::Handle& handle ); - bool ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement); + void ApplyStylesByActor( const TreeNode& root, + const TreeNode& node, + Dali::Handle& handle, + const Replacement& constant ); - Animation CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor ); + void SetProperties( const TreeNode& node, + Handle& handle, + const Replacement& constant ); - typedef std::vector KeyStack; + bool MapToTargetProperty( Handle& propertyObject, + const std::string& key, + const TreeNode& node, + const Replacement& constant, + Property::Index& index, + Property::Value& value ); /** - * Tests if the value is a string delimited by <>. If it is, then it attempts to - * change the value to the mapping from a matching key in the mappings table. + * Find the key in the mapping table, if it's present, then generate + * a property value for it (of the given type if available), + * recursing as necessary, and stopping if any cycles are detected. + * * @param[in] mappingRoot The JSON node containing the mappings - * @param[in,out] keyStack the stack of visited keys + * @param[in] theKey The key to search for + * @param[in] propertyType The property type if known, or NONE * @param[in,out] value The string value to test and write back to. - * @return true if the value was converted, false otherwise. */ - bool ConvertChildValue( const TreeNode& mappingRoot, KeyStack& keyStack, Property::Value& value ); + bool GetPropertyMap( const TreeNode& mappingRoot, + const char* theKey, + Property::Type propertyType, + Property::Value& value ); + + void SetCustomProperties( const TreeNode& node, + Handle& handle, + const Replacement& constant, + const std::string& childName, + Property::AccessMode accessMode ); /** - * Find the key in the mapping table, if it's present, then generate a property value for it (of the given type if available), recursing as necessary, and stopping if any cycles - * are detected. + * Find the key in the mapping table, if it's present, then generate + * a property value for it (of the given type if available), + * recursing as necessary, and stopping if any cycles are detected. + * * @param[in] mappingRoot The JSON node containing the mappings * @param[in] theKey The key to search for * @param[in,out] keyStack the stack of visited keys * @param[in] propertyType The property type if known, or NONE * @param[in,out] value The string value to test and write back to. */ - bool RecursePropertyMap( const TreeNode& mappingRoot, KeyStack& keyStack, const char* theKey, Property::Type propertyType, Property::Value& value ); + bool RecursePropertyMap( const TreeNode& mappingRoot, + KeyStack& keyStack, + const char* theKey, + Property::Type propertyType, + Property::Value& value ); + /** - * Find the key in the mapping table, if it's present, then generate a property value for it (of the given type if available), recursing as necessary, and stopping if any cycles - * are detected. + * Tests if the value is a string delimited by <>. If it is, then it attempts to + * change the value to the mapping from a matching key in the mappings table. * @param[in] mappingRoot The JSON node containing the mappings - * @param[in] theKey The key to search for - * @param[in] propertyType The property type if known, or NONE + * @param[in,out] keyStack the stack of visited keys * @param[in,out] value The string value to test and write back to. + * @return true if the value was converted, false otherwise. */ - bool GetPropertyMap( const TreeNode& mappingRoot, const char* theKey, Property::Type propertyType, Property::Value& value ); - - void ApplyProperties( const TreeNode& root, const TreeNode& node, - Dali::Handle& handle, const Replacement& constant ); - - void ApplyStylesByActor( const TreeNode& root, const TreeNode& node, - Dali::Handle& handle, const Replacement& constant ); - - void ApplyAllStyleProperties( const TreeNode& root, const TreeNode& node, - Dali::Handle& handle, const Replacement& constant ); - - void SetProperties( const TreeNode& node, Handle& handle, const Replacement& constant ); + bool ConvertChildValue( const TreeNode& mappingRoot, + KeyStack& keyStack, + Property::Value& value ); +private: + Toolkit::JsonParser mParser; + PathLut mPathLut; + PathConstrainerLut mPathConstrainerLut; + LinearConstrainerLut mLinearConstrainerLut; + SlotDelegate mSlotDelegate; + Property::Map mReplacementMap; + Property::Map mConfigurationMap; + MappingsLut mCompleteMappings; + Dictionary mStyles; // State based styles Toolkit::Builder::BuilderSignalType mQuitSignal; }; @@ -344,4 +408,4 @@ inline const Internal::Builder& GetImpl(const Dali::Toolkit::Builder& obj) } // namespace Dali -#endif // __DALI_TOOLKIT_INTERNAL_BUILDER_H__ +#endif // DALI_TOOLKIT_INTERNAL_BUILDER_H