X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fbuilder%2Fbuilder-impl.h;h=4c018aafb85f3344e17460f69e4257b9e5cc7e1c;hp=7747b49eee4be7056c392c726131b4e85c7fadcd;hb=c3f9162ab11786380e2ec9c55f217c2daf7722e8;hpb=af74001e7e61033e86323da5ad079ccbc310680a diff --git a/dali-toolkit/internal/builder/builder-impl.h b/dali-toolkit/internal/builder/builder-impl.h index 7747b49..4c018aa 100644 --- a/dali-toolkit/internal/builder/builder-impl.h +++ b/dali-toolkit/internal/builder/builder-impl.h @@ -1,33 +1,38 @@ #ifndef __DALI_TOOLKIT_INTERNAL_BUILDER_H__ #define __DALI_TOOLKIT_INTERNAL_BUILDER_H__ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // EXTERNAL INCLUDES #include #include #include -#include -#include +#include +#include +#include +#include +#include +#include #include // INTERNAL INCLUDES -#include -#include +#include +#include #include // Warning messages usually displayed @@ -81,62 +86,67 @@ public: /** * @copydoc Toolkit::Builder::AddConstants */ - void AddConstants( const PropertyValueMap& map ); + void AddConstants( const Property::Map& map ); /** - * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName ); + * @copydoc Toolkit::Builder::AddConstant */ - Animation CreateAnimation( const std::string& animationName ); + void AddConstant( const std::string& key, const Property::Value& value ); + + /** + * @copydoc Toolkit::Builder::GetConstants + */ + const Property::Map& GetConstants() const; /** - * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map ); + * @copydoc Toolkit::Builder::GetConstant */ - Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map ); + const Property::Value& GetConstant( const std::string& key ) const; /** - * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, Dali::Actor searchRoot ); + * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName ); */ - Animation CreateAnimation( const std::string& animationName, Dali::Actor searchRoot ); + Animation CreateAnimation( const std::string& animationName ); /** - * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor searchRoot ); + * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const Property::Map& map ); */ - Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor searchRoot ); + Animation CreateAnimation( const std::string& animationName, const Property::Map& map ); /** - * @copydoc Toolkit::Builder::CreateFromStyle( const std::string& styleName ); + * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,Dali::Actor); */ - BaseHandle CreateFromStyle( const std::string& styleName ); + Animation CreateAnimation( const std::string& animationName, Dali::Actor sourceActor ); /** - * @copydoc Toolkit::Builder::CreateFromStyle( const std::string& styleName, const PropertyValueMap& map ); + * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,const Property::Map&, Dali::Actor); */ - BaseHandle CreateFromStyle( const std::string& styleName, const PropertyValueMap& map ); + Animation CreateAnimation( const std::string& animationName, const Property::Map& map, Dali::Actor sourceActor ); /** - * @copydoc Toolkit::Builder::GetFont + * @copydoc Toolkit::Builder::Create( const std::string& templateName ); */ - Font GetFont(const std::string &name) const; + BaseHandle Create( const std::string& templateName ); /** - * @copydoc Toolkit::Builder::GetTextStyle + * @copydoc Toolkit::Builder::Create( const std::string& templateName, const Property::Map& map ); */ - TextStyle GetTextStyle(const std::string &name) const; + BaseHandle Create( const std::string& templateName, const Property::Map& map ); /** - * @copydoc Toolkit::Builder::GetImage + * @copydoc Toolkit::Builder::CreateFromJson( const std::string& json ); */ - Image GetImage(const std::string &name) const; + BaseHandle CreateFromJson( const std::string& json ); /** - * @copydoc Toolkit::Builder::GetActor + * @copydoc Toolkit::Builder::ApplyFromJson( Handle& handle, const std::string& json ); */ - Actor GetActor( const std::string &name ) const; + bool ApplyFromJson( Handle& handle, const std::string& json ); /** * @copydoc Toolkit::Builder::ApplyStyle */ - void ApplyStyle( const std::string& styleName, Handle& handle ); + bool ApplyStyle( const std::string& styleName, Handle& handle ); /** * @copydoc Toolkit::Builder::AddActors @@ -149,39 +159,60 @@ public: void AddActors( const std::string §ionName, Actor toActor ); /** - * @copydoc Toolkit::Builder::GetAnimation + * @copydoc Toolkit::Builder::CreateRenderTask */ - Animation GetAnimation( const std::string &name ) const; + void CreateRenderTask( const std::string &name ); /** - * @copydoc Toolkit::Builder::CreateRenderTask + * @copydoc Toolkit::Builder::GetFrameBufferImage */ - void CreateRenderTask( const std::string &name ); + FrameBufferImage GetFrameBufferImage( const std::string &name ); /** - * @copydoc Toolkit::Builder::GetShaderEffect + * @copydoc Toolkit::Builder::GetFrameBufferImage */ - ShaderEffect GetShaderEffect( const std::string &name ); + FrameBufferImage GetFrameBufferImage( const std::string &name, const Replacement& constant ); /** - * @copydoc Toolkit::Builder::GetShaderEffect + * @copydoc Toolkit::Builder::GetPath */ - ShaderEffect GetShaderEffect( const std::string &name, const Replacement& constant ); + Path GetPath( const std::string &name ); /** - * @copydoc Toolkit::Builder::GetFrameBufferImage + * @copydoc Toolkit::Builder::GetPathConstrainer */ - FrameBufferImage GetFrameBufferImage( const std::string &name ); + Dali::PathConstrainer GetPathConstrainer( const std::string& name ); + + /* + * Check if a given constrainer is of type PathConstrainer + * @param[in] name The name of the constrainer + * @return True if constainer is of type PathConstrainer, False otherwise + * + */ + bool IsPathConstrainer( const std::string& name ); /** - * @copydoc Toolkit::Builder::GetFrameBufferImage + * @copydoc Toolkit::Builder::GetLinearConstrainer */ - FrameBufferImage GetFrameBufferImage( const std::string &name, const Replacement& constant ); + Dali::LinearConstrainer GetLinearConstrainer( const std::string& name ); + + /* + * Check if a given constrainer is of type LinearConstrainer + * @param[in] name The name of the constrainer + * @return True if constainer is of type LinearConstrainer, False otherwise + * + */ + bool IsLinearConstrainer( const std::string& name ); /** - * @copydoc Toolkit::Builder::GetTopLevelActors + * @copydoc Toolkit::Builder::QuitSignal */ - ActorContainer GetTopLevelActors( void ) const; + Toolkit::Builder::BuilderSignalType& QuitSignal(); + + /** + * Emits the quit signal + */ + void EmitQuitSignal(); protected: @@ -194,29 +225,89 @@ private: void SetupTask( RenderTask& task, const Toolkit::TreeNode& node, const Replacement& replacement ); + void SetCustomProperties( const TreeNode& node, Handle& handle, const Replacement& constant, const std::string& childName, Property::AccessMode accessMode ); + private: Toolkit::JsonParser mParser; typedef std::map ImageLut; ImageLut mFrameBufferImageLut; - typedef std::map ShaderEffectLut; - ShaderEffectLut mShaderEffectLut; + typedef std::map PathLut; + PathLut mPathLut; + + typedef struct{ std::string name; Dali::PathConstrainer pathConstrainer; } PathConstrainerEntry; + typedef std::vector PathConstrainerLut; + PathConstrainerLut mPathConstrainerLut; + + typedef struct{ std::string name; Dali::LinearConstrainer linearConstrainer; } LinearConstrainerEntry; + typedef std::vector LinearConstrainerLut; + LinearConstrainerLut mLinearConstrainerLut; SlotDelegate mSlotDelegate; - PropertyValueMap mReplacementMap; + Property::Map mReplacementMap; + + typedef std::vector< TreeNode::KeyNodePair > MappingsLut; + MappingsLut mCompleteMappings; + + BaseHandle Create( const std::string& templateName, const Replacement& constant ); + + BaseHandle DoCreate( const TreeNode& root, const TreeNode& node, Actor parent, const Replacement& replacements ); + + void LoadConstants( const TreeNode& root, Property::Map& intoMap ); + + void LoadIncludes( const std::string& data ); + + bool ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement); + + Animation CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor ); + + typedef std::vector KeyStack; + + /** + * 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,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 ConvertChildValue( const TreeNode& mappingRoot, KeyStack& keyStack, 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. + * @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 ); + + /** + * 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] propertyType The property type if known, or NONE + * @param[in,out] value The string value to test and write back to. + */ + bool GetPropertyMap( const TreeNode& mappingRoot, const char* theKey, Property::Type propertyType, Property::Value& value ); - BaseHandle Create( const OptionalChild& optionalStyles, const TreeNode& node, const TreeNode& root, Actor parent, - const Replacement& replacement ); + void ApplyProperties( const TreeNode& root, const TreeNode& node, + Dali::Handle& handle, const Replacement& constant ); - void LoadConstants(); + void ApplyStylesByActor( const TreeNode& root, const TreeNode& node, + Dali::Handle& handle, const Replacement& constant ); - void ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement); + void ApplyAllStyleProperties( const TreeNode& root, const TreeNode& node, + Dali::Handle& handle, const Replacement& constant ); - Animation CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor searchRoot ); + void SetProperties( const TreeNode& node, Handle& handle, const Replacement& constant ); - BaseHandle CreateFromStyle( const std::string& styleName, const Replacement& replacement ); + Toolkit::Builder::BuilderSignalType mQuitSignal; }; } // namespace Internal