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=1d3505039c788cf5a42ced67fedca4868384fb7a;hp=ce9efcef2b2d26bdd91f8e217f0eea029b06711a;hb=1c3cb32385174b852b8d57b531625f733238f664;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..1d35050 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,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 "cube-transition-effect-impl.h" +// EXTERNAL INCLUDES +#include +#include +#include +#include + namespace Dali { @@ -26,6 +33,19 @@ namespace Toolkit namespace Internal { +namespace +{ + +// Signals + +const char* const SIGNAL_TRANSITION_COMPLETED = "transition-completed"; + +TypeRegistration typeRegistration( typeid( Toolkit::CubeTransitionEffect ), typeid( Dali::BaseHandle ), NULL ); + +SignalConnectorType signalConnector1( typeRegistration, SIGNAL_TRANSITION_COMPLETED , &CubeTransitionEffect::DoConnectSignal ); + +} + 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 ); @@ -173,19 +193,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 +315,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 +350,9 @@ void CubeTransitionEffect::OnImageLoaded(Image image) mTiles[mContainerIndex][idx].SetPixelArea( pixelArea ); } } - mIsImageLoading = false; } + void CubeTransitionEffect::OnTransitionFinished(Animation& source) { mRoot.SetVisible(false); @@ -331,12 +362,32 @@ void CubeTransitionEffect::OnTransitionFinished(Animation& source) //Emit signal Toolkit::CubeTransitionEffect handle( this ); - mTransitionCompletedSignalV2.Emit( handle, mCurrentImage ); + mTransitionCompletedSignal.Emit( handle, mCurrentImage ); } -Toolkit::CubeTransitionEffect::TransitionCompletedSignalV2& CubeTransitionEffect::TransitionCompletedSignal() +Toolkit::CubeTransitionEffect::TransitionCompletedSignalType& CubeTransitionEffect::TransitionCompletedSignal() { - return mTransitionCompletedSignalV2; + return mTransitionCompletedSignal; +} + +bool CubeTransitionEffect::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) +{ + 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