-//
-// 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 <dali/public-api/common/stage.h>
+#include <dali/public-api/images/image-attributes.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
+
namespace Dali
{
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 );
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 );
}
}
}
}
-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);
mTiles[mContainerIndex][idx].SetPixelArea( pixelArea );
}
}
- mIsImageLoading = false;
}
+
void CubeTransitionEffect::OnTransitionFinished(Animation& source)
{
mRoot.SetVisible(false);
//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