X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftransition-effects%2Fcube-transition-effect-impl.cpp;h=444a3fd1834f1517d35c6fe7d87af9fd6771060e;hp=ce9efcef2b2d26bdd91f8e217f0eea029b06711a;hb=c3f7ea6cb0c0b75c2276193aff88b5c7a679a2d5;hpb=e2eda444afbe82e9591fe198eef339227f90a616 diff --git a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp index ce9efce..444a3fd 100644 --- a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp +++ b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp @@ -1,22 +1,31 @@ -// -// 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 "cube-transition-effect-impl.h" +// EXTERNAL INCLUDES +#include // for strcmp +#include +#include +#include +#include +#include + namespace Dali { @@ -26,6 +35,18 @@ namespace Toolkit namespace Internal { +namespace +{ + +// Setup properties, signals and actions using the type-registry. +DALI_TYPE_REGISTRATION_BEGIN( Toolkit::CubeTransitionEffect, Dali::BaseHandle, NULL ); + +DALI_SIGNAL_REGISTRATION( Toolkit, CubeTransitionEffect, "transition-completed", SIGNAL_TRANSITION_COMPLETED ) + +DALI_TYPE_REGISTRATION_END() + +} + const Vector4 CubeTransitionEffect::FULL_BRIGHTNESS( 1.0f, 1.0f, 1.0f, 1.0f ); const Vector4 CubeTransitionEffect::HALF_BRIGHTNESS( 0.5f, 0.5f, 0.5f, 1.0f ); @@ -70,7 +91,7 @@ void CubeTransitionEffect::Initialize() (-mViewAreaSize.height + mTileSize.height) * 0.5f, -mTileSize.width * 0.5f ); - Image placeHolder = BitmapImage::WHITE(); + Image placeHolder = BufferImage::WHITE(); for( unsigned int y = 0; y < mNumRows; y++ ) { float positionY = y * mTileSize.height + basePosition.y; @@ -96,7 +117,7 @@ void CubeTransitionEffect::Initialize() // helper actor to create a off-screen image using shader effect mEmptyImage = ImageActor::New( placeHolder ); - mEmptyImage.SetSize(Stage::GetCurrent().GetSize()); + mEmptyImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mEmptyImage.SetParentOrigin( ParentOrigin::CENTER ); mEmptyImage.SetAnchorPoint( AnchorPoint::CENTER ); mFullImageCreator = FullAreaImageCreator::New(); @@ -173,19 +194,21 @@ void CubeTransitionEffect::SetTargetImage( ImageActor imageActor ) void CubeTransitionEffect::SetImage( ImageActor imageActor ) { mCurrentImage = imageActor; - mIsImageLoading = true; Image image = imageActor.GetImage(); + ResourceImage resourceImage = ResourceImage::DownCast( image ); mBufferIndex = mBufferIndex^1; //must make sure the image is already loaded before using its attributes - if( image.GetLoadingState() == ResourceLoadingSucceeded ) + if( resourceImage && resourceImage.GetLoadingState() != ResourceLoadingSucceeded ) { - OnImageLoaded( image ); + mIsImageLoading = true; + resourceImage.LoadingFinishedSignal().Connect( this, &CubeTransitionEffect::OnImageLoaded ); } else { - image.LoadingFinishedSignal().Connect( this, &CubeTransitionEffect::OnImageLoaded ); + mIsImageLoading = false; + PrepareTiles( image ); } } @@ -293,12 +316,21 @@ void CubeTransitionEffect::StopTransition() } } -void CubeTransitionEffect::OnImageLoaded(Image image) +void CubeTransitionEffect::OnImageLoaded(ResourceImage image) +{ + mIsImageLoading = false; + PrepareTiles( image ); +} + +/** + * Set sub-image to each tile. + * @param[in] image The image content of the imageActor for transition + */ +void CubeTransitionEffect::PrepareTiles( Image image ) { // Fit the image to view area, while keeping the aspect; FitKeepAspectRatio(imageSize, viewAreaSize) - ImageAttributes attributes( image.GetAttributes() ); - float scale = std::min( mViewAreaSize.width / attributes.GetWidth(), mViewAreaSize.height / attributes.GetHeight() ); - Vector2 imageSize(attributes.GetWidth()*scale, attributes.GetHeight()*scale); + float scale = std::min( mViewAreaSize.width / image.GetWidth(), mViewAreaSize.height / image.GetHeight() ); + Vector2 imageSize(image.GetWidth()*scale, image.GetHeight()*scale); mFullImageCreator.SetEffectImage(image); mFullImageCreator.SetRegionSize(mViewAreaSize, imageSize); @@ -319,9 +351,9 @@ void CubeTransitionEffect::OnImageLoaded(Image image) mTiles[mContainerIndex][idx].SetPixelArea( pixelArea ); } } - mIsImageLoading = false; } + void CubeTransitionEffect::OnTransitionFinished(Animation& source) { mRoot.SetVisible(false); @@ -331,12 +363,32 @@ void CubeTransitionEffect::OnTransitionFinished(Animation& source) //Emit signal Toolkit::CubeTransitionEffect handle( this ); - mTransitionCompletedSignalV2.Emit( handle, mCurrentImage ); + mTransitionCompletedSignal.Emit( handle, mCurrentImage ); +} + +Toolkit::CubeTransitionEffect::TransitionCompletedSignalType& CubeTransitionEffect::TransitionCompletedSignal() +{ + return mTransitionCompletedSignal; } -Toolkit::CubeTransitionEffect::TransitionCompletedSignalV2& CubeTransitionEffect::TransitionCompletedSignal() +bool CubeTransitionEffect::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) { - return mTransitionCompletedSignalV2; + Dali::BaseHandle handle( object ); + + bool connected( true ); + Toolkit::CubeTransitionEffect cubeTransitionEffect = Toolkit::CubeTransitionEffect::DownCast( handle ); + + if( 0 == strcmp( signalName.c_str(), SIGNAL_TRANSITION_COMPLETED ) ) + { + cubeTransitionEffect.TransitionCompletedSignal().Connect( tracker, functor ); + } + else + { + // signalName does not match any signal + connected = false; + } + + return connected; } } // namespace Internal