X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=inline;f=dali-toolkit%2Finternal%2Fcontrols%2Fsuper-blur-view%2Fsuper-blur-view-impl.cpp;h=384e291c3cf18f17027daf592cf7a222910cacd2;hb=402784aceba9171e57ffca8769ca46ef8aebcd2f;hp=b469f83b7cfaf19add14add832477fc68d3fd320;hpb=c8ffcb9f46ded14981915479af62d85970798db5;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp index b469f83..384e291 100644 --- a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp +++ b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp @@ -20,14 +20,14 @@ // EXTERNAL INCLUDES #include -#include #include #include #include +#include #include #include -namespace //unnamed namespace +namespace //Unnamed namespace { using namespace Dali; @@ -53,20 +53,20 @@ struct ActorOpacityConstraint mRange = Vector2( index*rangeLength, (index+1.f)*rangeLength ); } - float operator()( float current, const PropertyInput& blurProperty ) + void operator()( float& current, const PropertyInputContainer& inputs ) { - float blurStrength = blurProperty.GetFloat(); + float blurStrength = inputs[0]->GetFloat(); if(blurStrength <= mRange.x) { - return 1.f; + current = 1.f; } else if(blurStrength > mRange.y) { - return 0.f; + current = 0.f; } else { - return (mRange.y - blurStrength)/(mRange.y-mRange.x); + current = ( mRange.y - blurStrength) / ( mRange.y - mRange.x ); } } @@ -81,13 +81,12 @@ namespace Dali namespace Toolkit { -const Property::Index SuperBlurView::PROPERTY_IMAGE( Internal::SuperBlurView::SUPER_BLUR_VIEW_PROPERTY_START_INDEX ); - namespace Internal { namespace { + const unsigned int DEFAULT_BLUR_LEVEL(5u); ///< The default blur level when creating SuperBlurView from the type registry BaseHandle Create() @@ -95,10 +94,12 @@ BaseHandle Create() return Toolkit::SuperBlurView::New( DEFAULT_BLUR_LEVEL ); } -// Type registration -TypeRegistration typeRegistration( typeid(Toolkit::SuperBlurView), typeid(Toolkit::Control), Create ); +// Setup properties, signals and actions using the type-registry. +DALI_TYPE_REGISTRATION_BEGIN( Toolkit::SuperBlurView, Toolkit::Control, Create ) + +DALI_PROPERTY_REGISTRATION( SuperBlurView, "image", MAP, IMAGE ) -PropertyRegistration property1( typeRegistration, "image", Toolkit::SuperBlurView::PROPERTY_IMAGE, Property::MAP, &SuperBlurView::SetProperty, &SuperBlurView::GetProperty ); +DALI_TYPE_REGISTRATION_END() } // unnamed namespace @@ -150,7 +151,9 @@ void SuperBlurView::OnInitialize() for(unsigned int i=0; i < mBlurLevels; i++) { - mImageActors[i].ApplyConstraint( Constraint::New( Actor::Property::ColorAlpha, ParentSource( mBlurStrengthPropertyIndex ), ActorOpacityConstraint(mBlurLevels, i) ) ); + Constraint constraint = Constraint::New( mImageActors[i], Actor::Property::COLOR_ALPHA, ActorOpacityConstraint(mBlurLevels, i) ); + constraint.AddSource( ParentSource( mBlurStrengthPropertyIndex ) ); + constraint.Apply(); } Self().SetSize(Stage::GetCurrent().GetSize()); @@ -248,7 +251,7 @@ void SuperBlurView::ClearBlurResource() } } -void SuperBlurView::OnRelayout( const Vector2& size, ActorSizeContainer& container ) +void SuperBlurView::OnRelayout( const Vector2& size, RelayoutContainer& container ) { unsigned int numChildren = Self().GetChildCount(); @@ -277,24 +280,20 @@ void SuperBlurView::SetProperty( BaseObject* object, Property::Index propertyInd { Toolkit::SuperBlurView superBlurView = Toolkit::SuperBlurView::DownCast( Dali::BaseHandle( object ) ); - if ( superBlurView ) + if( superBlurView ) { SuperBlurView& superBlurViewImpl( GetImpl( superBlurView ) ); - switch ( propertyIndex ) + if( propertyIndex == Toolkit::SuperBlurView::Property::IMAGE ) { - case Toolkit::SuperBlurView::PROPERTY_IMAGE: + Dali::Image image = Scripting::NewImage( value ); + if ( image ) + { + superBlurViewImpl.SetImage( image ); + } + else { - Dali::Image image = Scripting::NewImage( value ); - if ( image ) - { - superBlurViewImpl.SetImage( image ); - } - else - { - DALI_LOG_ERROR( "Cannot create image from property value\n" ); - } - break; + DALI_LOG_ERROR( "Cannot create image from property value\n" ); } } } @@ -306,22 +305,18 @@ Property::Value SuperBlurView::GetProperty( BaseObject* object, Property::Index Toolkit::SuperBlurView pushButton = Toolkit::SuperBlurView::DownCast( Dali::BaseHandle( object ) ); - if ( pushButton ) + if( pushButton ) { SuperBlurView& superBlurViewImpl( GetImpl( pushButton ) ); - switch ( propertyIndex ) + if( propertyIndex == Toolkit::SuperBlurView::Property::IMAGE ) { - case Toolkit::SuperBlurView::PROPERTY_IMAGE: + Property::Map map; + if( !superBlurViewImpl.mImageActors.empty() && superBlurViewImpl.mImageActors[0] ) { - Property::Map map; - if ( !superBlurViewImpl.mImageActors.empty() && superBlurViewImpl.mImageActors[0] ) - { - Scripting::CreatePropertyMap( superBlurViewImpl.mImageActors[0], map ); - } - value = Property::Value( map ); - break; + Scripting::CreatePropertyMap( superBlurViewImpl.mImageActors[0], map ); } + value = Property::Value( map ); } }