Remove Constraints from Cluster,ToolBar,View & ImageView
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / internal / controls / view / view-impl.cpp
index a756f94..6c374c0 100644 (file)
@@ -1,24 +1,27 @@
-//
-// 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
+#include <dali/public-api/animation/constraints.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/object/type-registry.h>
 
 // INTERNAL INCLUDES
 
@@ -133,7 +136,7 @@ void View::SetBackground( ImageActor backgroundImage )
     mBackgroundLayer = Layer::New();
 
     mBackgroundLayer.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-    mBackgroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+    mBackgroundLayer.SetSize( mViewSize );
 
     // Add background layer to custom actor.
     Self().Add( mBackgroundLayer );
@@ -153,12 +156,7 @@ void View::SetBackground( ImageActor backgroundImage )
   }
 
   backgroundImage.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-  Constraint constraint = Constraint::New<Vector3>(
-      Actor::SCALE,
-      LocalSource( Actor::SIZE ),
-      ParentSource( Actor::SIZE ),
-      ScaleToFillXYKeepAspectRatioConstraint() );
-  backgroundImage.ApplyConstraint( constraint );
+  backgroundImage.SetScale( FillXYKeepAspectRatio( mViewSize, backgroundImage.GetSize() ) );
   mBackgroundLayer.Add( backgroundImage );
 }
 
@@ -230,10 +228,8 @@ void View::OrientationChanged( Dali::Orientation orientation )
     }
   }
 
-  mRotateAnimation.SetDestroyAction( Animation::Bake );
-
   Toolkit::View handle( GetOwner() );
-  mOrientationAnimationStartedSignalV2.Emit( handle, mRotateAnimation, orientation );
+  mOrientationAnimationStartedSignal.Emit( handle, mRotateAnimation, orientation );
 
   mRotateAnimation.Play();
 }
@@ -243,9 +239,9 @@ 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 )
@@ -269,7 +265,7 @@ bool View::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* trac
 }
 
 View::View(bool fullscreen)
-: ControlImpl( false ),  // doesn't require touch events
+: Control( CONTROL_BEHAVIOUR_NONE ),
   mOrientation( -1 ),
   mFullScreen(fullscreen),
   mContentLayers(),
@@ -298,6 +294,20 @@ void View::OnInitialize()
   }
 }
 
+void View::OnControlSizeSet( const Vector3& targetSize )
+{
+  mViewSize = targetSize;
+  if( mBackgroundLayer )
+  {
+    mBackgroundLayer.SetSize( mViewSize );
+    if( mBackgroundLayer.GetChildCount() > 0 )
+    {
+      Actor background = mBackgroundLayer.GetChildAt(0);
+      background.SetScale( FillXYKeepAspectRatio( mViewSize, background.GetSize() ) );
+    }
+  }
+}
+
 View::Orientation View::DegreeToViewOrientation( Degree degree )
 {
   View::Orientation orientation = PORTRAIT;