-#ifndef __DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H__
-#define __DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H__
+#ifndef DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H
+#define DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
// EXTERNAL INCLUDES
#include <dali/public-api/animation/animation.h>
-#include <dali/public-api/images/bitmap-image.h>
-#include <dali/public-api/images/frame-buffer-image.h>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/render-tasks/render-task.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/public-api/rendering/renderer.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/transition-effects/cube-transition-effect.h>
+#include <dali-toolkit/devel-api/transition-effects/cube-transition-effect.h>
+#include <dali-toolkit/public-api/controls/control-impl.h>
namespace Dali
{
-
namespace Toolkit
{
-
class CubeTransitionEffect;
namespace Internal
{
-
-/**
- * Create a image with size of viewAreaSize
- * with the effect image as its center part and (0,0,0,1) at other parts
- */
-class FullAreaImageCreator : public ShaderEffect
-{
-
-public:
-
- /**
- * Create an uninitialized FullAreaImageCreator
- * this can be initialized with FullAreaImageCreator::New()
- */
- FullAreaImageCreator(){}
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~FullAreaImageCreator(){}
-
- /**
- * Create an initialized FullAreaImageCreator.
- * @return A handle to a newly allocated Dali resource.
- */
- static FullAreaImageCreator New()
- {
- std::string vertexShader(
- "uniform mediump vec4 uRegion; \n"
- "void main() \n"
- "{\n"
- " gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n"
- " vTexCoord.s = (aTexCoord.s - uRegion.s) / uRegion.p;"
- " vTexCoord.t = ( 1.0 - aTexCoord.t - uRegion.t) / uRegion.q;"
- "}\n"
- );
-
- std::string fragmentShader(
- "uniform mediump vec4 uRegion; \n"
- "void main() \n"
- "{\n"
- " if( vTexCoord.s > 0.0 && vTexCoord.s < 1.0 && vTexCoord.t > 0.0 && vTexCoord.t < 1.0) \n"
- " { \n"
- " gl_FragColor = texture2D( sEffect, vTexCoord ) * uColor ; \n"
- " } \n"
- " else \n"
- " { \n"
- " gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); \n"
- " } \n"
- "}\n"
- );
-
- ShaderEffect shaderEffectCustom = ShaderEffect::New(vertexShader, fragmentShader);
- FullAreaImageCreator handle( shaderEffectCustom );
-
- return handle;
- }
-
- /**
- * Set up the position and size of the effect texture
- * @param[in] viewArea the size of full-area image to create
- * @param[in] size the size of effect texture
- */
- void SetRegionSize( const Vector2& viewArea, const Vector2& size )
- {
- Vector2 sizeRatio( std::min(1.f, size.x / viewArea.x), std::min(1.f, size.y / viewArea.y) );
- Vector4 region( (1.f-sizeRatio.x)*0.5f,
- (1.f-sizeRatio.y)*0.5f,
- sizeRatio.x,
- sizeRatio.y );
- SetUniform( "uRegion", region );
- }
-
-private:
-
- FullAreaImageCreator( ShaderEffect handle )
- : ShaderEffect( handle )
- {}
-
-};
-
-
-
/**
* CubeTransitionEffect implementation class
*/
-class CubeTransitionEffect : public Dali::BaseObject, public ConnectionTracker
+class CubeTransitionEffect : public Control
{
-
public:
-
/**
* Destructor
*/
/**
* @copydoc Toolkit::CubeTransitionEffect::SetTransitionDuration
*/
- void SetTransitionDuration( float duration );
+ void SetTransitionDuration(float duration);
/**
* @copydoc Toolkit::CubeTransitionEffect::GetTransitionDuration
/**
* @copydoc Toolkit::CubeTransitionEffect::SetCubeDisplacement
*/
- void SetCubeDisplacement( float displacement );
+ void SetCubeDisplacement(float displacement);
/**
* @copydoc Toolkit::CubeTransitionEffect::GetCubeDisplacement
float GetCubeDisplacement() const;
/**
- * @copydoc Toolkit::CubeTransitionEffect::GetRoot
+ * @copydoc Toolkit::CubeTransitionEffect::IsTransitioning
*/
- Actor GetRoot();
+ bool IsTransitioning();
/**
- * @copydoc Toolkit::CubeTransitionEffect::IsTransiting
+ * @copydoc Toolkit::CubeTransitionEffect::SetCurrentTexture
*/
- bool IsTransiting();
+ void SetCurrentTexture(Texture texture);
/**
- * @copydoc Toolkit::CubeTransitionEffect::SetFirstImage
+ * @copydoc Toolkit::CubeTransitionEffect::SetTargetTexture
*/
- void SetCurrentImage(ImageActor imageActor);
-
- /**
- * @copydoc Toolkit::CubeTransitionEffect::SetTargetImage
- */
- void SetTargetImage(ImageActor imageActor);
+ void SetTargetTexture(Texture texture);
/**
* @copydoc Toolkit::CubeTransitionEffect::StartTransition(bool)
*/
- void StartTransition( bool toNextImage = true );
+ void StartTransition(bool toNextImage = true);
/**
* @copydoc Toolkit::CubeTransitionEffect::StartTransition(Vector2, Vector2)
*/
- void StartTransition( Vector2 panPosition, Vector2 panDisplacement );
+ void StartTransition(Vector2 panPosition, Vector2 panDisplacement);
/**
* @copydoc Toolkit::CubeTransitionEffect::PauseTransition()
void StopTransition();
public: //Signal
-
/**
* @copydoc Toolkit::CubeTransitionEffect::TransitionCompletedSignal()
*/
Toolkit::CubeTransitionEffect::TransitionCompletedSignalType& TransitionCompletedSignal();
+ /**
+ * Connects a callback function with the object's signals.
+ * @param[in] object The object providing the signal.
+ * @param[in] tracker Used to disconnect the signal.
+ * @param[in] signalName The signal to connect to.
+ * @param[in] functor A newly allocated FunctorDelegate.
+ * @return True if the signal was connected.
+ * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+ */
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
+
protected:
+ /**
+ * @copydoc CustomActorImpl::OnSceneConnection()
+ */
+ void OnSceneConnection(int depth) override;
+
+ /**
+ * @copydoc CustomActorImpl::OnSceneDisconnection()
+ */
+ void OnSceneDisconnection() override;
+protected:
/**
* Construct a new CubeTransitionEffect object
* Called in the constructor of subclasses
* @param[in] numRows How many rows of cubes
* @param[in] numColumns How many columns of cubes
- * @param[in] viewAreaSize The size of view area for this transition effect
*/
- CubeTransitionEffect( unsigned int numRows, unsigned int numColumns, Size viewAreaSize );
+ CubeTransitionEffect(unsigned int numRows, unsigned int numColumns);
/**
* Initialization steps: creating a layer, two groups of tiles,
*/
void Initialize();
-private:
-
- /**
- * Create an image actor to serve as a face of the cube
- * @param[in] image The image to display.
- * @param[in] color The color to set to the actor
- * @return The tile actor created
- */
- ImageActor CreateTile( Image image, const Vector4& color );
-
- /**
- * Set Image content to tiles
- * As only when the image ready, can we get correct image attributes
- * so inside this function, the process needs to be passed to callBack of image resource loading succeed.
- * @param[in] imageActor The imageActor whose image content will be set to the tiles
- */
- void SetImage(ImageActor imageActor);
-
- /**
- * Callback function of image resource loading succeed
- * Set image and pixelArea to tiles
- * @param[in] image The image content of the imageActor for transition
- */
- void OnImageLoaded(Image image);
+protected:
+ void SetTargetLeft(unsigned int idx);
+ void SetTargetRight(unsigned int idx);
+ void SetTargetTop(unsigned int idx);
+ void SetTargetBottom(unsigned int idx);
+private:
/**
* Callback function of transition animation finished
- * Hide transition layer, show current imageActor, and set isAnimating flag to false
+ * Hide transition layer, show current image, and set isAnimating flag to false
* @param[in] source The cube transition animation
*/
void OnTransitionFinished(Animation& source);
* This method is called after the CubeTransitionEffect has been initialized. Derived classes should do
* any second phase initialization by overriding this method.
*/
- virtual void OnInitialize() { }
+ virtual void OnInitialize()
+ {
+ }
/**
* This method is called after the a new transition is activated.
* @param[in] panPosition The press down position of panGesture
* @param[in] panDisplacement The displacement vector of panGesture
*/
- virtual void OnStartTransition( Vector2 panPosition, Vector2 panDisplacement ) {}
+ virtual void OnStartTransition(Vector2 panPosition, Vector2 panDisplacement)
+ {
+ }
/**
* This method is called when the transition is forced stop in the middle of animation.
* Derived classed should set the rotation status of the cubes to the same as the final state when the animation is finished completely.
* So that the next transition would be started correctly.
*/
- virtual void OnStopTransition() {}
+ virtual void OnStopTransition()
+ {
+ }
+ void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
+
+ void ResetToInitialState();
protected:
+ typedef std::vector<Actor> ActorArray;
+ enum FACE
+ {
+ TOP,
+ BOTTOM,
+ LEFT,
+ RIGHT
+ };
- unsigned int mNumRows;
- unsigned int mNumColumns;
- Size mViewAreaSize;
- ActorContainer mBoxes;
- std::vector< ImageActor > mTiles[2];
- int mRotateIndex;
- Size mTileSize;
- Actor mRoot;
+ ActorArray mBoxes;
+ Vector<FACE> mBoxType;
+ ActorArray mCurrentTiles;
+ ActorArray mTargetTiles;
- ImageActor mCurrentImage;
- unsigned int mContainerIndex; //have the value 0 or 1, refer to mTiles[0] or mTiles[1]
+ Actor mBoxRoot;
- bool mChangeTurningDirection;
- bool mIsToNextImage; //if true, cubes rotate counter-clockwise; else clockwise
- bool mIsImageLoading;
+ unsigned int mRows;
+ unsigned int mColumns;
- float mAnimationDuration;
- Animation mAnimation;
- bool mIsAnimating;
- bool mIsPaused;
+ Renderer mCurrentRenderer;
+ Renderer mTargetRenderer;
- float mCubeDisplacement;
+ Texture mCurrentTexture;
+ Texture mTargetTexture;
- bool mFirstTransition;
+ Animation mAnimation;
- RenderTask mOffScreenTask;
- FrameBufferImage mOffScreenBuffer[2];
- ImageActor mEmptyImage;
- FullAreaImageCreator mFullImageCreator;
- unsigned int mBufferIndex;
+ Vector2 mTileSize;
- static const Vector4 FULL_BRIGHTNESS;
- static const Vector4 HALF_BRIGHTNESS;
+ bool mIsAnimating;
+ bool mIsPaused;
-private:
+ float mAnimationDuration;
+ float mCubeDisplacement;
- Toolkit::CubeTransitionEffect::TransitionCompletedSignalType mTransitionCompletedSignal;
+ static const Vector4 FULL_BRIGHTNESS;
+ static const Vector4 HALF_BRIGHTNESS;
+private:
+ Toolkit::CubeTransitionEffect::TransitionCompletedSignalType mTransitionCompletedSignal;
};
} // namespace Internal
{
DALI_ASSERT_ALWAYS(obj);
- Dali::BaseObject& handle = obj.GetBaseObject();
+ Dali::RefObject& handle = obj.GetImplementation();
return static_cast<Internal::CubeTransitionEffect&>(handle);
}
{
DALI_ASSERT_ALWAYS(obj);
- const Dali::BaseObject& handle = obj.GetBaseObject();
+ const Dali::RefObject& handle = obj.GetImplementation();
return static_cast<const Internal::CubeTransitionEffect&>(handle);
}
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H__ */
+#endif // DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H