// EXTERNAL INCLUDES
#include <dali/public-api/object/base-object.h>
#include <dali/integration-api/debug.h>
-#include <dali/integration-api/events/key-event-integ.h>
namespace Dali
{
bool RestoreAfterFocusLost() const;
void SetRestoreAfterFocusLost( bool toggle );
void NotifyCursorPosition();
- int GetCursorPosition();
void SetCursorPosition( unsigned int cursorPosition );
- void SetSurroundingText( std::string text );
- std::string GetSurroundingText();
+ unsigned int GetCursorPosition() const;
+ void SetSurroundingText( const std::string& text );
+ const std::string& GetSurroundingText() const;
public: // Signals
ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
- std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
ImfManagerSignalType mActivatedSignal;
ImfEventSignalType mEventSignal;
ImfManager::ImfManager( /*Ecore_X_Window ecoreXwin*/ )
: mIMFCursorPosition( 0 ),
- mSurroundingText(""),
+ mSurroundingText(),
mRestoreAfterFocusLost( false ),
- mIdleCallbackConnected( false ),
- mKeyEvents()
+ mIdleCallbackConnected( false )
{
CreateContext( /*ecoreXwin*/ );
ConnectCallbacks();
{
}
-int ImfManager::GetCursorPosition()
+void ImfManager::SetCursorPosition( unsigned int cursorPosition )
{
- return mIMFCursorPosition;
+ mIMFCursorPosition = static_cast< int >( cursorPosition );
}
-void ImfManager::SetCursorPosition( unsigned int cursorPosition )
+unsigned int ImfManager::GetCursorPosition() const
{
- mIMFCursorPosition = ( int )cursorPosition;
+ return static_cast<unsigned int>( mIMFCursorPosition );
}
-void ImfManager::SetSurroundingText( std::string text )
+void ImfManager::SetSurroundingText( const std::string& text )
{
mSurroundingText = text;
}
-std::string ImfManager::GetSurroundingText()
+const std::string& ImfManager::GetSurroundingText() const
{
return mSurroundingText;
}
return Internal::Adaptor::ImfManager::Get();
}
-ImfContext ImfManager::GetContext()
-{
- return NULL;
-}
-
void ImfManager::Activate()
{
Internal::Adaptor::ImfManager::GetImplementation(*this).Activate();
Internal::Adaptor::ImfManager::GetImplementation(*this).SetCursorPosition( SetCursorPosition );
}
-int ImfManager::GetCursorPosition()
+unsigned int ImfManager::GetCursorPosition() const
{
return Internal::Adaptor::ImfManager::GetImplementation(*this).GetCursorPosition();
}
-void ImfManager::SetSurroundingText( std::string text )
+void ImfManager::SetSurroundingText( const std::string& text )
{
Internal::Adaptor::ImfManager::GetImplementation(*this).SetSurroundingText( text );
}
-std::string ImfManager::GetSurroundingText()
+const std::string& ImfManager::GetSurroundingText() const
{
return Internal::Adaptor::ImfManager::GetImplementation(*this).GetSurroundingText();
}
}
}
-typedef void* ImfContext;
-
/**
* @brief The ImfManager class
+ *
* Specifically manages the ecore input method framework which enables the virtual or hardware keyboards.
*/
class ImfManager : public BaseHandle
{
public:
+ /**
+ * @brief Events that are generated by the IMF.
+ */
enum ImfEvent
{
- VOID,
- PREEDIT,
- COMMIT,
- DELETESURROUNDING,
- GETSURROUNDING
+ VOID, ///< No event
+ PREEDIT, ///< Pre-Edit changed
+ COMMIT, ///< Commit recieved
+ DELETESURROUNDING, ///< Event to delete a range of characters from the string
+ GETSURROUNDING ///< Event to query string and cursor position
};
/**
- * This structure is used to pass on data from the IMF regarding predictive text.
+ * @brief This structure is used to pass on data from the IMF regarding predictive text.
*/
struct ImfEventData
{
/**
- * Default Constructor.
+ * @brief Default Constructor.
*/
ImfEventData()
- : eventName( VOID ),
- predictiveString(""),
+ : predictiveString(),
+ eventName( VOID ),
cursorOffset( 0 ),
numberOfChars ( 0 )
{
};
/**
- * Constructor
+ * @brief Constructor
+ *
* @param[in] aEventName The name of the event from the IMF.
* @param[in] aPredictiveString The pre-edit or commit string.
* @param[in] aCursorOffset Start position from the current cursor position to start deleting characters.
* @param[in] aNumberOfChars The number of characters to delete from the cursorOffset.
*/
- ImfEventData(ImfEvent aEventName, const std::string& aPredictiveString, int aCursorOffset,int aNumberOfChars )
- : eventName(aEventName), predictiveString(aPredictiveString), cursorOffset( aCursorOffset ), numberOfChars( aNumberOfChars )
+ ImfEventData( ImfEvent aEventName, const std::string& aPredictiveString, int aCursorOffset, int aNumberOfChars )
+ : predictiveString( aPredictiveString ),
+ eventName( aEventName ),
+ cursorOffset( aCursorOffset ),
+ numberOfChars( aNumberOfChars )
{
}
// Data
- ImfEvent eventName; // The name of the event from the IMF.
- std::string predictiveString; // The pre-edit or commit string.
- int cursorOffset; // Start position from the current cursor position to start deleting characters.
- int numberOfChars; //number of characters to delete from the cursorOffset.
+ std::string predictiveString; ///< The pre-edit or commit string.
+ ImfEvent eventName; ///< The name of the event from the IMF.
+ int cursorOffset; ///< Start position from the current cursor position to start deleting characters.
+ int numberOfChars; ///< number of characters to delete from the cursorOffset.
};
/**
- * Data required my IMF from the callback
+ * @brief Data required by IMF from the callback
*/
struct ImfCallbackData
{
- ImfCallbackData( )
- : update( false ), cursorPosition( 0 ), preeditResetRequired ( false )
+ /**
+ * @brief Constructor
+ */
+ ImfCallbackData()
+ : currentText(),
+ cursorPosition( 0 ),
+ update( false ),
+ preeditResetRequired( false )
{
}
- ImfCallbackData(bool aUpdate, int aCursorPosition, std::string aCurrentText, bool aPreeditResetRequired )
- : update(aUpdate), cursorPosition(aCursorPosition), currentText( aCurrentText ), preeditResetRequired( aPreeditResetRequired )
+ /**
+ * @brief Constructor
+ * @param[in] aUpdate True if cursor position needs to be updated
+ * @param[in] aCursorPosition new position of cursor
+ * @param[in] aCurrentText current text string
+ * @param[in] aPreeditResetRequired flag if preedit reset is required.
+ */
+ ImfCallbackData( bool aUpdate, int aCursorPosition, const std::string& aCurrentText, bool aPreeditResetRequired )
+ : currentText( aCurrentText ),
+ cursorPosition( aCursorPosition ),
+ update( aUpdate ),
+ preeditResetRequired( aPreeditResetRequired )
{
}
- bool update; // if cursor position needs to be updated
- int cursorPosition; // new position of cursor
- std::string currentText; // current text string
- bool preeditResetRequired; // flag if preedit reset is required.
+ std::string currentText; ///< current text string
+ int cursorPosition; ///< new position of cursor
+ bool update :1; ///< if cursor position needs to be updated
+ bool preeditResetRequired :1; ///< flag if preedit reset is required.
};
- typedef Signal< void (ImfManager&) > ImfManagerSignalType;
-
- typedef Signal< ImfCallbackData ( ImfManager&, const ImfEventData& ) > ImfEventSignalType;
+ typedef Signal< void (ImfManager&) > ImfManagerSignalType; ///< Keyboard actived signal
+ typedef Signal< ImfCallbackData ( ImfManager&, const ImfEventData& ) > ImfEventSignalType; ///< keyboard events
public:
/**
- * Retrieve a handle to the instance of ImfManager.
+ * @brief Retrieve a handle to the instance of ImfManager.
* @return A handle to the ImfManager.
*/
static ImfManager Get();
/**
- * Get the current imf context.
- * @return current imf context.
- */
- ImfContext GetContext();
-
- /**
- * Activate the IMF.
+ * @brief Activate the IMF.
+ *
* It means that the text editing is started at somewhere.
* If the H/W keyboard isn't connected then it will show the virtual keyboard.
*/
void Activate();
/**
- * Deactivate the IMF.
+ * @brief Deactivate the IMF.
+ *
* It means that the text editing is finished at somewhere.
*/
void Deactivate();
/**
- * Get the restoration status, which controls if the keyboard is restored after the focus lost then regained.
+ * @brief Get the restoration status, which controls if the keyboard is restored after the focus lost then regained.
+ *
* If true then keyboard will be restored (activated) after focus is regained.
* @return restoration status.
*/
bool RestoreAfterFocusLost() const;
/**
- * Set status whether the IMF has to restore the keyboard after losing focus.
+ * @brief Set status whether the IMF has to restore the keyboard after losing focus.
+ *
* @param[in] toggle True means that keyboard should be restored after focus lost and regained.
*/
void SetRestoreAfterFocusLost( bool toggle );
/**
- * Send message reset the pred-edit state / imf module. Used to interupt pre-edit state maybe due to a touch input.
+ * @brief Send message reset the pred-edit state / imf module.
+ *
+ * Used to interupt pre-edit state maybe due to a touch input.
*/
void Reset();
/**
- * Notifies IMF context that the cursor position has changed, required for features like auto-capitalisation
+ * @brief Notifies IMF context that the cursor position has changed, required for features like auto-capitalisation.
*/
void NotifyCursorPosition();
/**
- * Sets cursor position stored in VirtualKeyboard, this is required by the IMF context
+ * @brief Sets cursor position stored in VirtualKeyboard, this is required by the IMF context.
+ *
* @param[in] cursorPosition position of cursor
*/
void SetCursorPosition( unsigned int cursorPosition );
/**
- * Gets cursor position stored in VirtualKeyboard, this is required by the IMF context
+ * @brief Gets cursor position stored in VirtualKeyboard, this is required by the IMF context.
+ *
* @return current position of cursor
*/
- int GetCursorPosition();
+ unsigned int GetCursorPosition() const;
/**
- * Method to store the string required by the IMF, this is used to provide predictive word suggestions.
+ * @brief Method to store the string required by the IMF, this is used to provide predictive word suggestions.
+ *
* @param[in] text The text string surrounding the current cursor point.
*/
- void SetSurroundingText( std::string text );
+ void SetSurroundingText( const std::string& text );
/**
- * Gets current text string set within the IMF manager, this is used to offer predictive suggestions
+ * @brief Gets current text string set within the IMF manager, this is used to offer predictive suggestions.
+ *
* @return current position of cursor
*/
- std::string GetSurroundingText();
+ const std::string& GetSurroundingText() const;
public:
// Signals
/**
- * This is emitted when the virtual keyboard is connected to or the hardware keyboard is activated.
+ * @brief This is emitted when the virtual keyboard is connected to or the hardware keyboard is activated.
+ *
* @return The IMF Activated signal.
*/
ImfManagerSignalType& ActivatedSignal();
/**
- * This is emitted when the IMF manager receives an event from the IMF
+ * @brief This is emitted when the IMF manager receives an event from the IMF.
+ *
* @return The Event signal containing the event data.
*/
ImfEventSignalType& EventReceivedSignal();
// Construction & Destruction
/**
- * Constructor
+ * @brief Constructor.
*/
ImfManager();
/**
- * Non virtual destructor.
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
*/
~ImfManager();
/**
- * This constructor is used by ImfManager::Get().
+ * @brief This constructor is used by ImfManager::Get().
+ *
* @param[in] imfManager A pointer to the imf Manager.
*/
- ImfManager( Internal::Adaptor::ImfManager* imfManager );
+ explicit ImfManager( Internal::Adaptor::ImfManager* imfManager );
};
} // namespace Dali
#include <dali-toolkit/devel-api/transition-effects/cube-transition-cross-effect.h>
#include <dali-toolkit/devel-api/transition-effects/cube-transition-fold-effect.h>
#include <dali-toolkit/devel-api/transition-effects/cube-transition-wave-effect.h>
+#include <dali/public-api/images/buffer-image.h>
const Vector2 PAN_DISPLACEMENT1( -5.f, 5.f );
const Vector2 PAN_POSITION2( VIEW_AREA_SIZE.x * 0.25f, VIEW_AREA_SIZE.y * 0.75f );
const Vector2 PAN_DISPLACEMENT2( 5.f, 5.f );
+const Vector4 FULL_BRIGHTNESS(1.f,1.f,1.f,1.f);
+const Vector4 HALF_BRIGHTNESS(0.5f, 0.5f, 0.5f, 1.f);
const int RENDER_FRAME_INTERVAL = 16;
static const float FLT_EPISILON = 0.0001f;
-const float OFFSCREEN_RENDER_DURATION = 0.05f;
+static const float EPISILON = 0.05f;
+const float TRANSITION_BEFORE_END_DURATION = TRANSITION_DURATION - 0.05f;
static bool gObjectCreatedCallBackCalled;
static void TestCallback(BaseHandle handle)
class TransitionCompletedCallback : public Dali::ConnectionTracker
{
public:
- TransitionCompletedCallback( bool& signalReceived, CubeTransitionEffect& effect, ImageActor& imageActor )
+ TransitionCompletedCallback( bool& signalReceived, CubeTransitionEffect& effect, Image& image )
: mSignalVerified( signalReceived ),
mCurrentEffect( effect ),
- mActorTransitTo( imageActor )
+ mActorTransitTo( image )
{
}
- void Callback( CubeTransitionEffect effect, ImageActor imageActor )
+ void Callback( CubeTransitionEffect effect, Image image )
{
tet_infoline( "Verifying TransitionCompletedSignal" );
- if( mCurrentEffect == effect && mActorTransitTo == imageActor )
+ if( mCurrentEffect == effect && mActorTransitTo == image )
{
mSignalVerified = true;
}
bool& mSignalVerified;
CubeTransitionEffect& mCurrentEffect;
- ImageActor& mActorTransitTo;
+ Image& mActorTransitTo;
};
} // namespace
DALI_TEST_CHECK( !waveEffect );
- waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
+ waveEffect.SetSize( VIEW_AREA_SIZE );
DALI_TEST_CHECK( waveEffect );
gObjectCreatedCallBackCalled = false;
registry.ObjectCreatedSignal().Connect( &TestCallback );
{
- CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
+ waveEffect.SetSize( VIEW_AREA_SIZE );
}
DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
END_TEST;
DALI_TEST_CHECK( !crossEffect );
- crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
+ crossEffect.SetSize( VIEW_AREA_SIZE );
DALI_TEST_CHECK( crossEffect );
gObjectCreatedCallBackCalled = false;
registry.ObjectCreatedSignal().Connect( &TestCallback );
{
- CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
+ crossEffect.SetSize( VIEW_AREA_SIZE );
}
DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
END_TEST;
DALI_TEST_CHECK( !foldEffect );
- foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
+ foldEffect.SetSize( VIEW_AREA_SIZE );
DALI_TEST_CHECK( foldEffect );
gObjectCreatedCallBackCalled = false;
registry.ObjectCreatedSignal().Connect( &TestCallback );
{
- CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
+ foldEffect.SetSize( VIEW_AREA_SIZE );
}
DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
END_TEST;
ToolkitTestApplication application;
tet_infoline(" UtcDaliCubeTransitionEffectSetGetTransitionDuration ");
- CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
waveEffect.SetTransitionDuration( TRANSITION_DURATION );
+ waveEffect.SetSize( VIEW_AREA_SIZE );
DALI_TEST_EQUALS( TRANSITION_DURATION, waveEffect.GetTransitionDuration(), TEST_LOCATION );
- CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
crossEffect.SetTransitionDuration( TRANSITION_DURATION );
+ crossEffect.SetSize( VIEW_AREA_SIZE );
DALI_TEST_EQUALS( TRANSITION_DURATION, crossEffect.GetTransitionDuration(), TEST_LOCATION );
- CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
+ foldEffect.SetSize( VIEW_AREA_SIZE );
foldEffect.SetTransitionDuration( TRANSITION_DURATION );
DALI_TEST_EQUALS( TRANSITION_DURATION, foldEffect.GetTransitionDuration(), TEST_LOCATION );
END_TEST;
ToolkitTestApplication application;
tet_infoline(" UtcDaliCubeTransitionEffectSetGetTransitionDuration ");
- CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS);
+ waveEffect.SetSize( VIEW_AREA_SIZE );
waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
DALI_TEST_EQUALS( CUBE_DISPLACEMENT, waveEffect.GetCubeDisplacement(), TEST_LOCATION );
- CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
+ crossEffect.SetSize( VIEW_AREA_SIZE );
crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
DALI_TEST_EQUALS( CUBE_DISPLACEMENT, crossEffect.GetCubeDisplacement(), TEST_LOCATION );
unsigned int totalNum = NUM_ROWS*NUM_COLUMNS;
- CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
- Actor rootActor = waveEffect.GetRoot();
+ Image image = BufferImage::New( 40, 40 ) ;
+
+ CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
+ waveEffect.SetSize( VIEW_AREA_SIZE );
+ Stage::GetCurrent().Add( waveEffect );
+ waveEffect.SetCurrentImage( image );
+ waveEffect.SetTargetImage( image );
+
+ application.SendNotification();
+ application.Render();
+
+ waveEffect.StartTransition();
+
+ Wait( application, TRANSITION_DURATION * 0.5f );
// check that we have a total of NUM_ROWS*NUM_COLUMNS cubes;
- DALI_TEST_CHECK( totalNum == rootActor.GetChildCount() );
+ Actor boxesRoot = waveEffect.GetChildAt(0);
+ DALI_TEST_CHECK( totalNum == boxesRoot.GetChildCount() );
// check that every cube has two children
- DALI_TEST_CHECK( 2 == rootActor.GetChildAt(0).GetChildCount() );
- DALI_TEST_CHECK( 2 == rootActor.GetChildAt(totalNum/2).GetChildCount() );
- DALI_TEST_CHECK( 2 == rootActor.GetChildAt(totalNum-1).GetChildCount() );
+ DALI_TEST_CHECK( 2 == boxesRoot.GetChildAt(0).GetChildCount() );
+ DALI_TEST_CHECK( 2 == boxesRoot.GetChildAt(totalNum/2).GetChildCount() );
+ DALI_TEST_CHECK( 2 == boxesRoot.GetChildAt(totalNum-1).GetChildCount() );
END_TEST;
}
-int UtcDaliCubeTransitionEffectIsTransiting(void)
+int UtcDaliCubeTransitionEffectIsTransitioning(void)
{
ToolkitTestApplication application;
tet_infoline(" UtcDaliCubeTransitionEffectIsTransiting ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
+ Image image = BufferImage::New( 40, 40 ) ;
- CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
- Actor rootActor = waveEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
+ CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
+ waveEffect.SetSize( VIEW_AREA_SIZE );
+ Stage::GetCurrent().Add( waveEffect );
waveEffect.SetTransitionDuration( TRANSITION_DURATION );
waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
- DALI_TEST_CHECK( !waveEffect.IsTransiting() );
+ DALI_TEST_CHECK( !waveEffect.IsTransitioning() );
- waveEffect.SetCurrentImage(imageActor);
- waveEffect.SetTargetImage(imageActor);
+ waveEffect.SetCurrentImage( image );
+ waveEffect.SetTargetImage( image );
//transition is started
waveEffect.StartTransition();
- DALI_TEST_CHECK( waveEffect.IsTransiting() );
+ DALI_TEST_CHECK( waveEffect.IsTransitioning() );
//transition is finished
Wait( application, TRANSITION_DURATION );
- DALI_TEST_CHECK( !waveEffect.IsTransiting() );
+ DALI_TEST_CHECK( !waveEffect.IsTransitioning() );
+
+ CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
+ crossEffect.SetSize( VIEW_AREA_SIZE );
+ Stage::GetCurrent().Add( crossEffect );
- CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
crossEffect.SetTransitionDuration( TRANSITION_DURATION );
crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
- DALI_TEST_CHECK( !crossEffect.IsTransiting() );
+ DALI_TEST_CHECK( !crossEffect.IsTransitioning() );
- crossEffect.SetCurrentImage(imageActor);
- crossEffect.SetTargetImage(imageActor);
+ crossEffect.SetCurrentImage( image );
+ crossEffect.SetTargetImage( image );
//transition is started
crossEffect.StartTransition(false);
- DALI_TEST_CHECK( crossEffect.IsTransiting() );
+ DALI_TEST_CHECK( crossEffect.IsTransitioning() );
//transition is finished
Wait( application, TRANSITION_DURATION );
- DALI_TEST_CHECK( !crossEffect.IsTransiting() );
+ DALI_TEST_CHECK( !crossEffect.IsTransitioning() );
+
+ CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
+ foldEffect.SetSize( VIEW_AREA_SIZE );
+ Stage::GetCurrent().Add( foldEffect );
- CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
foldEffect.SetTransitionDuration( TRANSITION_DURATION );
- DALI_TEST_CHECK( !foldEffect.IsTransiting() );
+ DALI_TEST_CHECK( !foldEffect.IsTransitioning() );
- foldEffect.SetCurrentImage( imageActor );
- foldEffect.SetTargetImage( imageActor );
+ foldEffect.SetCurrentImage( image );
+ foldEffect.SetTargetImage( image );
//transition is started
foldEffect.StartTransition(true);
- DALI_TEST_CHECK(foldEffect.IsTransiting() );
+ DALI_TEST_CHECK(foldEffect.IsTransitioning() );
//transition is finished
Wait( application, TRANSITION_DURATION );
- DALI_TEST_CHECK( !foldEffect.IsTransiting() );
+ DALI_TEST_CHECK( !foldEffect.IsTransitioning() );
END_TEST;
}
tet_infoline(" UtcDaliCubeTransitionEffectSetCurrentImage ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,40,40) ;
+ Image image = BufferImage::New( 40, 40 ) ;
- CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
- waveEffect.SetCurrentImage( imageActor );
+ CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
+ waveEffect.SetSize( VIEW_AREA_SIZE );
+ waveEffect.SetCurrentImage( image );
+
+ Stage::GetCurrent().Add( waveEffect );
+
+ application.SendNotification();
+ application.Render();
+
+ waveEffect.StartTransition();
// the current image content is set to the tiles facing the camera
- ImageActor tile = ImageActor::DownCast( (waveEffect.GetRoot().GetChildAt(0).GetChildAt(0)));
+ Actor currentTile = waveEffect.GetChildAt(0).GetChildAt(0).GetChildAt(0);
+ Actor targetTile = waveEffect.GetChildAt(0).GetChildAt(0).GetChildAt(1);
//check the pixel area set to the cube
- ImageActor::PixelArea pixelAreaDef( 0, 0, VIEW_AREA_SIZE.x / NUM_COLUMNS, VIEW_AREA_SIZE.y / NUM_ROWS);
- ImageActor::PixelArea pixelArea = tile.GetPixelArea();
- DALI_TEST_CHECK ( pixelAreaDef == pixelArea );
-
- //check the size of the off screen rendered image
- Wait( application, OFFSCREEN_RENDER_DURATION );
- DALI_TEST_EQUALS( tile.GetImage().GetWidth(), VIEW_AREA_SIZE.x, TEST_LOCATION );
- DALI_TEST_EQUALS( tile.GetImage().GetHeight(), VIEW_AREA_SIZE.y, TEST_LOCATION );
+ Vector4 pixelAreaDef( 0.f, 0.f, 1.f / NUM_COLUMNS, 1.f / NUM_ROWS);
+
+ Property::Index textureRectIndex = currentTile.GetPropertyIndex( "uTextureRect" );
+ DALI_TEST_CHECK( textureRectIndex != Property::INVALID_INDEX );
+ Property::Value textureRectValue = currentTile.GetProperty( textureRectIndex );
+ DALI_TEST_CHECK( textureRectValue.GetType() == Property::VECTOR4 );
+ Vector4 pixelArea;
+ DALI_TEST_CHECK( textureRectValue.Get( pixelArea ) );
+
+ DALI_TEST_EQUALS( pixelAreaDef, pixelArea, FLT_EPISILON, TEST_LOCATION );
+
END_TEST;
}
tet_infoline(" UtcDaliCubeTransitionEffectSetTargetImage ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
+ Image image = BufferImage::New( 30, 30 );
+
+ CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
+ waveEffect.SetSize( VIEW_AREA_SIZE );
+ Stage::GetCurrent().Add( waveEffect );
+
+ waveEffect.SetCurrentImage( image );
+ waveEffect.SetTargetImage( image );
+
+ Stage::GetCurrent().Add( waveEffect );
- CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
- Actor rootActor = waveEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
+ application.SendNotification();
+ application.Render();
- waveEffect.SetCurrentImage( imageActor );
- waveEffect.SetTargetImage( imageActor );
+ waveEffect.StartTransition();
// the target image content is set to the tiles currently invisible to the camera
- ImageActor tile = ImageActor::DownCast( (rootActor.GetChildAt(0).GetChildAt(1)));
+ Actor tile = waveEffect.GetChildAt(0).GetChildAt(0).GetChildAt(1);
//check the pixel area set to the cube
- ImageActor::PixelArea pixelAreaDef( 0, 0, VIEW_AREA_SIZE.x / NUM_COLUMNS, VIEW_AREA_SIZE.y / NUM_ROWS);
- ImageActor::PixelArea pixelArea = tile.GetPixelArea();
- DALI_TEST_CHECK ( pixelAreaDef == pixelArea );
-
- //check the size of the off screen rendered image
- Wait( application, OFFSCREEN_RENDER_DURATION );
- DALI_TEST_EQUALS( tile.GetImage().GetWidth(), VIEW_AREA_SIZE.x, TEST_LOCATION );
- DALI_TEST_EQUALS( tile.GetImage().GetHeight(), VIEW_AREA_SIZE.y, TEST_LOCATION );
+ Vector4 pixelAreaDef( 0.f, 0.f, 1.f / NUM_COLUMNS, 1.f / NUM_ROWS);
+
+ Property::Index textureRectIndex = tile.GetPropertyIndex( "uTextureRect" );
+ DALI_TEST_CHECK( textureRectIndex != -1 );
+ Property::Value textureRectValue = tile.GetProperty( textureRectIndex );
+ DALI_TEST_CHECK( textureRectValue.GetType() == Property::VECTOR4 );
+ Vector4 pixelArea;
+ DALI_TEST_CHECK( textureRectValue.Get( pixelArea ) );
+
+ DALI_TEST_EQUALS( pixelAreaDef, pixelArea, FLT_EPISILON, TEST_LOCATION );
+
END_TEST;
}
tet_infoline(" UtcDaliCubeTransitionWaveEffectStartTransition ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- ImageActor imageActor = ImageActor::New(ResourceImage::New("Image.jpg"));
+ Image image = ResourceImage::New( "Image.jpg" );
- CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
+ waveEffect.SetSize( VIEW_AREA_SIZE );
waveEffect.SetTransitionDuration( TRANSITION_DURATION );
waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
- Actor rootActor = waveEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
- Actor cube = rootActor.GetChildAt(0);
+ waveEffect.SetCurrentImage( image );
- waveEffect.SetCurrentImage( imageActor );
+ Stage::GetCurrent().Add( waveEffect );
- Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
- Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
+ application.SendNotification();
+ application.Render();
- //check the cube rotation value and color values after different transitions
- waveEffect.SetTargetImage( imageActor );
- waveEffect.StartTransition(true);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
+ waveEffect.StartTransition( true );
+
+ Actor cube = waveEffect.GetChildAt(0).GetChildAt(0);
+
+ //check the cube rotation value and color values just before the end of different transitions
+ waveEffect.SetTargetImage( image );
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
- waveEffect.SetTargetImage( imageActor );
+ waveEffect.SetTargetImage( image );
waveEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_180, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
- waveEffect.SetTargetImage( imageActor );
+ waveEffect.SetTargetImage( image );
waveEffect.StartTransition(false);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
- waveEffect.SetTargetImage( imageActor );
+ waveEffect.SetTargetImage( image );
waveEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
END_TEST;
}
tet_infoline(" UtcDaliCubeTransitionCrossEffectStartTransition ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- ImageActor imageActor = ImageActor::New(ResourceImage::New("Image.jpg"));
+ Image image = ResourceImage::New( "Image.jpg" );
- CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
+ crossEffect.SetSize( VIEW_AREA_SIZE );
crossEffect.SetTransitionDuration( TRANSITION_DURATION );
crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
- Actor rootActor = crossEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
- crossEffect.SetCurrentImage( imageActor );
- Actor cube0 = rootActor.GetChildAt(0);
- Actor cube1 = rootActor.GetChildAt(1);
+ crossEffect.SetCurrentImage( image );
+ crossEffect.SetTargetImage( image );
- Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
- Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
+ Stage::GetCurrent().Add( crossEffect );
+
+ application.SendNotification();
+ application.Render();
- //check the cube rotation values and color values after different transitions
- crossEffect.SetTargetImage( imageActor );
crossEffect.StartTransition(true);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
+ Actor cube0 = crossEffect.GetChildAt(0).GetChildAt(0);
+ Actor cube1 = crossEffect.GetChildAt(0).GetChildAt(1);
+
+ //check the cube rotation value and color values just before the end of different transitions
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::XAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
- crossEffect.SetTargetImage( imageActor );
+
+ crossEffect.SetTargetImage( image );
crossEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_180, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_180, Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::XAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
- crossEffect.SetTargetImage( imageActor );
+ crossEffect.SetTargetImage( image );
crossEffect.StartTransition(false);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::XAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
- crossEffect.SetTargetImage( imageActor );
+ crossEffect.SetTargetImage( image );
crossEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::XAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
END_TEST;
}
tet_infoline(" UtcDaliCubeTransitionFoldEffectStartTransition ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
+ Image image = BufferImage::New( 30, 30 );
- CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
+ foldEffect.SetSize( VIEW_AREA_SIZE );
foldEffect.SetTransitionDuration( TRANSITION_DURATION );
- Actor rootActor = foldEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
- foldEffect.SetCurrentImage( imageActor );
- Actor cube0 = rootActor.GetChildAt(0);
- Actor cube1 = rootActor.GetChildAt(1);
+ foldEffect.SetCurrentImage( image );
+ foldEffect.SetTargetImage( image );
+
+ Stage::GetCurrent().Add( foldEffect );
- Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
- Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
+ application.SendNotification();
+ application.Render();
- //check the cube rotation values and color values after different transitions
- foldEffect.SetTargetImage( imageActor );
foldEffect.StartTransition(true);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- foldEffect.SetTargetImage( imageActor );
+ Actor cube0 = foldEffect.GetChildAt(0).GetChildAt(0);
+ Actor cube1 = foldEffect.GetChildAt(0).GetChildAt(1);
+
+ //check the cube rotation value and color values just before the end of different transitions
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
+
+ foldEffect.SetTargetImage( image );
foldEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_180, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_180, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
- foldEffect.SetTargetImage( imageActor );
+ foldEffect.SetTargetImage( image );
foldEffect.StartTransition(false);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(),fullBrightness, FLT_EPISILON, TEST_LOCATION );
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(),FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
- foldEffect.SetTargetImage( imageActor );
+ foldEffect.SetTargetImage( image );
foldEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
- Wait( application, TRANSITION_DURATION );
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ Wait( application, TRANSITION_BEFORE_END_DURATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
END_TEST;
}
tet_infoline(" UtcDaliCubeTransitionEffectSignalTransitionCompleted ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
- ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
- ImageActor thirdImageActor = CreateSolidColorImageActor(application, Color::BLUE,40,40);
+ Image firstImage = BufferImage::New( 30, 30 );
+ Image secondImage = BufferImage::New( 20, 20 );
+ Image thirdImage = BufferImage::New( 40, 40 );
- CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
+ waveEffect.SetSize( VIEW_AREA_SIZE );
waveEffect.SetTransitionDuration( TRANSITION_DURATION );
waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
- Actor rootActor = waveEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
+ Stage::GetCurrent().Add( waveEffect );
- CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
+ crossEffect.SetSize( VIEW_AREA_SIZE );
crossEffect.SetTransitionDuration( TRANSITION_DURATION );
crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
- rootActor = crossEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
+ Stage::GetCurrent().Add( crossEffect );
- CubeTransitionEffect foldEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect foldEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
+ foldEffect.SetSize( VIEW_AREA_SIZE );
foldEffect.SetTransitionDuration( TRANSITION_DURATION );
- rootActor = foldEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
+ Stage::GetCurrent().Add( foldEffect );
bool signalVerified = false;
CubeTransitionEffect currentEffect;
- ImageActor actorTransitTo;
+ Image actorTransitTo;
TransitionCompletedCallback callback(signalVerified, currentEffect, actorTransitTo);
waveEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
crossEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
foldEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
- //check that the wave effect is used to transit to secondImageActor
+ //check that the wave effect is used to transit to secondImage
currentEffect = waveEffect;
- actorTransitTo = secondImageActor;
- waveEffect.SetCurrentImage( firstImageActor );
- waveEffect.SetTargetImage( secondImageActor );
+ actorTransitTo = secondImage;
+ waveEffect.SetCurrentImage( firstImage );
+ waveEffect.SetTargetImage( secondImage );
waveEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
Wait( application, TRANSITION_DURATION );
DALI_TEST_CHECK(callback.mSignalVerified);
callback.Reset();
- //check that the wave effect is used to transit to thirdImageActor
- actorTransitTo = thirdImageActor;
- waveEffect.SetTargetImage( thirdImageActor );
+ //check that the wave effect is used to transit to thirdImage
+ actorTransitTo = thirdImage;
+ waveEffect.SetTargetImage( thirdImage );
waveEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
Wait( application, TRANSITION_DURATION );
DALI_TEST_CHECK(callback.mSignalVerified);
callback.Reset();
- //check that the cross effect is used to transit to secondImageActor
+ //check that the cross effect is used to transit to secondImage
currentEffect = crossEffect;
- actorTransitTo = secondImageActor;
- crossEffect.SetCurrentImage( thirdImageActor );
- crossEffect.SetTargetImage( secondImageActor );
+ actorTransitTo = secondImage;
+ crossEffect.SetCurrentImage( thirdImage );
+ crossEffect.SetTargetImage( secondImage );
crossEffect.StartTransition(true);
Wait( application, TRANSITION_DURATION );
DALI_TEST_CHECK(callback.mSignalVerified);
callback.Reset();
- //check that the cross effect is used to transit to firstImageActor
- actorTransitTo = firstImageActor;
- crossEffect.SetTargetImage( firstImageActor );
+ //check that the cross effect is used to transit to firstImage
+ actorTransitTo = firstImage;
+ crossEffect.SetTargetImage( firstImage );
crossEffect.StartTransition(false);
Wait( application, TRANSITION_DURATION );
DALI_TEST_CHECK(callback.mSignalVerified);
callback.Reset();
- //check that the fold effect is used to transit to secondImageActor
+ //check that the fold effect is used to transit to secondImage
currentEffect = foldEffect;
- actorTransitTo = secondImageActor;
- foldEffect.SetCurrentImage( firstImageActor );
- foldEffect.SetTargetImage( secondImageActor );
+ actorTransitTo = secondImage;
+ foldEffect.SetCurrentImage( firstImage );
+ foldEffect.SetTargetImage( secondImage );
foldEffect.StartTransition();
Wait( application, TRANSITION_DURATION );
DALI_TEST_CHECK( callback.mSignalVerified );
callback.Reset();
- //check that the fold effect is used to transit to thirdImageActor
- actorTransitTo = thirdImageActor;
- foldEffect.SetTargetImage( thirdImageActor );
+ //check that the fold effect is used to transit to thirdImage
+ actorTransitTo = thirdImage;
+ foldEffect.SetTargetImage( thirdImage );
foldEffect.StartTransition( false );
Wait( application, TRANSITION_DURATION );
DALI_TEST_CHECK( callback.mSignalVerified );
tet_infoline(" UtcDaliCubeTransitionEffectPauseResumeTransition ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
- ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
+ Image firstImage = BufferImage::New( 30, 30 );
+ Image secondImage = BufferImage::New( 20, 20 );
- CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
+ waveEffect.SetSize( VIEW_AREA_SIZE );
waveEffect.SetTransitionDuration( TRANSITION_DURATION );
waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
- Actor rootActor = waveEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
+ Stage::GetCurrent().Add( waveEffect );
- CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
+ crossEffect.SetSize( VIEW_AREA_SIZE );
crossEffect.SetTransitionDuration( TRANSITION_DURATION );
crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
- rootActor = crossEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
+ Stage::GetCurrent().Add( crossEffect );
- CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
+ foldEffect.SetSize( VIEW_AREA_SIZE );
foldEffect.SetTransitionDuration( TRANSITION_DURATION );
- rootActor = crossEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
+ Stage::GetCurrent().Add( foldEffect );
bool signalVerified = false;
CubeTransitionEffect currentEffect;
- ImageActor actorTransitTo;
+ Image actorTransitTo;
TransitionCompletedCallback callback(signalVerified, currentEffect, actorTransitTo);
waveEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
crossEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
foldEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
currentEffect = waveEffect;
- actorTransitTo = secondImageActor;
- waveEffect.SetCurrentImage( firstImageActor );
- waveEffect.SetTargetImage( secondImageActor );
+ actorTransitTo = secondImage;
+ waveEffect.SetCurrentImage( firstImage );
+ waveEffect.SetTargetImage( secondImage );
// start transition; transit for 0.5*duration; pause for 0.5*duration;
// resume for 0.25*duration; pause for 0.25*duration; resume for another 0.25*duration;
// only until now the transition finished signal can be received
callback.Reset();
currentEffect = crossEffect;
- actorTransitTo = firstImageActor;
- crossEffect.SetCurrentImage( secondImageActor );
- crossEffect.SetTargetImage( firstImageActor );
+ actorTransitTo = firstImage;
+ crossEffect.SetCurrentImage( secondImage );
+ crossEffect.SetTargetImage( firstImage );
// start transition; transit for 0.25*duration; pause for 0.2*duration;
// resume for 0.5*duration; pause for 0.2*duration; resume for another 0.25*duration;
// only until now the transition finished signal can be received
callback.Reset();
currentEffect = foldEffect;
- actorTransitTo = secondImageActor;
- foldEffect.SetCurrentImage( firstImageActor );
- foldEffect.SetTargetImage( secondImageActor );
+ actorTransitTo = secondImage;
+ foldEffect.SetCurrentImage( firstImage );
+ foldEffect.SetTargetImage( secondImage );
// start transition; transit for 0.5*duration; pause for 0.5*duration;
// resume for 0.25*duration; pause for 0.25*duration; resume for another 0.25*duration;
// only until now the transition finished signal can be received
tet_infoline(" UtcDaliCubeTransitionWaveEffectStopTransition ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
- ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
+ Image firstImage = BufferImage::New( 30, 30 );
+ Image secondImage = BufferImage::New( 20, 20 );
- CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
+ waveEffect.SetSize( VIEW_AREA_SIZE );
waveEffect.SetTransitionDuration( TRANSITION_DURATION );
waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
- Actor rootActor = waveEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
- Actor cube = rootActor.GetChildAt(0);
- waveEffect.SetCurrentImage( firstImageActor );
+ waveEffect.SetCurrentImage( firstImage );
+ waveEffect.SetTargetImage( secondImage );
- Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
- Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
+ Stage::GetCurrent().Add( waveEffect );
+
+ application.SendNotification();
+ application.Render();
- //check the cube rotation value and color values after stopping different transitions in the middle
- waveEffect.SetTargetImage( secondImageActor );
waveEffect.StartTransition(true);
+
+ Actor cube = waveEffect.GetChildAt(0).GetChildAt(0);
+
+ //check the cube rotation value and color values reset after stopping different transitions in the middle
Wait( application, TRANSITION_DURATION*0.2f );
waveEffect.StopTransition();
application.SendNotification();
application.Render(RENDER_FRAME_INTERVAL);
- DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZERO), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
- waveEffect.SetTargetImage( firstImageActor );
+ waveEffect.SetTargetImage( firstImage );
waveEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
Wait( application, TRANSITION_DURATION*0.4f );
waveEffect.StopTransition();
application.SendNotification();
application.Render(RENDER_FRAME_INTERVAL);
- DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_180, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZERO), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
- waveEffect.SetTargetImage( secondImageActor );
+ waveEffect.SetTargetImage( secondImage );
waveEffect.StartTransition(false);
Wait( application, TRANSITION_DURATION*0.6f );
waveEffect.StopTransition();
application.SendNotification();
application.Render(RENDER_FRAME_INTERVAL);
- DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZERO), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
- waveEffect.SetTargetImage( firstImageActor );
+ waveEffect.SetTargetImage( firstImage );
waveEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
Wait( application, TRANSITION_DURATION*0.8f );
waveEffect.StopTransition();
application.SendNotification();
application.Render(RENDER_FRAME_INTERVAL);
- DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZERO), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
END_TEST;
}
tet_infoline(" UtcDaliCubeTransitionCrossEffectStopTransition ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
- ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
+ Image firstImage = BufferImage::New( 30, 30 );
+ Image secondImage = BufferImage::New( 20, 20 );
- CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
+ crossEffect.SetSize( VIEW_AREA_SIZE );
crossEffect.SetTransitionDuration( TRANSITION_DURATION );
crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
- Actor rootActor = crossEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
- crossEffect.SetCurrentImage( firstImageActor );
- Actor cube0 = rootActor.GetChildAt(0);
- Actor cube1 = rootActor.GetChildAt(1);
+ crossEffect.SetCurrentImage( firstImage );
+ crossEffect.SetTargetImage( secondImage );
- Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
- Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
+ Stage::GetCurrent().Add( crossEffect );
+
+ application.SendNotification();
+ application.Render();
- //check the cube rotation values and color values after stop the different transitions in the middle
- crossEffect.SetTargetImage( secondImageActor );
crossEffect.StartTransition(true);
+
+ Actor cube0 = crossEffect.GetChildAt(0).GetChildAt(0);
+ Actor cube1 = crossEffect.GetChildAt(0).GetChildAt(1);
+
+ //check the cube rotation values and color values reset after stop the different transitions in the middle
Wait( application, TRANSITION_DURATION*0.2f );
crossEffect.StopTransition();
application.SendNotification();
application.Render(RENDER_FRAME_INTERVAL);
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION );
-
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZERO), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZERO), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
- crossEffect.SetTargetImage( firstImageActor );
+ crossEffect.SetTargetImage( firstImage );
crossEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
Wait( application, TRANSITION_DURATION*0.4f );
crossEffect.StopTransition();
application.SendNotification();
application.Render(RENDER_FRAME_INTERVAL);
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_180, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_180, Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZERO), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZERO), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
- crossEffect.SetTargetImage( secondImageActor );
+ crossEffect.SetTargetImage( secondImage );
crossEffect.StartTransition(false);
Wait( application, TRANSITION_DURATION*0.6f );
crossEffect.StopTransition();
application.SendNotification();
application.Render(RENDER_FRAME_INTERVAL);
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZERO), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::ZERO), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
- crossEffect.SetTargetImage( firstImageActor );
+ crossEffect.SetTargetImage( firstImage );
crossEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
Wait( application, TRANSITION_DURATION*0.8f );
crossEffect.StopTransition();
application.Render(RENDER_FRAME_INTERVAL);
DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
END_TEST;
}
tet_infoline(" UtcDaliCubeTransitionFoldEffectStopTransition ");
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
- ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
+ Image firstImage = BufferImage::New( 30, 30 );
+ Image secondImage = BufferImage::New( 20, 20 );
- CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
+ CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
+ foldEffect.SetSize( VIEW_AREA_SIZE );
foldEffect.SetTransitionDuration( TRANSITION_DURATION );
- Actor rootActor = foldEffect.GetRoot();
- Stage::GetCurrent().Add( rootActor );
- foldEffect.SetCurrentImage( firstImageActor );
- Actor cube0 = rootActor.GetChildAt(0);
- Actor cube1 = rootActor.GetChildAt(1);
+ foldEffect.SetCurrentImage( firstImage );
+ foldEffect.SetTargetImage( secondImage );
- Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
- Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
+ Stage::GetCurrent().Add( foldEffect );
+
+ application.SendNotification();
+ application.Render();
- //check the cube rotation values and color values after stop the different transitions in the middle
- foldEffect.SetTargetImage( secondImageActor );
foldEffect.StartTransition(true);
+
+ Actor cube0 = foldEffect.GetChildAt(0).GetChildAt(0);
+ Actor cube1 = foldEffect.GetChildAt(0).GetChildAt(1);
+
+ //check the cube rotation values and color values after stop the different transitions in the middle
Wait( application, TRANSITION_DURATION*0.2f );
foldEffect.StopTransition();
application.SendNotification();
application.Render(RENDER_FRAME_INTERVAL);
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- foldEffect.SetTargetImage( firstImageActor );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+
+ foldEffect.SetTargetImage( firstImage );
foldEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
Wait( application, TRANSITION_DURATION*0.4f );
foldEffect.StopTransition();
application.SendNotification();
application.Render(RENDER_FRAME_INTERVAL);
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_180, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_180, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
- foldEffect.SetTargetImage( secondImageActor );
+ foldEffect.SetTargetImage( secondImage );
foldEffect.StartTransition(false);
Wait( application, TRANSITION_DURATION*0.6f );
foldEffect.StopTransition();
application.SendNotification();
application.Render(RENDER_FRAME_INTERVAL);
- DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( -Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_90, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
- foldEffect.SetTargetImage( firstImageActor );
+ foldEffect.SetTargetImage( firstImage );
foldEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
Wait( application, TRANSITION_DURATION*0.8f );
foldEffect.StopTransition();
application.Render(RENDER_FRAME_INTERVAL);
DALI_TEST_EQUALS( cube1.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
DALI_TEST_EQUALS( cube0.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), fullBrightness, FLT_EPISILON, TEST_LOCATION );
- DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), halfBrightness, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentColor(), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentColor(), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
END_TEST;
}
{
ToolkitTestApplication application;
- unsigned int sampleCount(4);
- ShaderEffect effect = Toolkit::CreateMotionBlurEffect(sampleCount);
- DALI_TEST_CHECK( effect );
+ Property::Map effect = Toolkit::CreateMotionBlurEffect();
+ DALI_TEST_CHECK( !effect.Empty() );
+
+ Property::Value* customShaderValue = effect.Find( "shader" );
+ DALI_TEST_CHECK( customShaderValue );
+
+ Property::Map customShader;
+ DALI_TEST_CHECK( customShaderValue->Get( customShader ) );
- Property::Value value = effect.GetProperty( effect.GetPropertyIndex("uNumSamples"));
- DALI_TEST_EQUALS( value.Get<float>(), (float)sampleCount, TEST_LOCATION );
+ Property::Value* vertexShaderValue = customShader.Find( "vertex-shader" );
+ DALI_TEST_CHECK( vertexShaderValue );
+
+ std::string vertexShader;
+ DALI_TEST_CHECK( vertexShaderValue->Get( vertexShader ) );
+ DALI_TEST_CHECK( !vertexShader.empty() );
+
+ Property::Value* fragmentShaderValue = customShader.Find( "fragment-shader" );
+ DALI_TEST_CHECK( fragmentShaderValue );
+
+ std::string fragmentShader;
+ DALI_TEST_CHECK( fragmentShaderValue->Get( fragmentShader ) );
+ DALI_TEST_CHECK( !fragmentShader.empty() );
+
+ Property::Value* gridXValue = customShader.Find( "subdivide-grid-x" );
+ DALI_TEST_CHECK( gridXValue );
+
+ int gridX = 0;
+ DALI_TEST_CHECK( gridXValue->Get( gridX ) );
+ DALI_TEST_CHECK( gridX > 1 );
+
+ Property::Value* gridYValue = customShader.Find( "subdivide-grid-y" );
+ DALI_TEST_CHECK( gridYValue );
+
+ int gridY = 0;
+ DALI_TEST_CHECK( gridYValue->Get( gridY ) );
+ DALI_TEST_CHECK( gridY > 1 );
+
+ Property::Value* hintsValue = customShader.Find( "hints" );
+ DALI_TEST_CHECK( hintsValue );
+
+ std::string hints;
+ DALI_TEST_CHECK( hintsValue->Get( hints ) );
+ DALI_TEST_CHECK( hints == "output-is-transparent" );
+
+ unsigned int sampleCount( 4 );
+ Actor actor = Actor::New();
+ Toolkit::SetMotionBlurProperties( actor, sampleCount );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uBlurTexCoordScale" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uGeometryStretchFactor" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uSpeedScalingFactor" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uObjectFadeStart" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uObjectFadeEnd" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uAlphaScale" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uNumSamples" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uModelLastFrame" ) != Property::INVALID_INDEX );
END_TEST;
}
{
ToolkitTestApplication application;
- ShaderEffect effect = Toolkit::CreateMotionStretchEffect();
- DALI_TEST_CHECK( effect );
+ Property::Map effect = Toolkit::CreateMotionStretchEffect();
+ DALI_TEST_CHECK( !effect.Empty() );
+
+ Property::Value* customShaderValue = effect.Find( "shader" );
+ DALI_TEST_CHECK( customShaderValue );
+
+ Property::Map customShader;
+ DALI_TEST_CHECK( customShaderValue->Get( customShader ) );
+
+ Property::Value* vertexShaderValue = customShader.Find( "vertex-shader" );
+ DALI_TEST_CHECK( vertexShaderValue );
+
+ std::string vertexShader;
+ DALI_TEST_CHECK( vertexShaderValue->Get( vertexShader ) );
+ DALI_TEST_CHECK( !vertexShader.empty() );
+
+ Property::Value* fragmentShaderValue = customShader.Find( "fragment-shader" );
+ DALI_TEST_CHECK( fragmentShaderValue );
+
+ std::string fragmentShader;
+ DALI_TEST_CHECK( fragmentShaderValue->Get( fragmentShader ) );
+ DALI_TEST_CHECK( !fragmentShader.empty() );
+
+ Property::Value* gridXValue = customShader.Find( "subdivide-grid-x" );
+ DALI_TEST_CHECK( gridXValue );
+
+ int gridX = 0;
+ DALI_TEST_CHECK( gridXValue->Get( gridX ) );
+ DALI_TEST_CHECK( gridX > 1 );
+
+ Property::Value* gridYValue = customShader.Find( "subdivide-grid-y" );
+ DALI_TEST_CHECK( gridYValue );
+
+ int gridY = 0;
+ DALI_TEST_CHECK( gridYValue->Get( gridY ) );
+ DALI_TEST_CHECK( gridY > 1 );
+
+ Property::Value* hintsValue = customShader.Find( "hints" );
+ DALI_TEST_CHECK( hintsValue );
+
+ std::string hints;
+ DALI_TEST_CHECK( hintsValue->Get( hints ) );
+ DALI_TEST_CHECK( hints == "output-is-transparent" );
+
+ Actor actor = Actor::New();
+ Toolkit::SetMotionStretchProperties( actor );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uGeometryStretchFactor" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uSpeedScalingFactor" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uObjectFadeStart" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uObjectFadeEnd" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uAlphaScale" ) != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( actor.GetPropertyIndex( "uModelLastFrame" ) != Property::INVALID_INDEX );
END_TEST;
}
GetImpl(*this).Remove(child);
}
-void ShadowView::SetShadowPlane(ImageActor shadowPlane)
+void ShadowView::SetShadowPlaneBackground(Actor shadowPlaneBackground)
{
- GetImpl(*this).SetShadowPlane(shadowPlane);
+ GetImpl(*this).SetShadowPlaneBackground(shadowPlaneBackground);
}
void ShadowView::SetPointLight(Actor pointLight)
void Remove(Actor child);
/**
- * Set the Shadow Plane for the shadow effect.
+ * Set the Shadow Plane Background for the shadow effect.
*
- * @param[in] shadowPlane An actor representing the shadow
+ * @param[in] shadowPlaneBackground An actor representing the shadow
* plane. The position of the actor represents the origin of the
* plane, and the orientation of the actor represents the direction
* of the plane normal. Make the plane sufficiently large if the shadows are
* clipped.
*/
- void SetShadowPlane(ImageActor shadowPlane);
+ void SetShadowPlaneBackground(Actor shadowPlaneBackground);
/**
* Set the Point Light for the shadow effect. This is usually NOT a renderable actor.
{
MAX_SIZE = PROPERTY_START_INDEX, ///< name "max-size", The maximum size the Popup can be, type VECTOR2
ENABLE_OVERSHOOT, ///< name "enable-overshoot", Whether the overshoot image is enabled, type BOOLEAN
+ SCROLL_VIEW, ///< name "scroll-view", Properties to set on scroll view type Property::Map
};
};
{
/**
+ * @brief Set the properties for the motion blur
+ *
+ * @param numBlurSamples Number of samples used by the shader
+ */
+inline void SetMotionBlurProperties( Actor& actor, unsigned int numBlurSamples = 8 )
+{
+ actor.RegisterProperty( "uBlurTexCoordScale", 0.125f );
+ actor.RegisterProperty( "uGeometryStretchFactor", 0.05f );
+ actor.RegisterProperty( "uSpeedScalingFactor", 0.5f );
+ actor.RegisterProperty( "uObjectFadeStart", Vector2( 0.25f, 0.25f ) );
+ actor.RegisterProperty( "uObjectFadeEnd", Vector2( 0.5f, 0.5f ) );
+ actor.RegisterProperty( "uAlphaScale", 0.75f );
+ actor.RegisterProperty( "uNumSamples", static_cast<float>( numBlurSamples ) );
+ actor.RegisterProperty( "uRecipNumSamples", 1.0f / static_cast<float>( numBlurSamples ) );
+ actor.RegisterProperty( "uRecipNumSamplesMinusOne", 1.0f / static_cast<float>( numBlurSamples - 1.0f ) );
+ Property::Index uModelProperty = actor.RegisterProperty( "uModelLastFrame", Matrix::IDENTITY );
+
+ Constraint constraint = Constraint::New<Matrix>( actor, uModelProperty, EqualToConstraint() );
+ constraint.AddSource( Source( actor , Actor::Property::WORLD_MATRIX ) );
+ constraint.Apply();
+}
+
+/**
* @brief Create a new MotionBlurEffect
*
* Motion blur shader works on a per object basis. Objects will
- * blur when they move, or if the camera moves. Can be applied to ImageActor or
- * TextActor only.
- *
- * Usage example:-
- *
- * // Create shader used for doing motion blur\n
- * ShaderEffect MotionBlurEffect = CreateMotionBlurEffect();
- *
- * // set actor shader to the blur one\n
- * Actor actor = Actor::New( ... );\n
- * actor.SetShaderEffect( MotionBlurEffect );
- *
- * // Constrain "uModelLastFrame" to be the same as the actor's world matrix\n
- * Dali::Property::Index uModelProperty = MotionBlurEffect.GetPropertyIndex( "uModelLastFrame" );
- * Constraint constraint = Constraint::New<Matrix>( MotionBlurEffect, uModelProperty, EqualToConstraint() );\n
- * constraint.AddSource( Source( actor , Actor::Property::WORLD_MATRIX ) );\n
- * constraint.Apply();\n
- *
+ * blur when they move, or if the camera moves.
*
* Animatable/Constrainable uniforms:
* "uBlurTexCoordScale" - This scales the offset for texture samples along the motion velocity vector.
* at the cost of performance.
* "uModelLastFrame" - The model to world space transformation matrix of the actor in the previous frame.
*
- * @param numBlurSamples Number of samples used by the shader
- * @return A handle to a newly allocated ShaderEffect
+ * @return The newly created Property::Map with the motion blur effect
*/
-inline ShaderEffect CreateMotionBlurEffect( unsigned int numBlurSamples = 8 )
+inline Property::Map CreateMotionBlurEffect()
{
- // Dali vertexSource prefix for reference:
- // precision highp float;
- // attribute vec3 aPosition;
- // attribute vec2 aTexCoord;
- // uniform mat4 uMvpMatrix;
- // uniform mat4 uModelView;
- // uniform mat3 uNormalMatrix;
- // uniform mat4 uProjection;
- // uniform vec4 uColor;
- // varying vec2 vTexCoord;
std::string vertexSource;
vertexSource =
"precision mediump float;\n"
+
+ "attribute vec2 aPosition;\n"
+
+ "uniform mat4 uMvpMatrix;\n"
+ "uniform mat4 uModelView;\n"
+ "uniform mat4 uViewMatrix;\n"
+ "uniform mat4 uProjection;\n"
+ "uniform vec3 uSize;\n"
+
"uniform mat4 uModelLastFrame;\n"
"float timeDelta = 0.0167;\n"
"varying vec2 vModelSpaceCenterToPos;\n"
"varying vec2 vScreenSpaceVelocityVector;\n"
"varying float vSpeed;\n"
+ "varying vec2 vTexCoord;\n"
"void main()\n"
"{\n"
// get view space position of vertex this frame and last frame
- " vec4 vertex = vec4(aPosition, 1.0);\n"
- " vec4 viewSpaceVertex = uModelView * vertex;\n"
- " vec4 viewSpaceVertexLastFrame = (uViewMatrix * uModelLastFrame) * vertex;\n"
+ " vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n"
+ " vertexPosition.xyz *= uSize;\n"
+
+ " vec4 viewSpaceVertex = uModelView * vertexPosition;\n"
+ " vec4 viewSpaceVertexLastFrame = (uViewMatrix * uModelLastFrame) * vertexPosition;\n"
" float reciprocalTimeDelta = 1.0 / timeDelta;\n"
// work out vertex's last movement in view space
" vec3 viewSpacePosDelta = viewSpaceVertex.xyz - viewSpaceVertexLastFrame.xyz;\n"
// get clip space position of vertex this frame and last frame
- " vec4 clipSpaceVertex = uMvpMatrix * vertex;\n"
+ " vec4 clipSpaceVertex = uMvpMatrix * vertexPosition;\n"
" vec4 clipSpaceVertexLastFrame = uProjection * viewSpaceVertexLastFrame;\n"
// decide how much this vertex is 'trailing', i.e. at the back of the object relative to its direction of motion. We do this
" float posDeltaLength = length(viewSpacePosDelta);\n"
" if(posDeltaLength > 0.001)\n" // avoid div by 0 if object has barely moved
" {\n"
- " vec4 viewSpaceCenterToPos = uModelView * vec4(aPosition, 0.0);\n"
+ " vec4 viewSpaceCenterToPos = uModelView * vec4(vertexPosition.xy, 0.0, 0.0);\n"
" float centerToVertexDist = length(viewSpaceCenterToPos);\n"
" if(centerToVertexDist > 0.001)\n" // avoid div by 0 if object has vertex at model space origin
" {\n"
" vSpeed = clamp(vSpeed, 0.0, 1.0);\n"
// provide fragment shader with vector from center of object to pixel (assumes the objects model space origin is at its center and verts have same z)
- " vModelSpaceCenterToPos = aPosition.xy;\n"
+ " vModelSpaceCenterToPos = viewSpaceVertex.xy;\n"
- " vTexCoord = aTexCoord;\n"
+ " vec2 texCoord = aPosition + vec2(0.5);"
+ " vTexCoord = texCoord;\n"
"}\n";
- // Dali fragmentSource prefix for reference:
- // precision highp float;
- // uniform sampler2D sTexture;
- // uniform sampler2D sEffect;
- // uniform vec4 uColor;
- // varying vec2 vTexCoord;
std::string fragmentSource;
fragmentSource =
"precision mediump float;\n"
+
+ "uniform sampler2D sTexture;\n"
+ "uniform vec4 uColor;\n"
+
"uniform vec2 uObjectFadeStart;\n"
"uniform vec2 uObjectFadeEnd;\n"
"uniform float uAlphaScale;\n"
"varying vec2 vModelSpaceCenterToPos;\n"
"varying vec2 vScreenSpaceVelocityVector;\n"
"varying float vSpeed;\n"
+ "varying vec2 vTexCoord;\n"
"void main()\n"
"{\n"
" col += texture2D(sTexture, vTexCoord + (velocity * t)) * uRecipNumSamples;\n"
" }\n"
" gl_FragColor = mix(colActor, col, vSpeed);\n" // lerp blurred and non-blurred actor based on speed of motion
- " gl_FragColor.a = colActor.a * fadeToEdgesScale;\n" // fade blurred actor to its edges based on speed of motion
+ " gl_FragColor.a = fadeToEdgesScale;//colActor.a * fadeToEdgesScale;\n" // fade blurred actor to its edges based on speed of motion
" gl_FragColor *= uColor;\n"
"}\n";
+
+ Property::Map map;
+
+ Property::Map customShader;
+ customShader[ "vertex-shader" ] = vertexSource;
+ customShader[ "fragment-shader" ] = fragmentSource;
+
+ customShader[ "subdivide-grid-x" ] = 10;
+ customShader[ "subdivide-grid-y" ] = 10;
+
// NOTE: we must turn on alpha blending for the actor (HINT_BLENDING)
- ShaderEffect shader = ShaderEffect::New( vertexSource, fragmentSource,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID) );
-
- //////////////////////////////////////
- // Register uniform properties
- //
- //
- shader.SetUniform( "uBlurTexCoordScale", 0.125f );
- shader.SetUniform( "uGeometryStretchFactor", 0.05f );
- shader.SetUniform( "uSpeedScalingFactor", 0.5f );
- shader.SetUniform( "uObjectFadeStart", Vector2( 0.25f, 0.25f ) );
- shader.SetUniform( "uObjectFadeEnd", Vector2( 0.5f, 0.5f ) );
- shader.SetUniform( "uAlphaScale", 0.75f );
- shader.SetUniform( "uNumSamples", static_cast<float>( numBlurSamples ) );
- shader.SetUniform( "uRecipNumSamples", 1.0f / static_cast<float>( numBlurSamples ) );
- shader.SetUniform( "uRecipNumSamplesMinusOne", 1.0f / static_cast<float>( numBlurSamples - 1.0f ) );
- shader.SetUniform( "uModelLastFrame", Matrix::IDENTITY );
-
- return shader;
+ customShader[ "hints" ] = "output-is-transparent";
+
+ map[ "shader" ] = customShader;
+ return map;
}
}
{
/**
+ * @brief Set the properties for the motion stretch
+ */
+inline void SetMotionStretchProperties( Actor& actor )
+{
+ actor.RegisterProperty( "uGeometryStretchFactor", 0.5f );
+ actor.RegisterProperty( "uSpeedScalingFactor", 0.5f );
+ actor.RegisterProperty( "uObjectFadeStart", Vector2( 0.25f, 0.25f ) );
+ actor.RegisterProperty( "uObjectFadeEnd", Vector2( 0.5f, 0.5f ) );
+ actor.RegisterProperty( "uAlphaScale", 0.75f );
+ Property::Index uModelProperty = actor.RegisterProperty( "uModelLastFrame", Matrix::IDENTITY );
+
+ Constraint constraint = Constraint::New<Matrix>( actor, uModelProperty, EqualToConstraint() );
+ constraint.AddSource( Source( actor , Actor::Property::WORLD_MATRIX ) );
+ constraint.Apply();
+}
+
+/**
* @brief Creates a new MotionStretchEffect
*
- * Motion stretch shader works on a per object basis. Objects will stretch in the direction of motion when they move, or if the camera moves. Can be applied
- * to ImageActor or TextActor only.
- *
- * Usage example:-
- *
- * // Create shader used for doing motion stretch\n
- * ShaderEffect MotionStretchEffect = CreateMotionStretchEffect();
- *
- * // set actor shader to the stretch one\n
- * Actor actor = Actor::New( ... );\n
- * actor.SetShaderEffect( MotionStretchEffect );
- *
- * // Constrain "uModelLastFrame" to be the same as the actor's world matrix\n
- * Dali::Property::Index uModelProperty = MotionBlurEffect.GetPropertyIndex( "uModelLastFrame" );
- * Constraint constraint = Constraint::New<Matrix>( MotionBlurEffect, uModelProperty, EqualToConstraint() );\n
- * constraint.AddSource( Source( actor , Actor::Property::WORLD_MATRIX ) );\n
- * constraint.Apply();\n
+ * Motion stretch shader works on a per object basis. Objects will stretch in the direction of motion when they move, or if the camera moves.
*
* Animatable/Constrainable uniforms:
* "uGeometryStretchFactor" - This scales the amount the geometry stretches along the motion velocity vector.
* applied. Default 0.75.
* "uModelLastFrame" - The model to world space transformation matrix of the actor in the previous frame.
*
- * @return A handle to a newly allocated ShaderEffect
+ * @return The newly created Property::Map with the motion stretch effect
*/
-inline ShaderEffect CreateMotionStretchEffect()
+inline Property::Map CreateMotionStretchEffect()
{
- // Dali vertexSource prefix for reference:
- // precision highp float;
- // attribute vec3 aPosition;
- // attribute vec2 aTexCoord;
- // uniform mat4 uMvpMatrix;
- // uniform mat4 uModelView;
- // uniform mat3 uNormalMatrix;
- // uniform mat4 uProjection;
- // uniform vec4 uColor;
- // varying vec2 vTexCoord;
std::string vertexSource;
vertexSource =
"precision mediump float;\n"
+
+ "attribute vec2 aPosition;\n"
+
+ "uniform mat4 uMvpMatrix;\n"
+ "uniform mat4 uModelView;\n"
+ "uniform mat4 uViewMatrix;\n"
+ "uniform mat4 uProjection;\n"
+ "uniform vec3 uSize;\n"
+
"uniform mat4 uModelLastFrame;\n"
- "uniform float uTimeDelta;\n"
+ "float timeDelta = 0.0167;\n"
"uniform float uGeometryStretchFactor;\n"
"uniform float uSpeedScalingFactor;\n"
"varying vec2 vModelSpaceCenterToPos;\n"
"varying vec2 vScreenSpaceVelocityVector;\n"
"varying float vSpeed;\n"
+ "varying vec2 vTexCoord;\n"
"void main()\n"
"{\n"
// get view space position of vertex this frame and last frame
- " vec4 vertex = vec4(aPosition, 1.0);\n"
- " vec4 viewSpaceVertex = uModelView * vertex;\n"
- " vec4 viewSpaceVertexLastFrame = uViewMatrix * uModelLastFrame * vertex;\n"
+ " vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n"
+ " vertexPosition.xyz *= uSize;\n"
+
+ " vec4 viewSpaceVertex = uModelView * vertexPosition;\n"
+ " vec4 viewSpaceVertexLastFrame = uViewMatrix * uModelLastFrame * vertexPosition;\n"
// work out vertex's last movement in view space
" vec3 viewSpacePosDelta = viewSpaceVertex.xyz - viewSpaceVertexLastFrame.xyz;\n"
- " float reciprocalTimeDelta = 1.0 / ((uTimeDelta > 0.0) ? uTimeDelta : 0.01);\n"
+ " float reciprocalTimeDelta = 1.0 / timeDelta;\n"
// get clip space position of vertex this frame and last frame
- " vec4 clipSpaceVertex = uMvpMatrix * vertex;\n"
+ " vec4 clipSpaceVertex = uMvpMatrix * vertexPosition;\n"
" vec4 clipSpaceVertexLastFrame = uProjection * viewSpaceVertexLastFrame;\n"
// decide how much this vertex is 'trailing', i.e. at the back of the object relative to its direction of motion. We do this
" float posDeltaLength = length(viewSpacePosDelta);\n"
" if(posDeltaLength > 0.001)\n" // avoid div by 0 if object has barely moved
" {\n"
- " vec4 viewSpaceCenterToPos = uModelView * vec4(aPosition, 0.0);\n"
+ " vec4 viewSpaceCenterToPos = uModelView * vec4(aPosition, 0.0, 0.0);\n"
" float centerToVertexDist = length(viewSpaceCenterToPos);\n"
" if(centerToVertexDist > 0.001)\n" // avoid div by 0 if object has vertex at model space origin
" {\n"
" vSpeed = clamp(vSpeed, 0.0, 1.0);\n"
// provide fragment shader with vector from center of object to pixel (assumes the objects model space origin is at its center and verts have same z)
- " vModelSpaceCenterToPos = aPosition.xy;\n"
+ " vModelSpaceCenterToPos = viewSpaceVertex.xy;\n"
- " vTexCoord = aTexCoord;\n"
+ " vec2 texCoord = aPosition + vec2(0.5);"
+ " vTexCoord = texCoord;\n"
"}\n";
-
- // Dali fragmentSource prefix for reference:
- // precision highp float;
- // uniform sampler2D sTexture;
- // uniform sampler2D sEffect;
- // uniform vec4 uColor;
- // varying vec2 vTexCoord;
std::string fragmentSource;
fragmentSource =
"precision mediump float;\n"
+ "uniform sampler2D sTexture;\n"
+ "uniform vec4 uColor;\n"
+
"uniform vec2 uObjectFadeStart;\n"
"uniform vec2 uObjectFadeEnd;\n"
"uniform float uAlphaScale;\n"
"varying vec2 vModelSpaceCenterToPos;\n"
"varying vec2 vScreenSpaceVelocityVector;\n"
"varying float vSpeed;\n"
+ "varying vec2 vTexCoord;\n"
"void main()\n"
"{\n"
" gl_FragColor *= uColor;\n"
"}";
+ Property::Map map;
+
+ Property::Map customShader;
+ customShader[ "vertex-shader" ] = vertexSource;
+ customShader[ "fragment-shader" ] = fragmentSource;
+
+ customShader[ "subdivide-grid-x" ] = 10;
+ customShader[ "subdivide-grid-y" ] = 10;
+
// NOTE: we must turn on alpha blending for the actor (HINT_BLENDING)
- ShaderEffect shaderEffect = ShaderEffect::New(
- vertexSource, fragmentSource,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ) );
-
-
- //////////////////////////////////////
- // Register uniform properties
- //
- //
- shaderEffect.SetUniform( "uGeometryStretchFactor", 0.5f );
- shaderEffect.SetUniform( "uSpeedScalingFactor", 0.5f );
- shaderEffect.SetUniform( "uObjectFadeStart", Vector2( 0.25f, 0.25f ) );
- shaderEffect.SetUniform( "uObjectFadeEnd", Vector2( 0.5f, 0.5f ) );
- shaderEffect.SetUniform( "uAlphaScale", 0.75f );
- shaderEffect.SetUniform( "uModelLastFrame", Matrix::IDENTITY );
-
- return shaderEffect;
+ customShader[ "hints" ] = "output-is-transparent";
+
+ map[ "shader" ] = customShader;
+ return map;
}
}
namespace Toolkit
{
-CubeTransitionCrossEffect::CubeTransitionCrossEffect(Internal::CubeTransitionCrossEffect* impl)
-: CubeTransitionEffect(impl)
+CubeTransitionCrossEffect::CubeTransitionCrossEffect( Internal::CubeTransitionCrossEffect& implementation )
+: CubeTransitionEffect( implementation )
{
}
-CubeTransitionCrossEffect CubeTransitionCrossEffect::New(unsigned int numRows, unsigned int numColumns, Size viewAreaSize)
+CubeTransitionCrossEffect::CubeTransitionCrossEffect( Dali::Internal::CustomActor* internal )
+: CubeTransitionEffect( internal )
{
- return Internal::CubeTransitionCrossEffect::New( numRows, numColumns, viewAreaSize );
+ VerifyCustomActorPointer< Internal::CubeTransitionCrossEffect >( internal );
+}
+
+CubeTransitionCrossEffect CubeTransitionCrossEffect::New( unsigned int numRows, unsigned int numColumns )
+{
+ return Internal::CubeTransitionCrossEffect::New( numRows, numColumns );
}
} // namespace Toolkit
/**
* SubClass of CubeTransitionEffect
- * Rotate the neighboring cubes in perpendicular directions to transite from one image to another
+ * Rotate the neighboring cubes in perpendicular directions to transition from one image to another
*/
class DALI_IMPORT_API CubeTransitionCrossEffect : public CubeTransitionEffect
{
* Create an initialized CubeTransitionCrossEffect
* @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
* @return The initialized CubeTransitionCrossEffect object
*/
- static CubeTransitionCrossEffect New( unsigned int numRows, unsigned int numColumns, Size viewAreaSize );
+ static CubeTransitionCrossEffect New( unsigned int numRows, unsigned int numColumns );
public: // Not intended for developer use
/**
- * This constructor is used by Dali New() methods.
- * @param [in] impl A pointer to a newly allocated Dali resource
+ * Creates a handle using the Toolkit::Internal implementation.
+ * @param[in] implementation The Control implementation.
*/
- explicit DALI_INTERNAL CubeTransitionCrossEffect( Internal::CubeTransitionCrossEffect* impl );
+ DALI_INTERNAL CubeTransitionCrossEffect( Internal::CubeTransitionCrossEffect& implementation );
+
+ /**
+ * Allows the creation of this Control from an Internal::CustomActor pointer.
+ * @param[in] internal A pointer to the internal CustomActor.
+ */
+ DALI_INTERNAL CubeTransitionCrossEffect( Dali::Internal::CustomActor* internal );
}; // class CubeTransitionCrossEffect
{
}
-CubeTransitionEffect::CubeTransitionEffect(Internal::CubeTransitionEffect* impl)
-: BaseHandle(impl)
+CubeTransitionEffect::CubeTransitionEffect( Internal::CubeTransitionEffect& implementation )
+: Control( implementation )
{
}
+CubeTransitionEffect::CubeTransitionEffect( Dali::Internal::CustomActor* internal )
+: Control( internal )
+{
+ VerifyCustomActorPointer<Internal::CubeTransitionEffect>(internal);
+}
+
CubeTransitionEffect CubeTransitionEffect::DownCast( BaseHandle handle )
{
- return CubeTransitionEffect( dynamic_cast< Dali::Toolkit::Internal::CubeTransitionEffect* >( handle.GetObjectPtr() ) );
+ return Control::DownCast<CubeTransitionEffect, Internal::CubeTransitionEffect>( handle );
}
void CubeTransitionEffect::SetTransitionDuration( float duration )
return GetImpl(*this).GetCubeDisplacement();
}
-Actor CubeTransitionEffect::GetRoot()
-{
- return GetImpl(*this).GetRoot();
-}
-
-bool CubeTransitionEffect::IsTransiting()
+bool CubeTransitionEffect::IsTransitioning()
{
- return GetImpl(*this).IsTransiting();
+ return GetImpl(*this).IsTransitioning();
}
-void CubeTransitionEffect::SetCurrentImage(ImageActor imageActor)
+void CubeTransitionEffect::SetCurrentImage( Image image )
{
- GetImpl(*this).SetCurrentImage( imageActor );
+ GetImpl(*this).SetCurrentImage( image );
}
-void CubeTransitionEffect::SetTargetImage(ImageActor imageActor)
+void CubeTransitionEffect::SetTargetImage( Image image )
{
- GetImpl(*this).SetTargetImage( imageActor );
+ GetImpl(*this).SetTargetImage( image );
}
void CubeTransitionEffect::StartTransition( bool toNextImage )
*
*/
-// EXTERNAL INCLUDES
-#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/actors/image-actor.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control.h>
namespace Dali
{
} // namespace Internal
/**
- * CubeTransitionEffect is a base class of custom transition effect on Image actors
+ * CubeTransitionEffect is a base class of custom transition effect on Images
* The two images are partitioned into tiles and serves as two perpendicular faces of cubes
* By rotating these cubes to transit from one image to another
*
*
* //create a new CubeTransitionEffect
* //use the New funtion of subclass ( CubeTransitionWaveEffect or CubeTransitionCrossEffect )
- * CubeTransitionEffect cubeEffect = CubeTransitionWaveEffect::New(numRows, numColumns, viewAreaSize);
+ * CubeTransitionEffect cubeEffect = CubeTransitionWaveEffect::New(numRows, numColumns);
*
* //set the duration of transition animation
* cubeEffect.SetTransitionDuration( animationDuration );
* cubeEffect.SetCubeDisplacement( cubeDisplacement );
*
* // Add to stage
- * stage.Add( cubeEffect.GetRoot() );
+ * stage.Add( cubeEffect );
*
* // Set the current image,
- * // only need to set at beginning or when the current image was transited to with no effect or other effect
- * cubeEffect.SetCurrentImage( firstImageActor );
+ * // only need to set at beginning or when the current image was transitioned to with no effect or other effect
+ * cubeEffect.SetCurrentImage( firstImage );
*
* // Set target image, paired with startTransition. These two steps would be repeated as needed
- * cubeEffect.SetTargetimage( secondImageActor );
+ * cubeEffect.SetTargetimage( secondImage );
* // Activate the effect
* // no param / param ture: default horizontally left panGesture
* // or param false: default horizontally right panGesture
* |----------------------|----------------------------------|
* | transition-completed | @ref TransitionCompletedSignal() |
*/
-class DALI_IMPORT_API CubeTransitionEffect : public BaseHandle
+class DALI_IMPORT_API CubeTransitionEffect : public Control
{
public:
void SetCubeDisplacement( float displacement );
/**
- * Getet the displacement of bouncing animation during cube's rotation
+ * Get the displacement of bouncing animation during cube's rotation
* @return displacement The displacement of bouncing animation
*/
float GetCubeDisplacement() const;
/**
- * Return the transition effect root actor, should then be added to stage
- * @return The transition effect root actor
- */
- Actor GetRoot();
-
- /**
* Return the transition status
* @return True if the transition is under processing; false if finished
*/
- bool IsTransiting();
+ bool IsTransitioning();
/**
- * Set the current image to transite from
- * if using this same effect continuely, only need to set once
- * @param[in] imageActor The current imageActor
+ * Set the current image to transition from
+ * if using this same effect continually, only need to set once
+ * @param[in] image The current image
*/
- void SetCurrentImage(ImageActor imageActor);
+ void SetCurrentImage(Image image);
/**
* Set the target image to transit to
- * @param[in] imageActor The new imageActor showing on stage
+ * @param[in] image The new Image showing on stage
*/
- void SetTargetImage(ImageActor imageActor);
+ void SetTargetImage(Image image);
/**
* Activate the transition animation with horizontally left/right panGesture
* @pre target image is set
- * @param[in] toNextImage Horizontally left panGesture if ture, horizontally right if false
+ * @param[in] toNextImage Horizontally left panGesture if true, horizontally right if false
*/
void StartTransition( bool toNextImage = true );
/**
* Inactivate the transition animation if it is running.
- * Also set the rotation and position of cubes, colors of tile to the same as the final state when the animation if finished completely
+ * Also set the rotation and position of cubes, colors of tile to the same as the start state when the animation if finished completely
* It does nothing if the animation is not running.
*/
void StopTransition();
public: //Signal
//Transition animation completed signal
- typedef Signal< void ( CubeTransitionEffect, ImageActor ) > TransitionCompletedSignalType;
+ typedef Signal< void ( CubeTransitionEffect, Image ) > TransitionCompletedSignalType;
/**
* Signal emitted when the transition has completed animation
public: // Not intended for developer use
- explicit DALI_INTERNAL CubeTransitionEffect( Internal::CubeTransitionEffect* impl );
+ /**
+ * @brief Creates a handle using the Toolkit::Internal implementation.
+ *
+ * @param[in] implementation The Control implementation.
+ */
+ DALI_INTERNAL CubeTransitionEffect( Internal::CubeTransitionEffect& implementation );
+
+ /**
+ * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
+ *
+ * @param[in] internal A pointer to the internal CustomActor.
+ */
+ DALI_INTERNAL CubeTransitionEffect( Dali::Internal::CustomActor* internal );
}; //class CubeTransitionEffect
namespace Toolkit
{
-CubeTransitionFoldEffect::CubeTransitionFoldEffect(Internal::CubeTransitionFoldEffect* impl)
-: CubeTransitionEffect(impl)
+CubeTransitionFoldEffect::CubeTransitionFoldEffect( Internal::CubeTransitionFoldEffect& implementation )
+: CubeTransitionEffect( implementation )
{
}
-CubeTransitionFoldEffect CubeTransitionFoldEffect::New(unsigned int numRows, unsigned int numColumns, Size viewAreaSize)
+CubeTransitionFoldEffect::CubeTransitionFoldEffect( Dali::Internal::CustomActor* internal )
+: CubeTransitionEffect( internal )
{
- return Internal::CubeTransitionFoldEffect::New( numRows, numColumns, viewAreaSize );
+ VerifyCustomActorPointer< Internal::CubeTransitionFoldEffect >( internal );
+}
+
+CubeTransitionFoldEffect CubeTransitionFoldEffect::New(unsigned int numRows, unsigned int numColumns )
+{
+ return Internal::CubeTransitionFoldEffect::New( numRows, numColumns );
}
} // namespace Toolkit
/**
* SubClass of CubeTransitionEffect
- * Rotate the neighboring cubes in opposite directions to transite from one image to another
+ * Rotate the neighboring cubes in opposite directions to transition from one image to another
*/
class DALI_IMPORT_API CubeTransitionFoldEffect : public CubeTransitionEffect
{
* Create an initialized CubeTransitionFoldEffect
* @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
* @return The initialized CubeTransitionFoldEffect object
*/
- static CubeTransitionFoldEffect New( unsigned int numRows, unsigned int numColumns, Size viewAreaSize );
+ static CubeTransitionFoldEffect New( unsigned int numRows, unsigned int numColumns );
public: // Not intended for developer use
/**
- * This constructor is used by Dali New() methods.
- * @param [in] impl A pointer to a newly allocated Dali resource
+ * Creates a handle using the Toolkit::Internal implementation.
+ * @param[in] implementation The Control implementation.
*/
- explicit DALI_INTERNAL CubeTransitionFoldEffect( Internal::CubeTransitionFoldEffect* impl );
+ DALI_INTERNAL CubeTransitionFoldEffect( Internal::CubeTransitionFoldEffect& implementation );
+
+ /**
+ * Allows the creation of this Control from an Internal::CustomActor pointer.
+ * @param[in] internal A pointer to the internal CustomActor.
+ */
+ DALI_INTERNAL CubeTransitionFoldEffect( Dali::Internal::CustomActor* internal );
}; // class CubeTransitionFoldEffect
namespace Toolkit
{
-CubeTransitionWaveEffect::CubeTransitionWaveEffect(Internal::CubeTransitionWaveEffect* impl)
-: CubeTransitionEffect(impl)
+CubeTransitionWaveEffect::CubeTransitionWaveEffect( Internal::CubeTransitionWaveEffect& implementation )
+: CubeTransitionEffect( implementation )
{
}
-CubeTransitionWaveEffect CubeTransitionWaveEffect::New(unsigned int numRows, unsigned int numColumns, Size viewAreaSize)
+CubeTransitionWaveEffect::CubeTransitionWaveEffect( Dali::Internal::CustomActor* internal )
+: CubeTransitionEffect( internal )
{
- return Internal::CubeTransitionWaveEffect::New( numRows, numColumns, viewAreaSize );
+ VerifyCustomActorPointer< Internal::CubeTransitionWaveEffect >( internal );
+}
+
+CubeTransitionWaveEffect CubeTransitionWaveEffect::New(unsigned int numRows, unsigned int numColumns )
+{
+ return Internal::CubeTransitionWaveEffect::New( numRows, numColumns );
}
} // namespace Toolkit
* Create an initialized CubeTransitionWaveEffect
* @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
* @return The initialized CubeTransitionWaveEffect object
*/
- static CubeTransitionWaveEffect New( unsigned int numRows, unsigned int numColumns, Size viewAreaSize );
+ static CubeTransitionWaveEffect New( unsigned int numRows, unsigned int numColumns );
public: // Not intended for developer use
/**
- * This constructor is used by Dali New() methods.
- * @param[in] impl A pointer to a newly allocated Dali resource
+ * Creates a handle using the Toolkit::Internal implementation.
+ * @param[in] implementation The Control implementation.
*/
- explicit DALI_INTERNAL CubeTransitionWaveEffect( Internal::CubeTransitionWaveEffect* impl );
+ DALI_INTERNAL CubeTransitionWaveEffect( Internal::CubeTransitionWaveEffect& implementation );
+
+ /**
+ * Allows the creation of this Control from an Internal::CustomActor pointer.
+ * @param[in] internal A pointer to the internal CustomActor.
+ */
+ DALI_INTERNAL CubeTransitionWaveEffect( Dali::Internal::CustomActor* internal );
}; // class CubeTransitionWaveEffect
size.y = mImageSize.GetHeight();
size.z = std::min(size.x, size.y);
- if( size.x > 0 && size.x > 0 )
+ if( size.x > 0 && size.y > 0 )
{
return size;
}
void ImageView::OnStageConnection( int depth )
{
+ Control::OnStageConnection( depth );
+
if( mRenderer )
{
CustomActor self = Self();
CustomActor self = Self();
mRenderer.SetOffStage( self );
}
+
+ Control::OnStageDisconnection();
}
void Model3dView::OnStageConnection( int depth )
{
+ Control::OnStageConnection( depth );
+
CustomActor self = Self();
self.AddRenderer( mRenderer );
#include <dali/public-api/render-tasks/render-task-list.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h>
mShadowView.SetPointLightFieldOfView( Math::PI / 2.0f);
mShadowView.SetShadowColor(DEFAULT_SHADOW_COLOR);
- mShadowPlane = CreateSolidColorActor( Vector4 (0.0f, 0.0f, 0.0f, 0.0f) );
- mShadowPlane.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
- mShadowPlane.SetSize( mControlSize );
- Self().Add( mShadowPlane );
- mShadowView.SetShadowPlane( mShadowPlane );
+ mShadowPlaneBackground = Actor::New();
+ mShadowPlaneBackground.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
+ mShadowPlaneBackground.SetSize( mControlSize );
+ Self().Add( mShadowPlaneBackground );
+ mShadowView.SetShadowPlaneBackground( mShadowPlaneBackground );
mPointLight = Actor::New();
mPointLight.SetAnchorPoint( origin );
void PageTurnView::OnStageConnection( int depth )
{
+ Control::OnStageConnection( depth );
+
SetupShadowView();
mTurningPageLayer.Raise();
}
if(mShadowView)
{
mPointLight.Unparent();
- mShadowPlane.Unparent();
+ mShadowPlaneBackground.Unparent();
mShadowView.Unparent();
}
SetSpineEffect( mPanActor, mIsTurnBack[mPanActor] );
}
+
+ Control::OnStageDisconnection();
}
void PageTurnView::SetPageSize( const Vector2& pageSize )
OnPageTurnViewInitialize();
- if( mShadowPlane )
+ if( mShadowPlaneBackground )
{
- mShadowPlane.SetSize( mControlSize );
+ mShadowPlaneBackground.SetSize( mControlSize );
}
}
Vector2 mControlSize; ///< The size of the control, it is decided by the page size, the SetSize from application can not change it
Layer mTurningPageLayer; ///< The layer for the turning page, to avoid possible depth conflict
Toolkit::ShadowView mShadowView; ///< The shadow view control for shadow casting
- ImageActor mShadowPlane; ///< The plane for the shadow to cast on
+ Actor mShadowPlaneBackground; ///< The plane for the shadow to cast on
Actor mPointLight; ///< The point light used for shadow casting
PageFactory& mPageFactory; ///< The page factory which provides the page actors
if( !geometry )
{
geometry = CreateBorderGeometry();
- mFactoryCache.SaveGeometry( RendererFactoryCache::QUAD_GEOMETRY, geometry );
+ mFactoryCache.SaveGeometry( RendererFactoryCache::BORDER_GEOMETRY, geometry );
}
Shader shader = mFactoryCache.GetShader( RendererFactoryCache::BORDER_SHADER );
if( !shader )
{
shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- mFactoryCache.SaveShader( RendererFactoryCache::COLOR_SHADER, shader );
+ mFactoryCache.SaveShader( RendererFactoryCache::BORDER_SHADER, shader );
}
Material material = Material::New( shader );
ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction)
: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+ mIndicatorShowAlpha(1.0f),
mDirection(direction),
mScrollableObject(WeakHandleBase()),
mPropertyScrollPosition(Property::INVALID_INDEX),
mIndicatorShowDuration(DEFAULT_INDICATOR_SHOW_DURATION),
mIndicatorHideDuration(DEFAULT_INDICATOR_HIDE_DURATION),
mScrollStart(0.0f),
- mIsPanning(false),
mCurrentScrollPosition(0.0f),
mIndicatorHeightPolicy(Toolkit::ScrollBar::Variable),
- mIndicatorFixedHeight(DEFAULT_INDICATOR_FIXED_HEIGHT)
+ mIndicatorFixedHeight(DEFAULT_INDICATOR_FIXED_HEIGHT),
+ mIsPanning(false),
+ mIndicatorFirstShow(true)
{
}
if( indicator )
{
mIndicator = indicator;
+ mIndicatorFirstShow = true;
Self().Add(mIndicator);
EnableGestureDetection(Gesture::Type(Gesture::Pan));
mAnimation.Reset();
}
+ if( mIndicatorFirstShow )
+ {
+ // Preserve the alpha value from the stylesheet
+ mIndicatorShowAlpha = Self().GetCurrentColor().a;
+ mIndicatorFirstShow = false;
+ }
+
if(mIndicatorShowDuration > 0.0f)
{
mAnimation = Animation::New( mIndicatorShowDuration );
- mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_IN );
+ mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ), mIndicatorShowAlpha, AlphaFunction::EASE_IN );
mAnimation.Play();
}
else
{
- mIndicator.SetOpacity(1.0f);
+ mIndicator.SetOpacity(mIndicatorShowAlpha);
}
}
private:
Actor mIndicator; ///< Image of scroll indicator.
+ float mIndicatorShowAlpha; ///< The alpha value when the indicator is fully shown
Animation mAnimation; ///< Scroll indicator Show/Hide Animation.
Toolkit::ScrollBar::Direction mDirection; ///< The direction of scroll bar (vertical or horizontal)
float mScrollStart; ///< Scroll Start position (start of drag)
Vector3 mGestureDisplacement; ///< Gesture Displacement.
- bool mIsPanning; ///< Whether the scroll bar is being panned.
float mCurrentScrollPosition; ///< The current scroll position updated by the pan gesture
Toolkit::ScrollBar::IndicatorHeightPolicy mIndicatorHeightPolicy; ///< The height policy of scroll indicator (variable or fixed)
Constraint mIndicatorPositionConstraint;
Constraint mIndicatorSizeConstraint;
Constraint mScrollPositionInCurrentAxisConstraint;
+
+ bool mIsPanning : 1; ///< Whether the scroll bar is being panned.
+ bool mIndicatorFirstShow : 1; ///< True if the indicator has never been shown
};
} // namespace Internal
ItemView::ItemView(ItemFactory& factory)
: Scrollable( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | REQUIRES_WHEEL_EVENTS | REQUIRES_KEYBOARD_NAVIGATION_SUPPORT ) ),
mItemFactory(factory),
+ mItemsParentOrigin(ParentOrigin::CENTER),
+ mItemsAnchorPoint(AnchorPoint::CENTER),
+ mTotalPanDisplacement(Vector2::ZERO),
mActiveLayout(NULL),
- mAnimatingOvershootOn(false),
- mAnimateOvershootOff(false),
- mAnchoringEnabled(false),
mAnchoringDuration(DEFAULT_ANCHORING_DURATION),
mRefreshIntervalLayoutPositions(0.0f),
- mRefreshOrderHint(true/*Refresh item 0 first*/),
mMinimumSwipeSpeed(DEFAULT_MINIMUM_SWIPE_SPEED),
mMinimumSwipeDistance(DEFAULT_MINIMUM_SWIPE_DISTANCE),
mWheelScrollDistanceStep(0.0f),
mScrollDistance(0.0f),
mScrollSpeed(0.0f),
- mTotalPanDisplacement(Vector2::ZERO),
mScrollOvershoot(0.0f),
- mIsFlicking(false),
mGestureState(Gesture::Clear),
+ mAnimatingOvershootOn(false),
+ mAnimateOvershootOff(false),
+ mAnchoringEnabled(false),
+ mRefreshOrderHint(true/*Refresh item 0 first*/),
+ mIsFlicking(false),
mAddingItems(false),
mRefreshEnabled(true),
- mItemsParentOrigin( ParentOrigin::CENTER),
- mItemsAnchorPoint( AnchorPoint::CENTER)
+ mInAnimation(false)
{
}
self.SetProperty(Toolkit::ItemView::Property::LAYOUT_POSITION, firstItemScrollPosition );
- if( (firstItemScrollPosition >= 0.0f && currentOvershoot < 1.0f) || (firstItemScrollPosition >= mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), layoutSize) && currentOvershoot > -1.0f) )
+ if( ( firstItemScrollPosition >= 0.0f &&
+ currentOvershoot < 1.0f ) ||
+ ( firstItemScrollPosition <= mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), layoutSize) &&
+ currentOvershoot > -1.0f ) )
{
mTotalPanDisplacement += gesture.displacement;
}
mScrollOvershoot = CalculateScrollOvershoot();
- self.SetProperty( Toolkit::ItemView::Property::OVERSHOOT, mScrollOvershoot );
+
+ // If the view is moved in a direction against the overshoot indicator, then the indicator should be animated off.
+ // First make sure we are not in an animation, otherwise a previously started
+ // off-animation will be overwritten as the user continues scrolling.
+ if( !mInAnimation )
+ {
+ // Check if the movement is against the current overshoot amount (if we are currently displaying the indicator).
+ if( ( ( mScrollOvershoot > Math::MACHINE_EPSILON_0 ) && ( mScrollDistance < -Math::MACHINE_EPSILON_0 ) ) ||
+ ( ( mScrollOvershoot < Math::MACHINE_EPSILON_0 ) && ( mScrollDistance > Math::MACHINE_EPSILON_0 ) ) )
+ {
+ // The user has moved against the indicator direction.
+ // First, we reset the total displacement. This means the overshoot amount will become zero the next frame,
+ // and if the user starts dragging in the overshoot direction again, the indicator will appear once more.
+ mTotalPanDisplacement = Vector2::ZERO;
+ // Animate the overshoot indicator off.
+ AnimateScrollOvershoot( 0.0f, false );
+ }
+ else
+ {
+ // Only set the property directly if we are not animating the overshoot away,
+ // as otherwise this will overwrite the animation generated value.
+ self.SetProperty( Toolkit::ItemView::Property::OVERSHOOT, mScrollOvershoot );
+ }
+ }
}
break;
{
AnimateScrollOvershoot(0.0f);
}
+ mInAnimation = false;
}
void ItemView::ScrollToItem(unsigned int itemId, float durationSeconds)
duration = mOvershootOverlay.GetCurrentSize().height * (animatingOn ? (1.0f - fabsf(currentOvershoot)) : fabsf(currentOvershoot)) / mOvershootAnimationSpeed;
}
+ // Mark the animation as in progress to prevent manual property sets overwriting it.
+ mInAnimation = true;
+ mAnimatingOvershootOn = animatingOn;
RemoveAnimation(mScrollOvershootAnimation);
mScrollOvershootAnimation = Animation::New(duration);
mScrollOvershootAnimation.FinishedSignal().Connect(this, &ItemView::OnOvershootOnFinished);
mScrollOvershootAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::OVERSHOOT), overshootAmount, TimePeriod(0.0f, duration) );
mScrollOvershootAnimation.Play();
-
- mAnimatingOvershootOn = animatingOn;
}
else
{
private:
- ItemFactory& mItemFactory;
-
typedef std::map<unsigned int, Actor> ItemPool;
typedef ItemPool::iterator ItemPoolIter;
typedef ItemPool::const_iterator ConstItemPoolIter;
ItemPool mItemPool;
-
- std::vector< ItemLayoutPtr > mLayouts; ///< Container of Dali::Toolkit::ItemLayout objects
- ItemLayout* mActiveLayout;
- Vector3 mActiveLayoutTargetSize;
-
+ ItemFactory& mItemFactory;
+ std::vector< ItemLayoutPtr > mLayouts; ///< Container of Dali::Toolkit::ItemLayout objects
+ Actor mOvershootOverlay; ///< The overlay actor for overshoot effect
Animation mResizeAnimation;
Animation mScrollAnimation;
Animation mScrollOvershootAnimation;
- bool mAnimatingOvershootOn; ///< whether we are currently animating overshoot to 1.0f/-1.0f (on) or to 0.0f (off)
- bool mAnimateOvershootOff; ///< whether we are currently animating overshoot to 1.0f/-1.0f (on) or to 0.0f (off)
+ Timer mWheelEventFinishedTimer; ///< The timer to determine whether there is no wheel event received for a certain period of time.
+ PropertyNotification mRefreshNotification; ///< Stores the property notification used for item view refresh
+ LayoutActivatedSignalType mLayoutActivatedSignal;
+ Vector3 mActiveLayoutTargetSize;
+ Vector3 mItemsParentOrigin;
+ Vector3 mItemsAnchorPoint;
+ Vector2 mTotalPanDisplacement;
+ ItemLayout* mActiveLayout;
- bool mAnchoringEnabled;
float mAnchoringDuration;
-
- float mRefreshIntervalLayoutPositions; ///< Refresh item view when the layout position changes by this interval in both positive and negative directions.
- PropertyNotification mRefreshNotification; // stores the property notification used for item view refresh
- bool mRefreshOrderHint; ///< True if scrolling towards the last item
-
- // Input handling
-
+ float mRefreshIntervalLayoutPositions; ///< Refresh item view when the layout position changes by this interval in both positive and negative directions.
float mMinimumSwipeSpeed;
float mMinimumSwipeDistance;
- float mWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates for each wheel event received.
-
+ float mWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates for each wheel event received.
float mScrollDistance;
float mScrollSpeed;
- Vector2 mTotalPanDisplacement;
-
float mScrollOvershoot;
- bool mIsFlicking;
-
- Timer mWheelEventFinishedTimer; ///< The timer to determine whether there is no wheel event received for a certain period of time.
-
- Dali::Gesture::State mGestureState;
- Actor mOvershootOverlay; ///< The overlay actor for overshoot effect
-
- bool mAddingItems;
-
- bool mRefreshEnabled; ///< Whether to refresh the cache automatically
-
- Vector3 mItemsParentOrigin;
- Vector3 mItemsAnchorPoint;
-
- LayoutActivatedSignalType mLayoutActivatedSignal;
+ Dali::Gesture::State mGestureState : 3;
+ bool mAnimatingOvershootOn : 1; ///< Whether we are currently animating overshoot to 1.0f/-1.0f (on) or to 0.0f (off)
+ bool mAnimateOvershootOff : 1; ///< Whether we are currently animating overshoot to 1.0f/-1.0f (on) or to 0.0f (off)
+ bool mAnchoringEnabled : 1;
+ bool mRefreshOrderHint : 1; ///< True if scrolling towards the last item
+ bool mIsFlicking : 1;
+ bool mAddingItems : 1;
+ bool mRefreshEnabled : 1; ///< Whether to refresh the cache automatically
+ bool mInAnimation : 1; ///< Keeps track of whether an animation is controlling the overshoot property.
};
} // namespace Internal
mOvershootProperty = IsVertical() ? Toolkit::ScrollView::Property::OVERSHOOT_Y : Toolkit::ScrollView::Property::OVERSHOOT_X;
// make sure height is set, since we only create a constraint for image width
+ mOvershootSize = mAttachedScrollView.GetOvershootSize();
mOvershootOverlay.SetSize( mOvershootSize );
mAttachedScrollView.AddOverlay(mOvershootOverlay);
void operator()( Vector2& scrollPostPosition, const PropertyInputContainer& inputs )
{
const Vector2& panPosition = inputs[0]->GetVector2();
+ const bool& inGesture = inputs[1]->GetBoolean();
- if(!mWasPanning)
+ // First check if we are within a gesture.
+ // The ScrollView may have received a start gesture from ::OnPan()
+ // while the finish gesture is received now in this constraint.
+ // This gesture must then be rejected as the value will be "old".
+ // Typically the last value from the end of the last gesture.
+ // If we are rejecting the gesture, we simply don't modify the constraint target.
+ if( inGesture )
{
- mPrePosition = scrollPostPosition;
- mStartPosition = mPrePosition;
- mCurrentPanMask = mInitialPanMask;
- mWasPanning = true;
- }
-
- // Calculate Deltas...
- const Vector2& currentPosition = panPosition;
- Vector2 panDelta( currentPosition - mLocalStart );
-
- // Axis Auto Lock - locks the panning to the horizontal or vertical axis if the pan
- // appears mostly horizontal or mostly vertical respectively...
- if( mAxisAutoLock )
- {
- mLockAxis = GetLockAxis(panDelta, mLockAxis, mAxisAutoLockGradient);
- if( mLockAxis == ScrollView::LockVertical )
+ if( !mWasPanning )
{
- mCurrentPanMask.y = 0.0f;
+ mPrePosition = scrollPostPosition;
+ mStartPosition = mPrePosition;
+ mCurrentPanMask = mInitialPanMask;
+ mWasPanning = true;
}
- else if( mLockAxis == ScrollView::LockHorizontal )
+
+ // Calculate Deltas...
+ const Vector2& currentPosition = panPosition;
+ Vector2 panDelta( currentPosition - mLocalStart );
+
+ // Axis Auto Lock - locks the panning to the horizontal or vertical axis if the pan
+ // appears mostly horizontal or mostly vertical respectively...
+ if( mAxisAutoLock )
{
- mCurrentPanMask.x = 0.0f;
+ mLockAxis = GetLockAxis( panDelta, mLockAxis, mAxisAutoLockGradient );
+ if( mLockAxis == ScrollView::LockVertical )
+ {
+ mCurrentPanMask.y = 0.0f;
+ }
+ else if( mLockAxis == ScrollView::LockHorizontal )
+ {
+ mCurrentPanMask.x = 0.0f;
+ }
}
- }
- // Restrict deltas based on ruler enable/disable and axis-lock state...
- panDelta *= mCurrentPanMask;
+ // Restrict deltas based on ruler enable/disable and axis-lock state...
+ panDelta *= mCurrentPanMask;
- // Perform Position transform based on input deltas...
- scrollPostPosition = mPrePosition;
- scrollPostPosition += panDelta;
+ // Perform Position transform based on input deltas...
+ scrollPostPosition = mPrePosition;
+ scrollPostPosition += panDelta;
- // if no wrapping then clamp preposition to maximum overshoot amount
- const Vector3& size = inputs[1]->GetVector3();
- if( mClampX )
- {
- float newXPosition = Clamp(scrollPostPosition.x, (mDomainMax.x + size.x) - mMaxOvershoot.x, mDomainMin.x + mMaxOvershoot.x );
- if( (newXPosition < scrollPostPosition.x - Math::MACHINE_EPSILON_1)
- || (newXPosition > scrollPostPosition.x + Math::MACHINE_EPSILON_1) )
+ // if no wrapping then clamp preposition to maximum overshoot amount
+ const Vector3& size = inputs[2]->GetVector3();
+ if( mClampX )
{
- mPrePosition.x = newXPosition;
- mLocalStart.x = panPosition.x;
+ float newXPosition = Clamp( scrollPostPosition.x, ( mDomainMax.x + size.x ) - mMaxOvershoot.x, mDomainMin.x + mMaxOvershoot.x );
+ if( (newXPosition < scrollPostPosition.x - Math::MACHINE_EPSILON_1)
+ || (newXPosition > scrollPostPosition.x + Math::MACHINE_EPSILON_1) )
+ {
+ mPrePosition.x = newXPosition;
+ mLocalStart.x = panPosition.x;
+ }
+ scrollPostPosition.x = newXPosition;
}
- scrollPostPosition.x = newXPosition;
- }
- if( mClampY )
- {
- float newYPosition = Clamp(scrollPostPosition.y, (mDomainMax.y + size.y) - mMaxOvershoot.y, mDomainMin.y + mMaxOvershoot.y );
- if( (newYPosition < scrollPostPosition.y - Math::MACHINE_EPSILON_1)
- || (newYPosition > scrollPostPosition.y + Math::MACHINE_EPSILON_1) )
+ if( mClampY )
{
- mPrePosition.y = newYPosition;
- mLocalStart.y = panPosition.y;
+ float newYPosition = Clamp( scrollPostPosition.y, ( mDomainMax.y + size.y ) - mMaxOvershoot.y, mDomainMin.y + mMaxOvershoot.y );
+ if( ( newYPosition < scrollPostPosition.y - Math::MACHINE_EPSILON_1 )
+ || ( newYPosition > scrollPostPosition.y + Math::MACHINE_EPSILON_1 ) )
+ {
+ mPrePosition.y = newYPosition;
+ mLocalStart.y = panPosition.y;
+ }
+ scrollPostPosition.y = newYPosition;
}
- scrollPostPosition.y = newYPosition;
- }
- // If we are using a fixed ruler in a particular axis, limit the maximum pages scrolled on that axis.
- if( mFixedRulerX || mFixedRulerY )
- {
- // Here we limit the maximum amount that can be moved from the starting position of the gesture to one page.
- // We do this only if we have a fixed ruler (on that axis) and the mode is enabled.
- // Note: 1.0f is subtracted to keep the value within one page size (otherwise we stray on to the page after).
- // Note: A further 1.0f is subtracted to handle a compensation that happens later within the flick handling code in SnapWithVelocity().
- // When a flick is completed, an adjustment of 1.0f is sometimes made to allow for the scenario where:
- // A flick finishes before the update thread has advanced the scroll position past the previous snap point.
- Vector2 pageSizeLimit( size.x - ( 1.0f + 1.0f ), size.y - ( 1.0f - 1.0f ) );
- Vector2 minPosition( mStartPosition.x - pageSizeLimit.x, mStartPosition.y - pageSizeLimit.y );
- Vector2 maxPosition( mStartPosition.x + pageSizeLimit.x, mStartPosition.y + pageSizeLimit.y );
-
- if( mFixedRulerX )
- {
- scrollPostPosition.x = Clamp( scrollPostPosition.x, minPosition.x, maxPosition.x );
- }
- if( mFixedRulerY )
+ // If we are using a fixed ruler in a particular axis, limit the maximum pages scrolled on that axis.
+ if( mFixedRulerX || mFixedRulerY )
{
- scrollPostPosition.y = Clamp( scrollPostPosition.y, minPosition.y, maxPosition.y );
+ // Here we limit the maximum amount that can be moved from the starting position of the gesture to one page.
+ // We do this only if we have a fixed ruler (on that axis) and the mode is enabled.
+ // Note: 1.0f is subtracted to keep the value within one page size (otherwise we stray on to the page after).
+ // Note: A further 1.0f is subtracted to handle a compensation that happens later within the flick handling code in SnapWithVelocity().
+ // When a flick is completed, an adjustment of 1.0f is sometimes made to allow for the scenario where:
+ // A flick finishes before the update thread has advanced the scroll position past the previous snap point.
+ Vector2 pageSizeLimit( size.x - ( 1.0f + 1.0f ), size.y - ( 1.0f - 1.0f ) );
+ Vector2 minPosition( mStartPosition.x - pageSizeLimit.x, mStartPosition.y - pageSizeLimit.y );
+ Vector2 maxPosition( mStartPosition.x + pageSizeLimit.x, mStartPosition.y + pageSizeLimit.y );
+
+ if( mFixedRulerX )
+ {
+ scrollPostPosition.x = Clamp( scrollPostPosition.x, minPosition.x, maxPosition.x );
+ }
+ if( mFixedRulerY )
+ {
+ scrollPostPosition.y = Clamp( scrollPostPosition.y, minPosition.y, maxPosition.y );
+ }
}
}
}
void ScrollView::OnStageConnection( int depth )
{
+ ScrollBase::OnStageConnection( depth );
+
DALI_LOG_SCROLL_STATE("[0x%X]", this);
if ( mSensitive )
DALI_LOG_SCROLL_STATE("[0x%X]", this);
StopAnimation();
+
+ ScrollBase::OnStageDisconnection();
}
ScrollView::~ScrollView()
mRulerX,
mRulerY ) );
mScrollMainInternalPrePositionConstraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) );
+ mScrollMainInternalPrePositionConstraint.AddSource( Source( detector, PanGestureDetector::Property::PANNING ) );
mScrollMainInternalPrePositionConstraint.AddSource( Source( self, Actor::Property::SIZE ) );
mScrollMainInternalPrePositionConstraint.Apply();
}
const char* const SHADOW_COLOR_PROPERTY_NAME = "ShadowColorProperty";
const char* const RENDER_SHADOW_VERTEX_SOURCE =
+
+ " attribute mediump vec2 aPosition;\n"
+ " uniform mediump mat4 uMvpMatrix;\n"
+ " uniform mediump mat4 uModelMatrix;\n"
+ " uniform vec3 uSize;\n"
+ " varying vec2 vTexCoord;\n"
+
" uniform mediump mat4 uLightCameraProjectionMatrix;\n"
" uniform mediump mat4 uLightCameraViewMatrix;\n"
"\n"
"void main()\n"
"{\n"
- " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
- " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
+ " mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n"
+ " vertexPosition.xyz *= uSize;\n"
+ " gl_Position = uMvpMatrix * vertexPosition;\n"
+ " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vertexPosition;\n"
" vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
"}\n";
const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
+ "varying mediump vec2 vTexCoord;\n"
"uniform lowp vec4 uShadowColor;\n"
+ "uniform sampler2D sTexture;\n"
+
"void main()\n"
"{\n"
" lowp float alpha;\n"
mChildrenRoot.Remove(child);
}
-void ShadowView::SetShadowPlane(Actor shadowPlane)
+void ShadowView::SetShadowPlaneBackground(Actor shadowPlaneBackground)
{
- mShadowPlaneBg = shadowPlane;
+ mShadowPlaneBg = shadowPlaneBackground;
- mShadowPlane = ImageActor::New();
+ mShadowPlane = Toolkit::ImageView::New();
mShadowPlane.SetName( "SHADOW_PLANE" );
mShadowPlane.SetParentOrigin(ParentOrigin::CENTER);
mShadowPlane.SetAnchorPoint(AnchorPoint::CENTER);
mShadowPlane.SetImage(mOutputImage);
- mShadowPlane.SetShaderEffect(mShadowRenderShader);
+ mShadowPlane.SetProperty( Toolkit::ImageView::Property::IMAGE, mShadowRenderShader );
+ SetShaderConstants();
// Rather than parent the shadow plane drawable and have constraints to move it to the same
// position, instead parent the shadow plane drawable on the shadow plane passed in.
mCachedBackgroundColor.g = color.g;
mCachedBackgroundColor.b = color.b;
- Self().SetProperty( mShadowColorPropertyIndex, mCachedShadowColor );
+ if( mShadowPlane )
+ {
+ mShadowPlane.SetProperty( mShadowColorPropertyIndex, mCachedShadowColor );
+ }
if(mRenderSceneTask)
{
mRenderSceneTask.SetClearColor( mCachedBackgroundColor );
mCameraActor.SetOrientation(Radian(Degree(180)), Vector3::YAXIS);
mCameraActor.SetPosition(DEFAULT_LIGHT_POSITION);
- mShadowRenderShader = ShaderEffect::New( RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE,
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_BLENDING ));
+
+ Property::Map customShader;
+ customShader[ "vertex-shader" ] = RENDER_SHADOW_VERTEX_SOURCE;
+ customShader[ "fragment-shader" ] = RENDER_SHADOW_FRAGMENT_SOURCE;
+
+ customShader[ "subdivide-grid-x" ] = 20;
+ customShader[ "subdivide-grid-y" ] = 20;
+
+ customShader[ "hints" ] = "output-is-transparent";
+
+ mShadowRenderShader[ "shader" ] = customShader;
// Create render targets needed for rendering from light's point of view
mSceneFromLightRenderTarget = FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 );
mBlurFilter.SetRootActor(mBlurRootActor);
mBlurFilter.SetBackgroundColor(Vector4::ZERO);
- SetShaderConstants();
+ CustomActor self = Self();
+ // Register a property that the user can use to control the blur in the internal object
+ mBlurStrengthPropertyIndex = self.RegisterProperty(BLUR_STRENGTH_PROPERTY_NAME, BLUR_STRENGTH_DEFAULT);
+
+ Constraint blurStrengthConstraint = Constraint::New<float>( mBlurFilter.GetHandleForAnimateBlurStrength(), mBlurFilter.GetBlurStrengthPropertyIndex(), EqualToConstraint() );
+ blurStrengthConstraint.AddSource( Source( self, mBlurStrengthPropertyIndex) );
+ blurStrengthConstraint.Apply();
}
void ShadowView::OnSizeSet(const Vector3& targetSize)
void ShadowView::SetShaderConstants()
{
- CustomActor self = Self();
-
- mShadowRenderShader.SetUniform( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME, Matrix::IDENTITY );
- mShadowRenderShader.SetUniform( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME, Matrix::IDENTITY );
- mShadowRenderShader.SetUniform( SHADER_SHADOW_COLOR_PROPERTY_NAME, mCachedShadowColor );
-
- Property::Index lightCameraProjectionMatrixPropertyIndex = mShadowRenderShader.GetPropertyIndex(SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME);
- Property::Index lightCameraViewMatrixPropertyIndex = mShadowRenderShader.GetPropertyIndex(SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME);
-
- Constraint projectionMatrixConstraint = Constraint::New<Dali::Matrix>( mShadowRenderShader, lightCameraProjectionMatrixPropertyIndex, EqualToConstraint() );
+ Property::Index lightCameraProjectionMatrixPropertyIndex = mShadowPlane.RegisterProperty( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME, Matrix::IDENTITY );
+ Constraint projectionMatrixConstraint = Constraint::New<Dali::Matrix>( mShadowPlane, lightCameraProjectionMatrixPropertyIndex, EqualToConstraint() );
projectionMatrixConstraint.AddSource( Source( mCameraActor, CameraActor::Property::PROJECTION_MATRIX ) );
+ projectionMatrixConstraint.Apply();
- Constraint viewMatrixConstraint = Constraint::New<Dali::Matrix>( mShadowRenderShader, lightCameraViewMatrixPropertyIndex, EqualToConstraint() );
+ Property::Index lightCameraViewMatrixPropertyIndex = mShadowPlane.RegisterProperty( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME, Matrix::IDENTITY );
+ Constraint viewMatrixConstraint = Constraint::New<Dali::Matrix>( mShadowPlane, lightCameraViewMatrixPropertyIndex, EqualToConstraint() );
viewMatrixConstraint.AddSource( Source( mCameraActor, CameraActor::Property::VIEW_MATRIX ) );
-
- projectionMatrixConstraint.Apply();
viewMatrixConstraint.Apply();
- // Register a property that the user can use to control the blur in the internal object
- mBlurStrengthPropertyIndex = self.RegisterProperty(BLUR_STRENGTH_PROPERTY_NAME, BLUR_STRENGTH_DEFAULT);
-
- Constraint blurStrengthConstraint = Constraint::New<float>( mBlurFilter.GetHandleForAnimateBlurStrength(), mBlurFilter.GetBlurStrengthPropertyIndex(), EqualToConstraint() );
- blurStrengthConstraint.AddSource( Source( self, mBlurStrengthPropertyIndex) );
- blurStrengthConstraint.Apply();
-
- // Register a property that the user can use to control the color of the shadow.
- Property::Index index = mShadowRenderShader.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
- mShadowColorPropertyIndex = self.RegisterProperty(SHADOW_COLOR_PROPERTY_NAME, mCachedShadowColor);
-
- Constraint shadowRenderShaderConstraint = Constraint::New<Dali::Vector4>( mShadowRenderShader, index, EqualToConstraint() );
- shadowRenderShaderConstraint.AddSource( Source( self, mShadowColorPropertyIndex ) );
- shadowRenderShaderConstraint.Apply();
+ mShadowColorPropertyIndex = mShadowPlane.RegisterProperty( SHADER_SHADOW_COLOR_PROPERTY_NAME, mCachedShadowColor );
}
} // namespace Internal
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/render-tasks/render-task.h>
#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/shadow-view/shadow-view.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
void Remove(Actor child);
/**
- * @copydoc Dali::Toolkit::ShadowView::SetShadowPlane(Actor shadowPlane)
+ * @copydoc Dali::Toolkit::ShadowView::SetShadowPlaneBackground(Actor shadowPlaneBackground)
*/
- void SetShadowPlane(Actor shadowPlane);
+ void SetShadowPlaneBackground(Actor shadowPlaneBackground);
/**
* @copydoc Dali::Toolkit::ShadowView::SetPointLight(Actor pointLight)
void CreateBlurFilter();
private:
- ImageActor mShadowPlane; // Shadow renders into this actor
+ Toolkit::ImageView mShadowPlane; // Shadow renders into this actor
Actor mShadowPlaneBg; // mShadowPlane renders directly in front of this actor
Actor mPointLight; // Shadow is cast from this point light
Actor mChildrenRoot; // Subtree for all user added child actors that should be rendered normally
Actor mBlurRootActor; // Root actor for blur filter processing
- ImageActor mShadowPlaneDrawable; // Positioned on top of mShadowPlane for drawing shadow image
RenderTask mRenderSceneTask;
CameraActor mCameraActor; // Constrained to same position as mPointLight and pointing at mShadowPlane
- ShaderEffect mShadowRenderShader;
+ Property::Map mShadowRenderShader;
BlurTwoPassFilter mBlurFilter;
Vector4 mCachedShadowColor; ///< Cached Shadow color.
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/public-api/text/rendering-backend.h>
#include <dali-toolkit/internal/controls/text-controls/text-font-style.h>
#include <dali-toolkit/internal/text/rendering/text-backend.h>
Actor renderableActor;
if( mRenderer )
{
- renderableActor = mRenderer->Render( mController->GetView(), self.GetHierarchyDepth() );
+ renderableActor = mRenderer->Render( mController->GetView(), TEXT_DEPTH_INDEX );
}
if( renderableActor != mRenderableActor )
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/public-api/text/rendering-backend.h>
#include <dali-toolkit/internal/controls/text-controls/text-font-style.h>
#include <dali-toolkit/internal/text/rendering/text-backend.h>
Actor renderableActor;
if( mRenderer )
{
- renderableActor = mRenderer->Render( mController->GetView(), self.GetHierarchyDepth() );
+ renderableActor = mRenderer->Render( mController->GetView(), TEXT_DEPTH_INDEX );
}
if( renderableActor != mRenderableActor )
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector4.h>
+#include <dali/public-api/object/property-map.h>
#include <dali/devel-api/object/type-registry-helper.h>
#include <cfloat>
namespace
{
-const Dali::Vector2 DEFAULT_MAX_SIZE( 400.0f, 65.0f ); ///< The maximum size of the Toolbar.
BaseHandle Create()
{
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionToolbar, "max-size", VECTOR2, MAX_SIZE )
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionToolbar, "enable-overshoot", BOOLEAN, ENABLE_OVERSHOOT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionToolbar, "scroll-view", MAP, SCROLL_VIEW )
DALI_TYPE_REGISTRATION_END()
}
case Toolkit::TextSelectionToolbar::Property::ENABLE_OVERSHOOT:
{
+ if( !impl.mScrollView )
+ {
+ impl.mScrollView = Toolkit::ScrollView::New();
+ }
impl.mScrollView.SetOvershootEnabled( value.Get< bool >() );
break;
}
+ case Toolkit::TextSelectionToolbar::Property::SCROLL_VIEW:
+ {
+ // Get a Property::Map from the property if possible.
+ Property::Map setPropertyMap;
+ if( value.Get( setPropertyMap ) )
+ {
+ impl.ConfigureScrollview( setPropertyMap );
+ }
+ break;
+ }
} // switch
} // TextSelectionToolbar
}
stencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
stencil.SetParentOrigin( ParentOrigin::CENTER );
- mScrollView = Toolkit::ScrollView::New();
+ if ( !mScrollView )
+ {
+ mScrollView = Toolkit::ScrollView::New();
+ }
SetUpScrollView();
// Toolbar must start with at least one option, adding further options with increase it's size
mTableOfButtons.SetParentOrigin( ParentOrigin::CENTER_LEFT );
mTableOfButtons.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
-
mStencilLayer.Add( stencil );
mStencilLayer.Add( mScrollView );
mScrollView.Add( mTableOfButtons );
mStencilLayer.RaiseAbove( target );
}
+void TextSelectionToolbar::ConfigureScrollview( const Property::Map& properties )
+{
+ // Set any properties specified for the label by iterating through all property key-value pairs.
+ for( unsigned int i = 0, mapCount = properties.Count(); i < mapCount; ++i )
+ {
+ const StringValuePair& propertyPair( properties.GetPair( i ) );
+
+ // Convert the property string to a property index.
+ Property::Index setPropertyIndex = mScrollView.GetPropertyIndex( propertyPair.first );
+ if( setPropertyIndex != Property::INVALID_INDEX )
+ {
+ // If the conversion worked, we have a valid property index,
+ // Set the property to the new value.
+ mScrollView.SetProperty( setPropertyIndex, propertyPair.second );
+ }
+ }
+
+ RelayoutRequest();
+}
+
+
TextSelectionToolbar::TextSelectionToolbar()
: Control( ControlBehaviour( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ) ),
mMaxSize (),
*/
const Dali::Vector2& GetPopupMaxSize() const;
+private: // Implementation
+
+ /**
+ * @copydoc Toolkit::TextSelectionToolbar::ConfigureScrollview()
+ */
+ void ConfigureScrollview( const Property::Map& properties );
+
/**
* @brief Set up scrollview to scroll Toolbar horizontally
*/
*/
void OnScrollCompleted( const Vector2& position );
-private: // Implementation
-
/**
* Construct a new TextField.
*/
EventData::EventData( DecoratorPtr decorator )
: mDecorator( decorator ),
+ mImfManager(),
mPlaceholderTextActive(),
mPlaceholderTextInactive(),
mPlaceholderTextColor( 0.8f, 0.8f, 0.8f, 0.8f ),
mScrollAfterUpdatePosition( false ),
mScrollAfterDelete( false ),
mAllTextSelected( false )
-{}
+{
+ mImfManager = ImfManager::Get();
+}
EventData::~EventData()
{}
mEventData->mUpdateCursorPosition = true;
mEventData->mScrollAfterUpdatePosition = true;
+
+ // Notify the cursor position to the imf manager.
+ if( mEventData->mImfManager )
+ {
+ mEventData->mImfManager.SetCursorPosition( mEventData->mPrimaryCursorPosition );
+ mEventData->mImfManager.NotifyCursorPosition();
+ }
}
}
}
// Get the glyphs per character table.
const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin();
- const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
// If the vector is void, there is no right to left characters.
const bool hasRightToLeftCharacters = NULL != visualToLogicalBuffer;
// Traverses glyphs in visual order. To do that use the visual to logical conversion table.
CharacterIndex visualIndex = startCharacter;
+ Length numberOfCharacters = 0u;
for( ; !matched && ( visualIndex < endCharacter ); ++visualIndex )
{
// The character in logical order.
// Get the script of the character.
const Script script = mLogicalModel->GetScript( characterLogicalOrderIndex );
- // The first glyph for that character in logical order.
- const GlyphIndex glyphLogicalOrderIndex = *( charactersToGlyphBuffer + characterLogicalOrderIndex );
// The number of glyphs for that character
const Length numberOfGlyphs = *( glyphsPerCharacterBuffer + characterLogicalOrderIndex );
+ ++numberOfCharacters;
- // Get the metrics for the group of glyphs.
- GlyphMetrics glyphMetrics;
- GetGlyphsMetrics( glyphLogicalOrderIndex,
- numberOfGlyphs,
- glyphMetrics,
- mVisualModel,
- mMetrics );
- const Vector2& position = *( positionsBuffer + glyphLogicalOrderIndex );
+ if( 0u != numberOfGlyphs )
+ {
+ // Get the first character/glyph of the group of glyphs.
+ const CharacterIndex firstVisualCharacterIndex = 1u + visualIndex - numberOfCharacters;
+ const CharacterIndex firstLogicalCharacterIndex = hasRightToLeftCharacters ? *( visualToLogicalBuffer + firstVisualCharacterIndex ) : firstVisualCharacterIndex;
+ const GlyphIndex firstLogicalGlyphIndex = *( charactersToGlyphBuffer + firstLogicalCharacterIndex );
- // Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ï»»...
- const Length numberOfCharactersInLigature = HasLigatureMustBreak( script ) ? *( charactersPerGlyphBuffer + glyphLogicalOrderIndex ) : 1u;
- const float glyphAdvance = glyphMetrics.advance / static_cast<float>( numberOfCharactersInLigature );
+ // Get the metrics for the group of glyphs.
+ GlyphMetrics glyphMetrics;
+ GetGlyphsMetrics( firstLogicalGlyphIndex,
+ numberOfGlyphs,
+ glyphMetrics,
+ mVisualModel,
+ mMetrics );
- for( GlyphIndex index = 0u; !matched && ( index < numberOfCharactersInLigature ); ++index )
- {
- // Find the mid-point of the area containing the glyph
- const float glyphCenter = -glyphMetrics.xBearing + position.x + ( static_cast<float>( index ) + 0.5f ) * glyphAdvance;
+ // Get the position of the first glyph.
+ const Vector2& position = *( positionsBuffer + firstLogicalGlyphIndex );
- if( visualX < glyphCenter )
+ // Whether the glyph can be split, like Latin ligatures fi, ff or Arabic ï»».
+ const bool isInterglyphIndex = ( numberOfCharacters > numberOfGlyphs ) && HasLigatureMustBreak( script );
+ const Length numberOfBlocks = isInterglyphIndex ? numberOfCharacters : 1u;
+ const float glyphAdvance = glyphMetrics.advance / static_cast<float>( numberOfBlocks );
+
+ GlyphIndex index = 0u;
+ for( ; !matched && ( index < numberOfBlocks ); ++index )
+ {
+ // Find the mid-point of the area containing the glyph
+ const float glyphCenter = -glyphMetrics.xBearing + position.x + ( static_cast<float>( index ) + 0.5f ) * glyphAdvance;
+
+ if( visualX < glyphCenter )
+ {
+ matched = true;
+ break;
+ }
+ }
+
+ if( matched )
{
- visualIndex += index;
- matched = true;
+ visualIndex = firstVisualCharacterIndex + index;
break;
}
- }
- if( matched )
- {
- break;
+ numberOfCharacters = 0u;
}
+
}
+
// Return the logical position of the cursor in characters.
if( !matched )
~EventData();
- DecoratorPtr mDecorator; ///< Pointer to the decorator
- std::string mPlaceholderTextActive; ///< The text to display when the TextField is empty with key-input focus
- std::string mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive
- Vector4 mPlaceholderTextColor; ///< The in/active placeholder text color
+ DecoratorPtr mDecorator; ///< Pointer to the decorator.
+ ImfManager mImfManager; ///< The Input Method Framework Manager.
+ std::string mPlaceholderTextActive; ///< The text to display when the TextField is empty with key-input focus.
+ std::string mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive.
+ Vector4 mPlaceholderTextColor; ///< The in/active placeholder text color.
/**
* This is used to delay handling events until after the model has been updated.
if( mEventData )
{
// Reset incase we are in a pre-edit state.
- ImfManager imfManager = ImfManager::Get();
- if ( imfManager )
+ if( mEventData->mImfManager )
{
- imfManager.Reset(); // Will trigger a commit message
+ mEventData->mImfManager.Reset(); // Will trigger a message ( commit, get surrounding )
}
ClearPreEditFlag();
cursorIndex = oldCursorIndex + cursorOffset;
}
- if( (cursorIndex + numberOfChars) > currentText.Count() )
+ if( ( cursorIndex + numberOfChars ) > currentText.Count() )
{
numberOfChars = currentText.Count() - cursorIndex;
}
- if( (cursorIndex + numberOfChars) <= currentText.Count() )
+ if( ( cursorIndex + numberOfChars ) <= currentText.Count() )
{
Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
Vector<Character>::Iterator last = first + numberOfChars;
else if( EventData::EDITING != mImpl->mEventData->mState &&
EventData::EDITING_WITH_GRAB_HANDLE != mImpl->mEventData->mState )
{
- if( mImpl->IsShowingPlaceholderText() && ! mImpl->IsFocusedPlaceholderAvailable() )
+ if( mImpl->IsShowingPlaceholderText() && !mImpl->IsFocusedPlaceholderAvailable() )
{
// Hide placeholder text
ResetText();
void Controller::PasteClipboardItemEvent()
{
+ // Retrieve the clipboard contents first
ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
std::string stringToPaste( notifier.GetContent() );
+
+ // Commit the current pre-edit text; the contents of the clipboard should be appended
+ mImpl->ResetImfManager();
+
+ // Paste
PasteText( stringToPaste );
}
ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
{
- bool update( false );
+ bool update = false;
bool requestRelayout = false;
std::string text;
{
if( mImpl->mEventData )
{
- ImfManager imfManager = ImfManager::Get();
-
- if( imfManager )
+ if( mImpl->mEventData->mImfManager )
{
// Notifying IMF of a cursor change triggers a surrounding text request so updating it now.
std::string text;
GetText( text );
- imfManager.SetSurroundingText( text );
+ mImpl->mEventData->mImfManager.SetSurroundingText( text );
- imfManager.SetCursorPosition( GetLogicalCursorPosition() );
- imfManager.NotifyCursorPosition();
+ mImpl->mEventData->mImfManager.SetCursorPosition( GetLogicalCursorPosition() );
+ mImpl->mEventData->mImfManager.NotifyCursorPosition();
}
}
}
namespace Internal
{
-CubeTransitionCrossEffect::CubeTransitionCrossEffect( unsigned int numRows, unsigned int numColumns, Size viewAreaSize )
-: CubeTransitionEffect( numRows, numColumns, viewAreaSize),
- mDisplacementRatio( 1.f )
+CubeTransitionCrossEffect::CubeTransitionCrossEffect( unsigned int numRows, unsigned int numColumns )
+: CubeTransitionEffect( numRows, numColumns ),
+ mDisplacementSpreadFactor( 0.008f )
{
}
-Toolkit::CubeTransitionCrossEffect CubeTransitionCrossEffect::New(unsigned int numRows, unsigned int numColumns, Size viewAreaSize)
+Toolkit::CubeTransitionCrossEffect CubeTransitionCrossEffect::New(unsigned int numRows, unsigned int numColumns )
{
// Create the implementation
- CubeTransitionCrossEffect* internalCubeTransEffect = new CubeTransitionCrossEffect( numRows, numColumns, viewAreaSize );
+ IntrusivePtr< CubeTransitionCrossEffect > internalCubeTransEffect = new CubeTransitionCrossEffect( numRows, numColumns );
// Pass ownership to CustomActor handle
- Toolkit::CubeTransitionCrossEffect cubeTransEffect( internalCubeTransEffect );
+ Toolkit::CubeTransitionCrossEffect cubeTransEffect( *internalCubeTransEffect );
//Initialization
internalCubeTransEffect->Initialize();
void CubeTransitionCrossEffect::OnInitialize()
{
- float offsetX = -mTileSize.width*0.5f;
- float offsetY = -mTileSize.height*0.5f;
unsigned int idx;
- for( unsigned int y = 0; y < mNumRows; y++ )
+ for( unsigned int y = 0; y < mRows; y++ )
{
- idx = y*mNumColumns;
- for( unsigned int x = y%2; x < mNumColumns; x=x+2)
+ for( unsigned int x = y % 2; x < mColumns; x += 2 )
{
- mBoxes[idx+x].SetZ( offsetY );
- mTiles[0][idx+x].SetZ( -offsetY );
- mTiles[1][idx+x].SetY( offsetY );
+ idx = y * mColumns + x;
+ SetTargetTop( idx );
}
- for( unsigned int x = (y+1)%2; x < mNumColumns; x=x+2)
+ for( unsigned int x = ( y + 1 ) % 2; x < mColumns; x += 2 )
{
- mTiles[0][idx+x].SetZ( -offsetX );
- mTiles[1][idx+x].SetX( offsetX );
+ idx = y * mColumns + x;
+ SetTargetRight( idx );
}
}
}
void CubeTransitionCrossEffect::OnStartTransition( Vector2 panPosition, Vector2 panDisplacement )
{
- float angle = mRotateIndex * Math::PI_2 ;
- Vector3 translation0 = mTiles[mContainerIndex][ 0 ].GetCurrentPosition()*(-2.f);
- Vector3 translation1 = mTiles[mContainerIndex][ mNumColumns ].GetCurrentPosition()*(-2.f);
-
+ float angle = Math::PI_2;
unsigned int idx;
- mDisplacementRatio = 1.f + mCubeDisplacement / (mTileSize.width + mTileSize.height);
- for( unsigned int y = 0; y < mNumRows; y++ )
+ if( panDisplacement.x < 0 )
{
- for( unsigned int x = y%2; x < mNumColumns; x=x+2) // rotate vertically
+ for( unsigned int y = 0; y < mRows; y++ )
{
- idx = y*mNumColumns + x;
- SetupAnimation( idx, -angle, Vector3::XAXIS, translation0 );
+ for( unsigned int x = y % 2; x < mColumns; x += 2 )
+ {
+ idx = y * mColumns + x;
+ SetTargetTop( idx );
+ }
+ for( unsigned int x = ( y + 1 ) % 2; x < mColumns; x += 2 )
+ {
+ idx = y * mColumns + x;
+ SetTargetRight( idx );
+ }
}
- for( unsigned int x = (y+1)%2; x < mNumColumns; x=x+2) // rotate horizontally
+ }
+ else
+ {
+ angle = -angle;
+
+ for( unsigned int y = 0; y < mRows; y++ )
{
- idx = y*mNumColumns + x;
- SetupAnimation( idx, angle, Vector3::YAXIS, translation1 );
+ for( unsigned int x = y % 2; x < mColumns; x += 2 )
+ {
+ idx = y * mColumns + x;
+ SetTargetBottom( idx );
+ }
+ for( unsigned int x = ( y + 1 ) % 2; x < mColumns; x += 2 )
+ {
+ idx = y * mColumns + x;
+ SetTargetLeft( idx );
+ }
}
}
- mAnimation.Play();
- mIsAnimating = true;
-}
+ const Vector2& size = Self().GetCurrentSize().GetVectorXY();
+ Vector2 halfSize = size * 0.5f;
+ //the centre to "explode" the tiles outwards from
+ Vector3 centre( halfSize.x, halfSize.y, -1.0f / mDisplacementSpreadFactor );
-void CubeTransitionCrossEffect::OnStopTransition()
-{
- float angle = mRotateIndex * Math::PI_2 ;
- unsigned int idx;
- for( unsigned int y = 0; y < mNumRows; y++ )
+ for( unsigned int y = 0; y < mRows; y++ )
{
- for( unsigned int x = y%2; x < mNumColumns; x=x+2)
+ for( unsigned int x = y%2; x < mColumns; x=x+2) // rotate vertically
{
- idx = y*mNumColumns + x;
- mBoxes[idx].SetOrientation( Radian(angle), Vector3::XAXIS );
+ idx = y*mColumns + x;
+ SetupAnimation( idx, x, y, -angle, Vector3::XAXIS, centre );
}
- for( unsigned int x = (y+1)%2; x < mNumColumns; x=x+2)
+ for( unsigned int x = (y+1)%2; x < mColumns; x=x+2) // rotate horizontally
{
- idx = y*mNumColumns + x;
- mBoxes[idx].SetOrientation( Radian(-angle), Vector3::YAXIS );
+ idx = y*mColumns + x;
+ SetupAnimation( idx, x, y, angle, Vector3::YAXIS, centre );
}
}
+
+ mAnimation.Play();
+ mIsAnimating = true;
}
-void CubeTransitionCrossEffect::SetupAnimation(unsigned int actorIndex, float angle,
- const Vector3 axis, Vector3 resetTranslation)
+void CubeTransitionCrossEffect::SetupAnimation( unsigned int actorIndex, unsigned int x, unsigned int y, float angle, const Vector3 axis, const Vector3& displacementCentre )
{
- if ( mFirstTransition && (!mIsToNextImage) ) // for the first transition and it is going to previous image
- {
- mTiles[mContainerIndex][actorIndex].SetOrientation( Radian( angle), axis );
- }
- else if( !mChangeTurningDirection ) // reset rotation, translation and color
- {
- mTiles[mContainerIndex][actorIndex].TranslateBy( resetTranslation );
- mTiles[mContainerIndex][actorIndex].SetOrientation( Radian( angle), axis );
- }
- mAnimation.AnimateTo( Property( mBoxes[actorIndex], Actor::Property::ORIENTATION ), Quaternion( Radian( -angle ), axis ), AlphaFunction::EASE_IN_OUT_SINE );
- Vector3 position(mBoxes[actorIndex].GetCurrentPosition());
- mAnimation.AnimateTo( Property( mBoxes[actorIndex], Actor::Property::POSITION ), position * mDisplacementRatio + Vector3( 0.f, 0.f, mCubeDisplacement ), AlphaFunction::BOUNCE );
- mAnimation.AnimateTo( Property( mTiles[mContainerIndex^1][actorIndex], Actor::Property::COLOR ), HALF_BRIGHTNESS, AlphaFunction::EASE_OUT );
- mAnimation.AnimateTo( Property( mTiles[mContainerIndex][actorIndex], Actor::Property::COLOR ), FULL_BRIGHTNESS, AlphaFunction::EASE_IN );
+ const Vector2& size = Self().GetCurrentSize().GetVectorXY();
+ Vector2 halfSize = size * 0.5f;
+
+ //the position of the centre of the front face tile
+ Vector3 position( halfSize.x * (2.0f * x + 1.0f) / mColumns, halfSize.y * (2.0f * y + 1.0f ) / mRows, 0.0f );
+
+ Vector3 direction = position - displacementCentre;
+ float length = direction.Length();
+ direction.Normalize();
+
+ float deltaLength = mCubeDisplacement / direction.z; //the length along the direction vector such that the projected direction onto the z axis is equal to mCubeDisplacement
+
+ Vector3 newPosition = ( direction * (length + deltaLength ) ) + displacementCentre;
+ Vector3 newLocalPosition = newPosition - position;
+
+ mAnimation.AnimateTo( Property( mBoxes[ actorIndex ], Actor::Property::ORIENTATION ), Quaternion( Radian( -angle ), axis ), AlphaFunction::EASE_IN_OUT_SINE );
+ mAnimation.AnimateTo( Property( mBoxes[ actorIndex ], Actor::Property::POSITION ), newLocalPosition, AlphaFunction::BOUNCE );
+
+ mAnimation.AnimateTo( Property( mCurrentTiles[ actorIndex ], Actor::Property::COLOR ), HALF_BRIGHTNESS, AlphaFunction::EASE_OUT );
+ mAnimation.AnimateTo( Property( mTargetTiles[ actorIndex ], Actor::Property::COLOR ), FULL_BRIGHTNESS, AlphaFunction::EASE_IN );
}
} // namespace Internal
/**
* @copydoc Toolkit::CubeTransitionCrossEffect::New
*/
- static Toolkit::CubeTransitionCrossEffect New(unsigned int numRows, unsigned int numColumns, Size viewAreaSize);
+ static Toolkit::CubeTransitionCrossEffect New( unsigned int numRows, unsigned int numColumns );
protected:
*/
virtual void OnStartTransition( Vector2 panPosition, Vector2 panDisplacement );
- /**
- * @copydoc Toolkit::Internal::CubeTransitionEffect::OnStopTransition
- */
- virtual void OnStopTransition();
-
private:
/**
- * Construct a new CubeTransitionCrossEffect object
+ * @brief Construct a new CubeTransitionCrossEffect object
+ *
* @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
*/
- CubeTransitionCrossEffect( unsigned int numRows, unsigned int numColumns, Size viewAreaSize );
+ CubeTransitionCrossEffect( unsigned int numRows, unsigned int numColumns );
/**
- * Set up animation to an Actor
+ * @brief Set up animation to an Actor
+ * This will also displace the cubes in the z direction by mCubeDisplacement and spread them apart on the xy plane
+ * given by the closeness of displacementCentre to the XY plane at 0.
+ *
* @param[in] actorIndex The index of the cube in the cube array
* @param[in] angle The angle of the rotation animation
- * @param[in] axis The axis of the rotation animation
- * @param[in] resetTranslation The translation used to reset the actor position before animation
+ * @param[in] the centre to "explode" the tiles outwards from
*/
-
- void SetupAnimation( unsigned int actorIndex, float angle, const Vector3 axis, Vector3 resetTranslation );
+ void SetupAnimation( unsigned int actorIndex, unsigned int x, unsigned int y, float angle, const Vector3 axis, const Vector3& displacementCentre );
private:
- float mDisplacementRatio;
+ /**
+ * The factor that determines how spread apart from each other the cubes will go
+ * when they are displaced during the transition animation.
+ * The larger the value the more the spread apart the cubes will be.
+ * it should be in the range (0.0, +infinity)
+ */
+ float mDisplacementSpreadFactor;
}; //class CubeTransitionCrossEffect
// Helpers for public-api forwarding methods
-inline Internal::CubeTransitionCrossEffect& GetImpl(Dali::Toolkit::CubeTransitionCrossEffect& obj)
+inline Internal::CubeTransitionCrossEffect& GetImpl( Dali::Toolkit::CubeTransitionCrossEffect& obj )
{
- DALI_ASSERT_ALWAYS(obj);
+ DALI_ASSERT_ALWAYS( obj );
- Dali::BaseObject& handle = obj.GetBaseObject();
+ Dali::RefObject& handle = obj.GetImplementation();
- return static_cast<Internal::CubeTransitionCrossEffect&>(handle);
+ return static_cast< Internal::CubeTransitionCrossEffect& >( handle );
}
-inline const Internal::CubeTransitionCrossEffect& GetImpl(const Dali::Toolkit::CubeTransitionCrossEffect& obj)
+inline const Internal::CubeTransitionCrossEffect& GetImpl( const Dali::Toolkit::CubeTransitionCrossEffect& obj )
{
- DALI_ASSERT_ALWAYS(obj);
+ DALI_ASSERT_ALWAYS( obj );
- const Dali::BaseObject& handle = obj.GetBaseObject();
+ const Dali::RefObject& handle = obj.GetImplementation();
- return static_cast<const Internal::CubeTransitionCrossEffect&>(handle);
+ return static_cast< const Internal::CubeTransitionCrossEffect& >( handle );
}
} // namespace Toolkit
// EXTERNAL INCLUDES
#include <cstring> // for strcmp
-#include <dali/public-api/common/stage.h>
-#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/object/type-registry-helper.h>
-#include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali/integration-api/debug.h>
namespace Dali
{
DALI_TYPE_REGISTRATION_END()
+const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
+ attribute mediump vec2 aPosition;\n
+ varying mediump vec2 vTexCoord;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ uniform mediump vec3 uSize;\n
+ uniform mediump vec4 uTextureRect;\n
+ \n
+ void main()\n
+ {\n
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
+ vertexPosition.xyz *= uSize;\n
+ vertexPosition = uMvpMatrix * vertexPosition;\n
+ \n
+ vTexCoord = aPosition + vec2(0.5);\n
+ vTexCoord = mix(uTextureRect.xy, uTextureRect.zw, vTexCoord);\n
+
+ gl_Position = vertexPosition;\n
+ }\n
+);
+
+const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
+ varying mediump vec2 vTexCoord;\n
+ uniform sampler2D sTexture;\n
+ uniform lowp vec4 uColor;\n
+ uniform lowp vec4 uSamplerRect;
+ \n
+ void main()\n
+ {\n
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
+ }\n
+);
+
+Actor CreateTile( const Vector4& samplerRect )
+{
+ Actor tile = Actor::New();
+ tile.SetAnchorPoint( AnchorPoint::CENTER );
+ tile.RegisterProperty( "uTextureRect", samplerRect );
+ return tile;
+}
+
+
+Geometry CreateQuadGeometry()
+{
+ const float halfWidth = 0.5f;
+ const float halfHeight = 0.5f;
+ struct QuadVertex { Vector2 position;};
+ QuadVertex quadVertexData[4] =
+ {
+ { Vector2(-halfWidth, -halfHeight) },
+ { Vector2( halfWidth, -halfHeight) },
+ { Vector2(-halfWidth, halfHeight) },
+ { Vector2( halfWidth, halfHeight) }
+ };
+
+ Property::Map quadVertexFormat;
+ quadVertexFormat["aPosition"] = Property::VECTOR2;
+ PropertyBuffer quadVertices = PropertyBuffer::New( quadVertexFormat, 4 );
+ quadVertices.SetData(quadVertexData);
+
+ // Create the geometry object
+ Geometry geometry = Geometry::New();
+ geometry.AddVertexBuffer( quadVertices );
+ geometry.SetGeometryType( Geometry::TRIANGLE_STRIP );
+
+ return geometry;
+}
+
}
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 );
-CubeTransitionEffect::CubeTransitionEffect( unsigned int numRows, unsigned int numColumns, Size viewAreaSize )
-: mNumRows( numRows ),
- mNumColumns( numColumns ),
- mViewAreaSize( viewAreaSize ),
- mRotateIndex( 0 ),
- mContainerIndex( 0 ),
- mChangeTurningDirection( false ),
- mIsToNextImage( true ),
- mIsImageLoading( false ),
- mAnimationDuration( 1.f ),
+CubeTransitionEffect::CubeTransitionEffect( unsigned int rows, unsigned int columns )
+: Control( ControlBehaviour( 0 ) ),
+ mRows( rows ),
+ mColumns( columns ),
mIsAnimating( false ),
mIsPaused( false ),
- mCubeDisplacement( 0.f ),
- mFirstTransition( true ),
- mBufferIndex( 0 )
+ mAnimationDuration( 1.f ),
+ mCubeDisplacement( 0.f )
{
}
{
}
-void CubeTransitionEffect::Initialize()
+void CubeTransitionEffect::SetTargetRight( unsigned int idx )
+{
+ mBoxType[ idx ] = RIGHT;
+
+ mBoxes[ idx ].SetProperty(Actor::Property::PARENT_ORIGIN_Z, 1.0f - mTileSize.x * 0.5f );
+
+ mTargetTiles[ idx ].SetParentOrigin( Vector3( 1.f, 0.5f, 0.5f) );
+ mTargetTiles[ idx ].SetOrientation( Degree( 90.f ), Vector3::YAXIS );
+}
+
+void CubeTransitionEffect::SetTargetLeft( unsigned int idx )
{
- //create root actor for the cube transition effect, only visible during the transition
- mRoot = Actor::New();
- mRoot.SetParentOrigin( ParentOrigin::CENTER );
- mRoot.SetAnchorPoint( AnchorPoint::CENTER );
- mRoot.SetVisible(false);
-
- // create two groups of tiles,
- // and one group of actors (cubes) serving as parents of every two tiles (one from each image).
- unsigned int totalNum = mNumColumns* mNumRows;
- mBoxes.resize( totalNum );
- mTiles[0].resize( totalNum );
- mTiles[1].resize( totalNum );
- mTileSize = Vector2( mViewAreaSize.width / mNumColumns, mViewAreaSize.height / mNumRows );
- const Vector3 basePosition( (-mViewAreaSize.width + mTileSize.width) * 0.5f,
- (-mViewAreaSize.height + mTileSize.height) * 0.5f,
- -mTileSize.width * 0.5f );
-
- Image placeHolder = BufferImage::WHITE();
- for( unsigned int y = 0; y < mNumRows; y++ )
+ mBoxType[ idx ] = LEFT;
+
+ mBoxes[ idx ].SetProperty(Actor::Property::PARENT_ORIGIN_Z, 1.0f - mTileSize.x * 0.5f );
+
+ mTargetTiles[ idx ].SetParentOrigin( Vector3( 0.f, 0.5f, 0.5f) );
+ mTargetTiles[ idx ].SetOrientation( Degree( -90.f ), Vector3::YAXIS );
+}
+
+void CubeTransitionEffect::SetTargetBottom( unsigned int idx )
+{
+ mBoxType[ idx ] = BOTTOM;
+
+ mBoxes[ idx ].SetProperty(Actor::Property::PARENT_ORIGIN_Z, 1.0f - mTileSize.y * 0.5f );
+
+ mTargetTiles[ idx ].SetParentOrigin( Vector3( 0.5f, 0.f, 0.5f) );
+ mTargetTiles[ idx ].SetOrientation( Degree( 90.f ), Vector3::XAXIS );
+}
+
+void CubeTransitionEffect::SetTargetTop( unsigned int idx )
+{
+ mBoxType[ idx ] = TOP;
+
+ mBoxes[ idx ].SetProperty(Actor::Property::PARENT_ORIGIN_Z, 1.0f - mTileSize.y * 0.5f );
+
+ mTargetTiles[ idx ].SetParentOrigin( Vector3( 0.5f, 1.f, 0.5f) );
+ mTargetTiles[ idx ].SetOrientation( Degree( -90.f ), Vector3::XAXIS );
+}
+
+void CubeTransitionEffect::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+ mTileSize = Vector2( size.x / mColumns, size.y / mRows );
+
+ mBoxRoot.SetProperty( Actor::Property::SIZE_WIDTH, size.x );
+ mBoxRoot.SetProperty( Actor::Property::SIZE_HEIGHT, size.y );
+ mBoxRoot.SetProperty( Actor::Property::SIZE_DEPTH, 1.0f );
+
+ for( size_t i = 0; i < mBoxes.size(); ++i )
{
- float positionY = y * mTileSize.height + basePosition.y;
- for( unsigned int x = 0; x < mNumColumns; x++)
+ mBoxes[ i ].SetProperty( Actor::Property::SIZE_WIDTH, mTileSize.x );
+ mBoxes[ i ].SetProperty( Actor::Property::SIZE_HEIGHT, mTileSize.y );
+
+ switch( mBoxType[i] )
{
- unsigned int idx = y*mNumColumns + x;
- Actor actor( Actor::New() );
- mBoxes[idx] = actor;
- actor.SetParentOrigin( ParentOrigin::CENTER );
- actor.SetAnchorPoint( AnchorPoint::CENTER );
- actor.SetPosition( x * mTileSize.width + basePosition.x,
- positionY,
- basePosition.z );
- mRoot.Add( actor );
-
- mTiles[ 0 ][idx] = CreateTile( placeHolder, FULL_BRIGHTNESS );
- actor.Add( mTiles[ 0 ][idx] );
-
- mTiles[ 1 ][idx] = CreateTile( placeHolder, HALF_BRIGHTNESS );
- actor.Add( mTiles[ 1 ][idx] );
+ case LEFT:
+ case RIGHT:
+ {
+ mBoxes[ i ].SetProperty( Actor::Property::PARENT_ORIGIN_Z, 1.0f - mTileSize.x * 0.5f );
+ mBoxes[ i ].SetProperty( Actor::Property::SIZE_DEPTH, mTileSize.x );
+ break;
+ }
+ case BOTTOM:
+ case TOP:
+ {
+ mBoxes[ i ].SetProperty( Actor::Property::PARENT_ORIGIN_Z, 1.0f - mTileSize.y * 0.5f );
+ mBoxes[ i ].SetProperty( Actor::Property::SIZE_DEPTH, mTileSize.y );
+ break;
+ }
}
}
- // helper actor to create a off-screen image using shader effect
- mEmptyImage = ImageActor::New( placeHolder );
- mEmptyImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- mEmptyImage.SetParentOrigin( ParentOrigin::CENTER );
- mEmptyImage.SetAnchorPoint( AnchorPoint::CENTER );
- mFullImageCreator = FullAreaImageCreator::New();
- mEmptyImage.SetShaderEffect( mFullImageCreator );
- Stage::GetCurrent().Add(mEmptyImage);
-
- // set up off-screen render task
- RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
- mOffScreenTask = taskList.CreateTask();
- mOffScreenTask.SetSourceActor(mEmptyImage);
- mOffScreenTask.SetExclusive(true);
- mOffScreenBuffer[0] = FrameBufferImage::New(mViewAreaSize.x, mViewAreaSize.y);
- mOffScreenBuffer[1] = FrameBufferImage::New(mViewAreaSize.x, mViewAreaSize.y);
- mOffScreenTask.SetTargetFrameBuffer(mOffScreenBuffer[mBufferIndex]);
- mOffScreenTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
+ for( ActorArray::iterator it = mCurrentTiles.begin(); it != mCurrentTiles.end(); ++it )
+ {
+ it->SetProperty( Actor::Property::SIZE_WIDTH, mTileSize.x );
+ it->SetProperty( Actor::Property::SIZE_HEIGHT, mTileSize.y );
+ }
+ for( ActorArray::iterator it = mTargetTiles.begin(); it != mTargetTiles.end(); ++it )
+ {
+ it->SetProperty( Actor::Property::SIZE_WIDTH, mTileSize.x );
+ it->SetProperty( Actor::Property::SIZE_HEIGHT, mTileSize.y );
+ }
+}
+
+void CubeTransitionEffect::Initialize()
+{
+ Self().RegisterProperty( "uTextureRect", Vector4( 0.0f, 0.0f, 1.0f, 1.0f ) );
+
+ mBoxType.Resize(mColumns * mRows);
+
+ //create the box parents
+ mBoxRoot = Actor::New();
+ mBoxRoot.SetParentOrigin( ParentOrigin::CENTER );
+ mBoxRoot.SetAnchorPoint( AnchorPoint::CENTER );
+
+ mCurrentTiles.clear();
+ mTargetTiles.clear();
+
+ mCurrentTiles.reserve( mColumns * mRows );
+ mTargetTiles.reserve( mColumns * mRows );
+
+ Vector2 gridSizeInv( 1.0f / mColumns, 1.0f / mRows );
+ Vector3 offset( 0.5f * gridSizeInv.x, 0.5f * gridSizeInv.y, 0.0f );
+
+ Vector3 anchor;
+ for( unsigned int y = 0; y < mRows; ++y, anchor.y += 1.0f / mRows )
+ {
+ anchor.x = 0.0f;
+ for( unsigned int x = 0; x <mColumns; ++x, anchor.x += 1.0f / mColumns )
+ {
+ Vector4 textureRect( anchor.x, anchor.y, anchor.x + gridSizeInv.x, anchor.y + gridSizeInv.y );
+
+ Actor currentTile = CreateTile( textureRect );
+ currentTile.SetProperty( Actor::Property::COLOR, FULL_BRIGHTNESS );
+ currentTile.SetParentOrigin( ParentOrigin::CENTER );
+ mCurrentTiles.push_back( currentTile );
+
+ Actor targetTile = CreateTile( textureRect );
+ targetTile.SetProperty( Actor::Property::COLOR, HALF_BRIGHTNESS );
+ mTargetTiles.push_back( targetTile );
+
+ Actor box = Actor::New();
+ box.SetParentOrigin( anchor + offset );
+ box.SetAnchorPoint( AnchorPoint::CENTER );
+
+ box.Add( currentTile );
+ box.Add( targetTile );
+
+ mBoxRoot.Add( box );
+
+ mBoxes.push_back( box );
+ }
+ }
OnInitialize();
}
-ImageActor CubeTransitionEffect::CreateTile( Image image, const Vector4& color )
+void CubeTransitionEffect::OnStageConnection( int depth )
{
- ImageActor tile = ImageActor::New( image );
- tile.SetParentOrigin( ParentOrigin::CENTER );
- tile.SetAnchorPoint( AnchorPoint::CENTER );
- tile.SetSize( mTileSize );
- tile.SetColorMode( Dali::USE_OWN_COLOR );
- tile.SetColor( color );
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- return tile;
+ Material material = Material::New( shader );
+
+ if( mCurrentImage )
+ {
+ material.AddTexture( mCurrentImage, "sTexture" );
+ }
+ mCurrentRenderer = Renderer::New( geometry, material );
+
+ mCurrentRenderer.SetDepthIndex( depth );
+ Self().AddRenderer( mCurrentRenderer );
+}
+
+void CubeTransitionEffect::OnStageDisconnection()
+{
+ if( mCurrentRenderer )
+ {
+ Self().RemoveRenderer( mCurrentRenderer );
+
+ for( ActorArray::iterator it = mCurrentTiles.begin(); it != mCurrentTiles.end(); ++it )
+ {
+ it->RemoveRenderer( mCurrentRenderer );
+ }
+ mCurrentRenderer.Reset();
+ }
+
+ if( mTargetRenderer )
+ {
+ for( ActorArray::iterator it = mTargetTiles.begin(); it != mTargetTiles.end(); ++it )
+ {
+ it->RemoveRenderer( mTargetRenderer );
+ }
+ mTargetRenderer.Reset();
+ }
}
void CubeTransitionEffect::SetTransitionDuration( float duration )
return mCubeDisplacement;
}
-Actor CubeTransitionEffect::GetRoot()
+bool CubeTransitionEffect::IsTransitioning()
{
- return mRoot;
+ return mIsAnimating;
}
-bool CubeTransitionEffect::IsTransiting()
+void CubeTransitionEffect::SetCurrentImage( Image image )
{
- return mIsImageLoading || mIsAnimating;
-}
+ mCurrentImage = image;
-void CubeTransitionEffect::SetCurrentImage( ImageActor imageActor )
-{
- mContainerIndex = std::abs(mRotateIndex) % 2;
- SetImage( imageActor );
-}
+ if( mCurrentRenderer )
+ {
+ Material material = mCurrentRenderer.GetMaterial();
-void CubeTransitionEffect::SetTargetImage( ImageActor imageActor )
-{
- mContainerIndex = std::abs( mRotateIndex+1 ) % 2;
- SetImage( imageActor );
+ int index = material.GetTextureIndex("sTexture" );
+ if( index != -1 )
+ {
+ material.SetTextureImage( index, mCurrentImage );
+ }
+ else
+ {
+ material.AddTexture( mCurrentImage, "sTexture" );
+ }
+ }
}
-void CubeTransitionEffect::SetImage( ImageActor imageActor )
+void CubeTransitionEffect::SetTargetImage( Image image )
{
- mCurrentImage = imageActor;
+ mTargetImage = image;
- 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( resourceImage && resourceImage.GetLoadingState() != ResourceLoadingSucceeded )
+ if( mTargetRenderer )
{
- mIsImageLoading = true;
- resourceImage.LoadingFinishedSignal().Connect( this, &CubeTransitionEffect::OnImageLoaded );
- }
- else
- {
- mIsImageLoading = false;
- PrepareTiles( image );
+ Material material = mTargetRenderer.GetMaterial();
+ material.AddTexture( mTargetImage, "sTexture" );
}
}
void CubeTransitionEffect::StartTransition( bool toNextImage )
{
+ Vector3 size = Self().GetCurrentSize();
if( toNextImage )
{
- StartTransition( Vector2( mViewAreaSize.width, mViewAreaSize.height*0.5f ), Vector2( -10.f, 0.f ) );
+ StartTransition( Vector2(size.x* 0.5f, size.y*0.5f), Vector2( -10.f, 0.f ) );
}
else
{
- StartTransition( Vector2( 0, mViewAreaSize.height*0.5f ), Vector2( 10.f, 0.f ));
+ StartTransition( Vector2(size.x* 0.5f, size.y*0.5f), Vector2( 10.f, 0.f ));
}
}
void CubeTransitionEffect::StartTransition( Vector2 panPosition, Vector2 panDisplacement )
{
- mRoot.SetVisible( true );
- mCurrentImage.SetVisible( false );
- bool toNextImage = ( panDisplacement.x < 0 ) ? true : false;
- if( mIsToNextImage != toNextImage )
+ if( !mCurrentRenderer )
{
- mChangeTurningDirection = true;
+ DALI_LOG_ERROR( "Trying to transition a cube transition without an image set" );
+ return;
}
- else
+
+ //create the target renderer
+ Material material = Material::New( mCurrentRenderer.GetMaterial().GetShader() );
+ if( mTargetImage )
{
- mChangeTurningDirection = false;
+ material.AddTexture( mTargetImage, "sTexture" );
}
- mIsToNextImage = toNextImage;
+ Geometry geometry = mCurrentRenderer.GetGeometry();
+ mTargetRenderer = Renderer::New( geometry, material );
- if( mIsToNextImage )
+ mTargetRenderer.SetDepthIndex( mCurrentRenderer.GetDepthIndex() );
+
+ for( size_t i = 0; i < mBoxes.size(); ++i )
{
- mRotateIndex += 1.f;
+ mBoxes[ i ].SetProperty( Actor::Property::ORIENTATION, Quaternion( Radian( 0.0f ), Vector3::XAXIS ) );
}
- else
+
+ for( ActorArray::iterator it = mCurrentTiles.begin(); it != mCurrentTiles.end(); ++it )
+ {
+ it->SetParentOrigin( Vector3( 0.5f, 0.5f, 1.0f) );
+ it->SetProperty( Actor::Property::ORIENTATION, Quaternion( Radian( 0.0f ), Vector3::XAXIS ) );
+ it->AddRenderer( mCurrentRenderer );
+ }
+ for( ActorArray::iterator it = mTargetTiles.begin(); it != mTargetTiles.end(); ++it )
{
- mRotateIndex -= 1.f;
+ it->AddRenderer( mTargetRenderer );
}
+ Self().RemoveRenderer( mCurrentRenderer );
+ Self().Add( mBoxRoot );
+
if(mAnimation)
{
mAnimation.Clear();
mAnimation.Reset();
}
+
mAnimation = Animation::New( mAnimationDuration );
- mAnimation.FinishedSignal().Connect(this, &CubeTransitionEffect::OnTransitionFinished);
+ mAnimation.FinishedSignal().Connect( this, &CubeTransitionEffect::OnTransitionFinished );
OnStartTransition( panPosition, panDisplacement );
}
void CubeTransitionEffect::StopTransition()
{
- if( mIsAnimating )
- {
- mAnimation.Clear();
- mAnimation.Reset();
- mIsPaused = false;
-
- //reset the position of the cubes
- //reset the color of the tiles
- //all these status should be the same as the final state when the transition animation is finished completely
- const Vector3 basePosition( (-mViewAreaSize.width + mTileSize.width) * 0.5f,
- (-mViewAreaSize.height + mTileSize.height) * 0.5f,
- -mTileSize.width * 0.5f );
- unsigned int anotherIndex = mContainerIndex^1;
- for( unsigned int y = 0; y < mNumRows; y++ )
- {
- float positionY = y * mTileSize.height + basePosition.y;
- for( unsigned int x = 0; x < mNumColumns; x++)
- {
- unsigned int idx = y*mNumColumns + x;
- mBoxes[idx].SetPosition( x * mTileSize.width + basePosition.x,
- positionY,
- basePosition.z );
- mTiles[mContainerIndex][idx].SetColor( FULL_BRIGHTNESS );
- mTiles[anotherIndex][idx].SetColor( HALF_BRIGHTNESS);
- }
- }
-
- // reset the rotation of the cubes, which is different process for different derived classes
- OnStopTransition();
-
- mRoot.SetVisible(false);
- mCurrentImage.SetVisible(true);
- mIsAnimating = false;
- mFirstTransition = false;
- }
-}
-
-void CubeTransitionEffect::OnImageLoaded(ResourceImage image)
-{
- mIsImageLoading = false;
- PrepareTiles( image );
+ ResetToInitialState();
}
-/**
- * Set sub-image to each tile.
- * @param[in] image The image content of the imageActor for transition
- */
-void CubeTransitionEffect::PrepareTiles( Image image )
+void CubeTransitionEffect::ResetToInitialState()
{
- // Fit the image to view area, while keeping the aspect; FitKeepAspectRatio(imageSize, viewAreaSize)
- float scale = std::min( mViewAreaSize.width / image.GetWidth(), mViewAreaSize.height / image.GetHeight() );
- Vector2 imageSize(image.GetWidth()*scale, image.GetHeight()*scale);
+ mAnimation.Clear();
+ mAnimation.Reset();
+ mIsAnimating = false;
- mFullImageCreator.SetEffectImage(image);
- mFullImageCreator.SetRegionSize(mViewAreaSize, imageSize);
+ Self().Remove( mBoxRoot );
- mOffScreenTask.SetTargetFrameBuffer(mOffScreenBuffer[mBufferIndex]);
- mOffScreenTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
+ for( size_t i = 0; i < mBoxes.size(); ++i )
+ {
+ mBoxes[ i ].SetProperty( Actor::Property::ORIENTATION, Quaternion( Radian( 0.0f ), Vector3::XAXIS ) );
+ }
- ImageActor::PixelArea pixelArea( 0, 0, mViewAreaSize.x / mNumColumns, mViewAreaSize.y / mNumRows);
+ for( ActorArray::iterator it = mCurrentTiles.begin(); it != mCurrentTiles.end(); ++it )
+ {
+ it->SetParentOrigin( Vector3( 0.5f, 0.5f, 1.0f) );
+ it->SetProperty( Actor::Property::ORIENTATION, Quaternion( Radian( 0.0f ), Vector3::XAXIS ) );
+ it->SetProperty( Actor::Property::COLOR, FULL_BRIGHTNESS );
+ }
+ if( mCurrentRenderer )
+ {
+ for( ActorArray::iterator it = mCurrentTiles.begin(); it != mCurrentTiles.end(); ++it )
+ {
+ it->RemoveRenderer( mCurrentRenderer );
+ }
+ Self().AddRenderer( mCurrentRenderer );
+ }
- for( unsigned int y = 0; y < mNumRows; y++ )
+ for( ActorArray::iterator it = mTargetTiles.begin(); it != mTargetTiles.end(); ++it )
+ {
+ it->SetProperty( Actor::Property::COLOR, HALF_BRIGHTNESS );
+ }
+ if( mTargetRenderer )
{
- pixelArea.y = y * pixelArea.height;
- for( unsigned int x = 0; x < mNumColumns; x++)
+ for( ActorArray::iterator it = mTargetTiles.begin(); it != mTargetTiles.end(); ++it )
{
- pixelArea.x = x * pixelArea.width;
- unsigned int idx = y*mNumColumns + x;
- mTiles[mContainerIndex][idx].SetImage( mOffScreenBuffer[mBufferIndex]);
- mTiles[mContainerIndex][idx].SetPixelArea( pixelArea );
+ it->RemoveRenderer( mTargetRenderer );
}
}
}
-
void CubeTransitionEffect::OnTransitionFinished(Animation& source)
{
- mRoot.SetVisible(false);
- mCurrentImage.SetVisible(true);
- mIsAnimating = false;
- mFirstTransition = false;
+
+ std::swap( mCurrentTiles, mTargetTiles );
+ std::swap( mCurrentRenderer, mTargetRenderer );
+ std::swap( mCurrentImage, mTargetImage );
+
+ ResetToInitialState();
//Emit signal
- Toolkit::CubeTransitionEffect handle( this );
+ Toolkit::CubeTransitionEffect handle( GetOwner() );
mTransitionCompletedSignal.Emit( handle, mCurrentImage );
}
// EXTERNAL INCLUDES
#include <dali/public-api/animation/animation.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/images/resource-image.h>
+#include <dali/devel-api/rendering/renderer.h>
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/transition-effects/cube-transition-effect.h>
+#include <dali-toolkit/public-api/controls/control-impl.h>
namespace Dali
{
{
/**
- * 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:
float GetCubeDisplacement() const;
/**
- * @copydoc Toolkit::CubeTransitionEffect::GetRoot
- */
- Actor GetRoot();
-
- /**
- * @copydoc Toolkit::CubeTransitionEffect::IsTransiting
+ * @copydoc Toolkit::CubeTransitionEffect::IsTransitioning
*/
- bool IsTransiting();
+ bool IsTransitioning();
/**
* @copydoc Toolkit::CubeTransitionEffect::SetFirstImage
*/
- void SetCurrentImage(ImageActor imageActor);
+ void SetCurrentImage( Image image );
/**
* @copydoc Toolkit::CubeTransitionEffect::SetTargetImage
*/
- void SetTargetImage(ImageActor imageActor);
+ void SetTargetImage( Image image );
/**
* @copydoc Toolkit::CubeTransitionEffect::StartTransition(bool)
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:
/**
* 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(ResourceImage image);
+protected:
+ void SetTargetLeft( unsigned int idx );
+ void SetTargetRight( unsigned int idx );
+ void SetTargetTop( unsigned int idx );
+ void SetTargetBottom( unsigned int idx );
- /**
- * Set sub-image to each tile.
- * @param[in] image The image content of the imageActor for transition
- */
- void PrepareTiles( Image image );
+private:
/**
* Callback function of transition animation finished
*/
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;
- std::vector< Actor > 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;
+ Renderer mCurrentRenderer;
+ Renderer mTargetRenderer;
+
+ Image mCurrentImage;
+ Image mTargetImage;
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;
{
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 Internal
{
-const float CubeTransitionFoldEffect::mDisplacementRatio = 1.4142f; //sqrt(2)
-
-CubeTransitionFoldEffect::CubeTransitionFoldEffect( unsigned int numRows, unsigned int numColumns, Size viewAreaSize )
-: CubeTransitionEffect( numRows, numColumns, viewAreaSize)
+CubeTransitionFoldEffect::CubeTransitionFoldEffect( unsigned int numRows, unsigned int numColumns )
+: CubeTransitionEffect( numRows, numColumns )
{
}
-Toolkit::CubeTransitionFoldEffect CubeTransitionFoldEffect::New(unsigned int numRows, unsigned int numColumns, Size viewAreaSize)
+Toolkit::CubeTransitionFoldEffect CubeTransitionFoldEffect::New(unsigned int numRows, unsigned int numColumns )
{
// Create the implementation
- CubeTransitionFoldEffect* internalCubeTransEffect = new CubeTransitionFoldEffect( numRows, numColumns, viewAreaSize );
+ IntrusivePtr< CubeTransitionFoldEffect > internalCubeTransEffect = new CubeTransitionFoldEffect( numRows, numColumns );
// Pass ownership to CustomActor handle
- Toolkit::CubeTransitionFoldEffect cubeTransEffect( internalCubeTransEffect );
+ Toolkit::CubeTransitionFoldEffect cubeTransEffect( *internalCubeTransEffect );
//Initialization
internalCubeTransEffect->Initialize();
void CubeTransitionFoldEffect::OnInitialize()
{
- float offset = mTileSize.width*0.5f;
unsigned int idx;
- for( unsigned int y = 0; y < mNumRows; y++ )
+ for( unsigned int y = 0; y < mRows; y++ )
{
- idx = y*mNumColumns;
- for( unsigned int x = y%2; x < mNumColumns; x=x+2)
+ idx = y*mColumns;
+ for( unsigned int x = y%2; x < mColumns; x=x+2)
{
- mTiles[0][idx+x].SetZ( offset );
- mTiles[1][idx+x].SetX( offset );
+ SetTargetLeft( idx + x );
}
- for( unsigned int x = (y+1)%2; x < mNumColumns; x=x+2)
+ for( unsigned int x = (y+1)%2; x < mColumns; x=x+2)
{
- mTiles[0][idx+x].SetZ( offset );
- mTiles[1][idx+x].SetX( -offset );
+ SetTargetRight( idx + x );
}
}
}
void CubeTransitionFoldEffect::OnStartTransition( Vector2 panPosition, Vector2 panDisplacement )
{
- float angle = mRotateIndex * Math::PI_2 ;
- Vector3 translation0 = mTiles[mContainerIndex][ 0 ].GetCurrentPosition()*(-2.f);
- Vector3 translation1 = mTiles[mContainerIndex][ mNumColumns ].GetCurrentPosition()*(-2.f);
+ float angle = Math::PI_2;
unsigned int idx;
-
- for( unsigned int y = 0; y < mNumRows; y++ )
+ if( panDisplacement.x < 0 )
{
- for( unsigned int x = y%2; x < mNumColumns; x=x+2)
+ for( unsigned int y = 0; y < mRows; y++ )
{
- idx = y*mNumColumns + x;
- SetupAnimation( idx, -angle, translation0 );
+ idx = y*mColumns;
+ for( unsigned int x = y%2; x < mColumns; x=x+2)
+ {
+ SetTargetLeft( idx + x );
+ }
+ for( unsigned int x = (y+1)%2; x < mColumns; x=x+2)
+ {
+ SetTargetRight( idx + x );
+ }
}
- for( unsigned int x = (y+1)%2; x < mNumColumns; x=x+2)
+ }
+ else
+ {
+ angle = -angle;
+
+ for( unsigned int y = 0; y < mRows; y++ )
{
- idx = y*mNumColumns + x;
- SetupAnimation( idx, angle, translation1 );
+ idx = y*mColumns;
+ for( unsigned int x = y%2; x < mColumns; x=x+2)
+ {
+ SetTargetRight( idx + x );
+ }
+ for( unsigned int x = (y+1)%2; x < mColumns; x=x+2)
+ {
+ SetTargetLeft( idx + x );
+ }
}
}
- mAnimation.Play();
- mIsAnimating = true;
-}
-
-void CubeTransitionFoldEffect::OnStopTransition()
-{
- float angle = mRotateIndex * Math::PI_2 ;
- unsigned int idx;
- for( unsigned int y = 0; y < mNumRows; y++ )
+ for( unsigned int y = 0; y < mRows; y++ )
{
- idx = y*mNumColumns;
- for( unsigned int x = y%2; x < mNumColumns; x=x+2)
+ idx = y*mColumns;
+ for( unsigned int x = y%2; x < mColumns; x=x+2)
{
- mBoxes[idx+x].SetOrientation( Radian(angle), Vector3::YAXIS );
+ SetupAnimation( idx + x, x, angle );
}
- for( unsigned int x = (y+1)%2; x < mNumColumns; x=x+2)
+ for( unsigned int x = (y+1)%2; x < mColumns; x=x+2)
{
- mBoxes[idx+x].SetOrientation( Radian(-angle), Vector3::YAXIS );
+ SetupAnimation( idx + x, x, -angle );
}
}
+
+ mAnimation.Play();
+ mIsAnimating = true;
}
-void CubeTransitionFoldEffect::SetupAnimation(unsigned int actorIndex, float angle, Vector3 resetTranslation)
+void CubeTransitionFoldEffect::SetupAnimation( unsigned int actorIndex, unsigned int x, float angle )
{
- Actor currentCube = mBoxes[actorIndex];
- ImageActor sideTile = mTiles[mContainerIndex][actorIndex];
- ImageActor frontTile = mTiles[mContainerIndex^1][actorIndex];
- if ( mFirstTransition && (!mIsToNextImage) ) // for the first transition, it is going to previous image
- {
- sideTile.SetOrientation( Radian( angle), Vector3::YAXIS );
- }
- else if( !mChangeTurningDirection ) // reset rotation, translation and color
- {
- sideTile.TranslateBy( resetTranslation );
- sideTile.SetOrientation( Radian( angle), Vector3::YAXIS );
- }
- mAnimation.AnimateTo( Property( currentCube, Actor::Property::ORIENTATION ), Quaternion( Radian( -angle ), Vector3::YAXIS ), AlphaFunction::LINEAR );
- Vector3 position(currentCube.GetCurrentPosition());
- mAnimation.AnimateTo( Property( currentCube, Actor::Property::POSITION ), Vector3( position.x*mDisplacementRatio, position.y, position.z ), AlphaFunction::BOUNCE );
- mAnimation.AnimateTo( Property( frontTile, Actor::Property::COLOR ), HALF_BRIGHTNESS, AlphaFunction::EASE_OUT );
- mAnimation.AnimateTo( Property( sideTile, Actor::Property::COLOR ), FULL_BRIGHTNESS, AlphaFunction::EASE_IN );
+ //rotate and translate the cube such that the edges remain in constant contact
+ //calculate the maximum distance the cube has to move when it the box has rotated 45 degrees
+ //ie distance from of centre of square to a vertex is given by:
+ // distance = width / sqrt(2)
+ //therefore the delta distance the cube should move is given by:
+ // delta_distance = ( width / 2 ) - distance
+ //re-arranging we get:
+ // delta_distance = ( width / 2 ) * ( sqrt(2) - 1 )
+ //accumulating over the length of the row we get:
+ // delta_distance_at_x = x * delta_distance;
+
+ float delta = (float)x * mTileSize.x * ( 1.4142f - 1.0f );
+
+ Vector3 position( mBoxes[ actorIndex ].GetCurrentPosition() );
+ mAnimation.AnimateTo( Property( mBoxes[ actorIndex ], Actor::Property::ORIENTATION ), Quaternion( Radian( angle ), Vector3::YAXIS ), AlphaFunction::LINEAR );
+ mAnimation.AnimateTo( Property( mBoxes[ actorIndex ], Actor::Property::POSITION_X ), position.x + delta, AlphaFunction::BOUNCE );
+
+ mAnimation.AnimateTo( Property( mCurrentTiles[ actorIndex ], Actor::Property::COLOR ), HALF_BRIGHTNESS, AlphaFunction::EASE_OUT );
+ mAnimation.AnimateTo( Property( mTargetTiles[ actorIndex ], Actor::Property::COLOR ), FULL_BRIGHTNESS, AlphaFunction::EASE_IN );
}
} // namespace Internal
/**
* @copydoc Toolkit::CubeTransitionFoldEffect::New
*/
- static Toolkit::CubeTransitionFoldEffect New(unsigned int numRows, unsigned int numColumns, Size viewAreaSize);
+ static Toolkit::CubeTransitionFoldEffect New( unsigned int numRows, unsigned int numColumns );
protected:
*/
virtual void OnStartTransition( Vector2 panPosition, Vector2 panDisplacement );
- /**
- * @copydoc Toolkit::Internal::CubeTransitionEffect::OnStopTransition
- */
- virtual void OnStopTransition();
private:
/**
* Construct a new CubeTransitionFoldEffect object
* @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
*/
- CubeTransitionFoldEffect( unsigned int numRows, unsigned int numColumns, Size viewAreaSize );
+ CubeTransitionFoldEffect( unsigned int numRows, unsigned int numColumns );
/**
* Set up animation to an Actor
* @param[in] actorIndex The index of the cube in the cube array
* @param[in] angle The angle of the rotation animation
- * @param[in] resetTranslation The translation used to reset the actor position before animation
*/
-
- void SetupAnimation( unsigned int actorIndex, float angle, Vector3 resetTranslation );
-
-private:
-
- static const float mDisplacementRatio;
+ void SetupAnimation( unsigned int actorIndex, unsigned int x, float angle );
}; //class CubeTransitionFoldEffect
// Helpers for public-api forwarding methods
-inline Internal::CubeTransitionFoldEffect& GetImpl(Dali::Toolkit::CubeTransitionFoldEffect& obj)
+inline Internal::CubeTransitionFoldEffect& GetImpl( Dali::Toolkit::CubeTransitionFoldEffect& obj )
{
- DALI_ASSERT_ALWAYS(obj);
+ DALI_ASSERT_ALWAYS( obj );
- Dali::BaseObject& handle = obj.GetBaseObject();
+ Dali::RefObject& handle = obj.GetImplementation();
- return static_cast<Internal::CubeTransitionFoldEffect&>(handle);
+ return static_cast< Internal::CubeTransitionFoldEffect& >( handle );
}
-inline const Internal::CubeTransitionFoldEffect& GetImpl(const Dali::Toolkit::CubeTransitionFoldEffect& obj)
+inline const Internal::CubeTransitionFoldEffect& GetImpl( const Dali::Toolkit::CubeTransitionFoldEffect& obj )
{
- DALI_ASSERT_ALWAYS(obj);
+ DALI_ASSERT_ALWAYS( obj );
- const Dali::BaseObject& handle = obj.GetBaseObject();
+ const Dali::RefObject& handle = obj.GetImplementation();
- return static_cast<const Internal::CubeTransitionFoldEffect&>(handle);
+ return static_cast< const Internal::CubeTransitionFoldEffect& >( handle );
}
} // namespace Toolkit
namespace Internal
{
-CubeTransitionWaveEffect::CubeTransitionWaveEffect( unsigned int numRows, unsigned int numColumns, Size viewAreaSize )
-: CubeTransitionEffect( numRows, numColumns, viewAreaSize),
+CubeTransitionWaveEffect::CubeTransitionWaveEffect( unsigned int numRows, unsigned int numColumns )
+: CubeTransitionEffect( numRows, numColumns ),
mSaddleAA( 1.f ),
mSaddleBB( 1.f ),
mSaddleB( 1.f )
{
}
-Toolkit::CubeTransitionWaveEffect CubeTransitionWaveEffect::New(unsigned int numRows, unsigned int numColumns, Size viewAreaSize)
+Toolkit::CubeTransitionWaveEffect CubeTransitionWaveEffect::New(unsigned int numRows, unsigned int numColumns )
{
// Create the implementation
- CubeTransitionWaveEffect* internalCubeTransEffect = new CubeTransitionWaveEffect( numRows, numColumns, viewAreaSize );
+ IntrusivePtr< CubeTransitionWaveEffect > internalCubeTransEffect = new CubeTransitionWaveEffect( numRows, numColumns );
// Pass ownership to CustomActor handle
- Toolkit::CubeTransitionWaveEffect cubeTransEffect( internalCubeTransEffect );
+ Toolkit::CubeTransitionWaveEffect cubeTransEffect( *internalCubeTransEffect );
//Initialization
internalCubeTransEffect->Initialize();
void CubeTransitionWaveEffect::OnInitialize()
{
- float offset = -mTileSize.width * 0.5f;
- unsigned int totalNum = mNumColumns* mNumRows;
- for( unsigned int idx = 0; idx < totalNum; idx++ )
+ for( unsigned int idx = 0; idx < mTargetTiles.size(); idx++ )
{
- mTiles[ 0 ][idx].SetZ( -offset );
- mTiles[ 1 ][idx].SetX( offset );
+ SetTargetRight( idx );
}
}
void CubeTransitionWaveEffect::OnStartTransition( Vector2 panPosition, Vector2 panDisplacement )
{
- float direc = mIsToNextImage ? 1.f : -1.f;
- CalculateSaddleSurfaceParameters( panPosition, panDisplacement*direc );
+ bool forward = panDisplacement.x < 0.0;
+ CalculateSaddleSurfaceParameters( panPosition, forward ? panDisplacement : -panDisplacement );
- float angle = mRotateIndex * 90.0f ;
- Vector3 translation = mTiles[mContainerIndex][ 0 ].GetCurrentPosition()*(-2.f);
+ float angle = Math::PI_2;
unsigned int idx;
- unsigned int totalNum = mNumColumns* mNumRows;
- if( mFirstTransition && (!mIsToNextImage) ) // the first transition is transiting to previous image
+ if( forward )
{
- for( unsigned int idx = 0; idx < totalNum; idx++ )
+ for( idx = 0; idx < mTargetTiles.size(); idx++ )
{
- mTiles[mContainerIndex][idx].SetOrientation( Degree( angle), Vector3::YAXIS );
+ SetTargetRight( idx );
}
}
- else if(!mChangeTurningDirection) // reset rotation, translation
+ else
{
- for( unsigned int idx = 0; idx < totalNum; idx++ )
+ angle = -angle;
+ for( idx = 0; idx < mTargetTiles.size(); idx++ )
{
- mTiles[mContainerIndex][idx].TranslateBy( translation );
- mTiles[mContainerIndex][idx].SetOrientation( Degree( angle), Vector3::YAXIS );
+ SetTargetLeft( idx );
}
}
float thirdAnimationDuration = mAnimationDuration / 3.f;
- unsigned int anotherIndex = mContainerIndex^1;
- for( unsigned int y = 0; y < mNumRows; y++ )
+ for( unsigned int y = 0; y < mRows; y++ )
{
- for( unsigned int x = 0; x < mNumColumns; x++)
+ idx = y * mColumns;
+ for( unsigned int x = 0; x < mColumns; x++, idx++)
{
- idx = y*mNumColumns + x;
// the delay value is within 0.f ~ 2.f*thirdAnimationDuration
- float delay = thirdAnimationDuration * CalculateDelay(x*mTileSize.width,y*mTileSize.height);
+ float delay = thirdAnimationDuration * CalculateDelay( x * mTileSize.width, y * mTileSize.height, forward );
- mAnimation.AnimateTo( Property( mBoxes[idx], Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( -angle ) ), Vector3::YAXIS ),
+ mAnimation.AnimateTo( Property( mBoxes[ idx ], Actor::Property::ORIENTATION ), Quaternion( Radian( -angle ), Vector3::YAXIS ),
AlphaFunction::EASE_OUT_SINE, TimePeriod( delay, thirdAnimationDuration ) );
mAnimation.AnimateBy( Property( mBoxes[idx], Actor::Property::POSITION ), Vector3( 0.f, 0.f, -mCubeDisplacement ),
AlphaFunction::BOUNCE, TimePeriod( delay, thirdAnimationDuration ) );
- mAnimation.AnimateTo( Property( mTiles[anotherIndex][idx], Actor::Property::COLOR ), HALF_BRIGHTNESS,
+
+ mAnimation.AnimateTo( Property( mCurrentTiles[ idx ], Actor::Property::COLOR ), HALF_BRIGHTNESS,
AlphaFunction::EASE_OUT, TimePeriod( delay, thirdAnimationDuration ) );
- mAnimation.AnimateTo( Property( mTiles[mContainerIndex][idx], Actor::Property::COLOR ), FULL_BRIGHTNESS,
+ mAnimation.AnimateTo( Property( mTargetTiles[ idx ], Actor::Property::COLOR ), FULL_BRIGHTNESS,
AlphaFunction::EASE_IN, TimePeriod( delay, thirdAnimationDuration ) );
}
}
mIsAnimating = true;
}
-void CubeTransitionWaveEffect::OnStopTransition()
-{
- float angle = - mRotateIndex * 90.0f ;
- unsigned int totalNum = mNumRows * mNumColumns;
- for( unsigned int idx = 0; idx < totalNum; idx++ )
- {
- mBoxes[idx].SetOrientation( Degree( angle ), Vector3::YAXIS );
- }
-}
-
void CubeTransitionWaveEffect::CalculateSaddleSurfaceParameters( Vector2 position, Vector2 displacement )
{
+ const Vector2& size = Self().GetCurrentSize().GetVectorXY();
// the line passes through 'position' and has the direction of 'displacement'
float coefA, coefB, coefC; //line equation: Ax+By+C=0;
coefA = displacement.y;
//distance from (0,0) to the line
float distanceTopLeft = fabsf(coefC) * inversedSqrtAABB;
//distance from (viewAreaSize.x, viewAreaSize.y) to the line
- float distanceBottomRight = fabsf(coefA*mViewAreaSize.x+coefB*mViewAreaSize.y+coefC) * inversedSqrtAABB;
+ float distanceBottomRight = fabsf(coefA*size.x+coefB*size.y+coefC) * inversedSqrtAABB;
saddleA = std::max( distanceTopLeft, distanceBottomRight );
//foot of a perpendicular: (viewAreaSize.x,0) to the line
- float footX1 = ( coefB*coefB*mViewAreaSize.x - coefA*coefC) * inversedAABB;
- float footY1 = (-coefA*coefB*mViewAreaSize.x - coefB*coefC) * inversedAABB;
+ float footX1 = ( coefB*coefB*size.x - coefA*coefC) * inversedAABB;
+ float footY1 = (-coefA*coefB*size.x - coefB*coefC) * inversedAABB;
//foot of a perpendicular: (0,viewAreaSize.y) to the line
- float footX2 = (-coefA*coefB*mViewAreaSize.y - coefA*coefC) * inversedAABB;
- float footY2 = ( coefA*coefA*mViewAreaSize.y - coefB*coefC) * inversedAABB;
+ float footX2 = (-coefA*coefB*size.y - coefA*coefC) * inversedAABB;
+ float footY2 = ( coefA*coefA*size.y - coefB*coefC) * inversedAABB;
mSaddleBB = (footX1-footX2)*(footX1-footX2) + (footY1-footY2)*(footY1-footY2);
mTranslation = Vector2(-footX2,-footY2);
}
else
{
//distance from(viewAreaSize.x,0) to the line
- float distanceTopRight = fabsf(coefA*mViewAreaSize.x+coefC) * inversedSqrtAABB;
+ float distanceTopRight = fabsf(coefA*size.x+coefC) * inversedSqrtAABB;
//distance from(0,viewAreaSize.y) to the line
- float distanceBottomLeft = fabsf(coefB*mViewAreaSize.y+coefC) * inversedSqrtAABB;
+ float distanceBottomLeft = fabsf(coefB*size.y+coefC) * inversedSqrtAABB;
saddleA = std::max( distanceTopRight, distanceBottomLeft );
//foot of a perpendicular: (0,0) to the line
float footX3 = (-coefA*coefC) * inversedAABB;
float footY3 = (-coefB*coefC) * inversedAABB;
//foot of a perpendicular: (viewAreaSize.x,viewAreaSize.y) to the line
- float footX4 = ( coefB*coefB*mViewAreaSize.x - coefA*coefB*mViewAreaSize.y - coefA*coefC) * inversedAABB;
- float footY4 = (-coefA*coefB*mViewAreaSize.x + coefA*coefA*mViewAreaSize.y - coefB*coefC) * inversedAABB;
+ float footX4 = ( coefB*coefB*size.x - coefA*coefB*size.y - coefA*coefC) * inversedAABB;
+ float footY4 = (-coefA*coefB*size.x + coefA*coefA*size.y - coefB*coefC) * inversedAABB;
mSaddleBB = (footX3-footX4)*(footX3-footX4) + (footY3-footY4)*(footY3-footY4);
mTranslation = Vector2(-footX3, -footY3);
}
mRotation.Normalize();
}
-float CubeTransitionWaveEffect::CalculateDelay(float x, float y)
+float CubeTransitionWaveEffect::CalculateDelay( float x, float y, bool forward )
{
float tx = x + mTranslation.x;
float ty = y + mTranslation.y;
float valueX = mRotation.x * tx - mRotation.y * ty;
float valueY = mRotation.y * tx + mRotation.x * ty;
- if(!mIsToNextImage) // to previous image
+ if( !forward ) // to previous image
{
valueX = mSaddleB - valueX;
}
/**
* @copydoc Toolkit::CubeTransitionWaveEffect::New
*/
- static Toolkit::CubeTransitionWaveEffect New(unsigned int numRows, unsigned int numColumns, Size viewAreaSize);
+ static Toolkit::CubeTransitionWaveEffect New(unsigned int numRows, unsigned int numColumns );
protected:
*/
virtual void OnStartTransition( Vector2 panPosition, Vector2 panDisplacement );
- /**
- * @copydoc Toolkit::Internal::CubeTransitionEffect::OnStopTransition
- */
- virtual void OnStopTransition();
-
private:
/**
* Construct a new CubeTransitionWaveEffect object
* @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
*/
- CubeTransitionWaveEffect( unsigned int numRows, unsigned int numColumns, Size viewAreaSize );
+ CubeTransitionWaveEffect( unsigned int numRows, unsigned int numColumns );
/**
* The Saddle surface (Hyperbolic paraboloid)function is used to calculate the delay of rotating animation for each cube
* @param[in] position The press down position of panGesture
* @param[in] displacement The displacement vector of panGesture
*/
- void CalculateSaddleSurfaceParameters( Vector2 position, Vector2 displacement );
+ void CalculateSaddleSurfaceParameters( Vector2 position, Vector2 displacement);
/**
* Calculate the delay of the animation for each cube
* @param[in] y The Y coordinate of the cube
* @return The delay time of the animation
*/
- float CalculateDelay(float x, float y);
+ float CalculateDelay( float x, float y, bool forward );
private:
// Helpers for public-api forwarding methods
-inline Internal::CubeTransitionWaveEffect& GetImpl(Dali::Toolkit::CubeTransitionWaveEffect& obj)
+inline Internal::CubeTransitionWaveEffect& GetImpl( Dali::Toolkit::CubeTransitionWaveEffect& obj )
{
- DALI_ASSERT_ALWAYS(obj);
+ DALI_ASSERT_ALWAYS( obj );
- Dali::BaseObject& handle = obj.GetBaseObject();
+ Dali::RefObject& handle = obj.GetImplementation();
- return static_cast<Internal::CubeTransitionWaveEffect&>(handle);
+ return static_cast< Internal::CubeTransitionWaveEffect& >( handle );
}
-inline const Internal::CubeTransitionWaveEffect& GetImpl(const Dali::Toolkit::CubeTransitionWaveEffect& obj)
+inline const Internal::CubeTransitionWaveEffect& GetImpl( const Dali::Toolkit::CubeTransitionWaveEffect& obj )
{
- DALI_ASSERT_ALWAYS(obj);
+ DALI_ASSERT_ALWAYS( obj );
- const Dali::BaseObject& handle = obj.GetBaseObject();
+ const Dali::RefObject& handle = obj.GetImplementation();
- return static_cast<const Internal::CubeTransitionWaveEffect&>(handle);
+ return static_cast< const Internal::CubeTransitionWaveEffect& >( handle );
}
} // namespace Toolkit
enum ControlDepthIndexRanges
{
- BACKGROUND_DEPTH_INDEX = static_cast<int>( -Dali::Layer::TREE_DEPTH_MULTIPLIER * 0.1f ),
+ BACKGROUND_DEPTH_INDEX = -Dali::Layer::TREE_DEPTH_MULTIPLIER / 10,
CONTENT_DEPTH_INDEX = 0,
- DECORATION_DEPTH_INDEX = static_cast<int>( Dali::Layer::TREE_DEPTH_MULTIPLIER * 0.1f )
+ TEXT_DEPTH_INDEX = Dali::Layer::TREE_DEPTH_MULTIPLIER / 100,
+ DECORATION_DEPTH_INDEX = Dali::Layer::TREE_DEPTH_MULTIPLIER / 10
};
/**
void Control::OnStageConnection( int depth )
{
- unsigned int controlRendererCount = Self().GetRendererCount();
- for( unsigned int i(0); i<controlRendererCount; ++i )
- {
- Renderer controlRenderer = Self().GetRendererAt(i);
- if( controlRenderer )
- {
- controlRenderer.SetDepthIndex( CONTENT_DEPTH_INDEX+depth );
- }
- }
-
if( mImpl->mBackgroundRenderer)
{
mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 1;
-const unsigned int TOOLKIT_MICRO_VERSION = 6;
+const unsigned int TOOLKIT_MICRO_VERSION = 7;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
},
"textselectiontoolbar":
{
- "enable-overshoot":true
+ "enable-overshoot":true,
+ "scroll-view":
+ {
+ "overshoot-animation-speed":120.0,
+ "overshoot-size":[480.0,42.0]
+ }
},
"scrollview":
{
},
"textselectiontoolbar":
{
- "enable-overshoot":true
+ "enable-overshoot":true,
+ "scroll-view":
+ {
+ "overshoot-animation-speed":360.0,
+ "overshoot-size":[720.0,130.0]
+ }
},
"scrollview":
{
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.1.6
+Version: 1.1.7
Release: 1
Group: System/Libraries
License: Apache-2.0, BSD-2.0, MIT