X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=optional%2Fdali-toolkit%2Finternal%2Fcontrols%2Fmagnifier%2Fmagnifier-impl.cpp;h=5f9139ce89b9eea72d8df96073acb18b02a00b70;hp=0cf34a086991ced9b92651ea1c1eef9fbff18903;hb=e5f2603c45d9423cd45e4708a969eb05b982bfd9;hpb=dba1997566a1445e0c95459b998c39c9444f19be diff --git a/optional/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp b/optional/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp index 0cf34a0..5f9139c 100644 --- a/optional/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp +++ b/optional/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp @@ -19,7 +19,6 @@ #include // EXTERNAL INCLUDES -#include #include #include #include @@ -177,10 +176,6 @@ void Magnifier::Initialize() mPropertySourcePosition = self.RegisterProperty( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME, Vector3::ZERO ); Vector2 stageSize(Stage::GetCurrent().GetSize()); - Layer dummyLayer = Layer::New(); - Stage().GetCurrent().Add(dummyLayer); - dummyLayer.SetParentOrigin(ParentOrigin::CENTER); - // NOTE: // sourceActor is a dummy delegate actor that takes the source property position, // and generates a WORLD_POSITION, which is 1 frame behind the source property. @@ -192,7 +187,7 @@ void Magnifier::Initialize() // Perhaps this is a bug in the way the constraint system factors into what is dirty // and what is not. mSourceActor = Actor::New(); - dummyLayer.Add(mSourceActor); + Stage().GetCurrent().Add(mSourceActor); mSourceActor.SetParentOrigin(ParentOrigin::CENTER); Constraint constraint = Constraint::New( Actor::POSITION, Source( self, mPropertySourcePosition ), @@ -275,56 +270,42 @@ void Magnifier::InitializeRenderTask() bool Magnifier::GetFrameVisibility() const { - return mFrameLayer; + return mFrame; } void Magnifier::SetFrameVisibility(bool visible) { - if(visible && !mFrameLayer) + if(visible && !mFrame) { Actor self(Self()); - Layer mFrameLayer = Layer::New(); - mFrameLayer.SetParentOrigin( ParentOrigin::CENTER ); - Stage::GetCurrent().Add(mFrameLayer); - Image image = Image::New( DEFAULT_FRAME_IMAGE_PATH ); - ImageActor frame = ImageActor::New( image ); - frame.SetDrawMode(DrawMode::OVERLAY); - frame.SetStyle( ImageActor::STYLE_NINE_PATCH ); - - frame.SetNinePatchBorder( Vector4::ONE * IMAGE_BORDER_INDENT ); - mFrameLayer.Add(frame); - - // Apply position constraint to the frame - Constraint constraint = Constraint::New( Actor::POSITION, - Source( self, Actor::WORLD_POSITION ), - EqualToConstraint() ); - frame.ApplyConstraint(constraint); - - // Apply scale constraint to the frame - constraint = Constraint::New( Actor::SCALE, - Source( self, Actor::SCALE ), - EqualToConstraint() ); - frame.ApplyConstraint(constraint); - - Source(self, Actor::SCALE), - - // Apply size constraint to the the frame - constraint = Constraint::New(Actor::SIZE, - Source(self, Actor::SIZE), - ImageBorderSizeConstraint()); - frame.ApplyConstraint(constraint); + mFrame = ImageActor::New( image ); + mFrame.SetDrawMode(DrawMode::OVERLAY); + mFrame.SetStyle( ImageActor::STYLE_NINE_PATCH ); + mFrame.SetPositionInheritanceMode(USE_PARENT_POSITION); + mFrame.SetInheritScale(true); + + mFrame.SetNinePatchBorder( Vector4::ONE * IMAGE_BORDER_INDENT ); + self.Add(mFrame); + + Vector3 sizeOffset(IMAGE_BORDER_INDENT*2.f - 2.f, IMAGE_BORDER_INDENT*2.f - 2.f, 0.0f); + mFrame.SetSize(mActorSize + sizeOffset); } - else if(!visible && mFrameLayer) + else if(!visible && mFrame) { - Stage::GetCurrent().Remove(mFrameLayer); - mFrameLayer.Reset(); + UnparentAndReset(mFrame); } } void Magnifier::OnControlSizeSet(const Vector3& targetSize) { + if( mFrame ) + { + Vector3 sizeOffset(IMAGE_BORDER_INDENT*2.f - 2.f, IMAGE_BORDER_INDENT*2.f - 2.f, 0.0f); + mFrame.SetSize(targetSize + sizeOffset); + } + // 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