X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fmagnifier%2Fmagnifier-impl.cpp;h=12205a6f5493c0f732f23f60f9ffa135f869160b;hb=380cdb40c8cb0aaefb60134268744e0331c35385;hp=d956e36a2e322b4bb60bdd3d6f92e8eb7d8566db;hpb=31df2b9472ccbe0ae460a958535be8ef790c96f2;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp b/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp index d956e36..12205a6 100644 --- a/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp +++ b/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -25,7 +25,14 @@ #include #include #include -#include +#include +#include + +// INTERNAL INCLUDES +#include +#include +#include +#include namespace Dali { @@ -47,16 +54,14 @@ Dali::BaseHandle Create() DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Magnifier, Toolkit::Control, Create ) -DALI_PROPERTY_REGISTRATION( Toolkit, Magnifier, "frame-visibility", BOOLEAN, FRAME_VISIBILITY ) -DALI_PROPERTY_REGISTRATION( Toolkit, Magnifier, "magnification-factor", FLOAT, MAGNIFICATION_FACTOR ) +DALI_PROPERTY_REGISTRATION( Toolkit, Magnifier, "frameVisibility", BOOLEAN, FRAME_VISIBILITY ) +DALI_PROPERTY_REGISTRATION( Toolkit, Magnifier, "magnificationFactor", FLOAT, MAGNIFICATION_FACTOR ) -DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Magnifier, "source-position", VECTOR3, SOURCE_POSITION ) +DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Magnifier, "sourcePosition", VECTOR3, SOURCE_POSITION ) DALI_TYPE_REGISTRATION_END() -const char* DEFAULT_FRAME_IMAGE_PATH = DALI_IMAGE_DIR "magnifier-image-frame.png"; - -const float IMAGE_BORDER_INDENT = 14.0f; ///< Indent of border in pixels. +const float IMAGE_BORDER_INDENT = 5.0f; ///< Indent of border in pixels. struct CameraActorPositionConstraint { @@ -138,7 +143,7 @@ Dali::Toolkit::Magnifier Magnifier::New() } Magnifier::Magnifier() -: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ), +: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), mDefaultCameraDistance(1000.f), mActorSize(Vector3::ZERO), mMagnificationFactor(1.0f) @@ -197,7 +202,7 @@ void Magnifier::Initialize() // Use a 1 frame delayed source position to determine the camera actor's position. // This is necessary as the viewport is determined by the Magnifier's Actor's World position (which is computed // at the end of the update cycle i.e. after constraints have been applied.) - //Property::Index propertySourcePositionDelayed = mCameraActor.RegisterProperty("delayed-source-position", Vector3::ZERO); + //Property::Index propertySourcePositionDelayed = mCameraActor.RegisterProperty("delayedSourcePosition", Vector3::ZERO); constraint = Constraint::New( mCameraActor, Actor::Property::POSITION, CameraActorPositionConstraint(stageSize, mDefaultCameraDistance) ); constraint.AddSource( Source( mSourceActor, Actor::Property::WORLD_POSITION ) ); @@ -253,20 +258,26 @@ void Magnifier::SetFrameVisibility(bool visible) { Actor self(Self()); - Image image = ResourceImage::New( DEFAULT_FRAME_IMAGE_PATH ); - mFrame = ImageActor::New( image ); - mFrame.SetStyle( ImageActor::STYLE_NINE_PATCH ); - mFrame.SetPositionInheritanceMode(DONT_INHERIT_POSITION); + mFrame = Actor::New( ); + mFrame.SetInheritPosition(false); mFrame.SetInheritScale(true); mFrame.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS ); Vector3 sizeOffset(IMAGE_BORDER_INDENT*2.f - 2.f, IMAGE_BORDER_INDENT*2.f - 2.f, 0.0f); mFrame.SetSizeModeFactor( sizeOffset ); + Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get(); + + Property::Map map; + map[ Toolkit::DevelVisual::Property::TYPE ] = Toolkit::Visual::BORDER; + map[ Toolkit::BorderVisual::Property::COLOR ] = Color::WHITE; + map[ Toolkit::BorderVisual::Property::SIZE ] = IMAGE_BORDER_INDENT; + Toolkit::Visual::Base borderVisual = visualFactory.CreateVisual( map ); + Toolkit::GetImplementation(borderVisual).SetOnStage( mFrame ); + Constraint constraint = Constraint::New( mFrame, Actor::Property::POSITION, EqualToConstraint() ); constraint.AddSource( ParentSource( Actor::Property::WORLD_POSITION ) ); constraint.Apply(); - mFrame.SetNinePatchBorder( Vector4::ONE * IMAGE_BORDER_INDENT ); self.Add(mFrame); } else if(!visible && mFrame) @@ -277,6 +288,8 @@ void Magnifier::SetFrameVisibility(bool visible) void Magnifier::OnSizeSet(const Vector3& targetSize) { + Control::OnSizeSet( targetSize ); + // TODO: Once Camera/CameraActor properties function as proper animatable properties // this code can disappear. // whenever the size of the magnifier changes, the field of view needs to change