X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fview%2Fview-impl.cpp;h=280bd24e37a7dfaaf6e11d44471d088098d9fd7a;hb=fbbecdf7055c52aa0a68ceb5c1f5131a7a5a21ad;hp=a756f94df6cd4ea12b50fac55965d29b925b0f13;hpb=e2eda444afbe82e9591fe198eef339227f90a616;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/view/view-impl.cpp b/dali-toolkit/internal/controls/view/view-impl.cpp index a756f94..280bd24 100644 --- a/dali-toolkit/internal/controls/view/view-impl.cpp +++ b/dali-toolkit/internal/controls/view/view-impl.cpp @@ -1,26 +1,29 @@ -// -// 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. + * + */ // CLASS HEADER - #include "view-impl.h" // EXTERNAL INCLUDES - -// INTERNAL INCLUDES +#include // for strcmp +#include +#include +#include +#include namespace Dali { @@ -31,7 +34,7 @@ namespace Toolkit namespace Internal { -namespace // to register type +namespace { BaseHandle Create() @@ -39,14 +42,11 @@ BaseHandle Create() return Toolkit::View::New(); } -TypeRegistration typeRegistration( typeid(Toolkit::View), typeid(Toolkit::Control), Create ); +DALI_TYPE_REGISTRATION_BEGIN( Toolkit::View, Toolkit::Control, Create ) -SignalConnectorType signalConnector1( typeRegistration, Toolkit::View::SIGNAL_ORIENTATION_ANIMATION_START , &View::DoConnectSignal ); +//DALI_SIGNAL_REGISTRATION( View, "orientation-animation-start", SIGNAL_ORIENTATION_ANIMATION_START ) -} - -namespace -{ +DALI_TYPE_REGISTRATION_END() const float ROTATION_ANIMATION_DURATION = 0.5f; @@ -133,7 +133,7 @@ void View::SetBackground( ImageActor backgroundImage ) mBackgroundLayer = Layer::New(); mBackgroundLayer.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - mBackgroundLayer.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); + mBackgroundLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Add background layer to custom actor. Self().Add( mBackgroundLayer ); @@ -153,25 +153,26 @@ void View::SetBackground( ImageActor backgroundImage ) } backgroundImage.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - Constraint constraint = Constraint::New( - Actor::SCALE, - LocalSource( Actor::SIZE ), - ParentSource( Actor::SIZE ), - ScaleToFillXYKeepAspectRatioConstraint() ); - backgroundImage.ApplyConstraint( constraint ); + backgroundImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + backgroundImage.SetSizeScalePolicy( SizeScalePolicy::FILL_WITH_ASPECT_RATIO ); mBackgroundLayer.Add( backgroundImage ); + + RelayoutRequest(); } void View::SetOrientationFunction( Degree portrait, Degree landscale, Degree portraitInverse, Degree landscapeInverse ) { - mOrientationFunction[View::PORTRAIT] = portrait; - mOrientationFunction[View::LANDSCAPE] = landscale; - mOrientationFunction[View::PORTRAIT_INVERSE] = portraitInverse; - mOrientationFunction[View::LANDSCAPE_INVERSE] = landscapeInverse; + mOrientationFunction[View::PORTRAIT] = portrait.degree; + mOrientationFunction[View::LANDSCAPE] = landscale.degree; + mOrientationFunction[View::PORTRAIT_INVERSE] = portraitInverse.degree; + mOrientationFunction[View::LANDSCAPE_INVERSE] = landscapeInverse.degree; } void View::OrientationChanged( Dali::Orientation orientation ) { + /* + Actor self = Self(); + // Nothing to do if orientation doesn't really change. if ( orientation.GetDegrees() == mOrientation || !mAutoRotateEnabled ) { @@ -182,13 +183,13 @@ void View::OrientationChanged( Dali::Orientation orientation ) // has parent so we expect it to be on stage mRotateAnimation = Animation::New( ROTATION_ANIMATION_DURATION ); - mRotateAnimation.RotateTo( Self(), Degree( -orientation.GetDegrees() ), Vector3::ZAXIS, AlphaFunctions::EaseOut ); + mRotateAnimation.AnimateTo( Property( self, Actor::Property::ORIENTATION ), Quaternion( Radian( -orientation.GetRadians() ), Vector3::ZAXIS ), AlphaFunctions::EaseOut ); // Resize the view if( mFullScreen ) { const Vector2& stageSize( Stage::GetCurrent().GetSize() ); - const Vector3& currentSize( Self().GetCurrentSize() ); + const Vector3& currentSize( self.GetCurrentSize() ); float minSize = std::min( stageSize.width, stageSize.height ); float maxSize = std::max( stageSize.width, stageSize.height ); @@ -218,24 +219,23 @@ void View::OrientationChanged( Dali::Orientation orientation ) { // width grows, shrink height faster Vector3 shrink( currentSize );shrink.height = targetSize.height; - mRotateAnimation.Resize( Self(), shrink, AlphaFunctions::EaseOut, 0.0f, ROTATION_ANIMATION_DURATION * 0.5f ); - mRotateAnimation.Resize( Self(), targetSize, AlphaFunctions::EaseIn, 0.0f, ROTATION_ANIMATION_DURATION ); + mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), shrink, AlphaFunctions::EaseOut, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION * 0.5f ) ); + mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), targetSize, AlphaFunctions::EaseIn, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION ) ); } else { // height grows, shrink width faster Vector3 shrink( currentSize );shrink.width = targetSize.width; - mRotateAnimation.Resize( Self(), shrink, AlphaFunctions::EaseOut, 0.0f, ROTATION_ANIMATION_DURATION * 0.5f ); - mRotateAnimation.Resize( Self(), targetSize, AlphaFunctions::EaseIn, 0.0f, ROTATION_ANIMATION_DURATION ); + mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), shrink, AlphaFunctions::EaseOut, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION * 0.5f ) ); + mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), targetSize, AlphaFunctions::EaseIn, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION ) ); } } - mRotateAnimation.SetDestroyAction( Animation::Bake ); - Toolkit::View handle( GetOwner() ); - mOrientationAnimationStartedSignalV2.Emit( handle, mRotateAnimation, orientation ); + mOrientationAnimationStartedSignal.Emit( handle, mRotateAnimation, orientation ); mRotateAnimation.Play(); + */ } void View::SetAutoRotate( bool enabled ) @@ -243,19 +243,22 @@ void View::SetAutoRotate( bool enabled ) mAutoRotateEnabled = enabled; } -Toolkit::View::OrientationAnimationStartedSignalV2& View::OrientationAnimationStartedSignal() +Toolkit::View::OrientationAnimationStartedSignalType& View::OrientationAnimationStartedSignal() { - return mOrientationAnimationStartedSignalV2; + return mOrientationAnimationStartedSignal; } bool View::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) { + return true; + + /* Dali::BaseHandle handle( object ); bool connected( true ); Toolkit::View view = Toolkit::View::DownCast(handle); - if( Toolkit::View::SIGNAL_ORIENTATION_ANIMATION_START == signalName ) + if( 0 == strcmp( signalName.c_str(), SIGNAL_ORIENTATION_ANIMATION_START ) ) { view.OrientationAnimationStartedSignal().Connect( tracker, functor ); } @@ -266,10 +269,11 @@ bool View::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* trac } return connected; + */ } View::View(bool fullscreen) -: ControlImpl( false ), // doesn't require touch events +: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), mOrientation( -1 ), mFullScreen(fullscreen), mContentLayers(), @@ -302,19 +306,19 @@ View::Orientation View::DegreeToViewOrientation( Degree degree ) { View::Orientation orientation = PORTRAIT; - if( fabsf( mOrientationFunction[PORTRAIT] - degree ) <= GetRangedEpsilon( mOrientationFunction[PORTRAIT], degree ) ) + if( fabsf( mOrientationFunction[PORTRAIT] - degree.degree ) <= GetRangedEpsilon( mOrientationFunction[PORTRAIT], degree.degree ) ) { orientation = PORTRAIT; } - else if( fabsf( mOrientationFunction[LANDSCAPE] - degree ) <= GetRangedEpsilon( mOrientationFunction[LANDSCAPE], degree ) ) + else if( fabsf( mOrientationFunction[LANDSCAPE] - degree.degree ) <= GetRangedEpsilon( mOrientationFunction[LANDSCAPE], degree.degree ) ) { orientation = LANDSCAPE; } - else if( fabsf( mOrientationFunction[PORTRAIT_INVERSE] - degree ) <= GetRangedEpsilon( mOrientationFunction[PORTRAIT_INVERSE], degree ) ) + else if( fabsf( mOrientationFunction[PORTRAIT_INVERSE] - degree.degree ) <= GetRangedEpsilon( mOrientationFunction[PORTRAIT_INVERSE], degree.degree ) ) { orientation = PORTRAIT_INVERSE; } - else if( fabsf( mOrientationFunction[LANDSCAPE_INVERSE] - degree ) <= GetRangedEpsilon( mOrientationFunction[LANDSCAPE_INVERSE], degree ) ) + else if( fabsf( mOrientationFunction[LANDSCAPE_INVERSE] - degree.degree ) <= GetRangedEpsilon( mOrientationFunction[LANDSCAPE_INVERSE], degree.degree ) ) { orientation = LANDSCAPE_INVERSE; }