X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftransition-effects%2Fcube-transition-effect-impl.h;h=5eda6b2ba8369580fa1898b60e17b0546adcdfd1;hb=dd0c9395ff85899332844c0acfa604fce5011b6a;hp=3a69422729c9ff6782db0d6fb5774118198b6802;hpb=e2eda444afbe82e9591fe198eef339227f90a616;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.h b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.h index 3a69422..5eda6b2 100644 --- a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.h +++ b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.h @@ -1,27 +1,30 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H__ -#define __DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H__ - -// -// 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. -// +#ifndef DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H +#define DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H + +/* + * Copyright (c) 2016 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. + * + */ // EXTERNAL INCLUDES +#include +#include // INTERNAL INCLUDES -#include -#include +#include +#include namespace Dali { @@ -35,91 +38,9 @@ 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(){} - - /** - * virtual destructor - */ - virtual ~FullAreaImageCreator(){} - - /** - * Create an initialized FullAreaImageCreator. - * @return A handle to a newly allocated Dali resource. - */ - static FullAreaImageCreator New() - { - std::string vertexShader( - "uniform 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 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: @@ -150,24 +71,19 @@ public: 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) @@ -199,7 +115,29 @@ public: //Signal /** * @copydoc Toolkit::CubeTransitionEffect::TransitionCompletedSignal() */ - Toolkit::CubeTransitionEffect::TransitionCompletedSignalV2& 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::OnStageConnection() + */ + virtual void OnStageConnection( int depth ); + + /** + * @copydoc CustomActorImpl::OnStageDisconnection() + */ + virtual void OnStageDisconnection(); protected: @@ -208,9 +146,8 @@ protected: * 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, @@ -218,34 +155,18 @@ protected: */ 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); +protected: + void SetTargetLeft( unsigned int idx ); + void SetTargetRight( unsigned int idx ); + void SetTargetTop( unsigned int idx ); + void SetTargetBottom( unsigned int idx ); - /** - * 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); +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); @@ -271,46 +192,47 @@ private: */ virtual void OnStopTransition() {} + virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); + + 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; + + Renderer mCurrentRenderer; + Renderer mTargetRenderer; + + Texture mCurrentTexture; + Texture mTargetTexture; - float mAnimationDuration; Animation mAnimation; + + Vector2 mTileSize; + bool mIsAnimating; bool mIsPaused; + float mAnimationDuration; float mCubeDisplacement; - bool mFirstTransition; - - RenderTask mOffScreenTask; - FrameBufferImage mOffScreenBuffer[2]; - ImageActor mEmptyImage; - FullAreaImageCreator mFullImageCreator; - unsigned int mBufferIndex; - static const Vector4 FULL_BRIGHTNESS; static const Vector4 HALF_BRIGHTNESS; private: - Toolkit::CubeTransitionEffect::TransitionCompletedSignalV2 mTransitionCompletedSignalV2; + Toolkit::CubeTransitionEffect::TransitionCompletedSignalType mTransitionCompletedSignal; }; @@ -322,7 +244,7 @@ inline Internal::CubeTransitionEffect& GetImpl(Dali::Toolkit::CubeTransitionEffe { DALI_ASSERT_ALWAYS(obj); - Dali::BaseObject& handle = obj.GetBaseObject(); + Dali::RefObject& handle = obj.GetImplementation(); return static_cast(handle); } @@ -331,7 +253,7 @@ inline const Internal::CubeTransitionEffect& GetImpl(const Dali::Toolkit::CubeTr { DALI_ASSERT_ALWAYS(obj); - const Dali::BaseObject& handle = obj.GetBaseObject(); + const Dali::RefObject& handle = obj.GetImplementation(); return static_cast(handle); } @@ -340,4 +262,4 @@ inline const Internal::CubeTransitionEffect& GetImpl(const Dali::Toolkit::CubeTr } // namespace Dali -#endif /* __DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H__ */ +#endif // DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H