X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=base%2Fdali-toolkit%2Finternal%2Fbuilder%2Fbuilder-impl.cpp;h=3f134b6fc82d7e29953b9c6dba895827a4c8359e;hb=aec3f20be4d0a67a042de96ff48f1370b85467f7;hp=544c4281c62fb45bae7a14f01c6080dbc261c02f;hpb=db3d8658c7848f918d591d2f7be5c7d9434a6307;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/base/dali-toolkit/internal/builder/builder-impl.cpp b/base/dali-toolkit/internal/builder/builder-impl.cpp index 544c428..3f134b6 100644 --- a/base/dali-toolkit/internal/builder/builder-impl.cpp +++ b/base/dali-toolkit/internal/builder/builder-impl.cpp @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include #include // INTERNAL INCLUDES @@ -49,8 +50,8 @@ extern bool SetPropertyFromNode( const TreeNode& node, Property::Value& value ); extern bool SetPropertyFromNode( const TreeNode& node, Property::Value& value, const Replacement& replacements ); extern bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value ); extern bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value, const Replacement& replacements ); -extern Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor); -extern Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor); +extern Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, boost::function quitAction); +extern Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, boost::function quitAction); extern Actor SetupActor( const TreeNode& node, Actor& actor, const Replacement& constant ); #if defined(DEBUG_ENABLED) @@ -86,6 +87,7 @@ std::string ToString(const Rect& value) return ss.str(); } +#if defined(DEBUG_ENABLED) std::string PropertyValueToString( const Property::Value& value ) { @@ -177,6 +179,7 @@ std::string PropertyValueToString( const Property::Value& value ) return ret; } +#endif // DEBUG_ENABLED /* * Recursively collects all stylesin a node (An array of style names). @@ -208,6 +211,23 @@ void CollectAllStyles( const TreeNode& stylesCollection, const TreeNode& style, } } +struct QuitAction +{ +public: + QuitAction( Builder& builder ) + : mBuilder( builder ) + { + } + + void operator()(void) + { + mBuilder.EmitQuitSignal(); + } + +private: + Builder& mBuilder; +}; + } // namespace anon /* @@ -335,9 +355,9 @@ void Builder::ApplyProperties( const TreeNode& root, const TreeNode& node, SetupActor( node, actor, constant ); // add signals - SetupSignalAction( mSlotDelegate.GetConnectionTracker(), root, node, actor ); - - SetupPropertyNotification( mSlotDelegate.GetConnectionTracker(), root, node, actor ); + QuitAction quitAction( *this ); + SetupSignalAction( mSlotDelegate.GetConnectionTracker(), root, node, actor, quitAction ); + SetupPropertyNotification( mSlotDelegate.GetConnectionTracker(), root, node, actor, quitAction ); } } else @@ -507,9 +527,7 @@ BaseHandle Builder::DoCreate( const TreeNode& root, const TreeNode& node, } } - ApplyProperties( root, node, handle, replacements ); - - if( actor) + if( actor ) { // add children of all the styles if( OptionalChild actors = IsChild( node, KEYNAME_ACTORS ) ) @@ -529,7 +547,10 @@ BaseHandle Builder::DoCreate( const TreeNode& root, const TreeNode& node, parent.Add( actor ); } } - + else + { + ApplyProperties( root, node, handle, replacements ); + } } else { @@ -725,6 +746,16 @@ FrameBufferImage Builder::GetFrameBufferImage( const std::string &name, const Re return ret; } +Toolkit::Builder::Signal& Builder::QuitSignal() +{ + return mQuitSignal; +} + +void Builder::EmitQuitSignal() +{ + mQuitSignal.Emit(); +} + void Builder::AddActors( Actor toActor ) { // 'stage' is the default/by convention section to add from @@ -981,7 +1012,6 @@ bool Builder::ApplyStyle( const std::string& styleName, Handle& handle, const Re } else { - DALI_SCRIPT_WARNING("No styles section to create style '%s'\n", styleName.c_str()); return false; } } @@ -1029,6 +1059,44 @@ BaseHandle Builder::Create( const std::string& templateName, const Replacement& return baseHandle; } +BaseHandle Builder::CreateFromJson( const std::string& json ) +{ + BaseHandle ret; + + // merge in new template, hoping no one else has one named '@temp@' + std::string newTemplate = + std::string("{\"templates\":{\"@temp@\":") + \ + json + \ + std::string("}}"); + + if( mParser.Parse(newTemplate) ) + { + Replacement replacement( mReplacementMap ); + ret = Create( "@temp@", replacement ); + } + + return ret; +} + +bool Builder::ApplyFromJson( Handle& handle, const std::string& json ) +{ + bool ret = false; + + // merge new style, hoping no one else has one named '@temp@' + std::string newStyle = + std::string("{\"styles\":{\"@temp@\":") + \ + json + \ + std::string("}}"); + + if( mParser.Parse(newStyle) ) + { + Replacement replacement( mReplacementMap ); + ret = ApplyStyle( "@temp@", handle, replacement ); + } + + return ret; +} + BaseHandle Builder::Create( const std::string& templateName ) {