// 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
DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
// change the blend color
- factory.ResetRenderer( colorRenderer, Color::CYAN );
+ Actor actor;
+ factory.ResetRenderer( colorRenderer, actor, Color::CYAN );
colorRenderer.CreatePropertyMap( resultMap );
colorValue = resultMap.Find( "blend-color", Property::VECTOR4 );
#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;
}
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uBlendColor", actualValue ) );
DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
- bool isNewRenderer = factory.ResetRenderer( controlRenderer, Color::GREEN );
- DALI_TEST_CHECK( !isNewRenderer );
+ factory.ResetRenderer( controlRenderer, actor, Color::GREEN );
application.SendNotification();
application.Render(0);
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uBlendColor", actualValue ) );
DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
Image bufferImage = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
- isNewRenderer = factory.ResetRenderer( controlRenderer, bufferImage );
- DALI_TEST_CHECK( isNewRenderer );
+ factory.ResetRenderer( controlRenderer, actor, bufferImage );
Actor actor2 = Actor::New();
actor2.SetSize(200.f, 200.f);
application.Render(0);
Image bufferImage = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
- bool isNewRenderer = factory.ResetRenderer( controlRenderer, bufferImage );
- DALI_TEST_CHECK( !isNewRenderer );
+ factory.ResetRenderer( controlRenderer, actor, bufferImage );
application.SendNotification();
application.Render(0);
- isNewRenderer = factory.ResetRenderer( controlRenderer, Color::RED );
- DALI_TEST_CHECK( isNewRenderer );
+ factory.ResetRenderer( controlRenderer, actor, Color::RED );
Actor actor2 = Actor::New();
actor2.SetSize(200.f, 200.f);
}
ControlRenderer::ControlRenderer(Internal::ControlRenderer *impl)
-: BaseHandle(impl)
+: BaseHandle( impl )
{
}
void ControlRenderer::SetSize( const Vector2& size )
{
- GetImplementation( *this ).SetSize(size);
+ GetImplementation( *this ).SetSize( size );
}
const Vector2& ControlRenderer::GetSize() const
void ControlRenderer::SetDepthIndex( float index )
{
- GetImplementation( *this ).SetDepthIndex(index);
+ GetImplementation( *this ).SetDepthIndex( index );
}
float ControlRenderer::GetDepthIndex() const
void ControlRenderer::SetOnStage( Actor& actor )
{
- GetImplementation( *this ).SetOnStage(actor);
+ GetImplementation( *this ).SetOnStage( actor );
}
void ControlRenderer::SetOffStage( Actor& actor )
{
- GetImplementation( *this ).SetOffStage(actor);
+ GetImplementation( *this ).SetOffStage( actor );
}
void ControlRenderer::RemoveAndReset( Actor& actor )
return GetImplementation( *this ).GetControlRenderer( color );
}
-bool RendererFactory::ResetRenderer( ControlRenderer& renderer, const Vector4& color )
+void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const Vector4& color )
{
- return GetImplementation( *this ).ResetRenderer( renderer, color );
+ GetImplementation( *this ).ResetRenderer( renderer, actor, color );
}
ControlRenderer RendererFactory::GetControlRenderer( float borderSize, const Vector4& borderColor )
return GetImplementation( *this ).GetControlRenderer( image );
}
-bool RendererFactory::ResetRenderer( ControlRenderer& renderer, const Image& image )
+void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const Image& image )
{
- return GetImplementation( *this ).ResetRenderer( renderer, image );
+ GetImplementation( *this ).ResetRenderer( renderer, actor, image );
}
ControlRenderer RendererFactory::GetControlRenderer( const std::string& url )
return GetImplementation( *this ).GetControlRenderer( url );
}
-bool RendererFactory::ResetRenderer( ControlRenderer& renderer, const std::string& url )
+void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const std::string& url )
{
- return GetImplementation( *this ).ResetRenderer( renderer, url );
+ GetImplementation( *this ).ResetRenderer( renderer, actor, url );
}
-bool RendererFactory::ResetRenderer( ControlRenderer& renderer, const Property::Map& propertyMap )
+void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap )
{
- return GetImplementation( *this ).ResetRenderer( renderer, propertyMap );
+ GetImplementation( *this ).ResetRenderer( renderer, actor, propertyMap );
}
} // namespace Toolkit
* else the renderer would be a handle to a newly created internal color renderer.
*
* @param[in] renderer The ControlRenderer to reset
+ * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] color The color to be rendered.
- * @return Whether a new internal control renderer is created.
*/
- bool ResetRenderer( ControlRenderer& renderer, const Vector4& color );
+ void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Vector4& color );
/**
* @brief Request the control renderer to renderer the border with the given size and color.
* else the renderer would be a handle to a newly created internal image renderer.
*
* @param[in] renderer The ControlRenderer to reset
+ * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] image The Image to be rendered.
- * @return Whether a new internal control renderer is created.
*/
- bool ResetRenderer( ControlRenderer& renderer, const Image& image );
+ void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Image& image );
/**
* @brief Request the control renderer to render the given resource at the url.
* else the renderer would be a handle to a newly created internal image renderer.
*
* @param[in] renderer The ControlRenderer to reset
+ * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] url The URL to the resource to be rendered.
- * @return Whether a new internal control renderer is created.
*/
- bool ResetRenderer( ControlRenderer& renderer, const std::string& url );
+ void ResetRenderer( ControlRenderer& renderer, Actor& actor, const std::string& url );
/**
* if the current renderer is capable of merging with the property map the reset the renderer with the merged properties
* else the renderer would be a handle to a newly created internal renderer.
*
+ * @param[in] renderer The ControlRenderer to reset
+ * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] propertyMap The map contains the properties required by the control renderer
* Depends on the content of the map, different kind of renderer would be returned.
- * @return Whether a new internal control renderer is created.
*/
- bool ResetRenderer( ControlRenderer& renderer, const Property::Map& propertyMap );
+ void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap );
private:
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
};
};
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
mImage = image;
- bool newRendererCreated = false;
- if( mRenderer )
- {
- newRendererCreated = Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, image );
- }
- else
- {
- mRenderer = Toolkit::RendererFactory::Get().GetControlRenderer( image );
- newRendererCreated = true;
- }
-
- //we need to inform any newly created renderers if it is on stage
- if( newRendererCreated && Self().OnStage() )
- {
- CustomActor self = Self();
- mRenderer.SetOnStage( self );
- }
-
+ Actor self = Self();
+ Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, self, image );
mImageSize = image ? ImageDimensions( image.GetWidth(), image.GetHeight() ) : ImageDimensions( 0, 0 );
}
}
{
mPropertyMap = map;
- bool newRendererCreated = false;
- if( mRenderer )
- {
- newRendererCreated = Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, mPropertyMap );
- }
- else
- {
- mRenderer = Toolkit::RendererFactory::Get().GetControlRenderer( mPropertyMap );
- newRendererCreated = true;
- }
-
- //we need to inform any newly created renderers if it is on stage
- CustomActor self = Self();
- if( newRendererCreated && self.OnStage() )
- {
- mRenderer.SetOnStage( self );
- }
+ Actor self = Self();
+ Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, self, mPropertyMap );
int width = 0;
Property::Value* widthValue = mPropertyMap.Find( "width" );
mUrl = url;
- bool newRendererCreated = false;
- if( mRenderer )
- {
- newRendererCreated = Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, mUrl );
- }
- else
- {
- mRenderer = Toolkit::RendererFactory::Get().GetControlRenderer( mUrl );
- newRendererCreated = true;
- }
-
- //we need to inform any newly created renderers if it is on stage
- if( newRendererCreated && Self().OnStage() )
- {
- CustomActor self = Self();
- mRenderer.SetOnStage( self );
- }
+ Actor self = Self();
+ Toolkit::RendererFactory::Get().ResetRenderer( mRenderer, self, mUrl );
mImageSize = ResourceImage::GetImageSize( mUrl );
}
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;
}
#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 );
if(mShadowView)
{
mPointLight.Unparent();
- mShadowPlane.Unparent();
+ mShadowPlaneBackground.Unparent();
mShadowView.Unparent();
}
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
{
}
-void BorderRenderer::DoInitialize( const Property::Map& propertyMap )
+void BorderRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
Property::Value* color = propertyMap.Find( COLOR_NAME );
if( !( color && color->Get(mBorderColor) ) )
void BorderRenderer::DoSetOnStage( Actor& actor )
{
+ InitializeRenderer();
+
mBorderColorIndex = (mImpl->mRenderer).RegisterProperty( COLOR_UNIFORM_NAME, mBorderColor );
if( mBorderColor.a < 1.f )
{
map.Insert( SIZE_NAME, mBorderSize );
}
-void BorderRenderer::InitializeRenderer( Renderer& renderer )
+void BorderRenderer::InitializeRenderer()
{
Geometry geometry = mFactoryCache.GetGeometry( RendererFactoryCache::BORDER_GEOMETRY );
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 );
}
- if( !renderer )
- {
- Material material = Material::New( shader );
- renderer = Renderer::New( geometry, material );
- }
- else
- {
- mImpl->mRenderer.SetGeometry( geometry );
- Material material = mImpl->mRenderer.GetMaterial();
- if( material )
- {
- material.SetShader( shader );
- }
- }
+ Material material = Material::New( shader );
+ mImpl->mRenderer = Renderer::New( geometry, material );
}
void BorderRenderer::SetBorderColor(const Vector4& color)
{
mBorderColor = color;
- if( mImpl->mIsOnStage )
+ if( mImpl->mRenderer )
{
(mImpl->mRenderer).SetProperty( mBorderColorIndex, color );
if( color.a < 1.f && (mImpl->mRenderer).GetMaterial().GetBlendMode() != BlendingMode::ON)
{
mBorderSize = size;
- if( mImpl->mIsOnStage )
+ if( mImpl->mRenderer )
{
(mImpl->mRenderer).SetProperty( mBorderSizeIndex, size );
}
/**
* @copydoc ControlRenderer::DoInitialize
*/
- virtual void DoInitialize( const Property::Map& propertyMap );
-
- /**
- * @copydoc ControlRenderer::InitializeRenderer
- */
- virtual void InitializeRenderer( Renderer& renderer );
+ virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
* @copydoc ControlRenderer::DoSetOnStage
private:
/**
+ * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
+ */
+ void InitializeRenderer();
+
+ /**
* Create the geometry which presents the border.
* @return The border geometry
*/
{
}
-void ColorRenderer::DoInitialize( const Property::Map& propertyMap )
+void ColorRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
Property::Value* color = propertyMap.Find( COLOR_NAME );
if( !( color && color->Get(mBlendColor) ) )
//ToDo: renderer applies the offset
}
+void ColorRenderer::DoSetOnStage( Actor& actor )
+{
+ InitializeRenderer();
+}
+
void ColorRenderer::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
map.Insert( COLOR_NAME, mBlendColor );
}
-void ColorRenderer::InitializeRenderer( Renderer& renderer )
+void ColorRenderer::InitializeRenderer()
{
Geometry geometry = mFactoryCache.GetGeometry( RendererFactoryCache::QUAD_GEOMETRY );
if( !geometry )
mFactoryCache.SaveShader( RendererFactoryCache::COLOR_SHADER, shader );
}
- if( !renderer )
- {
- Material material = Material::New( shader );
- renderer = Renderer::New( geometry, material );
- }
- else
- {
- mImpl->mRenderer.SetGeometry( geometry );
- Material material = mImpl->mRenderer.GetMaterial();
- if( material )
- {
- material.SetShader( shader );
- }
- }
+ Material material = Material::New( shader );
+ mImpl->mRenderer = Renderer::New( geometry, material );
- mBlendColorIndex = renderer.RegisterProperty( COLOR_UNIFORM_NAME, mBlendColor );
+ mBlendColorIndex = mImpl->mRenderer.RegisterProperty( COLOR_UNIFORM_NAME, mBlendColor );
if( mBlendColor.a < 1.f )
{
- renderer.GetMaterial().SetBlendMode( BlendingMode::ON );
+ mImpl->mRenderer.GetMaterial().SetBlendMode( BlendingMode::ON );
}
}
{
mBlendColor = color;
- if( mImpl->mIsOnStage )
+ if( mImpl->mRenderer )
{
(mImpl->mRenderer).SetProperty( mBlendColorIndex, color );
if( color.a < 1.f && (mImpl->mRenderer).GetMaterial().GetBlendMode() != BlendingMode::ON)
/**
* @copydoc ControlRenderer::DoInitialize
*/
- virtual void DoInitialize( const Property::Map& propertyMap );
+ virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc ControlRenderer::InitializeRenderer
+ * @copydoc ControlRenderer::DoSetOnStage
*/
- virtual void InitializeRenderer( Renderer& renderer );
+ virtual void DoSetOnStage( Actor& actor );
public:
void SetColor( const Vector4& color );
private:
+ /**
+ * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
+ */
+ void InitializeRenderer();
+
+private:
// Undefined
ColorRenderer( const ColorRenderer& colorRenderer );
Internal::ControlRenderer::Impl::Impl()
: mCustomShader(NULL),
mDepthIndex( 0.0f ),
- mIsOnStage( false )
+ mFlags( 0 )
{
}
struct Internal::ControlRenderer::Impl
{
+ enum Flags
+ {
+ IS_ON_STAGE = 1,
+ IS_FROM_CACHE = 1 << 1
+ };
+
struct CustomShader
{
std::string mVertexShader;
void CreatePropertyMap( Property::Map& map ) const;
};
- std::string mCachedRendererKey; ///< The key to use for caching of the renderer. If it is empty then no caching will occur
Renderer mRenderer;
CustomShader* mCustomShader;
Vector2 mOffset;
Rect<int> mClipRect;
float mDepthIndex;
- bool mIsOnStage;
+ int mFlags;
Impl();
~Impl();
delete mImpl;
}
-void ControlRenderer::Initialize( const Property::Map& propertyMap )
+void ControlRenderer::Initialize( Actor& actor, const Property::Map& propertyMap )
{
if( mImpl->mCustomShader )
{
}
}
}
- DoInitialize( propertyMap );
-
- if( mImpl->mIsOnStage )
- {
- InitializeRenderer( mImpl->mRenderer );
- }
+ DoInitialize( actor, propertyMap );
}
void ControlRenderer::SetSize( const Vector2& size )
return mImpl->mDepthIndex;
}
-void ControlRenderer::SetCachedRendererKey( const std::string& cachedRendererKey )
-{
- if( mImpl->mCachedRendererKey == cachedRendererKey )
- {
- return;
- }
- if( !mImpl->mIsOnStage )
- {
- mImpl->mCachedRendererKey = cachedRendererKey;
- }
- else
- {
- //clean the renderer from the cache since it may no longer be in use
- mFactoryCache.CleanRendererCache( mImpl->mCachedRendererKey );
-
- //add the new renderer
- mImpl->mCachedRendererKey = cachedRendererKey;
- if( !mImpl->mCachedRendererKey.empty() && !mImpl->mCustomShader )
- {
- DALI_ASSERT_DEBUG( mImpl->mRenderer && "The control render is on stage but it doesn't have a valid renderer.");
- mFactoryCache.SaveRenderer( mImpl->mCachedRendererKey, mImpl->mRenderer );
- }
- }
-}
-
void ControlRenderer::SetOnStage( Actor& actor )
{
- if( !mImpl->mCachedRendererKey.empty() && !mImpl->mCustomShader )
- {
- mImpl->mRenderer = mFactoryCache.GetRenderer( mImpl->mCachedRendererKey );
- if( !mImpl->mRenderer )
- {
- InitializeRenderer( mImpl->mRenderer );
- mFactoryCache.SaveRenderer( mImpl->mCachedRendererKey, mImpl->mRenderer );
- }
- }
-
- if( !mImpl->mRenderer )
- {
- InitializeRenderer( mImpl->mRenderer );
- }
+ DoSetOnStage( actor );
mImpl->mRenderer.SetDepthIndex( mImpl->mDepthIndex );
actor.AddRenderer( mImpl->mRenderer );
- mImpl->mIsOnStage = true;
-
- DoSetOnStage( actor );
+ mImpl->mFlags |= Impl::IS_ON_STAGE;
}
void ControlRenderer::SetOffStage( Actor& actor )
{
- if( mImpl->mIsOnStage )
+ if( GetIsOnStage() )
{
DoSetOffStage( actor );
actor.RemoveRenderer( mImpl->mRenderer );
mImpl->mRenderer.Reset();
- //clean the renderer from the cache since it may no longer be in use
- mFactoryCache.CleanRendererCache( mImpl->mCachedRendererKey );
-
- mImpl->mIsOnStage = false;
+ mImpl->mFlags &= ~Impl::IS_ON_STAGE;
}
}
DoCreatePropertyMap( map );
}
+bool ControlRenderer::GetIsOnStage() const
+{
+ return mImpl->mFlags & Impl::IS_ON_STAGE;
+}
+
+bool ControlRenderer::GetIsFromCache() const
+{
+ return mImpl->mFlags & Impl::IS_FROM_CACHE;
+}
+
} // namespace Internal
} // namespace Toolkit
* request the geometry and shader from the cache, if not available, create and save to the cache for sharing;
* record the property values.
*
+ * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] propertyMap The properties for the requested ControlRenderer object.
*/
- void Initialize( const Property::Map& propertyMap );
+ void Initialize( Actor& actor, const Property::Map& propertyMap );
/**
* @copydoc Toolkit::ControlRenderer::SetSize
/**
* @brief Called by Initialize() allowing sub classes to respond to the Initialize event
*
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] propertyMap The properties for the requested ControlRenderer object.
*/
- virtual void DoInitialize( const Property::Map& propertyMap ) = 0;
-
- /**
- * @brief Initialises a renderer ready to be put on stage.
- *
- * @param[inout] renderer The Renderer to initialise. If the renderer is not empty then re-initialise the renderer
- */
- virtual void InitializeRenderer( Renderer& renderer ) = 0;
+ virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap ) = 0;
protected:
virtual void DoSetOffStage( Actor& actor );
protected:
+ /**
+ * @brief Gets the on stage state for this ControlRenderer
+ *
+ * @return Returns true if this ControlRenderer is on stage, false if it is off the stage
+ */
+ bool GetIsOnStage() const;
/**
- * @brief Sets the key to use for caching the renderer. If this is empty then no caching will occur
+ * @brief Gets whether the Dali::Renderer is from a shared cache (and therefore any modifications will affect other users of that renderer)
*
- * @param[in] cachedRendererKey The key to use for caching the renderer.
+ * @return Returns true if the renderer is from shared cache, false otherwise
*/
- void SetCachedRendererKey( const std::string& cachedRendererKey );
+ bool GetIsFromCache() const;
private:
{
}
-void GradientRenderer::DoInitialize( const Property::Map& propertyMap )
+void GradientRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
Gradient::GradientUnits gradientUnits = Gradient::OBJECT_BOUNDING_BOX;
Property::Value* unitsValue = propertyMap.Find( GRADIENT_UNITS_NAME );
//ToDo: renderer applies the offset
}
+void GradientRenderer::DoSetOnStage( Actor& actor )
+{
+ InitializeRenderer();
+}
+
void GradientRenderer::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
}
}
-void GradientRenderer::InitializeRenderer( Dali::Renderer& renderer )
+void GradientRenderer::InitializeRenderer()
{
Geometry geometry = mFactoryCache.GetGeometry( RendererFactoryCache::QUAD_GEOMETRY );
if( !geometry )
}
Material material;
- if( !renderer )
- {
- material = Material::New( shader );
- renderer = Renderer::New( geometry, material );
- }
- else
- {
- mImpl->mRenderer.SetGeometry( geometry );
- material = mImpl->mRenderer.GetMaterial();
- if( material )
- {
- material.SetShader( shader );
- }
- }
+ material = Material::New( shader );
+ mImpl->mRenderer = Renderer::New( geometry, material );
Dali::BufferImage lookupTexture = mGradient->GenerateLookupTexture();
Sampler sampler = Sampler::New();
material.AddTexture( lookupTexture, UNIFORM_TEXTULRE_NAME, sampler );
- renderer.RegisterProperty( UNIFORM_ALIGNMENT_MATRIX_NAME, mGradientTransform );
+ mImpl->mRenderer.RegisterProperty( UNIFORM_ALIGNMENT_MATRIX_NAME, mGradientTransform );
}
bool GradientRenderer::NewGradient(Type gradientType, const Property::Map& propertyMap)
/**
* @copydoc ControlRenderer::DoInitialize
*/
- virtual void DoInitialize( const Property::Map& propertyMap );
+ virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc ControlRenderer::InitializeRenderer
+ * @copydoc ControlRenderer::DoSetOnStage
*/
- virtual void InitializeRenderer( Renderer& renderer );
+ virtual void DoSetOnStage( Actor& actor );
private:
/**
+ * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
+ */
+ void InitializeRenderer();
+
+ /**
* New a gradient object with the given property map.
*
* @return True if the property map provides valid properties to create a gradient. Otherwise, returns false.
{
}
-void ImageRenderer::DoInitialize( const Property::Map& propertyMap )
+void ImageRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
+ std::string oldImageUrl = mImageUrl;
+
Property::Value* imageURLValue = propertyMap.Find( IMAGE_URL_NAME );
if( imageURLValue )
{
imageURLValue->Get( mImageUrl );
if( !mImageUrl.empty() )
{
- SetCachedRendererKey( mImageUrl );
mImage.Reset();
}
mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
}
+
+ if( mImpl->mRenderer )
+ {
+ //remove old renderer
+ if( actor )
+ {
+ actor.RemoveRenderer( mImpl->mRenderer );
+ }
+
+ //clean the cache
+ if( !oldImageUrl.empty() )
+ {
+ mFactoryCache.CleanRendererCache( oldImageUrl );
+ }
+
+ //Initialize the renderer
+ if( !mImageUrl.empty() )
+ {
+ InitializeRenderer( mImageUrl );
+ }
+ else if( mImage )
+ {
+ InitializeRenderer( mImage );
+ }
+
+ //add the new renderer to the actor
+ if( actor && mImpl->mRenderer )
+ {
+ actor.AddRenderer( mImpl->mRenderer );
+ }
+ }
}
void ImageRenderer::SetSize( const Vector2& size )
{
}
-void ImageRenderer::InitializeRenderer( Renderer& renderer )
+Renderer ImageRenderer::CreateRenderer() const
{
Geometry geometry;
Shader shader;
+
if( !mImpl->mCustomShader )
{
geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) );
-
shader = mFactoryCache.GetShader( RendererFactoryCache::IMAGE_SHADER );
if( !shader )
{
else
{
geometry = CreateGeometry( mFactoryCache, mImpl->mCustomShader->mGridSize );
-
if( mImpl->mCustomShader->mVertexShader.empty() && mImpl->mCustomShader->mFragmentShader.empty() )
{
shader = mFactoryCache.GetShader( RendererFactoryCache::IMAGE_SHADER );
}
}
- if( !renderer )
+ Material material = Material::New( shader );
+ return Renderer::New( geometry, material );
+}
+
+void ImageRenderer::InitializeRenderer( const std::string& imageUrl )
+{
+ if( mImageUrl.empty() )
{
- Material material = Material::New( shader );
- renderer = Renderer::New( geometry, material );
+ mImpl->mFlags &= ~Impl::IS_FROM_CACHE;
+ return;
}
- else
+
+ mImpl->mRenderer.Reset();
+ if( !mImpl->mCustomShader )
{
- renderer.SetGeometry( geometry );
- Material material = renderer.GetMaterial();
- if( material )
+ mImpl->mRenderer = mFactoryCache.GetRenderer( imageUrl );
+ if( !mImpl->mRenderer )
{
- material.SetShader( shader );
+ mImpl->mRenderer = CreateRenderer();
+
+ ResourceImage image = Dali::ResourceImage::New( imageUrl );
+ image.LoadingFinishedSignal().Connect( this, &ImageRenderer::OnImageLoaded );
+ Material material = mImpl->mRenderer.GetMaterial();
+ material.AddTexture( image, TEXTURE_UNIFORM_NAME );
+
+ mFactoryCache.SaveRenderer( imageUrl, mImpl->mRenderer );
}
+ mImpl->mFlags |= Impl::IS_FROM_CACHE;
+ }
+ else
+ {
+ mImpl->mFlags &= ~Impl::IS_FROM_CACHE;
+ mImpl->mRenderer = CreateRenderer();
+ ResourceImage image = Dali::ResourceImage::New( imageUrl, mDesiredSize, mFittingMode, mSamplingMode );
+ image.LoadingFinishedSignal().Connect( this, &ImageRenderer::OnImageLoaded );
+ ApplyImageToSampler( image );
}
}
-void ImageRenderer::DoSetOnStage( Actor& actor )
+void ImageRenderer::InitializeRenderer( const Image& image )
{
- if( !mImageUrl.empty() && !mImage )
+ mImpl->mFlags &= ~Impl::IS_FROM_CACHE;
+
+ if( !image )
{
- Dali::ResourceImage resourceImage = Dali::ResourceImage::New( mImageUrl, mDesiredSize, mFittingMode, mSamplingMode );
- resourceImage.LoadingFinishedSignal().Connect( this, &ImageRenderer::OnImageLoaded );
+ return;
+ }
+
+ mImpl->mRenderer = CreateRenderer();
+ ApplyImageToSampler( image );
+}
- mImage = resourceImage;
+
+void ImageRenderer::DoSetOnStage( Actor& actor )
+{
+ if( !mImageUrl.empty() )
+ {
+ InitializeRenderer( mImageUrl );
}
+ else if( mImage )
+ {
+ InitializeRenderer( mImage );
+ }
+
+ if( !GetIsFromCache() )
+ {
+ Image image = mImage;
+ if( !mImageUrl.empty() )
+ {
+ ResourceImage resourceImage = Dali::ResourceImage::New( mImageUrl, mDesiredSize, mFittingMode, mSamplingMode );
+ resourceImage.LoadingFinishedSignal().Connect( this, &ImageRenderer::OnImageLoaded );
+ image = resourceImage;
+ }
- ApplyImageToSampler();
+ ApplyImageToSampler( image );
+ }
}
void ImageRenderer::DoSetOffStage( Actor& actor )
//If we own the image then make sure we release it when we go off stage
if( !mImageUrl.empty() )
{
+ //clean the renderer from the cache since it may no longer be in use
+ mFactoryCache.CleanRendererCache( mImageUrl );
+
mImage.Reset();
}
}
}
}
-void ImageRenderer::SetImage( const std::string& imageUrl )
+void ImageRenderer::SetImage( Actor& actor, const std::string& imageUrl )
{
- SetImage( imageUrl, 0, 0, Dali::FittingMode::DEFAULT, Dali::SamplingMode::DEFAULT );
+ SetImage( actor, imageUrl, 0, 0, Dali::FittingMode::DEFAULT, Dali::SamplingMode::DEFAULT );
}
-void ImageRenderer::SetImage( const std::string& imageUrl, int desiredWidth, int desiredHeight, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode )
+void ImageRenderer::SetImage( Actor& actor, const std::string& imageUrl, int desiredWidth, int desiredHeight, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode )
{
if( mImageUrl != imageUrl )
{
+ if( mImpl->mRenderer )
+ {
+ if( GetIsFromCache() )
+ {
+ //remove old renderer
+ if( actor )
+ {
+ actor.RemoveRenderer( mImpl->mRenderer );
+ }
+
+ //clean the cache
+ if( !mImageUrl.empty() )
+ {
+ mFactoryCache.CleanRendererCache( mImageUrl );
+ }
+
+ //Initialize the renderer
+ InitializeRenderer( imageUrl );
+
+ //add the new renderer to the actor
+ if( actor && mImpl->mRenderer )
+ {
+ actor.AddRenderer( mImpl->mRenderer );
+ }
+ }
+ else
+ {
+ ResourceImage image = Dali::ResourceImage::New( imageUrl, mDesiredSize, mFittingMode, mSamplingMode );
+ image.LoadingFinishedSignal().Connect( this, &ImageRenderer::OnImageLoaded );
+ ApplyImageToSampler( image );
+ }
+ }
+
mImageUrl = imageUrl;
- SetCachedRendererKey( mImageUrl );
mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
mFittingMode = fittingMode;
mSamplingMode = samplingMode;
-
- if( !mImageUrl.empty() && mImpl->mIsOnStage )
- {
- Dali::ResourceImage resourceImage = Dali::ResourceImage::New( mImageUrl, mDesiredSize, mFittingMode, mSamplingMode );
- resourceImage.LoadingFinishedSignal().Connect( this, &ImageRenderer::OnImageLoaded );
- mImage = resourceImage;
-
- ApplyImageToSampler();
- }
- else
- {
- mImage.Reset();
- }
+ mImage.Reset();
}
}
-void ImageRenderer::SetImage( Image image )
+void ImageRenderer::SetImage( Actor& actor, const Image& image )
{
if( mImage != image )
{
+ if( mImpl->mRenderer )
+ {
+ if( GetIsFromCache() )
+ {
+ //remove old renderer
+ if( actor )
+ {
+ actor.RemoveRenderer( mImpl->mRenderer );
+ }
+
+ //clean the cache
+ if( !mImageUrl.empty() )
+ {
+ mFactoryCache.CleanRendererCache( mImageUrl );
+ }
+
+ //Initialize the renderer
+ InitializeRenderer( image );
+
+ //add the new renderer to the actor
+ if( actor && mImpl->mRenderer )
+ {
+ actor.AddRenderer( mImpl->mRenderer );
+ }
+ }
+ else
+ {
+ ApplyImageToSampler( image );
+ }
+ }
+
+ mImage = image;
mImageUrl.clear();
mDesiredSize = ImageDimensions();
mFittingMode = FittingMode::DEFAULT;
mSamplingMode = SamplingMode::DEFAULT;
- mImage = image;
-
- if( mImage && mImpl->mIsOnStage )
- {
- ApplyImageToSampler();
- }
}
}
-Image ImageRenderer::GetImage() const
-{
- return mImage;
-}
-
-void ImageRenderer::ApplyImageToSampler()
+void ImageRenderer::ApplyImageToSampler( const Image& image )
{
- if( mImage )
+ if( image )
{
Material material = mImpl->mRenderer.GetMaterial();
if( material )
{
- int index = material.GetTextureIndex(TEXTURE_UNIFORM_NAME);
+ int index = material.GetTextureIndex( TEXTURE_UNIFORM_NAME );
if( index != -1 )
{
- material.SetTextureImage( index, mImage );
+ material.SetTextureImage( index, image );
return;
}
- material.AddTexture( mImage,TEXTURE_UNIFORM_NAME );
+ material.AddTexture( image, TEXTURE_UNIFORM_NAME );
}
}
}
{
if( image.GetLoadingState() == Dali::ResourceLoadingFailed )
{
- mImage = RendererFactory::GetBrokenRendererImage();
- if( mImpl->mIsOnStage )
+ Image image = RendererFactory::GetBrokenRendererImage();
+ if( mImpl->mRenderer )
{
- ApplyImageToSampler();
+ ApplyImageToSampler( image );
}
}
}
/**
* @copydoc ControlRenderer::DoInitialize
*/
- virtual void DoInitialize( const Property::Map& propertyMap );
+ virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
* @copydoc ControlRenderer::DoSetOnStage
*/
virtual void DoSetOffStage( Actor& actor );
- /**
- * @copydoc ControlRenderer::InitializeRenderer
- */
- virtual void InitializeRenderer( Renderer& renderer );
-
public:
/**
* @brief Sets the image of this renderer to the resource at imageUrl
* The renderer will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
*
+ * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] imageUrl The URL to to image resource to use
*/
- void SetImage( const std::string& imageUrl );
+ void SetImage( Actor& actor, const std::string& imageUrl );
/**
* @brief Sets the image of this renderer to the resource at imageUrl
* The renderer will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
*
+ * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] imageUrl The URL to to image resource to use
* @param[in] desiredWidth The desired width of the resource to load
* @param[in] desiredHeight The desired height of the resource to load
* @param[in] fittingMode The FittingMode of the resource to load
* @param[in] samplingMode The SamplingMode of the resource to load
*/
- void SetImage( const std::string& imageUrl, int desiredWidth, int desiredHeight, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode );
+ void SetImage( Actor& actor, const std::string& imageUrl, int desiredWidth, int desiredHeight, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode );
/**
* @brief Sets the image of this renderer to use
*
+ * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] image The image to use
*/
- void SetImage( Image image );
+ void SetImage( Actor& actor, const Image& image );
+
+private:
/**
- * @brief Gets the image this renderer uses
+ * @brief Applies the image to the material used for this renderer
*
- * @return The image this renderer uses, which may be null if the image is set from a URL string and the renderer is not set as onstage
+ * @param[in] image The Image to apply to the material used for this renderer
*/
- Image GetImage() const;
+ void ApplyImageToSampler( const Image& image );
-private:
+ /**
+ * @brief Initializes the Dali::Renderer from an image url string
+ *
+ * @param[in] imageUrl The image url string to intialize this ImageRenderer from
+ */
+ void InitializeRenderer( const std::string& imageUrl );
/**
- * @brief Applies this renderer's image to the sampler to the material used for this renderer
+ * @brief Initializes the Dali::Renderer from an image handle
+ *
+ * @param[in] image The image handle to intialize this ImageRenderer from
+ */
+ void InitializeRenderer( const Image& image );
+
+ /**
+ * @brief Creates the Dali::Renderer (potentially from the renderer cache), initializing it
+ *
+ * @return Returns the created Dali::Renderer
*/
- void ApplyImageToSampler();
+ Renderer CreateRenderer() const;
/**
* Callback function of image resource loading succeed
{
}
-void NPatchRenderer::DoInitialize( const Property::Map& propertyMap )
+void NPatchRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
Property::Value* imageURLValue = propertyMap.Find( IMAGE_URL_NAME );
if( imageURLValue )
//ToDo: renderer applies the offset
}
-void NPatchRenderer::InitializeRenderer( Renderer& renderer )
+Geometry NPatchRenderer::CreateGeometry()
{
Geometry geometry;
- Shader shader;
if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
{
if( !mBorderOnly )
mFactoryCache.SaveGeometry( RendererFactoryCache::NINE_PATCH_BORDER_GEOMETRY, geometry );
}
}
+ }
+ else if( mStretchPixelsX.Size() > 0 || mStretchPixelsY.Size() > 0)
+ {
+ Uint16Pair gridSize( 2 * mStretchPixelsX.Size() + 1, 2 * mStretchPixelsY.Size() + 1 );
+ geometry = !mBorderOnly ? CreateGeometry( gridSize ) : CreateGeometryBorder( gridSize );
+ }
+
+ return geometry;
+}
+Shader NPatchRenderer::CreateShader()
+{
+ Shader shader;
+ if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
+ {
shader = mFactoryCache.GetShader( RendererFactoryCache::NINE_PATCH_SHADER );
if( !shader )
{
}
else if( mStretchPixelsX.Size() > 0 || mStretchPixelsY.Size() > 0)
{
- Uint16Pair gridSize( 2 * mStretchPixelsX.Size() + 1, 2 * mStretchPixelsY.Size() + 1 );
- geometry = !mBorderOnly ? CreateGeometry( gridSize ) : CreateGeometryBorder( gridSize );
-
std::stringstream vertexShader;
vertexShader << "#define FACTOR_SIZE_X " << mStretchPixelsX.Size() + 2 << "\n"
<< "#define FACTOR_SIZE_Y " << mStretchPixelsY.Size() + 2 << "\n"
shader = Shader::New( vertexShader.str(), FRAGMENT_SHADER );
}
- else
+ return shader;
+}
+
+void NPatchRenderer::InitializeRenderer()
+{
+ Geometry geometry = CreateGeometry();
+ Shader shader = CreateShader();
+
+ if( !geometry || !shader )
{
DALI_LOG_ERROR("The 9 patch image '%s' doesn't have any valid stretch borders and so is not a valid 9 patch image\n", mImageUrl.c_str() );
InitializeFromBrokenImage();
}
- if( !renderer )
- {
- Material material = Material::New( shader );
- renderer = Renderer::New( geometry, material );
- }
- else
- {
- mImpl->mRenderer.SetGeometry( geometry );
- Material material = mImpl->mRenderer.GetMaterial();
- if( material )
- {
- material.SetShader( shader );
- }
- }
+ Material material = Material::New( shader );
+ mImpl->mRenderer = Renderer::New( geometry, material );
}
+
void NPatchRenderer::DoSetOnStage( Actor& actor )
{
if( !mCroppedImage )
{
InitializeFromImage( mImage );
}
-
- InitializeRenderer( mImpl->mRenderer );
}
+ //initialize the renderer after initializing from the image since we need to know the grid size from the image before creating the geometry
+ InitializeRenderer();
+
if( mCroppedImage )
{
ApplyImageToSampler();
map.Insert( BORDER_ONLY, mBorderOnly );
}
+void NPatchRenderer::ChangeRenderer( bool oldBorderOnly, size_t oldGridX, size_t oldGridY )
+{
+ //check to see if the border style has changed
+
+ bool borderOnlyChanged = oldBorderOnly != mBorderOnly;
+ bool gridChanged = oldGridX != mStretchPixelsX.Size() || oldGridY != mStretchPixelsY.Size();
+
+ if( borderOnlyChanged || gridChanged )
+ {
+ Geometry geometry = CreateGeometry();
+ if( geometry )
+ {
+ mImpl->mRenderer.SetGeometry( geometry );
+ }
+ else
+ {
+ InitializeFromBrokenImage();
+ }
+ }
+
+ if( gridChanged )
+ {
+ Shader shader = CreateShader();
+ Material material;
+ if( shader )
+ {
+ material = mImpl->mRenderer.GetMaterial();
+ if( material )
+ {
+ material.SetShader( shader );
+ }
+ }
+
+ if( !material )
+ {
+ InitializeFromBrokenImage();
+ }
+ }
+}
+
void NPatchRenderer::SetImage( const std::string& imageUrl, bool borderOnly )
{
+ bool oldBorderOnly = mBorderOnly;
+ size_t oldGridX = mStretchPixelsX.Size();
+ size_t oldGridY = mStretchPixelsY.Size();
+
mBorderOnly = borderOnly;
mImage.Reset();
if( mImageUrl == imageUrl )
}
mImageUrl = imageUrl;
- NinePatchImage nPatch = NinePatchImage::New( mImageUrl );
- InitializeFromImage( nPatch );
-
- if( mCroppedImage && mImpl->mIsOnStage )
+ if( mImpl->mRenderer )
{
- ApplyImageToSampler();
+ NinePatchImage nPatch = NinePatchImage::New( mImageUrl );
+ InitializeFromImage( nPatch );
+
+ ChangeRenderer( oldBorderOnly, oldGridX, oldGridY );
+
+ if( mCroppedImage )
+ {
+ ApplyImageToSampler();
+ }
}
}
void NPatchRenderer::SetImage( NinePatchImage image, bool borderOnly )
{
+ bool oldBorderOnly = mBorderOnly;
+ size_t oldGridX = mStretchPixelsX.Size();
+ size_t oldGridY = mStretchPixelsY.Size();
+
mBorderOnly = borderOnly;
mImageUrl.empty();
if( mImage == image )
}
mImage = image;
- InitializeFromImage( mImage );
-
- if( mCroppedImage && mImpl->mIsOnStage )
+ if( mImpl->mRenderer )
{
- ApplyImageToSampler();
+ InitializeFromImage( mImage );
+ ChangeRenderer( oldBorderOnly, oldGridX, oldGridY );
+
+ if( mCroppedImage )
+ {
+ ApplyImageToSampler();
+ }
}
}
/**
* @copydoc ControlRenderer::DoInitialize
*/
- virtual void DoInitialize( const Property::Map& propertyMap );
-
- /**
- * @copydoc ControlRenderer::InitializeRenderer
- */
- virtual void InitializeRenderer( Renderer& renderer );
+ virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
* @copydoc ControlRenderer::DoSetOnStage
private:
/**
+ * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
+ */
+ void InitializeRenderer();
+
+ /**
+ * @brief Creates a geometry for this renderer's grid size
+ *
+ * @return Returns the created geometry for this renderer's grid size
+ */
+ Geometry CreateGeometry();
+
+ /**
+ * @brief Creates a shader for this renderer's grid size
+ *
+ * @return Returns the created shader for this renderer's grid size
+ */
+ Shader CreateShader();
+
+ /**
* @brief Creates a geometry for the grid size to be used by this renderers' shaders
*
- * @param gridSize The grid size of the solid geometry to create
+ * @param[in] gridSize The grid size of the solid geometry to create
* @return Returns the created geometry for the grid size
*/
Geometry CreateGeometry( Uint16Pair gridSize );
* |/ |/ |/ |/ |/ |
* ---------------------
*
- * @param gridSize The grid size of the solid geometry to create
+ * @param[in] gridSize The grid size of the solid geometry to create
* @return Returns the created geometry for the grid size
*/
Geometry CreateGeometryBorder( Uint16Pair gridSize );
/**
* @brief Creates Image from the image url and parses the image for the stretch borders. Will create a error image if the n patch image is invalid
*
- * @param nPatchImage The NinePatchImage to base our cropped images and stretch borders from
+ * @param[in] nPatchImage The NinePatchImage to base our cropped images and stretch borders from
*/
void InitializeFromImage( NinePatchImage nPatchImage );
*/
void ApplyImageToSampler();
+ /**
+ * @brief Changes the current renderer if the n-patch meta data has changed
+ *
+ * @param[in] oldBorderOnly The old flag indicating if the image should omit the centre of the n-patch and only render the border
+ * @param[in] oldGridX The old horizontal grid size of the solid geometry
+ * @param[in] oldGridY The old vertical grid size of the solid geometry
+ */
+ void ChangeRenderer( bool oldBorderOnly, size_t oldGridX, size_t oldGridY );
+
private:
NinePatchImage mImage; ///< The image to render if the renderer was set from an NinePatchImage, empty otherwise
if( rendererPtr )
{
- rendererPtr->Initialize( propertyMap );
+ Actor actor;
+ rendererPtr->Initialize( actor, propertyMap );
}
else
{
return Toolkit::ControlRenderer( rendererPtr );
}
-bool RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, const Vector4& color )
+void RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Vector4& color )
{
ColorRenderer* rendererPtr = dynamic_cast< ColorRenderer* >( &GetImplementation( renderer ) );
if( rendererPtr )
{
rendererPtr->SetColor( color );
- return false;
}
else
{
+ renderer.RemoveAndReset( actor );
renderer = GetControlRenderer( color );
- return true;
+
+ if( actor.OnStage() )
+ {
+ renderer.SetOnStage( actor );
+ }
}
}
else
{
ImageRenderer* rendererPtr = new ImageRenderer( *( mFactoryCache.Get() ) );
- rendererPtr->SetImage( image );
+ Actor actor;
+ rendererPtr->SetImage( actor, image );
return Toolkit::ControlRenderer( rendererPtr );
}
}
-bool RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, const Image& image )
+void RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Image& image )
{
- NinePatchImage npatchImage = NinePatchImage::DownCast( image );
- if( npatchImage )
+ if( renderer )
{
- NPatchRenderer* rendererPtr = dynamic_cast< NPatchRenderer* >( &GetImplementation( renderer ) );
- if( rendererPtr )
+ NinePatchImage npatchImage = NinePatchImage::DownCast( image );
+ if( npatchImage )
{
- rendererPtr->SetImage( npatchImage );
- return false;
+ NPatchRenderer* rendererPtr = dynamic_cast< NPatchRenderer* >( &GetImplementation( renderer ) );
+ if( rendererPtr )
+ {
+ rendererPtr->SetImage( npatchImage );
+ return;
+ }
}
- }
- else
- {
- ImageRenderer* rendererPtr = dynamic_cast< ImageRenderer* >( &GetImplementation( renderer ) );
- if( rendererPtr )
+ else
{
- rendererPtr->SetImage( image );
- return false;
+ ImageRenderer* rendererPtr = dynamic_cast< ImageRenderer* >( &GetImplementation( renderer ) );
+ if( rendererPtr )
+ {
+ rendererPtr->SetImage( actor, image );
+ return;
+ }
}
}
+ renderer.RemoveAndReset( actor );
renderer = GetControlRenderer( image );
- return true;
+ if( actor.OnStage() )
+ {
+ renderer.SetOnStage( actor );
+ }
}
Toolkit::ControlRenderer RendererFactory::GetControlRenderer( const std::string& url )
else
{
ImageRenderer* rendererPtr = new ImageRenderer( *( mFactoryCache.Get() ) );
- rendererPtr->SetImage( url );
+ Actor actor;
+ rendererPtr->SetImage( actor, url );
return Toolkit::ControlRenderer( rendererPtr );
}
}
-bool RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, const std::string& url )
+void RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const std::string& url )
{
- if( NinePatchImage::IsNinePatchUrl( url ) )
+ if( renderer )
{
- NPatchRenderer* rendererPtr = dynamic_cast< NPatchRenderer* >( &GetImplementation( renderer ) );
- if( rendererPtr )
+ if( NinePatchImage::IsNinePatchUrl( url ) )
{
- rendererPtr->SetImage( url );
- return false;
+ NPatchRenderer* rendererPtr = dynamic_cast< NPatchRenderer* >( &GetImplementation( renderer ) );
+ if( rendererPtr )
+ {
+ rendererPtr->SetImage( url );
+ return;
+ }
}
- }
- else
- {
- ImageRenderer* rendererPtr = dynamic_cast< ImageRenderer* >( &GetImplementation( renderer ) );
- if( rendererPtr )
+ else
{
- rendererPtr->SetImage( url );
- return false;
+ ImageRenderer* rendererPtr = dynamic_cast< ImageRenderer* >( &GetImplementation( renderer ) );
+ if( rendererPtr )
+ {
+ rendererPtr->SetImage( actor, url );
+ return;
+ }
}
}
+ renderer.RemoveAndReset( actor );
+ renderer = GetControlRenderer( url );
+ if( actor.OnStage() )
{
- renderer = GetControlRenderer( url );
- return true;
+ renderer.SetOnStage( actor );
}
}
-bool RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, const Property::Map& propertyMap )
+void RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap )
{
- Property::Value* type = propertyMap.Find( RENDERER_TYPE_NAME );
- std::string typeValue ;
- if( type && type->Get( typeValue ))
+ if( renderer )
{
- //If there's been a renderer type change then we have to return a new shader
- if( typeValue == COLOR_RENDERER && typeid( renderer ) != typeid( ColorRenderer ) )
- {
- renderer = GetControlRenderer( propertyMap );
- return true;
- }
- else if( typeValue == GRADIENT_RENDERER && typeid( renderer ) != typeid( GradientRenderer ) )
- {
- renderer = GetControlRenderer( propertyMap );
- return true;
- }
- else if( typeValue == IMAGE_RENDERER && typeid( renderer ) != typeid( ImageRenderer ) )
+ Property::Value* type = propertyMap.Find( RENDERER_TYPE_NAME );
+ std::string typeValue ;
+ if( type && type->Get( typeValue ))
{
- renderer = GetControlRenderer( propertyMap );
- return true;
- }
- else if( typeValue == N_PATCH_RENDERER && typeid( renderer ) != typeid( NPatchRenderer ) )
- {
- renderer = GetControlRenderer( propertyMap );
- return true;
- }
- else if( typeValue == BORDER_RENDERER && typeid( renderer ) != typeid( BorderRenderer ) )
- {
- renderer = GetControlRenderer( propertyMap );
- return true;
+ //If there's been a renderer type change then we have to return a new shader
+ if( typeValue == COLOR_RENDERER && typeid( renderer ) != typeid( ColorRenderer ) )
+ {
+ renderer = GetControlRenderer( propertyMap );
+ return;
+ }
+ else if( typeValue == GRADIENT_RENDERER && typeid( renderer ) != typeid( GradientRenderer ) )
+ {
+ renderer = GetControlRenderer( propertyMap );
+ return;
+ }
+ else if( typeValue == IMAGE_RENDERER && typeid( renderer ) != typeid( ImageRenderer ) )
+ {
+ renderer = GetControlRenderer( propertyMap );
+ return;
+ }
+ else if( typeValue == N_PATCH_RENDERER && typeid( renderer ) != typeid( NPatchRenderer ) )
+ {
+ renderer = GetControlRenderer( propertyMap );
+ return;
+ }
+ else if( typeValue == BORDER_RENDERER && typeid( renderer ) != typeid( BorderRenderer ) )
+ {
+ renderer = GetControlRenderer( propertyMap );
+ return;
+ }
}
+
+ GetImplementation( renderer ).Initialize( actor, propertyMap );
+ }
+ else
+ {
+ renderer = GetControlRenderer( propertyMap );
}
- GetImplementation( renderer ).Initialize( propertyMap );
- return false;
}
Image RendererFactory::GetBrokenRendererImage()
Toolkit::ControlRenderer GetControlRenderer( const Property::Map& propertyMap );
/**
- * @copydoc Toolkit::RenderFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, const Property::Map& propertyMap )
+ * @copydoc Toolkit::RenderFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap )
*/
- bool ResetRenderer( Toolkit::ControlRenderer& renderer, const Property::Map& propertyMap );
+ void ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap );
/**
* @copydoc Toolkit::RenderFactory::GetControlRenderer( const Vector4& )
Toolkit::ControlRenderer GetControlRenderer( const Vector4& color );
/**
- * @copydoc Toolkit::RendererFactory::ResetRenderer( Toolkit::ControlRenderer&, const Vector4& )
+ * @copydoc Toolkit::RendererFactory::ResetRenderer( Toolkit::ControlRenderer&, Actor& actor, const Vector4& )
*/
- bool ResetRenderer( Toolkit::ControlRenderer& renderer, const Vector4& color );
+ void ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Vector4& color );
/**
* @copydoc Toolkit::RenderFactory::GetControlRenderer( float, const Vector4& )
Toolkit::ControlRenderer GetControlRenderer( const Image& image );
/**
- * @copydoc Toolkit::RendererFactory::ResetRenderer( Toolkit::ControlRenderer&, const Image& )
+ * @copydoc Toolkit::RendererFactory::ResetRenderer( Toolkit::ControlRenderer&, Actor& actor, const Image& )
*/
- bool ResetRenderer( Toolkit::ControlRenderer& renderer, const Image& image );
+ void ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Image& image );
/**
* @copydoc Toolkit::RenderFactory::GetControlRenderer( const std::string& )
Toolkit::ControlRenderer GetControlRenderer( const std::string& image );
/**
- * @copydoc Toolkit::RendererFactory::ResetRenderer( Toolkit::ControlRenderer&, const std::string& )
+ * @copydoc Toolkit::RendererFactory::ResetRenderer( Toolkit::ControlRenderer&, Actor& actor, const std::string& )
*/
- bool ResetRenderer( Toolkit::ControlRenderer& renderer, const std::string& image );
+ void ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const std::string& image );
public:
/**
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)
{
}
}
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);
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();
+ }
}
}
}
~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();
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
};
/**
if( mImpl->mBackgroundRenderer )
{
- Toolkit::ControlRenderer currentRenderer( mImpl->mBackgroundRenderer );
- // if ResetRenderer returns false, we continue to use the current renderer with a new color set to it.
- if( ! factory.ResetRenderer( mImpl->mBackgroundRenderer, color ) )
- {
- return;
- }
- // ResetRenderer returns true, a new renderer is created. Remove the current renderer and reset.
- currentRenderer.RemoveAndReset( self );
+ factory.ResetRenderer( mImpl->mBackgroundRenderer, self, color );
}
else
{
mImpl->mBackgroundRenderer = factory.GetControlRenderer( color );
- }
- if( self.OnStage() )
- {
- mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
- mImpl->mBackgroundRenderer.SetOnStage( self );
+ if( self.OnStage() )
+ {
+ mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
+ mImpl->mBackgroundRenderer.SetOnStage( self );
+ }
}
}
if( mImpl->mBackgroundRenderer )
{
- Toolkit::ControlRenderer currentRenderer( mImpl->mBackgroundRenderer );
- // if ResetRenderer returns false, we continue to use the current renderer with a new image set to it.
- if( ! factory.ResetRenderer( mImpl->mBackgroundRenderer, image ) )
- {
- return;
- }
- // ResetRenderer returns true, a new renderer is created. Remove the current renderer and reset.
- currentRenderer.RemoveAndReset( self );
+ factory.ResetRenderer( mImpl->mBackgroundRenderer, self, image );
}
else
{
mImpl->mBackgroundRenderer = factory.GetControlRenderer( image );
- }
- if( self.OnStage() )
- {
- mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
- mImpl->mBackgroundRenderer.SetOnStage( self );
+ if( self.OnStage() )
+ {
+ mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
+ mImpl->mBackgroundRenderer.SetOnStage( self );
+ }
}
}
void Control::ClearBackground()
{
- Actor self(Self());
+ Actor self( Self() );
mImpl->mBackgroundRenderer.RemoveAndReset( self );
}
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 = 7;
+const unsigned int TOOLKIT_MICRO_VERSION = 8;
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":
{
'<(DALI_JS_DIR)/image/resource-image-api.cpp',
'<(DALI_JS_DIR)/image/nine-patch-image-api.cpp',
'<(DALI_JS_DIR)/object/handle-wrapper.cpp',
+ '<(DALI_JS_DIR)/object/property-buffer-api.cpp',
+ '<(DALI_JS_DIR)/object/property-buffer-wrapper.cpp',
'<(DALI_JS_DIR)/object/property-value-wrapper.cpp',
'<(DALI_JS_DIR)/signals/signal-manager.cpp',
'<(DALI_JS_DIR)/render-tasks/render-task-list-api.cpp',
'<(DALI_JS_DIR)/render-tasks/render-task-list-wrapper.cpp',
'<(DALI_JS_DIR)/render-tasks/render-task-api.cpp',
'<(DALI_JS_DIR)/render-tasks/render-task-wrapper.cpp',
+ '<(DALI_JS_DIR)/rendering/geometry-api.cpp',
+ '<(DALI_JS_DIR)/rendering/geometry-wrapper.cpp',
+ '<(DALI_JS_DIR)/rendering/material-api.cpp',
+ '<(DALI_JS_DIR)/rendering/material-wrapper.cpp',
+ '<(DALI_JS_DIR)/rendering/renderer-api.cpp',
+ '<(DALI_JS_DIR)/rendering/renderer-wrapper.cpp',
+ '<(DALI_JS_DIR)/rendering/sampler-api.cpp',
+ '<(DALI_JS_DIR)/rendering/sampler-wrapper.cpp',
+ '<(DALI_JS_DIR)/rendering/shader-api.cpp',
+ '<(DALI_JS_DIR)/rendering/shader-wrapper.cpp',
'<(DALI_JS_DIR)/toolkit/builder/builder-api.cpp',
'<(DALI_JS_DIR)/toolkit/builder/builder-wrapper.cpp',
'<(DALI_JS_DIR)/toolkit/focus-manager/keyboard-focus-manager-api.cpp',
--- /dev/null
+ var window= {
+ x:0,
+ y:0,
+ width:1920,
+ height: 1080,
+ transparent: false,
+ name:'line-mesh-app'
+ };
+
+ var viewMode={
+ 'stereoscopic-mode':'mono', // stereo-horizontal, stereo-vertical, stereo-interlaced,
+ 'stereo-base': 65 // Distance in millimeters between left/right cameras typically between (50-70mm)
+ };
+
+ var options= {
+ 'window': window,
+ 'view-mode': viewMode,
+ }
+
+var dali = require('./build/Release/dali')( options );
+
+var daliApp = {};
+
+daliApp.createMeshActor = function() {
+
+ // Create shader
+ var vertShader =
+ "attribute mediump vec2 aPosition1;\
+ attribute mediump vec2 aPosition2;\
+ uniform mediump mat4 uMvpMatrix;\
+ uniform mediump vec3 uSize;\
+ uniform mediump float uMorphAmount;\
+ void main()\
+ {\
+ mediump vec2 morphPosition = mix(aPosition1, aPosition2, uMorphAmount);\
+ mediump vec4 vertexPosition = vec4(morphPosition, 0.0, 1.0);\
+ vertexPosition.xyz *= uSize;\
+ vertexPosition = uMvpMatrix * vertexPosition;\
+ gl_Position = vertexPosition;\
+ }";
+
+ var fragShader =
+ "uniform lowp vec4 uColor;\
+ uniform sampler2D sTexture;\
+ void main()\
+ {\
+ gl_FragColor = uColor;\
+ }";
+
+ var shaderOptions = {
+ vertexShader : vertShader,
+ fragmentShader: fragShader
+ };
+
+ var shader = new dali.Shader(shaderOptions);
+
+ var material = new dali.Material( shader );
+
+ // Create vertex buffer
+ var pentagonVertexFormat ={ "aPosition1" : dali.PROPERTY_VECTOR2 };
+
+ var pentagonVertexData = [ 0, 1,
+ -0.95, 0.31,
+ -0.59, -0.81,
+ 0.59, -0.81,
+ 0.95, 0.31];
+
+ var pentagonVertexDataArray = new Float32Array(pentagonVertexData.length);
+ pentagonVertexDataArray.set(pentagonVertexData, 0);
+ var pentagonVertices = new dali.PropertyBuffer(pentagonVertexFormat, 5);
+ pentagonVertices.setData(pentagonVertexDataArray);
+
+ var pentacleVertexFormat ={ "aPosition2" : dali.PROPERTY_VECTOR2};
+
+ var pentacleVertexData = [ 0, -1,
+ 0.59, 0.81,
+ -0.95, -0.31,
+ 0.95, -0.31,
+ -0.59, 0.81];
+
+ var pentacleVertexDataArray = new Float32Array(pentacleVertexData.length);
+ pentacleVertexDataArray.set(pentacleVertexData, 0);
+ var pentacleVertices = new dali.PropertyBuffer(pentacleVertexFormat, 5);
+ pentacleVertices.setData(pentacleVertexDataArray);
+
+ var indexFormat ={ "indices" : dali.PROPERTY_INTEGER };
+
+ var indexData = [0, 1, 1, 2, 2, 3, 3, 4, 4, 0];
+
+ var indexDataArray = new Uint32Array(indexData.length);
+ indexDataArray.set(indexData, 0);
+ var indices = new dali.PropertyBuffer(indexFormat, 10);
+ indices.setData(indexDataArray);
+
+ // Create geometry
+ var geometry = new dali.Geometry();
+ geometry.addVertexBuffer( pentagonVertices );
+ geometry.addVertexBuffer( pentacleVertices );
+ geometry.setIndexBuffer( indices );
+ geometry.setGeometryType( dali.GEOMETRY_LINES );
+
+ var renderer = new dali.Renderer(geometry, material);
+ renderer.depthIndex = 0;
+
+ // Create mesh actor
+ var meshActor = new dali.Actor();
+ meshActor.addRenderer( renderer );
+ meshActor.size = [300, 300, 0];
+ meshActor.parentOrigin = dali.CENTER;
+ meshActor.anchorPoint = dali.CENTER;
+ meshActor.registerAnimatableProperty("uMorphAmount", 0.0);
+
+ dali.stage.add( meshActor );
+
+ // Animate the mesh actor
+ var animation = new dali.Animation(5);
+
+ var keyFramesIndex = [{progress:0.0, value: 0.0}, {progress:1.0, value:1.0}];
+ var animOptions = { alpha:"sin", delay:0, duration:5};
+
+ animation.animateBetween( meshActor, "uMorphAmount", keyFramesIndex, animOptions );
+ animation.setLooping(true);
+ animation.play();
+}
+
+function startup()
+{
+ daliApp.init();
+}
+
+daliApp.init = function()
+{
+ daliApp.createMeshActor();
+}
+
+
+startup();
+
--- /dev/null
+ var window= {
+ x:0,
+ y:0,
+ width:1920,
+ height: 1080,
+ transparent: false,
+ name:'mesh-morph-app'
+ };
+
+ var viewMode={
+ 'stereoscopic-mode':'mono', // stereo-horizontal, stereo-vertical, stereo-interlaced,
+ 'stereo-base': 65 // Distance in millimeters between left/right cameras typically between (50-70mm)
+ };
+
+ var options= {
+ 'window': window,
+ 'view-mode': viewMode,
+ }
+
+var dali = require('./build/Release/dali')( options );
+
+var daliApp = {};
+
+daliApp.createMeshActor = function() {
+
+ // Create shader
+ var vertShader =
+ "attribute mediump vec2 aInitPos;\
+ attribute mediump vec2 aFinalPos;\
+ attribute mediump vec3 aColor;\
+ uniform mediump mat4 uMvpMatrix;\
+ uniform mediump vec3 uSize;\
+ uniform mediump float uDelta;\
+ uniform lowp vec4 uColor;\
+ varying lowp vec4 vColor;\
+ void main()\
+ {\
+ mediump vec4 vertexPosition = vec4(mix(aInitPos, aFinalPos, uDelta), 0.0, 1.0);\
+ vertexPosition.xyz *= uSize;\
+ vertexPosition = uMvpMatrix * vertexPosition;\
+ gl_Position = vertexPosition;\
+ vColor = vec4(aColor, 0.) * uColor;\
+ }";
+
+ var fragShader =
+ "varying lowp vec4 vColor;\
+ void main()\
+ {\
+ gl_FragColor = vColor;\
+ }";
+
+ var shaderOptions = {
+ vertexShader : vertShader,
+ fragmentShader : fragShader
+ };
+
+ var shader = new dali.Shader(shaderOptions);
+
+ var material = new dali.Material( shader );
+
+ // Create vertex buffer for initial positions
+ var initialPositionVertexFormat = { "aInitPos" : dali.PROPERTY_VECTOR2 };
+
+ var initialPositionVertexData = [
+ // yellow
+ -0.50, -0.50,
+ 0.0, 0.0,
+ -0.50, 0.50,
+
+ // green
+ -0.50, -0.50,
+ 0.50, -0.50,
+ 0.0, 0.0,
+
+ // blue
+ 0.50, -0.50,
+ 0.50, 0.0,
+ 0.25, -0.25,
+
+ // red
+ 0.25, -0.25,
+ 0.50, 0.0,
+ 0.25, 0.25,
+ 0.25, 0.25,
+ 0.0, 0.0,
+ 0.25, -0.25,
+
+ // cyan
+ 0.0, 0.0,
+ 0.25, 0.25,
+ -0.25, 0.25,
+
+ // magenta
+ -0.25, 0.25,
+ 0.25, 0.25,
+ 0.0, 0.50,
+ 0.0, 0.50,
+ -0.50, 0.50,
+ -0.25, 0.25,
+
+ // orange
+ 0.50, 0.0,
+ 0.50, 0.50,
+ 0.0, 0.50
+ ];
+
+ var initialPositionVertexDataArray = new Float32Array(initialPositionVertexData.length);
+ initialPositionVertexDataArray.set(initialPositionVertexData, 0);
+ var initialPositionVertices = new dali.PropertyBuffer(initialPositionVertexFormat, 27);
+ initialPositionVertices.setData(initialPositionVertexDataArray);
+
+ // Create vertex buffer for final positions
+ var finalPositionVertexFormat = { "aFinalPos" : dali.PROPERTY_VECTOR2 };
+
+ var bigSide = 0.707106781;
+ var side = bigSide * 0.5;
+
+ var finalPositionVertexData = [
+ // yellow
+ side, 0.25, // pA
+ side, 0.25 + bigSide, // pB
+ side - bigSide, 0.25 + bigSide, // pC
+
+ // green
+ side - 0.50, -0.25, // pD
+ side, 0.25, // pA
+ side - 0.50, 0.75, // pE
+
+ // blue
+ side - 0.50, -0.75, // pJ
+ side - 0.50, -0.25, // pD
+ side - 0.75, -0.50, // pI
+
+ // red
+ side - 0.75, -0.50, // pI
+ side - 0.50, -0.25, // pD
+ side - 0.75, 0.0, // pG
+ side - 0.75, 0.0, // pG
+ side - 1.0, -0.25, // pH
+ side - 0.75, -0.50, // pI
+
+ // cyan
+ side - 0.75, -0.50, // pI
+ side - 1.0, -0.25, // pH
+ side - 1.0, -0.75, // pK
+
+ // magenta
+ side, 0.25 + bigSide - side, // pL
+ side * 2.0, 0.25 + bigSide - side * 2.0, // pM
+ side * 2.0, 0.25 + bigSide - side, // pN
+ side * 2.0, 0.25 + bigSide - side, // pN
+ side, 0.25 + bigSide, // pB
+ side, 0.25 + bigSide - side, // pL
+
+ // orange
+ side - 0.50, -0.25, // pD
+ side - 0.50, -0.25 + bigSide, // pF2
+ - 0.50, -0.25 + side // pF
+ ];
+
+ var finalPositionVertexDataArray = new Float32Array(finalPositionVertexData.length);
+ finalPositionVertexDataArray.set(finalPositionVertexData, 0);
+ var finalPositionVertices = new dali.PropertyBuffer(finalPositionVertexFormat, 27);
+ finalPositionVertices.setData(finalPositionVertexDataArray);
+
+ // Create vertex buffer for color
+ var colorVertexFormat = { "aColor" : dali.PROPERTY_VECTOR3 };
+
+ var colorVertexData = [
+ // yellow
+ 1.0, 1.0, 0.0,
+ 1.0, 1.0, 0.0,
+ 1.0, 1.0, 0.0,
+
+ // green
+ 0.0, 1.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 1.0, 0.0,
+
+ // blue
+ 0.0, 0.0, 1.0,
+ 0.0, 0.0, 1.0,
+ 0.0, 0.0, 1.0,
+
+ // red
+ 1.0, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+
+ // cyan
+ 0.0, 1.0, 1.0,
+ 0.0, 1.0, 1.0,
+ 0.0, 1.0, 1.0,
+
+ // magenta
+ 1.0, 0.0, 1.0,
+ 1.0, 0.0, 1.0,
+ 1.0, 0.0, 1.0,
+ 1.0, 0.0, 1.0,
+ 1.0, 0.0, 1.0,
+ 1.0, 0.0, 1.0,
+
+ // orange
+ 1.0, 0.5, 0.0,
+ 1.0, 0.5, 0.0,
+ 1.0, 0.5, 0.0
+ ];
+
+ var colorVertexDataArray = new Float32Array(colorVertexData.length);
+ colorVertexDataArray.set(colorVertexData, 0);
+ var colorVertices = new dali.PropertyBuffer(colorVertexFormat, 27);
+ colorVertices.setData(colorVertexDataArray);
+
+ // Create geometry
+ var geometry = new dali.Geometry();
+ geometry.addVertexBuffer( initialPositionVertices );
+ geometry.addVertexBuffer( finalPositionVertices );
+ geometry.addVertexBuffer( colorVertices );
+
+ var renderer = new dali.Renderer(geometry, material);
+ renderer.depthIndex = 0;
+
+ // Create mesh actor
+ var meshActor = new dali.Actor();
+ meshActor.addRenderer( renderer );
+ meshActor.size = [400, 400, 0];
+ meshActor.parentOrigin = dali.CENTER;
+ meshActor.anchorPoint = dali.CENTER;
+ meshActor.registerAnimatableProperty("uDelta", 0.0);
+
+ dali.stage.add( meshActor );
+
+ // Animate the mesh actor
+ var animation = new dali.Animation(5);
+
+ var animOptions = { alpha:"sin", delay:0, duration:5};
+
+ animation.animateTo( meshActor, "uDelta", 1.0, animOptions );
+ animation.setLooping(true);
+ animation.play();
+}
+
+function startup()
+{
+ daliApp.init();
+}
+
+daliApp.init = function()
+{
+ daliApp.createMeshActor();
+}
+
+
+startup();
+
--- /dev/null
+ var window= {
+ x:0,
+ y:0,
+ width:1920,
+ height: 1080,
+ transparent: false,
+ name:'line-mesh-app'
+ };
+
+ var viewMode={
+ 'stereoscopic-mode':'mono', // stereo-horizontal, stereo-vertical, stereo-interlaced,
+ 'stereo-base': 65 // Distance in millimeters between left/right cameras typically between (50-70mm)
+ };
+
+ var options= {
+ 'window': window,
+ 'view-mode': viewMode,
+ }
+
+var imageDir = "./";
+
+var dali = require('./build/Release/dali')( options );
+
+var daliApp = {};
+
+daliApp.createMeshActor = function() {
+
+ // Create shader
+ var vertShader =
+ "attribute mediump vec2 aPosition;\
+ attribute highp float aHue;\
+ varying mediump vec2 vTexCoord;\
+ uniform mediump mat4 uMvpMatrix;\
+ uniform mediump vec3 uSize;\
+ uniform mediump float uPointSize;\
+ uniform lowp vec4 uFadeColor;\
+ varying mediump vec3 vVertexColor;\
+ varying mediump float vHue;\
+ vec3 hsv2rgb(vec3 c)\
+ {\
+ vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\
+ vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\
+ return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\
+ }\
+ void main()\
+ {\
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\
+ vertexPosition.xyz *= (uSize-uPointSize);\
+ vertexPosition = uMvpMatrix * vertexPosition;\
+ vVertexColor = hsv2rgb( vec3( aHue, 0.7, 1.0 ) );\
+ vHue = aHue;\
+ gl_PointSize = uPointSize;\
+ gl_Position = vertexPosition;\
+ }";
+
+ var fragShader =
+ "varying mediump vec3 vVertexColor;\
+ varying mediump float vHue;\
+ uniform lowp vec4 uColor;\
+ uniform sampler2D sTexture1;\
+ uniform sampler2D sTexture2;\
+ uniform lowp vec4 uFadeColor;\
+ void main()\
+ {\
+ mediump vec4 texCol1 = texture2D(sTexture1, gl_PointCoord);\
+ mediump vec4 texCol2 = texture2D(sTexture2, gl_PointCoord);\
+ gl_FragColor = vec4(vVertexColor, 1.0) * ((texCol1*vHue) + (texCol2*(1.0-vHue)));\
+ }";
+
+ var shaderOptions = {
+ vertexShader : vertShader,
+ fragmentShader: fragShader
+ };
+
+ var shader = new dali.Shader(shaderOptions);
+
+ var material = new dali.Material( shader );
+ var image = new dali.ResourceImage( {url: imageDir + "image-1.jpg"} );
+ material.addTexture(image, "sTexture");
+
+ // Create vertex buffer
+ var polyhedraVertexFormat ={ "aPosition" : dali.PROPERTY_VECTOR2,
+ "aHue" : dali.PROPERTY_FLOAT };
+
+ var numSides = 20;
+ var angle = 0;
+ var sectorAngle = 2.0 * Math.PI / numSides;
+
+ var polyhedraVertexData = [];
+ for(i=0; i<numSides; ++i)
+ {
+ var positionX = Math.sin(angle) * 0.5;
+ var positionY = Math.cos(angle) * 0.5;
+ var hue = angle / ( 2.0 * Math.PI);
+
+ polyhedraVertexData[i*3+0] = positionX;
+ polyhedraVertexData[i*3+1] = positionY;
+ polyhedraVertexData[i*3+2] = hue;
+
+ angle += sectorAngle;
+ }
+
+ var polyhedraVertexDataArray = new Float32Array(polyhedraVertexData.length);
+ polyhedraVertexDataArray.set(polyhedraVertexData, 0);
+ var polyhedraVertices = new dali.PropertyBuffer(polyhedraVertexFormat, numSides);
+ polyhedraVertices.setData(polyhedraVertexDataArray);
+
+ // Create geometry
+ var geometry = new dali.Geometry();
+ geometry.addVertexBuffer( polyhedraVertices );
+ geometry.setGeometryType( dali.GEOMETRY_POINTS );
+
+ var renderer = new dali.Renderer(geometry, material);
+ renderer.registerAnimatableProperty("uFadeColor", [1.0, 0.0, 1.0, 1.0]); // Green
+ renderer.registerAnimatableProperty("uPointSize", 80.0);
+ renderer.depthIndex = 0;
+
+ // Create mesh actor
+ var meshActor = new dali.Actor();
+ meshActor.addRenderer( renderer );
+ meshActor.size = [400, 400, 0];
+ meshActor.parentOrigin = dali.CENTER;
+ meshActor.anchorPoint = dali.CENTER;
+ meshActor.registerAnimatableProperty("uFadeColor", [0.0, 1.0, 0.0, 1.0]); // Magenta
+
+ dali.stage.add( meshActor );
+
+ // Animate the mesh actor
+ var animation = new dali.Animation(5);
+ var animOptions = { alpha:"linear", delay:0, duration:5};
+ var rotation = new dali.Rotation(360,0,0,1);
+ animation.animateBy( meshActor, "orientation", rotation, animOptions );
+ animation.setLooping(true);
+ animation.play();
+}
+
+function startup()
+{
+ daliApp.init();
+}
+
+daliApp.init = function()
+{
+ daliApp.createMeshActor();
+}
+
+
+startup();
+
--- /dev/null
+ var window= {
+ x:0,
+ y:0,
+ width:1920,
+ height: 1080,
+ transparent: false,
+ name:'texture-mesh-app'
+ };
+
+ var viewMode={
+ 'stereoscopic-mode':'mono', // stereo-horizontal, stereo-vertical, stereo-interlaced,
+ 'stereo-base': 65 // Distance in millimeters between left/right cameras typically between (50-70mm)
+ };
+
+ var options= {
+ 'window': window,
+ 'view-mode': viewMode,
+ }
+
+var imageDir = "./";
+
+var dali = require('./build/Release/dali')( options );
+
+var daliApp = {};
+
+daliApp.createMeshActor = function() {
+
+ // Create shader
+ var vertShader =
+ "attribute mediump vec2 aPosition;\
+ attribute highp vec2 aTexCoord;\
+ varying mediump vec2 vTexCoord;\
+ uniform mediump mat4 uMvpMatrix;\
+ uniform mediump vec3 uSize;\
+ uniform lowp vec4 uFadeColor;\
+ void main()\
+ {\
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\
+ vertexPosition.xyz *= uSize;\
+ vertexPosition = uMvpMatrix * vertexPosition;\
+ vTexCoord = aTexCoord;\
+ gl_Position = vertexPosition;\
+ }";
+
+ var fragShader =
+ "varying mediump vec2 vTexCoord;\
+ uniform lowp vec4 uColor;\
+ uniform sampler2D sTexture;\
+ uniform lowp vec4 uFadeColor;\
+ void main()\
+ {\
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * uFadeColor;\
+ }";
+
+ var shaderOptions = {
+ vertexShader : vertShader,
+ fragmentShader: fragShader
+ };
+
+ var shader = new dali.Shader(shaderOptions);
+
+ var material = new dali.Material( shader );
+ var image = new dali.ResourceImage( {url: imageDir + "image-1.jpg"} );
+ material.addTexture(image, "sTexture");
+
+ var material2 = new dali.Material( shader );
+ var image2 = new dali.ResourceImage( {url: imageDir + "image-2.jpg"} );
+ material2.addTexture(image2, "sTexture");
+
+ // Create vertex buffer
+ var texturedQuadVertexFormat ={ "aPosition" : dali.PROPERTY_VECTOR2,
+ "aTexCoord" : dali.PROPERTY_VECTOR2 };
+
+ var halfQuadSize = 0.5;
+ var texturedQuadVertexData = [ -halfQuadSize, -halfQuadSize, 0.0, 0.0,
+ halfQuadSize, -halfQuadSize, 1.0, 0.0,
+ -halfQuadSize, halfQuadSize, 0.0, 1.0,
+ halfQuadSize, halfQuadSize, 1.0, 1.0 ];
+
+ var texturedQuadVertexDataArray = new Float32Array(texturedQuadVertexData.length);
+ texturedQuadVertexDataArray.set(texturedQuadVertexData, 0);
+ var texturedQuadVertices = new dali.PropertyBuffer(texturedQuadVertexFormat, 4);
+ texturedQuadVertices.setData(texturedQuadVertexDataArray);
+
+ var indexFormat ={ "indices" : dali.PROPERTY_INTEGER };
+
+ var indexData = [0, 3, 1, 0, 2, 3];
+
+ var indexDataArray = new Uint32Array(indexData.length);
+ indexDataArray.set(indexData, 0);
+ var indices = new dali.PropertyBuffer(indexFormat, 6);
+ indices.setData(indexDataArray);
+
+ // Create geometry
+ var geometry = new dali.Geometry();
+ geometry.addVertexBuffer( texturedQuadVertices );
+ geometry.setIndexBuffer( indices );
+
+ var renderer = new dali.Renderer(geometry, material);
+ renderer.depthIndex = 0;
+
+ var meshActor = new dali.Actor();
+ meshActor.addRenderer( renderer );
+ meshActor.size = [530, 530, 0];
+ meshActor.parentOrigin = dali.TOP_CENTER;
+ meshActor.anchorPoint = dali.TOP_CENTER;
+ meshActor.registerAnimatableProperty("uFadeColor", [1.0, 0.0, 1.0, 1.0]);
+
+ dali.stage.add( meshActor );
+
+ var renderer2 = new dali.Renderer(geometry, material2);
+ renderer2.depthIndex = 0;
+
+ var meshActor2 = new dali.Actor();
+ meshActor2.addRenderer( renderer2 );
+ meshActor2.size = [530, 530, 0];
+ meshActor2.parentOrigin = dali.BOTTOM_CENTER;
+ meshActor2.anchorPoint = dali.BOTTOM_CENTER;
+ meshActor2.registerAnimatableProperty("uFadeColor", [0.0, 0.0, 1.0, 1.0]);
+
+ dali.stage.add( meshActor2 );
+
+ // Animate the mesh actors
+ var animation = new dali.Animation(5);
+
+ var keyFramesIndex = [{progress:0.0, value: [0.0, 0.0, 0.0, 0.0]}, {progress:1.0, value:[0.0, 1.0, 0.0, 1.0]}];
+ var animOptions = { alpha:"sin", delay:0, duration:5};
+
+ var keyFramesIndex2 = [{progress:0.0, value: [0.0, 0.0, 0.0, 0.0]}, {progress:1.0, value:[1.0, 0.0, 1.0, 1.0]}];
+ var animOptions2 = { alpha:"sin", delay:0, duration:5};
+
+ animation.animateBetween( meshActor, "uFadeColor", keyFramesIndex, animOptions );
+ animation.animateBetween( meshActor2, "uFadeColor", keyFramesIndex2, animOptions2 );
+ animation.setLooping(true);
+ animation.play();
+}
+
+function startup()
+{
+ daliApp.init();
+}
+
+daliApp.init = function()
+{
+ daliApp.createMeshActor();
+}
+
+
+startup();
+
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.1.7
+Version: 1.1.8
Release: 1
Group: System/Libraries
License: Apache-2.0, BSD-2.0, MIT
* @class Actor
+ * @extends Handle
*/
| PIXEL_FORMAT_COMPRESSED_RGB8_ETC1 | integer value |
| PIXEL_FORMAT_COMPRESSED_RGB_PVRTC_4BPPV1 | integer value |
+|**Texture filtering mode ** | |
+|FILTER_MODE_NONE | integer value |
+|FILTER_MODE_DEFAULT | integer value |
+|FILTER_MODE_NEAREST | integer value |
+|FILTER_MODE_LINEAR | integer value |
+
+|**Sampler wrap mode ** | |
+|WRAP_MODE_DEFAULT | integer value |
+|WRAP_MODE_CLAMP_TO_EDGE | integer value |
+|WRAP_MODE_REPEAT | integer value |
+|WRAP_MODE_MIRRORED_REPEAT | integer value |
+
+|**Material face culling mode ** | |
+|MATERIAL_NONE | integer value |
+|MATERIAL_CULL_BACK | integer value |
+|MATERIAL_CULL_FRONT | integer value |
+|MATERIAL_CULL_BACK_AND_FRONT | integer value |
+
+|**Geometry primitives type ** | |
+|GEOMETRY_POINTS | integer value |
+|GEOMETRY_LINES | integer value |
+|GEOMETRY_LINE_LOOP | integer value |
+|GEOMETRY_LINE_STRIP | integer value |
+|GEOMETRY_TRIANGLES | integer value |
+|GEOMETRY_TRIANGLE_FAN | integer value |
+|GEOMETRY_TRIANGLE_STRIP | integer value |
+
+|**Property type ** | |
+|PROPERTY_NONE | integer value |
+|PROPERTY_BOOLEAN | integer value |
+|PROPERTY_FLOAT | integer value |
+|PROPERTY_INTEGER | integer value |
+|PROPERTY_VECTOR2 | integer value |
+|PROPERTY_VECTOR3 | integer value |
+|PROPERTY_VECTOR4 | integer value |
+|PROPERTY_MATRIX3 | integer value |
+|PROPERTY_MATRIX | integer value |
+|PROPERTY_RECTANGLE | integer value |
+|PROPERTY_ROTATION | integer value |
+|PROPERTY_STRING | integer value |
+|PROPERTY_ARRAY | integer value |
+|PROPERTY_MAP | integer value |
+|PROPERTY_INVALID_INDEX | integer value |
+
* @class Constants
*/
$(v8_plugin_dir)/image/resource-image-api.cpp \
$(v8_plugin_dir)/image/nine-patch-image-api.cpp \
$(v8_plugin_dir)/object/handle-wrapper.cpp \
+ $(v8_plugin_dir)/object/property-buffer-api.cpp \
+ $(v8_plugin_dir)/object/property-buffer-wrapper.cpp \
$(v8_plugin_dir)/object/property-value-wrapper.cpp \
$(v8_plugin_dir)/signals/signal-manager.cpp \
$(v8_plugin_dir)/render-tasks/render-task-list-api.cpp \
$(v8_plugin_dir)/render-tasks/render-task-list-wrapper.cpp \
$(v8_plugin_dir)/render-tasks/render-task-api.cpp \
$(v8_plugin_dir)/render-tasks/render-task-wrapper.cpp \
+ $(v8_plugin_dir)/rendering/geometry-api.cpp \
+ $(v8_plugin_dir)/rendering/geometry-wrapper.cpp \
+ $(v8_plugin_dir)/rendering/material-api.cpp \
+ $(v8_plugin_dir)/rendering/material-wrapper.cpp \
+ $(v8_plugin_dir)/rendering/renderer-api.cpp \
+ $(v8_plugin_dir)/rendering/renderer-wrapper.cpp \
+ $(v8_plugin_dir)/rendering/sampler-api.cpp \
+ $(v8_plugin_dir)/rendering/sampler-wrapper.cpp \
+ $(v8_plugin_dir)/rendering/shader-api.cpp \
+ $(v8_plugin_dir)/rendering/shader-wrapper.cpp \
$(v8_plugin_dir)/toolkit/builder/builder-api.cpp \
$(v8_plugin_dir)/toolkit/builder/builder-wrapper.cpp \
$(v8_plugin_dir)/toolkit/focus-manager/keyboard-focus-manager-api.cpp \
#include <v8-utils.h>
#include <actors/actor-wrapper.h>
#include <animation/path-constrainer-wrapper.h>
+#include <rendering/renderer-wrapper.h>
+#include <rendering/renderer-api.h>
namespace Dali
{
actor.ScaleBy( vector );
}
+/**
+ * Add a renderer to this actor.
+ * @example
+ *
+ * var renderer = new dali.Renderer( geometry, material );
+ * actor.addRenderer( renderer );
+ *
+ * @for Actor
+ * @method addRenderer
+ * @param {object} renderer Renderer to add to the actor
+ * @return {integer} The index of the Renderer that was added
+ */
+void ActorApi::AddRenderer( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+ Actor actor = GetActor( isolate, args );
+
+ unsigned int index = 0;
+
+ bool found( false );
+ Renderer renderer = RendererApi::GetRendererFromParams( 0, found, isolate, args );
+ if( found )
+ {
+ index = actor.AddRenderer(renderer);
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Renderer parameter missing" );
+ return;
+ }
+
+ args.GetReturnValue().Set( v8::Integer::New( isolate, index ) );
+}
+
+/**
+ * Get the number of renderers on this actor.
+ * @example
+ *
+ * var count = actor.getRendererCount();
+ *
+ * @for Actor
+ * @method getRendererCount
+ * @return {integer} the number of renderers on this actor
+ */
+void ActorApi::GetRendererCount( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Actor actor = GetActor( isolate, args );
+ args.GetReturnValue().Set( v8::Integer::New( isolate, actor.GetRendererCount() ) );
+}
+
+/**
+ * Get a Renderer by index.
+ * @example
+ *
+ * var renderer = actor.getRendererAt( 0 );
+ *
+ * @for Actor
+ * @method getRendererAt
+ * @param {integer} index The index of the renderer to fetch, which must be between 0 and getRendererCount()-1
+ * @return {object} The renderer at the specified index
+ */
+void ActorApi::GetRendererAt( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+ Actor actor = GetActor( isolate, args );
+
+ Renderer renderer;
+
+ bool found( false );
+ int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
+ return;
+ }
+ else
+ {
+ renderer = actor.GetRendererAt(static_cast<unsigned int>(index));
+ if( !renderer )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "renderer not found" );
+ return;
+ }
+ }
+
+ // Wrap the renderer
+ v8::Local<v8::Object> localObject = RendererWrapper::WrapRenderer( isolate, renderer );
+ args.GetReturnValue().Set( localObject );
+}
+
+/**
+ * Remove an renderer from the actor by index.
+ * @example
+ *
+ * actor.removeRenderer( 0 );
+ *
+ * @for Actor
+ * @method removeRenderer
+ * @param {integer} index Index of the renderer to be removed, which must be between 0 and getRendererCount()-1
+ */
+void ActorApi::RemoveRenderer( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+ Actor actor = GetActor( isolate, args );
+
+ bool found( false );
+ int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
+ }
+ else
+ {
+ actor.RemoveRenderer(static_cast<unsigned int>(index));
+ }
+}
+
+
} // namespace V8Plugin
} // namespace Dali
void TranslateBy( const v8::FunctionCallbackInfo< v8::Value >& args );
void RotateBy( const v8::FunctionCallbackInfo< v8::Value >& args );
void ScaleBy( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void AddRenderer( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetRendererCount( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetRendererAt( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void RemoveRenderer( const v8::FunctionCallbackInfo< v8::Value >& args );
// new function just for JavaScript API, to help developers know what type of actor
// they're dealing with, returns actor name as a string
{ "SetKeyboardFocusable", ActorApi::SetKeyboardFocusable, ACTOR_API }, //-- should this be a property???
{ "IsKeyboardFocusable" , ActorApi::IsKeyboardFocusable, ACTOR_API }, //-- should this be a property???
+ { "AddRenderer", ActorApi::AddRenderer, ACTOR_API },
+ { "GetRendererCount", ActorApi::GetRendererCount, ACTOR_API },
+ { "GetRendererAt" , ActorApi::GetRendererAt, ACTOR_API },
+ { "RemoveRenderer" , ActorApi::RemoveRenderer, ACTOR_API },
+
/**************************************
* Layer API (in order of layer.h)
**************************************/
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/actors/blending.h>
#include <dali/public-api/actors/camera-actor.h>
+#include <dali/public-api/actors/sampling.h>
#include <dali/public-api/render-tasks/render-task.h>
#include <dali/public-api/common/loading-state.h>
-
+#include <dali/devel-api/rendering/material.h>
+#include <dali/devel-api/rendering/geometry.h>
namespace Dali
{
{"IMAGE_ACTOR_STYLE_QUAD", ImageActor::STYLE_QUAD},
{"IMAGE_ACTOR_STYLE_NINE_PATCH", ImageActor::STYLE_NINE_PATCH},
- {"IMAGE_ACTOR_STYLE_NINE_PATCH_NO_CENTER",ImageActor::STYLE_NINE_PATCH_NO_CENTER }
-
+ {"IMAGE_ACTOR_STYLE_NINE_PATCH_NO_CENTER",ImageActor::STYLE_NINE_PATCH_NO_CENTER },
+
+ { "FILTER_MODE_NONE", FilterMode::NONE },
+ { "FILTER_MODE_DEFAULT", FilterMode::DEFAULT },
+ { "FILTER_MODE_NEAREST", FilterMode::NEAREST },
+ { "FILTER_MODE_LINEAR", FilterMode::LINEAR },
+
+ { "WRAP_MODE_DEFAULT", WrapMode::DEFAULT },
+ { "WRAP_MODE_CLAMP_TO_EDGE", WrapMode::CLAMP_TO_EDGE },
+ { "WRAP_MODE_REPEAT", WrapMode::REPEAT },
+ { "WRAP_MODE_MIRRORED_REPEAT", WrapMode::MIRRORED_REPEAT },
+
+ { "MATERIAL_NONE", Material::NONE },
+ { "MATERIAL_CULL_BACK", Material::CULL_BACK },
+ { "MATERIAL_CULL_FRONT", Material::CULL_FRONT },
+ { "MATERIAL_CULL_BACK_AND_FRONT", Material::CULL_BACK_AND_FRONT },
+
+ { "GEOMETRY_POINTS", Geometry::POINTS },
+ { "GEOMETRY_LINES", Geometry::LINES },
+ { "GEOMETRY_LINE_LOOP", Geometry::LINE_LOOP },
+ { "GEOMETRY_LINE_STRIP", Geometry::LINE_STRIP },
+ { "GEOMETRY_TRIANGLES", Geometry::TRIANGLES },
+ { "GEOMETRY_TRIANGLE_FAN", Geometry::TRIANGLE_FAN },
+ { "GEOMETRY_TRIANGLE_STRIP", Geometry::TRIANGLE_STRIP },
+
+ { "PROPERTY_NONE", Property::NONE },
+ { "PROPERTY_BOOLEAN", Property::BOOLEAN },
+ { "PROPERTY_FLOAT", Property::FLOAT },
+ { "PROPERTY_INTEGER", Property::INTEGER },
+ { "PROPERTY_VECTOR2", Property::VECTOR2 },
+ { "PROPERTY_VECTOR3", Property::VECTOR3 },
+ { "PROPERTY_VECTOR4", Property::VECTOR4 },
+ { "PROPERTY_MATRIX3", Property::MATRIX3 },
+ { "PROPERTY_MATRIX", Property::MATRIX },
+ { "PROPERTY_RECTANGLE", Property::RECTANGLE },
+ { "PROPERTY_ROTATION", Property::ROTATION },
+ { "PROPERTY_STRING", Property::STRING },
+ { "PROPERTY_ARRAY", Property::ARRAY },
+ { "PROPERTY_MAP", Property::MAP },
+ { "PROPERTY_INVALID_INDEX", Property::INVALID_INDEX },
};
const unsigned int EnumTableCount = sizeof(EnumTable)/sizeof(EnumTable[0]);
#include <animation/animation-wrapper.h>
#include <events/pan-gesture-detector-wrapper.h>
#include <shader-effects/shader-effect-wrapper.h>
+#include <object/property-buffer-wrapper.h>
+#include <rendering/geometry-wrapper.h>
+#include <rendering/material-wrapper.h>
+#include <rendering/renderer-wrapper.h>
+#include <rendering/shader-wrapper.h>
+#include <rendering/sampler-wrapper.h>
#include <shared/object-template-helper.h>
#include <constants/constants-wrapper.h>
#include <toolkit/builder/builder-wrapper.h>
{ "FrameBufferImage", ImageWrapper::NewImage },
{ "Animation", AnimationWrapper::NewAnimation},
{ "ShaderEffect", ShaderEffectWrapper::NewShaderEffect},
+ { "Shader", ShaderWrapper::NewShader},
+ { "Sampler", SamplerWrapper::NewSampler},
+ { "Material", MaterialWrapper::NewMaterial},
+ { "Geometry", GeometryWrapper::NewGeometry},
+ { "Renderer", RendererWrapper::NewRenderer},
+ { "PropertyBuffer", PropertyBufferWrapper::NewPropertyBuffer},
{ "Builder", BuilderWrapper::NewBuilder},
{ "PanGestureDetector", PanGestureDetectorWrapper::NewPanGestureDetector},
namespace V8Plugin
{
+namespace // un-named name space
+{
+
+/**
+ * Contains a list of all functions that can be called
+ */
+const ApiFunction HandleFunctionTable[]=
+{
+ { "RegisterAnimatableProperty", HandleWrapper::RegisterAnimatableProperty },
+};
+
+const unsigned int HandleFunctionTableCount = sizeof(HandleFunctionTable)/sizeof(HandleFunctionTable[0]);
+} //un-named space
+
+/**
+ * @class Handle
+ */
+
HandleWrapper::HandleWrapper( BaseWrappedObject::Type type,
Handle handle,
GarbageCollectorInterface& gc ) :
objTemplate->SetNamedPropertyHandler( HandleWrapper::PropertyGet, HandleWrapper::PropertySet);
+ // add function properties
+ ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, HandleFunctionTable, HandleFunctionTableCount );
+
ObjectTemplateHelper::AddSignalConnectAndDisconnect( isolate, objTemplate );
}
+/**
+ * Register a new animatable property.
+ *
+ * The object should support dynamic properties.
+ * Property names are expected to be unique, but this is not enforced.
+ * Property indices are unique to each registered custom property in a given object.
+ * returns dali.PROPERTY_INVALID_INDEX if registration failed. This can happen if you try
+ * to register animatable property on an object that does not have scene graph object.
+ *
+ * @method registerAnimatableProperty
+ * @for Handle
+ * @param {string} name The name of the property.
+ * @param {Object} propertyValue The new value of the property.
+ * @return {integer} The index of the property or dali.PROPERTY_INVALID_INDEX if registration failed
+ * @example
+ *
+ * var morphPropertyIdex = actor.registerAnimatableProperty("uMorphAmount", 0.0f);
+ * var fadeColorPropertyIdex = handle.registerAnimatableProperty("uFadeColor", [1.0, 0.0, 0.0, 1.0]);
+ *
+ */
+void HandleWrapper::RegisterAnimatableProperty( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ // unwrap the object
+ HandleWrapper* handleWrapper = Unwrap( isolate, args.This() );
+ if( !handleWrapper )
+ {
+ return;
+ }
+
+ Handle handle = handleWrapper->mHandle;
+
+ bool found( false );
+ std::string propertyName = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "bad property name parameter" );
+ return;
+ }
+
+ found = false;
+ Dali::Property::Value daliPropertyValue = V8Utils::GetPropertyValueParameter(PARAMETER_1, found, isolate, args );
+ if( !found || Dali::Property::NONE == daliPropertyValue.GetType() )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "bad property value parameter" );
+ return;
+ }
+ else
+ {
+ args.GetReturnValue().Set( v8::Integer::New( isolate, handle.RegisterProperty(propertyName, daliPropertyValue) ) );
+ }
+}
} // namespace V8Plugin
*/
static void AddInterceptsToTemplate( v8::Isolate* isolate, v8::Local<v8::ObjectTemplate>& objTemplate );
+ /**
+ * @brief Register an animatable property for a JavaScript object that
+ * contains a Dali Handle.
+ * @param[in] args v8 function call arguments interpreted
+ */
+ static void RegisterAnimatableProperty( const v8::FunctionCallbackInfo< v8::Value >& args );
Handle GetHandle() { return mHandle; }
Handle mHandle;
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "property-buffer-api.h"
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <object/property-buffer-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+namespace // unnamed namespace
+{
+
+struct PropertyBufferParameters
+{
+ PropertyBufferParameters()
+ : mSize( 0 )
+ {
+ }
+
+ PropertyBuffer NewPropertyBuffer()
+ {
+ return PropertyBuffer::New( mBufferFormat,
+ mSize);
+ }
+
+ Property::Map mBufferFormat;
+ std::size_t mSize;
+};
+
+} // unnamed space
+
+/**
+ * ## PropertyBuffer API
+ *
+ * PropertyBuffer is a handle to an object that contains a buffer of structured properties.
+ * It can be used to provide data to Geometry objects.
+ *
+ * ### Simple example
+ *
+ *```
+ * var vertexFormat ={ "aPosition" : dali.PROPERTY_VECTOR2 };
+ * var vertexData = [ 0, 1,
+ * -0.95, 0.31,
+ * -0.59, -0.81,
+ * 0.59, -0.81,
+ * 0.95, 0.31];
+ *
+ * var vertexDataArray = new Float32Array(vertexData.length);
+ * vertexDataArray.set(vertexData, 0);
+ * var vertices = new dali.PropertyBuffer(vertexFormat, 5);
+ * vertices.setData(vertexDataArray);
+ *
+ * var geometry = new dali.Geometry();
+ * geometry.addVertexBuffer( vertices );
+ *```
+ * @class PropertyBuffer
+ */
+
+PropertyBuffer PropertyBufferApi::GetPropertyBuffer( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::HandleScope handleScope( isolate );
+
+ v8::Local<v8::Object> object = args.This();
+ v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
+ void* ptr = field->Value();
+
+ PropertyBufferWrapper* wrapper = static_cast< PropertyBufferWrapper *>(ptr);
+ return wrapper->GetPropertyBuffer();
+}
+
+PropertyBuffer PropertyBufferApi::GetPropertyBufferFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ found = false;
+
+ v8::HandleScope handleScope( isolate );
+ BaseWrappedObject* wrappedObject = V8Utils::GetWrappedDaliObjectParameter( paramIndex, BaseWrappedObject::PROPERTY_BUFFER, isolate, args );
+ if( wrappedObject )
+ {
+ found = true;
+ PropertyBufferWrapper* wrapper = static_cast< PropertyBufferWrapper *>(wrappedObject);
+ return wrapper->GetPropertyBuffer();
+ }
+ else
+ {
+ return PropertyBuffer();
+ }
+}
+
+/**
+ * Create a new PropertyBuffer
+ *
+ * PropertyBuffers contains a buffer of structured properties and can be
+ * used to provide data to Geometry objects.
+ *
+ * @constructor
+ * @for PropertyBuffer
+ * @method PropertyBuffer
+ * @param {Object} bufferFormat
+ * @param {integer} size
+ * @return {Object} PropertyBuffer
+ * @example
+ *```
+ * var bufferFormat = {
+ * "aPosition" : dali.PROPERTY_VECTOR2,
+ * "aTexCoord" : dali.PROPERTY_VECTOR2,
+ * "aHue" : dali.PROPERTY_FLOAT,
+ * };
+ *
+ * var buffer = new dali.PropertyBuffer(bufferFormat, 5);
+ *```
+ */
+PropertyBuffer PropertyBufferApi::New( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::HandleScope handleScope( isolate );
+
+ bool found( false );
+ Dali::Property::Map bufferFormat = V8Utils::GetPropertyMapParameter( PARAMETER_0, found, isolate, args);
+ if( !found || bufferFormat.Empty() )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid property map parameter" );
+ return PropertyBuffer();
+ }
+
+ found = false;
+ int size = V8Utils::GetIntegerParameter( PARAMETER_1, found, isolate, args, 0);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing buffer size from param 1" );
+ return PropertyBuffer();
+ }
+
+ return PropertyBuffer::New(bufferFormat, static_cast<std::size_t>(size));
+}
+
+/**
+ * Update the whole buffer information
+ *
+ * This function expects an array of data with the same format that was given
+ * in the construction, and the number of elements to be the same as the size
+ * of the buffer.
+ *
+ * @method setData
+ * @for PropertyBuffer
+ * @param {Object} data The data that will be copied to the buffer.
+ * @example
+ *```
+ * var vertexData = [ 0, 1,
+ * -0.95, 0.31,
+ * -0.59, -0.81,
+ * 0.59, -0.81,
+ * 0.95, 0.31];
+ *
+ * var vertexDataArray = new Float32Array(vertexData.length);
+ * vertexDataArray.set(vertexData, 0);
+ *
+ * propertyBuffer.setData( vertexDataArray );
+ *```
+ */
+void PropertyBufferApi::SetData( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ PropertyBuffer buffer = GetPropertyBuffer( isolate, args );
+
+ bool found( false );
+ void* data = V8Utils::GetArrayBufferViewParameter( PARAMETER_0, found, isolate, args);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid data parameter" );
+ }
+ else
+ {
+ buffer.SetData( data );
+ }
+}
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_PROPERTY_BUFFER_API_H__
+#define __DALI_V8PLUGIN_PROPERTY_BUFFER_API_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/object/property-buffer.h>
+
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+namespace PropertyBufferApi
+{
+
+ /**
+ * @brief Helper to get property buffer from args.This()
+ * @param[in] isolate v8 isolated instance
+ * @param[in] args v8 function call arguments interpreted
+ */
+ PropertyBuffer GetPropertyBuffer( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * @brief Helper to get property buffer from the JavaScript object held in the given function argument
+ * @param[in] paramIndex Argument index the object is held in
+ * @param[in] found Whether property buffer is found in the given function parameter
+ * @param[in] isolate v8 isolated instance
+ * @param[in] args v8 function call arguments interpreted
+ */
+ PropertyBuffer GetPropertyBufferFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * Constructor
+ */
+ PropertyBuffer New( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * PropertyBuffer API see property-buffer.h for a description
+ */
+ void SetData( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+}; // namespace PropertyBufferApi
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // header __DALI_V8PLUGIN_PROPERTY_BUFFER_API_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "property-buffer-wrapper.h"
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <object/property-buffer-api.h>
+#include <shared/api-function.h>
+#include <shared/object-template-helper.h>
+#include <dali-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+v8::Persistent<v8::ObjectTemplate> PropertyBufferWrapper::mPropertyBufferTemplate;
+
+namespace // un-named name space
+{
+
+/**
+ * Contains a list of all functions that can be called
+ */
+const ApiFunction PropertyBufferFunctionTable[]=
+{
+ /**************************************
+ * PropertyBuffer API (in order of property-buffer.h)
+ **************************************/
+
+ { "SetData" , PropertyBufferApi::SetData },
+};
+
+const unsigned int PropertyBufferFunctionTableCount = sizeof(PropertyBufferFunctionTable)/sizeof(PropertyBufferFunctionTable[0]);
+} //un-named space
+
+
+PropertyBufferWrapper::PropertyBufferWrapper( const Dali::PropertyBuffer& buffer, GarbageCollectorInterface& gc )
+: BaseWrappedObject( BaseWrappedObject::PROPERTY_BUFFER , gc )
+{
+ mPropertyBuffer = buffer;
+}
+
+v8::Handle<v8::Object> PropertyBufferWrapper::WrapPropertyBuffer(v8::Isolate* isolate, const Dali::PropertyBuffer& buffer )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ objectTemplate = GetPropertyBufferTemplate( isolate);
+
+ // create an instance of the template
+ v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
+
+ // create the PropertyBuffer wrapper
+ PropertyBufferWrapper* pointer = new PropertyBufferWrapper( buffer, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
+
+ // assign the JavaScript object to the wrapper.
+ pointer->SetJavascriptObject( isolate, localObject );
+
+ return handleScope.Escape( localObject );
+}
+
+v8::Local<v8::ObjectTemplate> PropertyBufferWrapper::GetPropertyBufferTemplate( v8::Isolate* isolate)
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ if( mPropertyBufferTemplate.IsEmpty() )
+ {
+ objectTemplate = MakePropertyBufferTemplate( isolate );
+ mPropertyBufferTemplate.Reset( isolate, objectTemplate );
+ }
+ else
+ {
+ // get the object template
+ objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, mPropertyBufferTemplate );
+ }
+ return handleScope.Escape( objectTemplate );
+}
+
+v8::Handle<v8::ObjectTemplate> PropertyBufferWrapper::MakePropertyBufferTemplate( v8::Isolate* isolate )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+
+ v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
+
+ objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
+
+ // add our function properties
+ ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, PropertyBufferFunctionTable, PropertyBufferFunctionTableCount );
+
+ return handleScope.Escape( objTemplate );
+}
+
+void PropertyBufferWrapper::NewPropertyBuffer( const v8::FunctionCallbackInfo< v8::Value >& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate);
+
+ if(!args.IsConstructCall())
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "PropertyBuffer constructor called without 'new'");
+ return;
+ }
+ Dali::PropertyBuffer buffer = PropertyBufferApi::New( isolate, args );
+
+ if(buffer)
+ {
+ v8::Local<v8::Object> localObject = WrapPropertyBuffer( isolate, buffer );
+ args.GetReturnValue().Set( localObject );
+ }
+}
+
+
+PropertyBuffer PropertyBufferWrapper::GetPropertyBuffer()
+{
+ return mPropertyBuffer;
+}
+
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_PROPERTY_BUFFER_WRAPPER_H__
+#define __DALI_V8PLUGIN_PROPERTY_BUFFER_WRAPPER_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/object/property-buffer.h>
+
+// INTERNAL INCLUDES
+#include <shared/base-wrapped-object.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+
+/**
+ * A PropertyBuffer wrapper.
+ * Provides access to PropertyBuffer specific functionality and V8 memory handling.
+ */
+class PropertyBufferWrapper : public BaseWrappedObject
+{
+
+public:
+
+ /**
+ * @brief Constructor
+ * @param[in] propertyBuffer DALi property buffer
+ * @param[in] gc garbage collection interface
+ */
+ PropertyBufferWrapper( const PropertyBuffer& propertyBuffer,
+ GarbageCollectorInterface& gc );
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~PropertyBufferWrapper()
+ {
+ };
+
+ /**
+ * @brief Creates a new PropertyBuffer wrapped inside a Javascript Object.
+ * @param[in] args v8 function call arguments interpreted
+ */
+ static void NewPropertyBuffer( const v8::FunctionCallbackInfo< v8::Value >& args);
+
+ /**
+ * Wraps a property buffer
+ */
+ static v8::Handle<v8::Object> WrapPropertyBuffer(v8::Isolate* isolate, const Dali::PropertyBuffer& );
+
+
+ // The PropertyBufferAttribute ObjectTemplate, we cache templates so we don't have
+ // keep generating them everytime we want to create a PropertyBuffer
+ static v8::Persistent<v8::ObjectTemplate> mPropertyBufferTemplate;
+
+ /**
+ * @brief Gets the handle of property buffer
+ */
+ PropertyBuffer GetPropertyBuffer();
+
+
+private:
+
+ // PropertyBuffer
+ PropertyBuffer mPropertyBuffer;
+
+ static v8::Handle<v8::ObjectTemplate> MakePropertyBufferTemplate( v8::Isolate* isolate );
+ static v8::Local<v8::ObjectTemplate> GetPropertyBufferTemplate( v8::Isolate* isolate );
+
+};
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // __DALI_V8PLUGIN_PROPERTY_BUFFER_WRAPPER_H__
daliPropertyValue = ArrayFromV8Array( isolate, v8Value );
break;
}
+ case Dali::Property::MAP:
+ {
+ if( v8Value->IsObject() )
+ {
+ v8::Local<v8::Object> object = v8::Handle<v8::Object>::Cast(v8Value);
+ Dali::Property::Map propertyMap = V8Utils::GetPropertyMapFromObject(isolate, object);
+ daliPropertyValue = Dali::Property::Value( propertyMap );
+ }
+ break;
+ }
case Dali::Property::NONE:
default:
{
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+// CLASS HEADER
+#include "geometry-api.h"
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <rendering/geometry-wrapper.h>
+#include <object/property-buffer-api.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+/**
+ * ## Geometry API
+ *
+ * Geometry is handle to an object that can be used to define a geometric elements.
+ *
+ * @class Geometry
+ * @extends Handle
+ */
+
+Geometry GeometryApi::GetGeometry( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::HandleScope handleScope( isolate );
+
+ v8::Local<v8::Object> object = args.This();
+ v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
+ void* ptr = field->Value();
+
+ GeometryWrapper* wrapper = static_cast< GeometryWrapper *>(ptr);
+ return wrapper->GetGeometry();
+}
+
+Geometry GeometryApi::GetGeometryFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ found = false;
+
+ v8::HandleScope handleScope( isolate );
+ BaseWrappedObject* wrappedObject = V8Utils::GetWrappedDaliObjectParameter( paramIndex, BaseWrappedObject::GEOMETRY, isolate, args );
+ if( wrappedObject )
+ {
+ found = true;
+ GeometryWrapper* wrapper = static_cast< GeometryWrapper *>(wrappedObject);
+ return wrapper->GetGeometry();
+ }
+ else
+ {
+ return Geometry();
+ }
+}
+
+/**
+ * Create a new geometry object.
+ *
+ * @constructor
+ * @method Geometry
+ * @for Geometry
+ * @return {Object} Geometry
+ */
+Geometry GeometryApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ return Geometry::New();
+}
+
+/**
+ * Add a PropertyBuffer to be used as source of geometry vertices
+ *
+ * @method addVertexBuffer
+ * @for Geometry
+ * @param {Object} vertexBuffer PropertyBuffer to be used as source of geometry vertices
+ * @return {interger} Index of the newly added buffer, can be used with RemoveVertexBuffer
+ * to remove this buffer if no longer required
+ * @example
+ *```
+ * var vertexFormat ={ "aPosition" : dali.PROPERTY_VECTOR2 };
+ * var vertexData = [ 0, 1,
+ * -0.95, 0.31,
+ * -0.59, -0.81,
+ * 0.59, -0.81,
+ * 0.95, 0.31];
+ *
+ * var vertexDataArray = new Float32Array(vertexData.length);
+ * vertexDataArray.set(vertexData, 0);
+ * var vertices = new dali.PropertyBuffer(vertexFormat, 5);
+ * vertices.setData(vertexDataArray);
+ *
+ * var geometry = new dali.Geometry();
+ * geometry.addVertexBuffer( vertices );
+ *```
+ */
+void GeometryApi::AddVertexBuffer( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Geometry geometry = GetGeometry( isolate, args );
+
+ bool found( false );
+ PropertyBuffer vertexBuffer = PropertyBufferApi::GetPropertyBufferFromParams( 0, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid property buffer parameter" );
+ }
+ else
+ {
+ args.GetReturnValue().Set( v8::Integer::New( isolate, geometry.AddVertexBuffer(vertexBuffer) ) );
+ }
+}
+
+/**
+ * Retrieve the number of vertex buffers that have been added to this geometry
+ *
+ * @method getNumberOfVertexBuffers
+ * @for Geometry
+ * @return {integer} Number of vertex buffers that have been added to this geometry
+ */
+void GeometryApi::GetNumberOfVertexBuffers( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Geometry geometry = GetGeometry( isolate, args );
+
+ args.GetReturnValue().Set( v8::Integer::New( isolate, geometry.GetNumberOfVertexBuffers() ) );
+}
+
+/**
+ * Remove a vertex buffer
+ *
+ * @method removeVertexBuffer
+ * @for Geometry
+ * @param {integer} index Index to the vertex buffer to remove,
+ * which must be between 0 and getNumberOfVertexBuffers()
+ */
+void GeometryApi::RemoveVertexBuffer( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Geometry geometry = GetGeometry( isolate, args );
+
+ bool found( false );
+ int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing index from param 0" );
+ }
+ else
+ {
+ geometry.RemoveVertexBuffer(static_cast<std::size_t>(index));
+ }
+}
+
+/**
+ * Set a PropertyBuffer to be used as a source of indices for the geometry
+ *
+ * This buffer is required to have exactly one component and it must be of the
+ * type dali.PROPERTY_INTEGER
+ *
+ * By setting this buffer it will cause the geometry to be rendered using indices.
+ * To unset call SetIndexBuffer with an empty handle.
+ *
+ * @method setIndexBuffer
+ * @for Geometry
+ * @param {Object} indexBuffer PropertyBuffer to be used as a source of indices
+ * for the geometry
+ */
+void GeometryApi::SetIndexBuffer( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Geometry geometry = GetGeometry( isolate, args );
+
+ bool found( false );
+ PropertyBuffer indexBuffer = PropertyBufferApi::GetPropertyBufferFromParams( 0, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid property buffer parameter" );
+ }
+ else
+ {
+ geometry.SetIndexBuffer(indexBuffer);
+ }
+}
+
+/**
+ * Set the type of primitives this geometry contains
+ *
+ * @method setGeometryType
+ * @for Geometry
+ * @param {integer} geometryType Type of primitives this geometry contains
+ * @example
+ * // geometry type is one of the following
+ * dali.GEOMETRY_POINTS
+ * dali.GEOMETRY_LINES
+ * dali.GEOMETRY_LINE_LOOP
+ * dali.GEOMETRY_LINE_STRIP
+ * dali.GEOMETRY_TRIANGLES
+ * dali.GEOMETRY_TRIANGLE_FAN
+ * dali.GEOMETRY_TRIANGLE_STRIP
+ *
+ * geometry.SetGeometryType( dali.GEOMETRY_LINES );
+ */
+void GeometryApi::SetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Geometry geometry = GetGeometry( isolate, args );
+
+ bool found( false );
+ int geometryType = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing geometryType from param 0" );
+ }
+ else
+ {
+ geometry.SetGeometryType(static_cast<Geometry::GeometryType>(geometryType));
+ }
+}
+
+/**
+ * Get the type of primitives this geometry contains
+ *
+ * @method getGeometryType
+ * @for Geometry
+ * @return {integer} Type of primitives this geometry contains
+ * @example
+ * // returns one of the following
+ * dali.GEOMETRY_POINTS
+ * dali.GEOMETRY_LINES
+ * dali.GEOMETRY_LINE_LOOP
+ * dali.GEOMETRY_LINE_STRIP
+ * dali.GEOMETRY_TRIANGLES
+ * dali.GEOMETRY_TRIANGLE_FAN
+ * dali.GEOMETRY_TRIANGLE_STRIP
+ */
+void GeometryApi::GetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Geometry geometry = GetGeometry( isolate, args );
+
+ args.GetReturnValue().Set( v8::Integer::New( isolate, geometry.GetGeometryType() ) );
+}
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_GEOMETRY_API_H__
+#define __DALI_V8PLUGIN_GEOMETRY_API_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/geometry.h>
+
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+namespace GeometryApi
+{
+
+ /**
+ * Helper to get geometry from args.This()
+ */
+ Geometry GetGeometry( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * @brief Helper to get geometry from the JavaScript object held in the given function argument
+ * @param[in] paramIndex Argument index the object is held in
+ * @param[in] found Whether geometry is found in the given function parameter
+ * @param[in] isolate v8 isolated instance
+ * @param[in] args v8 function call arguments interpreted
+ */
+ Geometry GetGeometryFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * Constructor
+ */
+ Geometry New( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * Geometry API see geometry.h for a description
+ */
+ void AddVertexBuffer( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetNumberOfVertexBuffers( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void RemoveVertexBuffer( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetIndexBuffer( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+}; // namespace GeometryApi
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // header __DALI_V8PLUGIN_GEOMETRY_API_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "geometry-wrapper.h"
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <rendering/geometry-api.h>
+#include <shared/api-function.h>
+#include <shared/object-template-helper.h>
+#include <dali-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+v8::Persistent<v8::ObjectTemplate> GeometryWrapper::mGeometryTemplate;
+
+namespace // un-named name space
+{
+
+/**
+ * Contains a list of all functions that can be called
+ */
+const ApiFunction GeometryFunctionTable[]=
+{
+ /**************************************
+ * Geometry API (in order of Geometry.h)
+ **************************************/
+
+ { "AddVertexBuffer" , GeometryApi::AddVertexBuffer },
+ { "GetNumberOfVertexBuffers" , GeometryApi::GetNumberOfVertexBuffers },
+ { "RemoveVertexBuffer" , GeometryApi::RemoveVertexBuffer },
+ { "SetIndexBuffer" , GeometryApi::SetIndexBuffer },
+ { "SetGeometryType" , GeometryApi::SetGeometryType },
+ { "GetGeometryType" , GeometryApi::GetGeometryType },
+};
+
+const unsigned int GeometryFunctionTableCount = sizeof(GeometryFunctionTable)/sizeof(GeometryFunctionTable[0]);
+} //un-named space
+
+
+GeometryWrapper::GeometryWrapper( const Dali::Geometry& geometry, GarbageCollectorInterface& gc )
+: HandleWrapper( BaseWrappedObject::GEOMETRY , geometry, gc )
+{
+ mGeometry = geometry;
+}
+
+v8::Handle<v8::Object> GeometryWrapper::WrapGeometry(v8::Isolate* isolate, const Dali::Geometry& geometry )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ objectTemplate = GetGeometryTemplate( isolate);
+
+ // create an instance of the template
+ v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
+
+ // create the Geometry wrapper
+ GeometryWrapper* pointer = new GeometryWrapper( geometry, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
+
+ // assign the JavaScript object to the wrapper.
+ pointer->SetJavascriptObject( isolate, localObject );
+
+ return handleScope.Escape( localObject );
+}
+
+v8::Local<v8::ObjectTemplate> GeometryWrapper::GetGeometryTemplate( v8::Isolate* isolate)
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ if( mGeometryTemplate.IsEmpty() )
+ {
+ objectTemplate = MakeGeometryTemplate( isolate );
+ mGeometryTemplate.Reset( isolate, objectTemplate );
+ }
+ else
+ {
+ // get the object template
+ objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, mGeometryTemplate );
+ }
+ return handleScope.Escape( objectTemplate );
+}
+
+v8::Handle<v8::ObjectTemplate> GeometryWrapper::MakeGeometryTemplate( v8::Isolate* isolate )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+
+ v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
+
+ // property handle intercepts property getters and setters and signals
+ HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate );
+
+ objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
+
+ // add our function properties
+ ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, GeometryFunctionTable, GeometryFunctionTableCount );
+
+ return handleScope.Escape( objTemplate );
+}
+
+void GeometryWrapper::NewGeometry( const v8::FunctionCallbackInfo< v8::Value >& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate);
+
+ if(!args.IsConstructCall())
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Geometry constructor called without 'new'");
+ return;
+ }
+ Dali::Geometry geometry = GeometryApi::New( args );
+
+ if(geometry)
+ {
+ v8::Local<v8::Object> localObject = WrapGeometry( isolate, geometry );
+ args.GetReturnValue().Set( localObject );
+ }
+}
+
+
+Geometry GeometryWrapper::GetGeometry()
+{
+ return mGeometry;
+}
+
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_GEOMETRY_WRAPPER_H__
+#define __DALI_V8PLUGIN_GEOMETRY_WRAPPER_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/geometry.h>
+
+// INTERNAL INCLUDES
+#include <object/handle-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+
+/**
+ * A Geometry wrapper.
+ * Provides access to Geometry specific functionality and V8 memory handling.
+ */
+class GeometryWrapper : public HandleWrapper
+{
+
+public:
+
+ /**
+ * @brief Constructor
+ * @param[in] propertyBuffer DALi geometry
+ * @param[in] gc garbage collection interface
+ */
+ GeometryWrapper( const Geometry& geometry,
+ GarbageCollectorInterface& gc );
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~GeometryWrapper()
+ {
+ };
+
+ /**
+ * @brief Creates a new Geometry wrapped inside a Javascript Object.
+ * @param[in] args v8 function call arguments interpreted
+ */
+ static void NewGeometry( const v8::FunctionCallbackInfo< v8::Value >& args);
+
+ /**
+ * Wraps a geometry
+ */
+ static v8::Handle<v8::Object> WrapGeometry(v8::Isolate* isolate, const Dali::Geometry& );
+
+
+ // The GeometryAttribute ObjectTemplate, we cache templates so we don't have
+ // keep generating them everytime we want to create a Geometry
+ static v8::Persistent<v8::ObjectTemplate> mGeometryTemplate;
+
+ /**
+ * @brief Gets the handle of geometry
+ * @return the handle of geometry
+ */
+ Geometry GetGeometry();
+
+
+private:
+
+ // Geometry
+ Geometry mGeometry;
+
+ /**
+ * @brief Creates the object template that used to create geometry at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Handle<v8::ObjectTemplate> MakeGeometryTemplate( v8::Isolate* isolate );
+
+ /**
+ * @brief Gets the object template that used to create geometry at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Local<v8::ObjectTemplate> GetGeometryTemplate( v8::Isolate* isolate );
+
+};
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // __DALI_V8PLUGIN_GEOMETRY_WRAPPER_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+// CLASS HEADER
+#include "material-api.h"
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <rendering/material-wrapper.h>
+#include <rendering/shader-wrapper.h>
+#include <rendering/shader-api.h>
+#include <rendering/sampler-wrapper.h>
+#include <rendering/sampler-api.h>
+#include <image/image-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+/**
+ * ## Material API
+ *
+ * Material is a handle to an object that specifies the visual properties of the renderer.
+ *
+ * @class Material
+ * @extends Handle
+ */
+
+Material MaterialApi::GetMaterial( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::HandleScope handleScope( isolate );
+
+ v8::Local<v8::Object> object = args.This();
+ v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
+ void* ptr = field->Value();
+
+ MaterialWrapper* wrapper = static_cast< MaterialWrapper *>(ptr);
+ return wrapper->GetMaterial();
+}
+
+Material MaterialApi::GetMaterialFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ found = false;
+
+ v8::HandleScope handleScope( isolate );
+ BaseWrappedObject* wrappedObject = V8Utils::GetWrappedDaliObjectParameter( paramIndex, BaseWrappedObject::MATERIAL, isolate, args );
+ if( wrappedObject )
+ {
+ found = true;
+ MaterialWrapper* wrapper = static_cast< MaterialWrapper *>(wrappedObject);
+ return wrapper->GetMaterial();
+ }
+ else
+ {
+ return Material();
+ }
+}
+
+/**
+ * Create a new material object.
+ *
+ * @constructor
+ * @method Material
+ * @for Material
+ * @param {Object} shader The shader used by the material
+ * @return {Object} Material
+ */
+Material MaterialApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ bool found( false );
+ Shader shader = ShaderApi::GetShaderFromParams( 0, found, isolate, args );
+ if( found )
+ {
+ return Material::New( shader );
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing shader from param 0" );
+ return Material();
+ }
+}
+
+/**
+ * Set the Shader used by this material
+ *
+ * @method setShader
+ * @for Material
+ * @param {Object} shader Handle to the shader
+ */
+void MaterialApi::SetShader( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ bool found( false );
+ Shader shader = ShaderApi::GetShaderFromParams( 0, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid shader parameter" );
+ }
+ else
+ {
+ return material.SetShader( shader );
+ }
+}
+
+/**
+ * Get the Shader used by this material
+ *
+ * @method getShader
+ * @for Material
+ * @return {Object} Shader
+ */
+void MaterialApi::GetShader( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+ Shader shader = material.GetShader();
+
+ // Wrap the shader
+ v8::Local<v8::Object> localObject = ShaderWrapper::WrapShader( isolate, shader );
+ args.GetReturnValue().Set( localObject );
+}
+
+/**
+ * Add a new texture to be used by the material
+ *
+ * @method addTexture
+ * @for Material
+ * @param {Object} image The image used by this sampler
+ * @param {String} uniformName The string with the name of the uniform
+ * @param {Object} sampler The sampler to add to this material
+ * @return {integer} The index of the texture in the array of textures or -1 if texture can not be added
+ */
+void MaterialApi::AddTexture( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ bool found( false );
+ Image image = V8Utils::GetImageParameter( PARAMETER_0, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing image from param 0" );
+ return;
+ }
+
+ found = false;
+ std::string uniformName = V8Utils::GetStringParameter( PARAMETER_1, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing uniform name from param 1" );
+ return;
+ }
+
+ found = false;
+ Sampler sampler = SamplerApi::GetSamplerFromParams( PARAMETER_2, found, isolate, args );
+ if( !found )
+ {
+ args.GetReturnValue().Set( v8::Integer::New( isolate, material.AddTexture( image, uniformName ) ) );
+ }
+ else
+ {
+ args.GetReturnValue().Set( v8::Integer::New( isolate, material.AddTexture( image, uniformName, sampler ) ) );
+ }
+}
+
+/**
+ * Removes a texture from the material
+ *
+ * @method removeTexture
+ * @for Material
+ * @param {integer} index The index of the texture in the array of textures
+ */
+void MaterialApi::RemoveTexture( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ bool found( false );
+ int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
+ }
+ else
+ {
+ material.RemoveTexture( index );
+ }
+}
+
+/**
+ * Sets the image to be used by a given texture
+ * @method setTextureImage
+ * @for Material
+ * @param {integer} index The index of the texture in the array of textures
+ * @param {Object} image The image used by this sampler
+ */
+void MaterialApi::SetTextureImage( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ bool found( false );
+ int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
+ return;
+ }
+
+ found = false;
+ Image image = V8Utils::GetImageParameter( PARAMETER_1, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing image from param 1" );
+ }
+ else
+ {
+ material.SetTextureImage(index, image);
+ }
+}
+
+/**
+ * Set the sampler used by a given texture
+ * @method setTextureSampler
+ * @for Material
+ * @param {integer} index The index of the texture in the array of textures
+ * @param {Object} sampler The new sampler
+ */
+void MaterialApi::SetTextureSampler( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ bool found( false );
+ int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
+ return;
+ }
+
+ found = false;
+ Sampler sampler = SamplerApi::GetSamplerFromParams( PARAMETER_1, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing sampler from param 1" );
+ }
+ else
+ {
+ material.SetTextureSampler(index, sampler);
+ }
+}
+
+/**
+ * Set the uniform name of a given texture
+ * @method setTextureUniformName
+ * @for Material
+ * @param {integer} index The index of the texture in the array of textures
+ * @param {string} uniformName The new uniform name
+ */
+void MaterialApi::SetTextureUniformName( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ bool found( false );
+ int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
+ return;
+ }
+
+ found = false;
+ std::string uniformName = V8Utils::GetStringParameter( PARAMETER_1, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid uniform name parameter" );
+ }
+ else
+ {
+ material.SetTextureUniformName(index, uniformName);
+ }
+}
+
+/**
+ * Establish if a given texture will affect the transparency of the material ( true by default )
+ * @method setTextureAffectsTransparency
+ * @for Material
+ * @param {integer} index The index of the texture in the array of textures
+ * @param {string} affectsTransparency True if the texture affects transparency, false otherwise
+ */
+void MaterialApi::SetTextureAffectsTransparency( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ bool found( false );
+ int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
+ return;
+ }
+
+ found = false;
+ bool affectsTransparency = V8Utils::GetBooleanParameter( PARAMETER_1, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid affectsTransparency parameter" );
+ }
+ else
+ {
+ material.SetTextureAffectsTransparency(index, affectsTransparency);
+ }
+}
+
+/**
+ * Retrive the index of a texture given its uniform name
+ * @method getTextureIndex
+ * @for Material
+ * @param {string} uniformName The uniform name
+ * @return {integer} The index in the array of textures or -1 if the texture is not found
+ */
+void MaterialApi::GetTextureIndex( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ bool found( false );
+ std::string uniformName = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid uniform name parameter" );
+ }
+ else
+ {
+ args.GetReturnValue().Set( v8::Integer::New( isolate, material.GetTextureIndex(uniformName) ) );
+ }
+}
+
+/**
+ * Retrieve the number of textures used by the material
+ *
+ * @method getNumberOfTextures
+ * @for Material
+ * @return {integer} The number of textures
+ */
+void MaterialApi::GetNumberOfTextures( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ args.GetReturnValue().Set( v8::Integer::New( isolate, material.GetNumberOfTextures() ) );
+}
+
+/**
+ * Set the culling mode for this material
+ *
+ * @method setFaceCullingMode
+ * @for Material
+ * @param {integer} cullingMode The culling mode for this material
+ * @example
+ * // face culling mode is one of the following
+ * dali.MATERIAL_NONE // None of the faces should be culled
+ * dali.MATERIAL_CULL_BACK // Cull back face, back face should never be shown
+ * dali.MATERIAL_CULL_FRONT // Cull front face, back face should never be shown
+ * dali.MATERIAL_CULL_BACK_AND_FRONT // Cull back and front faces, if the geometry is composed of triangles none of the faces will be shown
+ *
+ * material.setFaceCullingMode( dali.MATERIAL_NONE );
+ */
+void MaterialApi::SetFaceCullingMode( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ bool found( false );
+ int mode = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid cullingMode parameter" );
+ }
+ else
+ {
+ material.SetFaceCullingMode( static_cast<Material::FaceCullingMode>(mode) );
+ }
+}
+
+/**
+ * Set the blending mode.
+ *
+ * If blending is disabled (BLENDING_OFF) fade in and fade out animations do not work.
+ *
+ * @for Material
+ * @method setBlendMode
+ * @param { integer } mode The blending mode.
+ * @example
+ * // blend mode is one of the following
+ * dali.BLENDING_OFF // Blending is disabled.
+ * dali.BLENDING_AUTO // Blending is enabled if there is alpha channel.
+ * dali.BLENDING_ON // Blending is enabled.
+ *
+ * material.setBlendMode( dali.BLENDING_AUTO );
+ */
+void MaterialApi::SetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ bool found( false );
+ int mode = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid blendMode parameter" );
+ }
+ else
+ {
+ material.SetBlendMode( static_cast<Dali::BlendingMode::Type>( mode ) );
+ }
+}
+
+/**
+ * Retrieves the blending mode.
+ *
+ * @for Material
+ * @method getBlendMode
+ * @return { integer } blendMode
+ * @example returns one of the following:
+ *
+ * dali.BLENDING_OFF // Blending is disabled.
+ * dali.BLENDING_AUTO // Blending is enabled if there is alpha channel.
+ * dali.BLENDING_ON // Blending is enabled.
+ */
+void MaterialApi::GetBlendMode( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ args.GetReturnValue().Set( v8::Integer::New( isolate, material.GetBlendMode() ) );
+}
+
+/**
+ * Specify the pixel arithmetic used when the actor is blended.
+ *
+ * @for Material
+ * @method setBlendFunc
+ * @param {integer} srcFactorRgb Source Blending RGB
+ * @param {integer} destFactorRgb Destination Blending RGB
+ * @param {integer} srcFactorAlpha Source Blending Alpha
+ * @param {integer} destFactorAlpha Destinatino Blending Alpha
+ * @example
+ * //blending constants
+ * dali.BLEND_FACTOR_ZERO
+ * dali.BLEND_FACTOR_ONE
+ * dali.BLEND_FACTOR_SRC_COLOR
+ * dali.BLEND_FACTOR_ONE_MINUS_SRC_COLOR
+ * dali.BLEND_FACTOR_SRC_ALPHA
+ * dali.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
+ * dali.BLEND_FACTOR_DST_ALPHA
+ * dali.BLEND_FACTOR_ONE_MINUS_DST_ALPHA
+ * dali.BLEND_FACTOR_DST_COLOR
+ * dali.BLEND_FACTOR_ONE_MINUS_DST_COLOR
+ * dali.BLEND_FACTOR_SRC_ALPHA_SATURATE
+ * dali.BLEND_FACTOR_CONSTANT_COLOR
+ * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
+ * dali.BLEND_FACTOR_CONSTANT_ALPHA
+ * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA
+ *
+ * material.setBlendFunc( dali.BLEND_FACTOR_CONSTANT_COLOR, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
+ * dali.BLEND_FACTOR_CONSTANT_ALPHA, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA );
+ */
+void MaterialApi::SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ int params[4];
+ bool foundAllParams(false);
+ V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 4, args, 0 );
+ if( foundAllParams )
+ {
+ material.SetBlendFunc( static_cast< Dali::BlendingFactor::Type>(params[0]),
+ static_cast< Dali::BlendingFactor::Type>(params[1]),
+ static_cast< Dali::BlendingFactor::Type>(params[2]),
+ static_cast< Dali::BlendingFactor::Type>(params[3]) );
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid blendFunc parameter");
+ }
+}
+
+/**
+ * Query the pixel arithmetic used when the actor is blended.
+ *
+ * @for Material
+ * @method getBlendFunc
+ * @return {Object} Blend properties
+ * @example Blend properties object has 4 fields
+ *
+ * blendProperties.sourceRgb // source rgb enum
+ * blendProperties.destinationRgb // destination rgb enum
+ * blendProperties.sourceAlpha source // alpha enum
+ * blendProperties.destinationAlpha // destination alpha enum
+ */
+void MaterialApi::GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ // Pass by reference doesn't work in Javascript
+ // For now just return a vector 4...
+
+ BlendingFactor::Type srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha;
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ material.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+
+ v8::Local<v8::Object> blendProperties = v8::Object::New( isolate );
+
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceRgb" ), v8::Integer::New( isolate, srcFactorRgb) );
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationRgb" ), v8::Integer::New( isolate, destFactorRgb ) );
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceAlpha" ), v8::Integer::New( isolate, srcFactorAlpha ) );
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationAlpha" ), v8::Integer::New( isolate, destFactorAlpha ) );
+
+ args.GetReturnValue().Set( blendProperties );
+}
+
+/**
+ * Specify the equation used when the actor is blended.
+ *
+ * @for Material
+ * @method setBlendEquation
+ * @param { integer } equationRgb The equation used for combining red, green, and blue components.
+ * @param { integer } equationAlpha The equation used for combining the alpha component.
+ * @example
+ * // blend equation is one of the following
+ * dali.BLEND_EQUATION_ADD
+ * dali.BLEND_EQUATION_SUBTRACT
+ * dali.BLEND_EQUATION_REVERSE_SUBTRACT
+ *
+ * material.setBlendEquation( dali.BLEND_EQUATION_ADD, dali.BLEND_EQUATION_REVERSE_SUBTRACT );
+ */
+void MaterialApi::SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ int params[2];
+ bool foundAllParams(false);
+ V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 2, args, 0 );
+ if( foundAllParams )
+ {
+ material.SetBlendEquation( static_cast< BlendingEquation::Type>(params[0]), static_cast< BlendingEquation::Type>(params[1]) );
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid BlendEquation parameter");
+ }
+}
+
+/**
+ * Query the equation used when the actor is blended.
+ *
+ * @for Material
+ * @method getBlendEquation
+ * @return {Object} Blend equations
+ * @example Blend equations object has 2 fields
+ *
+ * blendEquations.equationRgb // equation used for combining rgb components
+ * blendEquations.equationAlpha // equation used for combining alpha components
+ */
+void MaterialApi::GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ // Pass by reference doesn't work in Javascript
+ // For now just return a vector 2...
+
+ BlendingEquation::Type equationRgb, equationAlpha;
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Material material = GetMaterial( isolate, args );
+
+ material.GetBlendEquation( equationRgb, equationAlpha );
+
+ v8::Local<v8::Object> blendEquations = v8::Object::New( isolate );
+
+ blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationRgb" ), v8::Integer::New( isolate, equationRgb) );
+ blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationAlpha" ), v8::Integer::New( isolate, equationAlpha ) );
+
+ args.GetReturnValue().Set( blendEquations );
+}
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_MATERIAL_API_H__
+#define __DALI_V8PLUGIN_MATERIAL_API_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/material.h>
+
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+namespace MaterialApi
+{
+
+ /**
+ * Helper to get material from args.This()
+ */
+ Material GetMaterial( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * @brief Helper to get material from the JavaScript object held in the given function argument
+ * @param[in] paramIndex Argument index the object is held in
+ * @param[in] found Whether material is found in the given function parameter
+ * @param[in] isolate v8 isolated instance
+ * @param[in] args v8 function call arguments interpreted
+ */
+ Material GetMaterialFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * Constructor
+ */
+ Material New( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * Material API see material.h for a description
+ */
+ void SetShader( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetShader( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void AddTexture( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void RemoveTexture( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetTextureImage( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetTextureSampler( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetTextureUniformName( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetTextureAffectsTransparency( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetTextureIndex( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetNumberOfTextures( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetFaceCullingMode( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+}; // namespace MaterialApi
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // header __DALI_V8PLUGIN_MATERIAL_API_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "material-wrapper.h"
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <rendering/material-api.h>
+#include <shared/api-function.h>
+#include <shared/object-template-helper.h>
+#include <dali-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+v8::Persistent<v8::ObjectTemplate> MaterialWrapper::mMaterialTemplate;
+
+namespace // un-named name space
+{
+
+/**
+ * Contains a list of all functions that can be called
+ */
+const ApiFunction MaterialFunctionTable[]=
+{
+ /**************************************
+ * Material API (in order of Material.h)
+ **************************************/
+
+ { "SetShader" , MaterialApi::SetShader },
+ { "GetShader" , MaterialApi::GetShader },
+ { "AddTexture" , MaterialApi::AddTexture },
+ { "RemoveTexture" , MaterialApi::RemoveTexture },
+ { "SetTextureImage" , MaterialApi::SetTextureImage },
+ { "SetTextureSampler" , MaterialApi::SetTextureSampler },
+ { "SetTextureUniformName" , MaterialApi::SetTextureUniformName },
+ { "SetTextureAffectsTransparency" , MaterialApi::SetTextureAffectsTransparency },
+ { "GetTextureIndex" , MaterialApi::GetTextureIndex },
+ { "GetNumberOfTextures" , MaterialApi::GetNumberOfTextures },
+ { "SetFaceCullingMode" , MaterialApi::SetFaceCullingMode },
+ { "SetBlendMode" , MaterialApi::SetBlendMode },
+ { "GetBlendMode" , MaterialApi::GetBlendMode },
+ { "SetBlendFunc" , MaterialApi::SetBlendFunc },
+ { "GetBlendFunc" , MaterialApi::GetBlendFunc },
+ { "SetBlendEquation" , MaterialApi::SetBlendEquation },
+ { "GetBlendEquation" , MaterialApi::GetBlendEquation },
+};
+
+const unsigned int MaterialFunctionTableCount = sizeof(MaterialFunctionTable)/sizeof(MaterialFunctionTable[0]);
+} //un-named space
+
+
+MaterialWrapper::MaterialWrapper( const Dali::Material& material, GarbageCollectorInterface& gc )
+: HandleWrapper( BaseWrappedObject::MATERIAL , material, gc )
+{
+ mMaterial = material;
+}
+
+v8::Handle<v8::Object> MaterialWrapper::WrapMaterial(v8::Isolate* isolate, const Dali::Material& material )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ objectTemplate = GetMaterialTemplate( isolate);
+
+ // create an instance of the template
+ v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
+
+ // create the Material wrapper
+ MaterialWrapper* pointer = new MaterialWrapper( material, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
+
+ // assign the JavaScript object to the wrapper.
+ pointer->SetJavascriptObject( isolate, localObject );
+
+ return handleScope.Escape( localObject );
+}
+
+v8::Local<v8::ObjectTemplate> MaterialWrapper::GetMaterialTemplate( v8::Isolate* isolate)
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ if( mMaterialTemplate.IsEmpty() )
+ {
+ objectTemplate = MakeMaterialTemplate( isolate );
+ mMaterialTemplate.Reset( isolate, objectTemplate );
+ }
+ else
+ {
+ // get the object template
+ objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, mMaterialTemplate );
+ }
+ return handleScope.Escape( objectTemplate );
+}
+
+v8::Handle<v8::ObjectTemplate> MaterialWrapper::MakeMaterialTemplate( v8::Isolate* isolate )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+
+ v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
+
+ // property handle intercepts property getters and setters and signals
+ HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate );
+
+ objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
+
+ // add our function properties
+ ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, MaterialFunctionTable, MaterialFunctionTableCount );
+
+ return handleScope.Escape( objTemplate );
+}
+
+void MaterialWrapper::NewMaterial( const v8::FunctionCallbackInfo< v8::Value >& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate);
+
+ if(!args.IsConstructCall())
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Material constructor called without 'new'");
+ return;
+ }
+ Dali::Material material = MaterialApi::New( args );
+
+ if(material)
+ {
+ v8::Local<v8::Object> localObject = WrapMaterial( isolate, material );
+ args.GetReturnValue().Set( localObject );
+ }
+}
+
+
+Material MaterialWrapper::GetMaterial()
+{
+ return mMaterial;
+}
+
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_MATERIAL_WRAPPER_H__
+#define __DALI_V8PLUGIN_MATERIAL_WRAPPER_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/material.h>
+
+// INTERNAL INCLUDES
+#include <object/handle-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+
+/**
+ * A Material wrapper.
+ * Provides access to Material specific functionality and V8 memory handling.
+ */
+class MaterialWrapper : public HandleWrapper
+{
+
+public:
+
+ /**
+ * @brief Constructor
+ * @param[in] material DALi material
+ * @param[in] gc garbage collection interface
+ */
+ MaterialWrapper( const Material& material,
+ GarbageCollectorInterface& gc );
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~MaterialWrapper()
+ {
+ };
+
+ /**
+ * @brief Creates a new Material wrapped inside a Javascript Object.
+ * @param[in] args v8 function call arguments interpreted
+ */
+ static void NewMaterial( const v8::FunctionCallbackInfo< v8::Value >& args);
+
+ /**
+ * Wraps a sampler
+ */
+ static v8::Handle<v8::Object> WrapMaterial(v8::Isolate* isolate, const Dali::Material& );
+
+
+ // The MaterialAttribute ObjectTemplate, we cache templates so we don't have
+ // keep generating them everytime we want to create a Material
+ static v8::Persistent<v8::ObjectTemplate> mMaterialTemplate;
+
+ /**
+ * @brief Gets the handle of material
+ * @return the handle of material
+ */
+ Material GetMaterial();
+
+
+private:
+
+ // Material
+ Material mMaterial;
+
+ /**
+ * @brief Creates the object template that used to create material at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Handle<v8::ObjectTemplate> MakeMaterialTemplate( v8::Isolate* isolate );
+
+ /**
+ * @brief Gets the object template that used to create material at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Local<v8::ObjectTemplate> GetMaterialTemplate( v8::Isolate* isolate );
+
+};
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // __DALI_V8PLUGIN_MATERIAL_WRAPPER_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+// CLASS HEADER
+#include "renderer-api.h"
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <rendering/renderer-wrapper.h>
+#include <rendering/geometry-api.h>
+#include <rendering/geometry-wrapper.h>
+#include <rendering/material-api.h>
+#include <rendering/material-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+/**
+ * ## Renderer API
+ *
+ * Renderer is a handle to an object that can be used to provide an image to a material.
+ *
+ * @class Renderer
+ * @extends Handle
+ */
+
+Renderer RendererApi::GetRenderer( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::HandleScope handleScope( isolate );
+
+ v8::Local<v8::Object> object = args.This();
+ v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
+ void* ptr = field->Value();
+
+ RendererWrapper* wrapper = static_cast< RendererWrapper *>(ptr);
+ return wrapper->GetRenderer();
+}
+
+Renderer RendererApi::GetRendererFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ found = false;
+
+ v8::HandleScope handleScope( isolate );
+ BaseWrappedObject* wrappedObject = V8Utils::GetWrappedDaliObjectParameter( paramIndex, BaseWrappedObject::RENDERER, isolate, args );
+ if( wrappedObject )
+ {
+ found = true;
+ RendererWrapper* wrapper = static_cast< RendererWrapper *>(wrappedObject);
+ return wrapper->GetRenderer();
+ }
+ else
+ {
+ return Renderer();
+ }
+}
+
+/**
+ * Create a new renderer object.
+ *
+ * @constructor
+ * @method Renderer
+ * @for Renderer
+ * @param {Object} geometry The geometry to be used by this renderer
+ * @param {Object} material The material to be used by this renderer
+ * @return {Object} Renderer
+ */
+Renderer RendererApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ bool found( false );
+ Geometry geometry = GeometryApi::GetGeometryFromParams( 0, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing geometry from param 0" );
+ return Renderer();
+ }
+
+ found = false;
+ Material material = MaterialApi::GetMaterialFromParams( 1, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing material from param 0" );
+ return Renderer();
+ }
+
+ return Renderer::New(geometry, material);
+}
+
+/**
+ * Sets the geometry to be used by this renderer
+ *
+ * @method setGeometry
+ * @for Renderer
+ * @param {Object} geometry The geometry to be used by this renderer
+ */
+void RendererApi::SetGeometry( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+
+ bool found( false );
+ Geometry geometry = GeometryApi::GetGeometryFromParams( 0, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing geometry from param 0" );
+ }
+ else
+ {
+ renderer.SetGeometry(geometry);
+ }
+}
+
+/**
+ * Gets the geometry used by this renderer
+ *
+ * @method getGeometry
+ * @for Renderer
+ * @return {Object} The geometry used by this renderer
+ */
+void RendererApi::GetGeometry( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+ Geometry geometry = renderer.GetGeometry();
+
+ // Wrap the geometry
+ v8::Local<v8::Object> localObject = GeometryWrapper::WrapGeometry( isolate, geometry );
+ args.GetReturnValue().Set( localObject );
+}
+
+/**
+ * Sets the material to be used by this renderer
+ *
+ * @method setMaterial
+ * @for Renderer
+ * @param {Object} material The material to be used by this renderer
+ */
+void RendererApi::SetMaterial( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+
+ bool found( false );
+ Material material = MaterialApi::GetMaterialFromParams( 0, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing material from param 0" );
+ }
+ else
+ {
+ renderer.SetMaterial(material);
+ }
+}
+
+/**
+ * Gets the material used by this renderer
+ *
+ * @method getMaterial
+ * @for Renderer
+ * @return {Object} The material used by this renderer
+ */
+void RendererApi::GetMaterial( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+ Material material = renderer.GetMaterial();
+
+ // Wrap the material
+ v8::Local<v8::Object> localObject = MaterialWrapper::WrapMaterial( isolate, material );
+ args.GetReturnValue().Set( localObject );
+}
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_RENDERER_API_H__
+#define __DALI_V8PLUGIN_RENDERER_API_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/renderer.h>
+
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+namespace RendererApi
+{
+
+ /**
+ * Helper to get renderer from args.This()
+ */
+ Renderer GetRenderer( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * @brief Helper to get renderer from the JavaScript object held in the given function argument
+ * @param[in] paramIndex Argument index the object is held in
+ * @param[in] found Whether renderer is found in the given function parameter
+ * @param[in] isolate v8 isolated instance
+ * @param[in] args v8 function call arguments interpreted
+ */
+ Renderer GetRendererFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * Constructor
+ */
+ Renderer New( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * Renderer API see renderer.h for a description
+ */
+ void SetGeometry( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetGeometry( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetMaterial( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetMaterial( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+}; // namespace RendererApi
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // header __DALI_V8PLUGIN_RENDERER_API_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "renderer-wrapper.h"
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <rendering/renderer-api.h>
+#include <shared/api-function.h>
+#include <shared/object-template-helper.h>
+#include <dali-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+v8::Persistent<v8::ObjectTemplate> RendererWrapper::mRendererTemplate;
+
+namespace // un-named name space
+{
+
+/**
+ * Contains a list of all functions that can be called
+ */
+const ApiFunction RendererFunctionTable[]=
+{
+ /**************************************
+ * Renderer API (in order of Renderer.h)
+ **************************************/
+
+ { "SetGeometry" , RendererApi::SetGeometry },
+ { "GetGeometry" , RendererApi::GetGeometry },
+ { "SetMaterial" , RendererApi::SetMaterial },
+ { "GetMaterial" , RendererApi::GetMaterial },
+};
+
+const unsigned int RendererFunctionTableCount = sizeof(RendererFunctionTable)/sizeof(RendererFunctionTable[0]);
+} //un-named space
+
+
+RendererWrapper::RendererWrapper( const Dali::Renderer& renderer, GarbageCollectorInterface& gc )
+: HandleWrapper( BaseWrappedObject::RENDERER , renderer, gc )
+{
+ mRenderer = renderer;
+}
+
+v8::Handle<v8::Object> RendererWrapper::WrapRenderer(v8::Isolate* isolate, const Dali::Renderer& renderer )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ objectTemplate = GetRendererTemplate( isolate);
+
+ // create an instance of the template
+ v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
+
+ // create the Renderer wrapper
+ RendererWrapper* pointer = new RendererWrapper( renderer, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
+
+ // assign the JavaScript object to the wrapper.
+ pointer->SetJavascriptObject( isolate, localObject );
+
+ return handleScope.Escape( localObject );
+}
+
+v8::Local<v8::ObjectTemplate> RendererWrapper::GetRendererTemplate( v8::Isolate* isolate)
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ if( mRendererTemplate.IsEmpty() )
+ {
+ objectTemplate = MakeRendererTemplate( isolate );
+ mRendererTemplate.Reset( isolate, objectTemplate );
+ }
+ else
+ {
+ // get the object template
+ objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, mRendererTemplate );
+ }
+ return handleScope.Escape( objectTemplate );
+}
+
+v8::Handle<v8::ObjectTemplate> RendererWrapper::MakeRendererTemplate( v8::Isolate* isolate )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+
+ v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
+
+ // property handle intercepts property getters and setters and signals
+ HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate );
+
+ objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
+
+ // add our function properties
+ ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, RendererFunctionTable, RendererFunctionTableCount );
+
+ return handleScope.Escape( objTemplate );
+}
+
+void RendererWrapper::NewRenderer( const v8::FunctionCallbackInfo< v8::Value >& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate);
+
+ if(!args.IsConstructCall())
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Renderer constructor called without 'new'");
+ return;
+ }
+ Dali::Renderer renderer = RendererApi::New( args );
+
+ if(renderer)
+ {
+ v8::Local<v8::Object> localObject = WrapRenderer( isolate, renderer );
+ args.GetReturnValue().Set( localObject );
+ }
+}
+
+
+Renderer RendererWrapper::GetRenderer()
+{
+ return mRenderer;
+}
+
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_RENDERER_WRAPPER_H__
+#define __DALI_V8PLUGIN_RENDERER_WRAPPER_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/renderer.h>
+
+// INTERNAL INCLUDES
+#include <object/handle-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+
+/**
+ * A Renderer wrapper.
+ * Provides access to Renderer specific functionality and V8 memory handling.
+ */
+class RendererWrapper : public HandleWrapper
+{
+
+public:
+
+ /**
+ * @brief Constructor
+ * @param[in] renderer DALi renderer
+ * @param[in] gc garbage collection interface
+ */
+ RendererWrapper( const Renderer& renderer,
+ GarbageCollectorInterface& gc );
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~RendererWrapper()
+ {
+ };
+
+ /**
+ * @brief Creates a new Renderer wrapped inside a Javascript Object.
+ * @param[in] args v8 function call arguments interpreted
+ */
+ static void NewRenderer( const v8::FunctionCallbackInfo< v8::Value >& args);
+
+ /**
+ * Wraps a renderer
+ */
+ static v8::Handle<v8::Object> WrapRenderer(v8::Isolate* isolate, const Dali::Renderer& );
+
+
+ // The RendererAttribute ObjectTemplate, we cache templates so we don't have
+ // keep generating them everytime we want to create a Renderer
+ static v8::Persistent<v8::ObjectTemplate> mRendererTemplate;
+
+ /**
+ * @brief Gets the handle of renderer
+ * @return the handle of renderer
+ */
+ Renderer GetRenderer();
+
+
+private:
+
+ // Renderer
+ Renderer mRenderer;
+
+ /**
+ * @brief Creates the object template that used to create renderer at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Handle<v8::ObjectTemplate> MakeRendererTemplate( v8::Isolate* isolate );
+
+ /**
+ * @brief Gets the object template that used to create renderer at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Local<v8::ObjectTemplate> GetRendererTemplate( v8::Isolate* isolate );
+
+};
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // __DALI_V8PLUGIN_RENDERER_WRAPPER_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "sampler-api.h"
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <rendering/sampler-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+/**
+ * ## Sampler API
+ *
+ * Sampler is a handle to an object that can be used to provide the sampling parameters to sample textures
+ *
+ * @class Sampler
+ */
+
+Sampler SamplerApi::GetSampler( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::HandleScope handleScope( isolate );
+
+ v8::Local<v8::Object> object = args.This();
+ v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
+ void* ptr = field->Value();
+
+ SamplerWrapper* wrapper = static_cast< SamplerWrapper *>(ptr);
+ return wrapper->GetSampler();
+}
+
+Sampler SamplerApi::GetSamplerFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ found = false;
+
+ v8::HandleScope handleScope( isolate );
+ BaseWrappedObject* wrappedObject = V8Utils::GetWrappedDaliObjectParameter( paramIndex, BaseWrappedObject::SAMPLER, isolate, args );
+ if( wrappedObject )
+ {
+ found = true;
+ SamplerWrapper* wrapper = static_cast< SamplerWrapper *>(wrappedObject);
+ return wrapper->GetSampler();
+ }
+ else
+ {
+ return Sampler();
+ }
+}
+
+/**
+ * Create a new sampler object.
+ *
+ * @constructor
+ * @method Sampler
+ * @for Sampler
+ * @return {Object} Sampler
+ */
+Sampler SamplerApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ return Sampler::New();
+}
+
+/**
+ * Set the filter modes for this sampler
+ * @method setFilterMode
+ * @for Sampler
+ * @param {integer} minFilter The minification filter that will be used
+ * @param {integer} magFilter The magnification filter that will be used
+ * @example
+ * // filter mode is one of the following
+ * dali.FILTER_MODE_NONE // Use GL system defaults (minification NEAREST_MIPMAP_LINEAR, magnification LINEAR)
+ * dali.FILTER_MODE_DEFAULT // Use dali defaults (minification LINEAR, magnification LINEAR)
+ * dali.FILTER_MODE_NEAREST // Filter nearest
+ * dali.FILTER_MODE_LINEAR // Filter linear
+ *
+ * sampler.setFilterMode( dali.FILTER_MODE_DEFAULT, dali.FILTER_MODE_LINEAR );
+ */
+void SamplerApi::SetFilterMode( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Sampler sampler = GetSampler( isolate, args );
+
+ bool found( false );
+ int minFilter = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing minification filter from param 0" );
+ return;
+ }
+
+ found = false;
+ int magFilter = V8Utils::GetIntegerParameter( PARAMETER_1, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing magnification filter from param 1" );
+ }
+ else
+ {
+ sampler.SetFilterMode(static_cast<FilterMode::Type>(minFilter), static_cast<FilterMode::Type>(magFilter));
+ }
+}
+
+/**
+ * Set the wrap modes for this sampler
+ * @method setWrapMode
+ * @for Sampler
+ * @param {integer} uWrap Wrap mode for u coordinates
+ * @param {integer} vWrap Wrap mode for v coordinates
+ * @example
+ * // wrap mode is one of the following
+ * dali.WRAP_MODE_DEFAULT
+ * dali.WRAP_MODE_CLAMP_TO_EDGE
+ * dali.WRAP_MODE_REPEAT
+ * dali.WRAP_MODE_MIRRORED_REPEAT
+ *
+ * sampler.setWrapMode( dali.WRAP_MODE_CLAMP_TO_EDGE, dali.WRAP_MODE_REPEAT );
+ */
+void SamplerApi::SetWrapMode( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Sampler sampler = GetSampler( isolate, args );
+
+ bool found( false );
+ int uWrap = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing wrap mode for u coordinates from param 0" );
+ return;
+ }
+
+ found = false;
+ int vWrap = V8Utils::GetIntegerParameter( PARAMETER_1, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing wrap mode for v coordinates from param 1" );
+ }
+ else
+ {
+ sampler.SetWrapMode(static_cast<WrapMode::Type>(uWrap), static_cast<WrapMode::Type>(vWrap));
+ }
+}
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_SAMPLER_API_H__
+#define __DALI_V8PLUGIN_SAMPLER_API_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/sampler.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+namespace SamplerApi
+{
+ /**
+ * Helper to get sampler from args.This()
+ */
+ Sampler GetSampler( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * @brief Helper to get sampler from the JavaScript object held in the given function argument
+ * @param[in] paramIndex Argument index the object is held in
+ * @param[in] found Whether sampler is found in the given function parameter
+ * @param[in] isolate v8 isolated instance
+ * @param[in] args v8 function call arguments interpreted
+ */
+ Sampler GetSamplerFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * Constructor
+ */
+ Sampler New( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * Sampler API see sampler.h for a description
+ */
+ void SetFilterMode( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetWrapMode( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+}; // namespace SamplerApi
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // header __DALI_V8PLUGIN_SAMPLER_API_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "sampler-wrapper.h"
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <dali-wrapper.h>
+#include <shared/api-function.h>
+#include <shared/object-template-helper.h>
+#include <rendering/sampler-api.h>
+
+namespace Dali
+{
+namespace V8Plugin
+{
+
+v8::Persistent<v8::ObjectTemplate> SamplerWrapper::mSamplerTemplate;
+
+namespace
+{
+
+/**
+ * Contains a list of all functions that can be called
+ */
+const ApiFunction SamplerFunctionTable[]=
+{
+ /**************************************
+ * Sampler API (in order of sampler.h)
+ **************************************/
+
+ { "SetFilterMode", SamplerApi::SetFilterMode },
+ { "SetWrapMode", SamplerApi::SetWrapMode },
+};
+
+const unsigned int SamplerFunctionTableCount = sizeof(SamplerFunctionTable)/sizeof(SamplerFunctionTable[0]);
+} //un-named space
+
+
+SamplerWrapper::SamplerWrapper( const Sampler& sampler, GarbageCollectorInterface& gc )
+: BaseWrappedObject( BaseWrappedObject::SAMPLER , gc )
+{
+ mSampler = sampler;
+}
+
+v8::Handle<v8::Object> SamplerWrapper::WrapSampler(v8::Isolate* isolate, const Sampler& sampler )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ objectTemplate = GetSamplerTemplate( isolate);
+
+ // create an instance of the template
+ v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
+
+ // create the Sampler wrapper
+ SamplerWrapper* pointer = new SamplerWrapper( sampler, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
+
+ // assign the JavaScript object to the wrapper.
+ pointer->SetJavascriptObject( isolate, localObject );
+
+ return handleScope.Escape( localObject );
+}
+
+v8::Local<v8::ObjectTemplate> SamplerWrapper::GetSamplerTemplate( v8::Isolate* isolate)
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ if( mSamplerTemplate.IsEmpty() )
+ {
+ objectTemplate = MakeSamplerTemplate( isolate );
+ mSamplerTemplate.Reset( isolate, objectTemplate );
+ }
+ else
+ {
+ // get the object template
+ objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, mSamplerTemplate );
+ }
+ return handleScope.Escape( objectTemplate );
+}
+
+v8::Handle<v8::ObjectTemplate> SamplerWrapper::MakeSamplerTemplate( v8::Isolate* isolate )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+
+ v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
+
+ objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
+
+ // add our function properties
+ ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, SamplerFunctionTable, SamplerFunctionTableCount );
+
+ return handleScope.Escape( objTemplate );
+}
+
+void SamplerWrapper::NewSampler( const v8::FunctionCallbackInfo< v8::Value >& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate);
+
+ if(!args.IsConstructCall())
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Sampler constructor called without 'new'");
+ return;
+ }
+ Dali::Sampler sampler = SamplerApi::New( args );
+
+ if(sampler)
+ {
+ v8::Local<v8::Object> localObject = WrapSampler( isolate, sampler );
+ args.GetReturnValue().Set( localObject );
+ }
+}
+
+Sampler SamplerWrapper::GetSampler()
+{
+ return mSampler;
+}
+
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_SAMPLER_WRAPPER_H__
+#define __DALI_V8PLUGIN_SAMPLER_WRAPPER_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/sampler.h>
+
+// INTERNAL INCLUDES
+#include <shared/base-wrapped-object.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+/**
+ * A Sampler wrapper.
+ * Provides access to Sampler specific functionality and V8 memory handling.
+ */
+class SamplerWrapper : public BaseWrappedObject
+{
+
+public:
+
+ /**
+ * @brief Constructor
+ * @param[in] sampler DALi sampler
+ * @param[in] gc garbage collection interface
+ */
+ SamplerWrapper( const Sampler& sampler,
+ GarbageCollectorInterface& gc );
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~SamplerWrapper()
+ {
+ };
+
+ /**
+ * @brief Creates a new Sampler wrapped inside a Javascript Object.
+ * @param[in] args v8 function call arguments interpreted
+ */
+ static void NewSampler( const v8::FunctionCallbackInfo< v8::Value >& args);
+
+ /**
+ * Wraps a sampler
+ */
+ static v8::Handle<v8::Object> WrapSampler(v8::Isolate* isolate, const Sampler& );
+
+ // The SamplerAttribute ObjectTemplate, we cache templates so we don't have
+ // keep generating them everytime we want to create a Sampler
+ static v8::Persistent<v8::ObjectTemplate> mSamplerTemplate;
+
+ /**
+ * @brief Gets the handle of sampler
+ * @return the handle of sampler
+ */
+ Sampler GetSampler();
+
+private:
+
+ // Sampler
+ Sampler mSampler;
+
+ /**
+ * @brief Creates the object template that used to create sampler at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Handle<v8::ObjectTemplate> MakeSamplerTemplate( v8::Isolate* isolate );
+
+ /**
+ * @brief Gets the object template that used to create sampler at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Local<v8::ObjectTemplate> GetSamplerTemplate( v8::Isolate* isolate );
+};
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // __DALI_V8PLUGIN_SAMPLER_WRAPPER_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+// CLASS HEADER
+#include "shader-api.h"
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <rendering/shader-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+/**
+ * ## Shader API
+ *
+ * Shaders allows custom vertex and color transformations in the GPU
+ *
+ * ### Simple example
+ *
+ *```
+ * // this will match the default shaders for image
+ * var vertexShader = " void main() \
+ * { \
+ * gl_Position = uProjection * uModelView * vec4(aPosition, 1.0); \
+ * vTexCoord = aTexCoord; \
+ * }; "
+ * var fragShader = " void main() \
+ * { \
+ * gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\
+ * }; "
+ * var shaderOptions = {
+ * vertexShader: vertexShader,
+ * fragmentShader: fragShader
+ * };
+ *
+ * var shader = new dali.Shader(shaderOptions);
+ *```
+ * @class Shader
+ * @extends Handle
+ */
+
+namespace // unnamed namespace
+{
+
+typedef std::vector< std::string > HintsArray;
+
+struct ShaderHintPair
+{
+ const char* name;
+ Shader::ShaderHints hint;
+};
+
+const ShaderHintPair ShaderHintTable[]=
+{
+ {"requiresSelfDepthTest", Shader::HINT_REQUIRES_SELF_DEPTH_TEST },
+ {"outputIsTransparent", Shader::HINT_OUTPUT_IS_TRANSPARENT },
+ {"outputIsOpaque", Shader::HINT_OUTPUT_IS_OPAQUE },
+ {"modifiesGeometry", Shader::HINT_MODIFIES_GEOMETRY },
+};
+
+const unsigned int ShaderHintTableCount = sizeof(ShaderHintTable)/sizeof(ShaderHintTable[0]);
+
+struct ShaderParameters
+{
+ ShaderParameters()
+ : mHints( Shader::HINT_NONE )
+ {
+ }
+
+ Shader::ShaderHints GetShaderHint( const std::string& hint )
+ {
+ for( unsigned int i = 0 ; i < ShaderHintTableCount; ++i )
+ {
+ if( hint == ShaderHintTable[i].name )
+ {
+ return ShaderHintTable[i].hint;
+ }
+ }
+ return Shader::HINT_NONE;
+ }
+
+ void ProcessHintsArray( const HintsArray& hintsArray )
+ {
+ for( HintsArray::const_iterator iter = hintsArray.begin(); iter != hintsArray.end() ; ++iter )
+ {
+ mHints= static_cast<Shader::ShaderHints>( mHints | GetShaderHint( *iter ) );
+ }
+ }
+
+ Shader NewShader()
+ {
+ return Shader::New( mVertex,
+ mFragment,
+ mHints);
+ }
+
+ std::string mVertex;
+ std::string mFragment;
+ Shader::ShaderHints mHints;
+};
+
+Shader GetShader( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::HandleScope handleScope( isolate );
+
+ v8::Local<v8::Object> object = args.This();
+ v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
+ void* ptr = field->Value();
+
+ ShaderWrapper* wrapper = static_cast< ShaderWrapper *>(ptr);
+ return wrapper->GetShader();
+}
+
+} // unnamed space
+
+/**
+ * Create a new Shader
+ * @constructor
+ * @for Shader
+ * @method Shader
+ * @param {Object} shaderOptions
+ * @param {String} [shaderOptions.vertexShader] VertexShader code for the shader. If not defined, the default version will be used
+ * @param {String} [shaderOptions.fragmentShader] FragmentShader code for the shader. If not defined, the default version will be used
+ * @param {Array} [shaderOptions.shaderHints] Hints for rendering/subdividing geometry, e.g. [ "requiresSelfDepthTest", "outputIsTransparent", "outputIsOpaque","modifiesGeometry" ]
+ * @return {Object} Shader
+ * @example
+
+ // this will match the default shaders for image
+ var vertexShader = " void main() \
+ { \
+ gl_Position = uProjection * uModelView * vec4(aPosition, 1.0); \
+ vTexCoord = aTexCoord; \
+ }; "
+
+ var fragShader = " void main() \
+ { \
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\
+ }; "
+
+ var shaderOptions = {
+ vertexShader: vertexShader,
+ fragmentShader: fragShader
+ };
+
+ var shader = new dali.Shader(shaderOptions);
+ *
+ */
+Shader ShaderApi::New( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::HandleScope handleScope( isolate );
+
+ ShaderParameters shaderParams;
+
+ if( args[0]->IsObject() )
+ {
+ v8::Local<v8::Object > obj = args[0]->ToObject();
+
+ v8::Local<v8::Value> vertexValue = obj->Get(v8::String::NewFromUtf8( isolate, "vertexShader"));
+ if( vertexValue->IsString() )
+ {
+ shaderParams.mVertex = V8Utils::v8StringToStdString( vertexValue );
+ }
+
+ v8::Local<v8::Value> fragmentValue = obj->Get(v8::String::NewFromUtf8( isolate, "fragmentShader"));
+ if( fragmentValue->IsString() )
+ {
+ shaderParams.mFragment = V8Utils::v8StringToStdString( fragmentValue );
+ }
+ // Get any hints
+ v8::Local<v8::Value> hints = obj->Get(v8::String::NewFromUtf8( isolate, "shaderHints"));
+ if( hints->IsArray() )
+ {
+ HintsArray hintsArray;
+ v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast( hints );
+ for( uint32_t i=0; i < array->Length(); ++i)
+ {
+ v8::Handle<v8::Value> entry = array->Get( v8::Integer::New( isolate, i) );
+ if( entry->IsString() )
+ {
+ std::string entryString = V8Utils::v8StringToStdString( entry );
+ hintsArray.push_back( entryString );
+ }
+ }
+ shaderParams.ProcessHintsArray( hintsArray );
+ }
+ }
+
+ return shaderParams.NewShader();
+}
+
+Shader ShaderApi::GetShaderFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ found = false;
+
+ v8::HandleScope handleScope( isolate );
+ BaseWrappedObject* wrappedObject = V8Utils::GetWrappedDaliObjectParameter( paramIndex, BaseWrappedObject::SHADER, isolate, args );
+ if( wrappedObject )
+ {
+ found = true;
+ ShaderWrapper* wrapper = static_cast< ShaderWrapper *>(wrappedObject);
+ return wrapper->GetShader();
+ }
+ else
+ {
+ return Shader();
+ }
+}
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_SHADER_API_H__
+#define __DALI_V8PLUGIN_SHADER_API_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/shader.h>
+
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+namespace ShaderApi
+{
+
+ /**
+ * Constructor
+ */
+ Shader New( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * @brief Helper to get shader from the JavaScript object held in the given function argument
+ * @param[in] paramIndex Argument index the object is held in
+ * @param[in] found Whether shader is found in the given function parameter
+ * @param[in] isolate v8 isolated instance
+ * @param[in] args v8 function call arguments interpreted
+ */
+ Shader GetShaderFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args );
+
+}; // namespace ShaderApi
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // header __DALI_V8PLUGIN_SHADER_API_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "shader-wrapper.h"
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <rendering/shader-api.h>
+#include <shared/api-function.h>
+#include <shared/object-template-helper.h>
+#include <dali-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+v8::Persistent<v8::ObjectTemplate> ShaderWrapper::mShaderTemplate;
+
+ShaderWrapper::ShaderWrapper( const Dali::Shader& shader, GarbageCollectorInterface& gc )
+: HandleWrapper( BaseWrappedObject::SHADER , shader, gc )
+{
+ mShader = shader;
+}
+
+v8::Handle<v8::Object> ShaderWrapper::WrapShader(v8::Isolate* isolate, const Dali::Shader& shader )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ objectTemplate = GetShaderTemplate( isolate);
+
+ // create an instance of the template
+ v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
+
+ // create the Shader wrapper
+ ShaderWrapper* pointer = new ShaderWrapper( shader, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
+
+ // assign the JavaScript object to the wrapper.
+ pointer->SetJavascriptObject( isolate, localObject );
+
+ return handleScope.Escape( localObject );
+}
+
+v8::Local<v8::ObjectTemplate> ShaderWrapper::GetShaderTemplate( v8::Isolate* isolate)
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ if( mShaderTemplate.IsEmpty() )
+ {
+ objectTemplate = MakeShaderTemplate( isolate );
+ mShaderTemplate.Reset( isolate, objectTemplate );
+ }
+ else
+ {
+ // get the object template
+ objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, mShaderTemplate );
+ }
+ return handleScope.Escape( objectTemplate );
+}
+
+v8::Handle<v8::ObjectTemplate> ShaderWrapper::MakeShaderTemplate( v8::Isolate* isolate )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+
+ v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
+
+ // property handle intercepts property getters and setters and signals
+ HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate );
+
+ objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
+
+ return handleScope.Escape( objTemplate );
+}
+
+void ShaderWrapper::NewShader( const v8::FunctionCallbackInfo< v8::Value >& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate);
+
+ if(!args.IsConstructCall())
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Shader constructor called without 'new'");
+ return;
+ }
+ Dali::Shader shader = ShaderApi::New( isolate, args );
+
+ if(shader)
+ {
+ v8::Local<v8::Object> localObject = WrapShader( isolate, shader );
+ args.GetReturnValue().Set( localObject );
+ }
+}
+
+
+Shader ShaderWrapper::GetShader()
+{
+ return mShader;
+}
+
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_SHADER_WRAPPER_H__
+#define __DALI_V8PLUGIN_SHADER_WRAPPER_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/shader.h>
+
+// INTERNAL INCLUDES
+#include <object/handle-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+
+/**
+ * A Shader wrapper.
+ * Provides access to Shader specific functionality and V8 memory handling.
+ */
+class ShaderWrapper : public HandleWrapper
+{
+
+public:
+
+ /**
+ * @brief Constructor
+ * @param[in] shader DALi shader
+ * @param[in] gc garbage collection interface
+ */
+ ShaderWrapper( const Shader& shader,
+ GarbageCollectorInterface& gc );
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~ShaderWrapper()
+ {
+ };
+
+ /**
+ * @brief Creates a new Shader wrapped inside a Javascript Object.
+ * @param[in] args v8 function call arguments interpreted
+ */
+ static void NewShader( const v8::FunctionCallbackInfo< v8::Value >& args);
+
+ /**
+ * Wraps a shader
+ */
+ static v8::Handle<v8::Object> WrapShader(v8::Isolate* isolate, const Dali::Shader& );
+
+
+ // The ShaderAttribute ObjectTemplate, we cache templates so we don't have
+ // keep generating them everytime we want to create a Shader
+ static v8::Persistent<v8::ObjectTemplate> mShaderTemplate;
+
+ /**
+ * @brief Gets the handle of shader
+ * @return the handle of shader
+ */
+ Shader GetShader();
+
+
+private:
+
+ // Shader
+ Shader mShader;
+
+ /**
+ * @brief Creates the object template that used to create shader at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Handle<v8::ObjectTemplate> MakeShaderTemplate( v8::Isolate* isolate );
+
+ /**
+ * @brief Gets the object template that used to create shader at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Local<v8::ObjectTemplate> GetShaderTemplate( v8::Isolate* isolate );
+
+};
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // __DALI_V8PLUGIN_SHADER_WRAPPER_H__
RENDER_TASK,
RENDER_TASK_LIST,
TIMER,
+ SHADER,
+ SAMPLER,
+ MATERIAL,
+ GEOMETRY,
+ RENDERER,
+ PROPERTY_BUFFER,
TAP_GESTURE,
SHADER_EFFECT,
PAN_GESTURE,
#include <image/image-wrapper.h>
#include <animation/animation-wrapper.h>
#include <shader-effects/shader-effect-wrapper.h>
+#include <rendering/shader-wrapper.h>
namespace Dali
v8::Local<v8::Object> image = ImageWrapper::WrapImage(isolate, Image::DownCast(handle) );
args.GetReturnValue().Set( image );
}
+ if( typeName == "ShaderEffect")
+ {
+ v8::Local<v8::Object> shaderEffect = ShaderEffectWrapper::WrapShaderEffect(isolate, ShaderEffect::DownCast( handle ));
+ args.GetReturnValue().Set( shaderEffect );
+ }
if( typeName == "Shader")
{
- v8::Local<v8::Object> shader = ShaderEffectWrapper::WrapShaderEffect(isolate, ShaderEffect::DownCast( handle ));
+ v8::Local<v8::Object> shader = ShaderWrapper::WrapShader(isolate, Shader::DownCast( handle ));
args.GetReturnValue().Set( shader );
}
-
}
void BuilderApi::ApplyStyle( const v8::FunctionCallbackInfo< v8::Value >& args )
{
{
v8::HandleScope handleScope( isolate);
- Property::Value daliPropertyValue;// creates a property with Property::INVALID
+ Property::Value daliPropertyValue;// creates a property with Property::NONE
found = false;
// Get the value
v8::Local<v8::Value> value = object->Get( key );
- std::string valueString = V8Utils::v8StringToStdString( value );
-
- propertyMap[ keyString ] = valueString.c_str();
+ if( value->IsBoolean() )
+ {
+ v8::Local<v8::Boolean> v = value->ToBoolean();
+ propertyMap[ keyString ] = v->Value();
+ }
+ else if( value->IsNumber() )
+ {
+ v8::Local<v8::Number> v = value->ToNumber();
+ propertyMap[ keyString ] = static_cast<float>(v->Value());
+ }
+ else if( value->IsInt32() || value->IsUint32() )
+ {
+ v8::Local<v8::Int32> v = value->ToInt32();
+ propertyMap[ keyString ] = static_cast<int>(v->Value());
+ }
+ else if( value->IsString() )
+ {
+ std::string valueString = V8Utils::v8StringToStdString( value );
+ propertyMap[ keyString ] = valueString.c_str();
+ }
+ else if( value->IsArray() )
+ {
+ propertyMap[ keyString ] = PropertyValueWrapper::VectorOrMatrixFromV8Array( isolate, value);
+ }
}
+
return propertyMap;
}
found = true;
return args[ index ]->Int32Value();
}
+ else
{
return defaultValue;
}
found = true;
return args[ index ]->NumberValue();
}
+ else
{
return defaultValue;
}
}
}
+void* GetArrayBufferViewParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ found = false;
+ unsigned int length = args.Length();
+ if( index < length && args[index]->IsArrayBufferView() )
+ {
+ found = true;
+ v8::ArrayBufferView* bufferView = v8::ArrayBufferView::Cast(*(args[index]));
+ v8::Handle<v8::ArrayBuffer> buffer = bufferView->Buffer();
+ v8::ArrayBuffer::Contents contents = buffer->Externalize();
+ return contents.Data();
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
Handle GetHandleParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
{
v8::HandleScope handleScope( isolate);
}
}
+
RenderTask GetRenderTaskParameter( unsigned int paramIndex, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
{
found = false;
}
}
-
BaseWrappedObject* GetWrappedDaliObjectParameter( unsigned int index, BaseWrappedObject::Type type, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
{
v8::HandleScope handleScope( isolate);
/**
* Given a JavaScript object with
* @param [in] object JavaScrript object
- * @return DALi ProperyMap from the JavaScript object
+ * @return DALi ProperyMap from the JavaScript object
*/
Property::Map GetPropertyMapFromObject( v8::Isolate* isolate, const v8::Local<v8::Object>& object);
/**
* @param [in] index parameter index, e.g. callMyFunc( index0, index1, index2).
* @param[out] found whether the parameter was found
+ * @return ArrayBufferView from the JavaScript function arguments
+ */
+void* GetArrayBufferViewParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );
+
+/**
+ * @param [in] index parameter index, e.g. callMyFunc( index0, index1, index2).
+ * @param[out] found whether the parameter was found
* @return DALi Handle value from the JavaScript function arguments
*/
Handle GetHandleParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );