void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; }
void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; }
void DummyControlImplOverride::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
-void DummyControlImplOverride::OnStageConnection( unsigned int depth ) { stageConnectionCalled = true; }
+void DummyControlImplOverride::OnStageConnection( int depth ) { stageConnectionCalled = true; }
void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; }
void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
private: // From CustomActorImpl
- virtual void OnStageConnection( unsigned int depth );
+ virtual void OnStageConnection( int depth );
virtual void OnStageDisconnection();
virtual void OnChildAdd(Actor& child);
virtual void OnChildRemove(Actor& child);
return result;
}
+
int RunTestCaseInChildProcess( struct ::testcase_s& testCase, bool suppressOutput )
{
int testResult = EXIT_STATUS_TESTCASE_FAILED;
#ifdef WCOREDUMP
if(WCOREDUMP(status))
{
- printf("Test case %s crashed\n", testCase.name);
+ printf("Test case %s failed: due to a crash\n", testCase.name);
}
#endif
- printf("Test case %s exited with signal %s\n", testCase.name, strsignal(WTERMSIG(status)));
+ printf("Test case %s failed: exit with signal %s\n", testCase.name, strsignal(WTERMSIG(status)));
}
else if(WIFSTOPPED(status))
{
- printf("Test case %s stopped with signal %s\n", testCase.name, strsignal(WSTOPSIG(status)));
+ printf("Test case %s failed: stopped with signal %s\n", testCase.name, strsignal(WSTOPSIG(status)));
}
}
return testResult;
#include "toolkit-accessibility-adaptor.h"
#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/devel-api/adaptor-framework/accessibility-action-handler.h>
namespace Dali
{
public:
+ // Functions to modify mock returns:
+
+ void MockSetReadPosition( Vector2& position );
+
+public:
+
bool IsEnabled() const;
void SetActionHandler(Dali::AccessibilityActionHandler& handler);
void SetGestureHandler(Dali::AccessibilityGestureHandler& handler);
+ Vector2 GetReadPosition() const;
+
+ bool HandleActionNextEvent();
+ bool HandleActionPreviousEvent();
+ bool HandleActionActivateEvent();
+ bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
+ bool HandleActionReadNextEvent();
+ bool HandleActionReadPreviousEvent();
+ bool HandleActionUpEvent();
+ bool HandleActionDownEvent();
+ bool HandleActionClearFocusEvent();
+ bool HandleActionScrollEvent(TouchPoint& point, unsigned long timeStamp);
+ bool HandleActionBackEvent();
+ bool HandleActionEnableEvent();
+ bool HandleActionDisableEvent();
+ bool HandleActionScrollUpEvent();
+ bool HandleActionScrollDownEvent();
+ bool HandleActionPageLeftEvent();
+ bool HandleActionPageRightEvent();
+ bool HandleActionPageUpEvent();
+ bool HandleActionPageDownEvent();
+ bool HandleActionMoveToFirstEvent();
+ bool HandleActionMoveToLastEvent();
+ bool HandleActionReadFromTopEvent();
+ bool HandleActionReadFromNextEvent();
+ bool HandleActionZoomEvent();
+ bool HandleActionReadIndicatorInformationEvent();
+ bool HandleActionReadPauseResumeEvent();
+ bool HandleActionStartStopEvent();
+
public: // Signals
private:
bool mIsEnabled;
Dali::AccessibilityActionHandler* mActionHandler;
Dali::AccessibilityGestureHandler* mGestureHandler;
+ Vector2 mReadPosition;
static Dali::AccessibilityAdaptor mToolkitAccessibilityAdaptor;
};
Dali::AccessibilityAdaptor AccessibilityAdaptor::Get()
{
- if( ! mToolkitAccessibilityAdaptor )
+ if( !mToolkitAccessibilityAdaptor )
{
mToolkitAccessibilityAdaptor = Dali::AccessibilityAdaptor( new Dali::Internal::Adaptor::AccessibilityAdaptor() );
}
}
AccessibilityAdaptor::AccessibilityAdaptor()
-: mIsEnabled(false)
+: mIsEnabled(false),
+ mReadPosition( 0.0f, 0.0f )
{
}
{
}
+Vector2 AccessibilityAdaptor::GetReadPosition() const
+{
+ return mReadPosition;
+}
+
+void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
+{
+ mReadPosition = position;
+}
+
bool AccessibilityAdaptor::IsEnabled() const
{
return mIsEnabled;
mGestureHandler = &handler;
}
+bool AccessibilityAdaptor::HandleActionNextEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionNext( true );
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionPreviousEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionPrevious( true );
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionActivateEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionActivate();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionRead( allowReadAgain );
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionReadNextEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionReadNext( true );
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionReadPreviousEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionReadPrevious( true );
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionUpEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionUp();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionDownEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionDown();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionClearFocusEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->ClearAccessibilityFocus();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionScrollEvent(TouchPoint& point, unsigned long timeStamp)
+{
+ if( mActionHandler )
+ {
+ Dali::TouchEvent touchEvent;
+ touchEvent.points.push_back( point );
+ return mActionHandler->AccessibilityActionScroll( touchEvent );
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionBackEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionBack();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionEnableEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->ChangeAccessibilityStatus();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionDisableEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->ChangeAccessibilityStatus();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionScrollUpEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionScrollUp();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionScrollDownEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionScrollDown();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionPageLeftEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionPageLeft();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionPageRightEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionPageRight();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionPageUpEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionPageUp();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionPageDownEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionPageDown();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionMoveToFirst();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionMoveToLast();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionReadFromTop();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionReadFromNext();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionZoomEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionZoom();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionReadIndicatorInformation();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionReadPauseResume();
+ }
+ return false;
+}
+
+bool AccessibilityAdaptor::HandleActionStartStopEvent()
+{
+ if( mActionHandler )
+ {
+ return mActionHandler->AccessibilityActionStartStop();
+ }
+ return false;
+}
+
static Internal::Adaptor::AccessibilityAdaptor& GetImplementation(Dali::AccessibilityAdaptor& adaptor)
{
BaseObject& handle = adaptor.GetBaseObject();
{
}
-Vector2 AccessibilityAdaptor::GetReadPosition() const
+// Mock setup:
+
+void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
+{
+ Internal::Adaptor::GetImplementation(*this).MockSetReadPosition( position );
+}
+
+// Methods:
+
+Vector2 AccessibilityAdaptor::GetReadPosition()
{
- //return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
- return Vector2::ZERO;
+ return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
}
bool AccessibilityAdaptor::IsEnabled() const
bool AccessibilityAdaptor::HandleActionNextEvent()
{
- return true; //Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent();
}
bool AccessibilityAdaptor::HandleActionPreviousEvent()
{
- return true; //Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent();
}
bool AccessibilityAdaptor::HandleActionActivateEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionActivateEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionActivateEvent();
}
bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionReadEvent(x, y, allowReadAgain);
+ return Internal::Adaptor::GetImplementation(*this).HandleActionReadEvent( x, y, allowReadAgain );
}
bool AccessibilityAdaptor::HandleActionReadNextEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent();
}
bool AccessibilityAdaptor::HandleActionReadPreviousEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent();
}
bool AccessibilityAdaptor::HandleActionUpEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionUpEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionUpEvent();
}
bool AccessibilityAdaptor::HandleActionDownEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionDownEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionDownEvent();
}
bool AccessibilityAdaptor::HandleActionClearFocusEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionClearFocusEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionClearFocusEvent();
}
bool AccessibilityAdaptor::HandleActionScrollEvent(TouchPoint& point, unsigned long timeStamp)
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
+ return Internal::Adaptor::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
}
bool AccessibilityAdaptor::HandleActionBackEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionBackEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionBackEvent();
}
void AccessibilityAdaptor::HandleActionEnableEvent()
{
- //Internal::Adaptor::GetImplementation(*this).HandleActionEnableEvent();
+ Internal::Adaptor::GetImplementation(*this).HandleActionEnableEvent();
}
void AccessibilityAdaptor::HandleActionDisableEvent()
{
- //Internal::Adaptor::GetImplementation(*this).HandleActionDisableEvent();
+ Internal::Adaptor::GetImplementation(*this).HandleActionDisableEvent();
}
bool AccessibilityAdaptor::HandleActionScrollUpEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionScrollUpEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionScrollUpEvent();
}
bool AccessibilityAdaptor::HandleActionScrollDownEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionScrollDownEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionScrollDownEvent();
}
bool AccessibilityAdaptor::HandleActionPageLeftEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionPageLeftEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionPageLeftEvent();
}
bool AccessibilityAdaptor::HandleActionPageRightEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionPageRightEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionPageRightEvent();
}
bool AccessibilityAdaptor::HandleActionPageUpEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionPageUpEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionPageUpEvent();
}
bool AccessibilityAdaptor::HandleActionPageDownEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionPageDownEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionPageDownEvent();
}
bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionMoveToFirstEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToFirstEvent();
}
bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionMoveToLastEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToLastEvent();
}
bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionReadFromTopEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromTopEvent();
}
bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionReadFromNextEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromNextEvent();
}
bool AccessibilityAdaptor::HandleActionZoomEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionZoomEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionZoomEvent();
}
bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionReadIndicatorInformationEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionReadIndicatorInformationEvent();
}
bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent();
}
bool AccessibilityAdaptor::HandleActionStartStopEvent()
{
- return true;//Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent();
+ return Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent();
}
AccessibilityAdaptor::AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor )
AccessibilityAdaptor();
~AccessibilityAdaptor();
+public: // Mock object setup.
+
+ void MockSetReadPosition( Vector2& position );
+
public: // Getters
+
static AccessibilityAdaptor Get();
- Vector2 GetReadPosition() const;
+
+ Vector2 GetReadPosition();
bool IsEnabled() const;
void SetActionHandler(AccessibilityActionHandler& handler);
void SetGestureHandler(AccessibilityGestureHandler& handler);
+
bool HandleActionNextEvent();
bool HandleActionPreviousEvent();
bool HandleActionActivateEvent();
static Dali::SingletonService New();
static Dali::SingletonService Get();
void Register( const std::type_info& info, BaseHandle singleton );
+ void UnregisterAll();
BaseHandle GetSingleton( const std::type_info& info ) const;
private:
}
}
+void SingletonService::UnregisterAll()
+{
+ mSingletonContainer.clear();
+}
+
BaseHandle SingletonService::GetSingleton( const std::type_info& info ) const
{
BaseHandle object;
{
}
+SingletonService SingletonService::New()
+{
+ return Internal::Adaptor::SingletonService::New();
+}
+
SingletonService SingletonService::Get()
{
return Internal::Adaptor::SingletonService::Get();
GetImplementation( *this ).Register( info, singleton );
}
+void SingletonService::UnregisterAll()
+{
+ GetImplementation( *this ).UnregisterAll();
+}
+
BaseHandle SingletonService::GetSingleton( const std::type_info& info ) const
{
return GetImplementation( *this ).GetSingleton( info );
{
public:
SingletonService();
+ static Dali::SingletonService New();
static SingletonService Get();
~SingletonService();
void Register( const std::type_info& info, BaseHandle singleton );
+ void UnregisterAll();
BaseHandle GetSingleton( const std::type_info& info ) const;
public: // Not intended for application developers
// Need to override adaptor classes for toolkit test harness, so include
// test harness headers before dali headers.
#include <dali-toolkit-test-suite-utils.h>
+#include <toolkit-accessibility-adaptor.h>
#include <dali-toolkit/dali-toolkit.h>
END_TEST;
}
+
+// Note: No negative test for GetReadPosition as it will always return something.
+int UtcDaliAccessibilityManagerGetReadPositionP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliAccessibilityManagerGetReadPositionP");
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ Vector2 position( 1.0f, 2.0f );
+ accessibilityAdaptor.MockSetReadPosition( position );
+
+ DALI_TEST_EQUALS( manager.GetReadPosition(), position, TEST_LOCATION );
+
+ END_TEST;
+}
+
+// Functor to test if an accessibility signal has been called.
+class AccessibilityManagerSignalHandler : public Dali::ConnectionTracker
+{
+public:
+ AccessibilityManagerSignalHandler() :
+ mCalls( 0 )
+ {
+ }
+
+ bool Callback( AccessibilityManager& accessibilityManager )
+ {
+ mCalls++;
+ tet_infoline( "Signal called" );
+ return true;
+ }
+
+ unsigned int GetCalls() const
+ {
+ return mCalls;
+ }
+
+private:
+ unsigned int mCalls; ///< Keeps track of how many times the signal has been called.
+};
+
+int UtcDaliAccessibilityManagerStatusChangedSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerStatusChangedSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.StatusChangedSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ // Cause a state change.
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionEnableEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerStatusChangedSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerStatusChangedSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.StatusChangedSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionNextSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionNextSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionNextEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionNextSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionNextSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionPreviousSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionPreviousSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionPreviousEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionPreviousSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionPreviousSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionActivateSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionActivateSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionActivateSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionActivateEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionActivateSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionActivateSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionActivateSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionReadEvent( 100.0f, 200.0f, true );
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionOverSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionOverSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionOverSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ // Note that the ActionOverSignal is provoked by a read even when "allow read again" is set to false.
+ accessibilityAdaptor.HandleActionReadEvent( 100.0f, 200.0f, false );
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionOverSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionOverSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionOverSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadNextSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadNextSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionReadNextEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadNextSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadNextSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadPreviousSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadPreviousSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionReadPreviousEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadPreviousSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadPreviousSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionUpSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionUpSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionUpEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionUpSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionUpSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionDownSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionDownSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionDownEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionDownSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionDownSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionClearFocusSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionClearFocusSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionClearFocusSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionClearFocusEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionClearFocusSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionClearFocusSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionClearFocusSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionBackSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionBackSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionBackSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionBackEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionBackSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionBackSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionBackSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionScrollUpSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionScrollUpSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionScrollUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionScrollUpEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionScrollUpSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionScrollUpSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionScrollUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionScrollDownSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionScrollDownSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionScrollDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionScrollDownEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionScrollDownSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionScrollDownSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionScrollDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionPageLeftSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionPageLeftSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionPageLeftSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionPageLeftEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionPageLeftSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionPageLeftSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionPageLeftSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionPageRightSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionPageRightSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionPageRightSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionPageRightEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionPageRightSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionPageRightSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionPageRightSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionPageUpSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionPageUpSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionPageUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionPageUpEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionPageUpSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionPageUpSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionPageUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionPageDownSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionPageDownSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionPageDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionPageDownEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionPageDownSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionPageDownSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionPageDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionMoveToFirstSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionMoveToFirstSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionMoveToFirstSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionMoveToFirstEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionMoveToFirstSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionMoveToFirstSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionMoveToFirstSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionMoveToLastSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionMoveToLastSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionMoveToLastSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionMoveToLastEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionMoveToLastSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionMoveToLastSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionMoveToLastSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadFromTopSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadFromTopSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadFromTopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionReadFromTopEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadFromTopSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadFromTopSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadFromTopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadFromNextSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadFromNextSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadFromNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionReadFromNextEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadFromNextSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadFromNextSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadFromNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionZoomSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionZoomSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionZoomSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionZoomEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionZoomSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionZoomSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionZoomSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadIndicatorInformationSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionReadIndicatorInformationEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadIndicatorInformationSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadPauseResumeSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadPauseResumeSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadPauseResumeSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionReadPauseResumeEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionReadPauseResumeSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionReadPauseResumeSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionReadPauseResumeSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionStartStopSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionStartStopSignalP" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionStartStopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+ accessibilityAdaptor.HandleActionStartStopEvent();
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionStartStopSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionStartStopSignalN" );
+
+ AccessibilityManagerSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionStartStopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+// Functor to test if a accessibility scroll signal has been called.
+class AccessibilityManagerScrollSignalHandler : public Dali::ConnectionTracker
+{
+public:
+ AccessibilityManagerScrollSignalHandler() :
+ mCalls( 0 )
+ {
+ }
+
+ bool Callback( AccessibilityManager& accessibilityManager, const Dali::TouchEvent& touchEvent )
+ {
+ mCalls++;
+ mTouchEvent = touchEvent;
+ tet_infoline( "Signal called" );
+ return true;
+ }
+
+ unsigned int GetCalls() const
+ {
+ return mCalls;
+ }
+
+ const Dali::TouchEvent& GetTouchEvent() const
+ {
+ return mTouchEvent;
+ }
+
+private:
+ unsigned int mCalls; ///< Keeps track of how many times the signal has been called.
+ Dali::TouchEvent mTouchEvent; ///< Stores the last touch event received.
+};
+
+int UtcDaliAccessibilityManagerActionScrollSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionScrollSignalP" );
+
+ AccessibilityManagerScrollSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionScrollSignal().Connect( &callback, &AccessibilityManagerScrollSignalHandler::Callback );
+
+ Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
+
+ TouchPoint point( 0, TouchPoint::Started, 100.0f, 200.0f );
+ accessibilityAdaptor.HandleActionScrollEvent( point, 0u );
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
+
+ const TouchEvent& signalTouchEvent = callback.GetTouchEvent();
+ DALI_TEST_EQUALS( signalTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
+
+ const TouchPoint& signalTouchPoint = signalTouchEvent.GetPoint( 0u );
+
+ DALI_TEST_EQUALS( signalTouchPoint.state, TouchPoint::Started, TEST_LOCATION );
+ DALI_TEST_EQUALS( signalTouchPoint.screen.x, 100.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( signalTouchPoint.screen.y, 200.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityManagerActionScrollSignalN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliAccessibilityManagerActionScrollSignalN" );
+
+ AccessibilityManagerScrollSignalHandler callback;
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK( manager );
+
+ manager.ActionScrollSignal().Connect( &callback, &AccessibilityManagerScrollSignalHandler::Callback );
+
+ DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
-const Dali::Vector4 LIGHT_BLUE( (0xb2 / 255.0f), (0xeb / 255.0f), (0xf2 / 255.0f), 0.5f ); // The text highlight color.
+const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
const float TO_MILLISECONDS = 1000.f;
# Tizen Profile options
AC_ARG_ENABLE([profile],
- [AC_HELP_STRING([--enable-profile=COMMON,MOBILE,WEARABLE,TV],
+ [AC_HELP_STRING([--enable-profile=UBUNTU,MOBILE,WEARABLE,TV],
[Select the variant of tizen])],
[dali_profile=$enableval],
- [dali_profile=COMMON])
+ [dali_profile=UBUNTU])
+
+# Ensure valid profile selected
+if test "x$dali_profile" != "xUBUNTU" -a "x$dali_profile" != "xMOBILE" -a "x$dali_profile" != "xWEARABLE" -a "x$dali_profile" != "xTV" ; then
+ AC_MSG_ERROR([$enable_profile is an invalid profile])
+fi
if test x$DALI_DATA_RW_DIR != x; then
dataReadWriteDir=${DALI_DATA_RW_DIR}/
dataReadOnlyDir=${prefix}/share/dali/
fi
-DALI_TOOLKIT_CFLAGS="$DALI_TOOLKIT_CFLAGS -DDALI_PROFILE_${enable_profile}"
-AM_CONDITIONAL([COMMON_PROFILE], [test x$enable_profile = xCOMMON])
-AM_CONDITIONAL([MOBILE_PROFILE], [test x$enable_profile = xMOBILE])
+DALI_TOOLKIT_CFLAGS="$DALI_TOOLKIT_CFLAGS -DDALI_PROFILE_${dali_profile}"
+
+# Style paths
+if test "x$dali_profile" = "xUBUNTU"; then
+ STYLE_DIR=../../../dali-toolkit/styles
+fi
+
+if test "x$dali_profile" = "xMOBILE"; then
+ STYLE_DIR=../../../dali-toolkit/styles/mobile
+fi
+
+AC_SUBST(STYLE_DIR)
# v8 version 4+ requires c++11
PKG_CHECK_MODULES(V8, v8 = 3.32.7, [ pkg_check_v8=yes ], [ pkg_check_v8=no ] )
public_api_src_dir = ../../../dali-toolkit/public-api
devel_api_src_dir = ../../../dali-toolkit/devel-api
-if MOBILE_PROFILE
-toolkit_styles_dir = ../../../dali-toolkit/styles/mobile
-else
-toolkit_styles_dir = ../../../dali-toolkit/styles
-endif
+toolkit_styles_dir = $(STYLE_DIR)
include ../../../dali-toolkit/images/file.list
include ../../../dali-toolkit/sounds/file.list
return Control::DownCast<TextSelectionPopup, Internal::TextSelectionPopup>(handle);
}
+void TextSelectionPopup::RaiseAbove( Layer target )
+{
+ GetImpl(*this).RaiseAbove( target );
+}
+
TextSelectionPopup::TextSelectionPopup( Internal::TextSelectionPopup& implementation )
: Control(implementation)
{
*/
static TextSelectionPopup DownCast( BaseHandle handle );
+ /**
+ * @brief Raises the toolbar's layer above the given @e target layer.
+ *
+ * @param[in] target The layer to get above of.
+ */
+ void RaiseAbove( Layer target );
+
public: // Not intended for application developers
/**
GetImpl(*this).ResizeDividers( size );
}
+void TextSelectionToolbar::RaiseAbove( Layer target )
+{
+ GetImpl(*this).RaiseAbove( target );
+}
+
TextSelectionToolbar TextSelectionToolbar::DownCast( BaseHandle handle )
{
return Control::DownCast<TextSelectionToolbar, Internal::TextSelectionToolbar>(handle);
void ResizeDividers( Size& size );
/**
+ * @brief Raises the layer above the given @e target layer.
+ *
+ * @param[in] target The layer to get above of.
+ */
+ void RaiseAbove( Layer target );
+
+ /**
* @brief Downcast a handle to TextSelectionToolbar.
*
* If the BaseHandle points is a TextSelectionToolbar the downcast returns a valid handle.
return actor;
}
+Vector2 AccessibilityManager::GetReadPosition() const
+{
+ AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get();
+ return adaptor.GetReadPosition();
+}
+
void AccessibilityManager::SetGroupMode(bool enabled)
{
mIsFocusWithinGroup = enabled;
*/
Actor GetFocusGroup(Actor actor);
+ /**
+ * @copydoc Toolkit::AccessibilityManager::GetReadPosition
+ */
+ Vector2 GetReadPosition() const;
+
public:
/**
}
Dali::Atlas atlas = Dali::Atlas::New( width, height, pixelformat );
+ atlas.Clear( Vector4::ZERO );
+ mUploadedImages.PushBack( NULL );
AtlasDescriptor atlasDescriptor;
atlasDescriptor.mAtlas = atlas;
atlasDescriptor.mSize = size;
atlasDescriptor.mPixelFormat = pixelformat;
- atlasDescriptor.mNextFreeBlock = 1u; // indicate next free block will be the first ( +1 )
+ atlasDescriptor.mTotalBlocks = ( width / blockWidth ) * ( height / blockHeight );
+ atlasDescriptor.mAvailableBlocks = atlasDescriptor.mTotalBlocks - 1u;
atlas.UploadedSignal().Connect( this, &AtlasManager::OnUpload );
// What size do we need for this atlas' strip buffer ( assume 32bit pixel format )?
SizeType width = image.GetWidth();
SizeType height = image.GetHeight();
SizeType blockArea = 0;
- SizeType totalBlocks = 0;
SizeType foundAtlas = 0;
SizeType index = 0;
slot.mImageId = 0;
// If there is a preferred atlas then check for room in that first
if ( atlas-- )
{
- foundAtlas = CheckAtlas( atlas, width, height, pixelFormat, blockArea, totalBlocks );
+ foundAtlas = CheckAtlas( atlas, width, height, pixelFormat, blockArea );
}
// Search current atlases to see if there is a good match
-
while( !foundAtlas && index < mAtlasList.size() )
{
- foundAtlas = CheckAtlas( index, width, height, pixelFormat, blockArea, totalBlocks );
+ foundAtlas = CheckAtlas( index, width, height, pixelFormat, blockArea );
++index;
}
}
else
{
- foundAtlas = CheckAtlas( newAtlas, width, height, pixelFormat, blockArea, totalBlocks );
+ foundAtlas = CheckAtlas( newAtlas, width, height, pixelFormat, blockArea );
}
}
- if ( Toolkit::AtlasManager::FAIL_ON_ADD_FAILS == mAddFailPolicy || !foundAtlas-- )
+ if ( !foundAtlas-- || Toolkit::AtlasManager::FAIL_ON_ADD_FAILS == mAddFailPolicy )
{
// Haven't found an atlas for this image!!!!!!
return;
for ( SizeType i = 0; i < blockArea; ++i )
{
// Is there currently a next free block available ?
- if ( mAtlasList[ foundAtlas ].mNextFreeBlock )
+ if ( mAtlasList[ foundAtlas ].mAvailableBlocks )
{
- // Yes, so use this for our next block
- SizeType selectedBlock = mAtlasList[ foundAtlas ].mNextFreeBlock - 1u;
- desc.mBlocksList.PushBack( selectedBlock );
-
- // Any blocks going to be available after this one (adjust to store +1 )?
- selectedBlock++;
- selectedBlock++;
- if ( selectedBlock > totalBlocks )
- {
- // No so start trying to use free blocks list
- selectedBlock = 0;
- }
- mAtlasList[ foundAtlas ].mNextFreeBlock = selectedBlock;
+ // Yes, so select our next block
+ desc.mBlocksList.PushBack( mAtlasList[ foundAtlas ].mTotalBlocks - mAtlasList[ foundAtlas ].mAvailableBlocks-- );
}
else
{
desc.mCount = 1u;
// See if there's a previously freed image ID that we can assign to this new image
- uint32_t imageId = 0;
- for ( uint32_t i = 0; i < mImageList.size(); ++i )
+ uint32_t imageId = 0u;
+ for ( uint32_t i = 0u; i < mImageList.size(); ++i )
{
if ( !mImageList[ i ].mCount )
{
SizeType width,
SizeType height,
Pixel::Format pixelFormat,
- SizeType& blockArea,
- SizeType& totalBlocks )
+ SizeType& blockArea )
{
if ( pixelFormat == mAtlasList[ atlas ].mPixelFormat )
{
- // Check to see if there are any unused blocks in this atlas to accomodate our image
- SizeType blocksInX = mAtlasList[ atlas ].mSize.mWidth / mAtlasList[ atlas ].mSize.mBlockWidth;
- SizeType blocksInY = mAtlasList[ atlas ].mSize.mHeight / mAtlasList[ atlas ].mSize.mBlockHeight;
- totalBlocks = blocksInX * blocksInY;
- SizeType blocksFree = mAtlasList[ atlas ].mNextFreeBlock ?
- totalBlocks - mAtlasList[ atlas ].mNextFreeBlock + 1u :
- mAtlasList[ atlas ].mFreeBlocksList.Size();
-
// Check to see if the image will fit in these blocks, if not we'll need to create a new atlas
- if ( blocksFree
- && width + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mSize.mBlockWidth
- && height + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mSize.mBlockHeight )
+ if ( ( mAtlasList[ atlas ].mAvailableBlocks + mAtlasList[ atlas ].mFreeBlocksList.Size() )
+ && width + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mSize.mBlockWidth
+ && height + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mSize.mBlockHeight )
{
blockArea = 1u;
return ( atlas + 1u );
}
}
- return 0;
+ return 0u;
}
void AtlasManager::CreateMesh( SizeType atlas,
Toolkit::AtlasManager::Mesh2D& mesh,
AtlasSlotDescriptor& desc )
{
-
Toolkit::AtlasManager::Vertex2D vertex;
uint32_t faceIndex = 0; // TODO change to unsigned short when property type is available
float texelX = 1.0f / static_cast< float >( width );
float texelY = 1.0f / static_cast< float >( height );
+ float halfTexelX = texelX * 0.5f;
+ float halfTexelY = texelY * 0.5f;
+
// Get the normalized size of a block in texels
float texelBlockWidth = texelX * vertexBlockWidth;
float texelBlockHeight = texelY * vertexBlockHeight;
float vertexEdgeHeight = static_cast< float >( imageHeight % blockHeight );
// And in texels
- float texelEdgeWidth = vertexEdgeWidth * texelX;
- float texelEdgeHeight = vertexEdgeHeight * texelY;
+ float texelEdgeWidth = texelX * vertexEdgeWidth;
+ float texelEdgeHeight = texelY * vertexEdgeHeight;
+
+ // We're going to 'blit' half a pixel more on each edge
+ vertexBlockWidth++;
+ vertexEdgeWidth++;
+ vertexBlockHeight++;
+ vertexEdgeHeight++;
// Block by block create the two triangles for the quad
SizeType blockIndex = 0;
float ndcVWidth;
float ndcVHeight;
- Vector2 topLeft = position;
+ // Move back half a pixel
+ Vector2 topLeft = Vector2( position.x - 0.5f, position.y - 0.5f );
for ( SizeType y = 0; y < heightInBlocks; ++y )
{
if ( ( heightInBlocks - 1u ) == y && vertexEdgeHeight > 0.0f )
{
- ndcHeight = texelEdgeHeight;
+ ndcHeight = texelEdgeHeight + texelY;
ndcVHeight = vertexEdgeHeight;
}
else
{
- ndcHeight = texelBlockHeight;
+ ndcHeight = texelBlockHeight + texelY;
ndcVHeight = vertexBlockHeight;
}
float fBlockY = texelBlockHeight * static_cast< float >( block / atlasWidthInBlocks );
// Add on texture filtering compensation
- fBlockX += texelX;
- fBlockY += texelY;
+ fBlockX += halfTexelX;
+ fBlockY += halfTexelY;
if ( ( widthInBlocks - 1u ) == x && vertexEdgeWidth > 0.0f )
{
- ndcWidth = texelEdgeWidth;
+ ndcWidth = texelEdgeWidth + texelX;
ndcVWidth = vertexEdgeWidth;
}
else
{
- ndcWidth = texelBlockWidth;
+ ndcWidth = texelBlockWidth + texelX;
ndcVWidth = vertexBlockWidth;
}
Toolkit::AtlasManager::Mesh2D optimizedMesh;
OptimizeMesh( mesh, optimizedMesh );
}
- //PrintMeshData( mesh );
}
void AtlasManager::PrintMeshData( const Toolkit::AtlasManager::Mesh2D& mesh )
Toolkit::AtlasManager::Vertex2D v = in.mVertices[ in.mIndices[ i ] ];
for ( SizeType j = 0; j < out.mVertices.Size(); ++j )
{
- if ( v.mPosition.x == out.mVertices[ j ].mPosition.x && v.mPosition.y == out.mVertices[ j ].mPosition.y &&
- v.mTexCoords.x == out.mVertices[ j ].mTexCoords.x && v.mTexCoords.y == out.mVertices[ j ].mTexCoords.y )
+ if ( ( fabsf( v.mPosition.x - out.mVertices[ j ].mPosition.x ) < Math::MACHINE_EPSILON_1000 ) &&
+ ( fabsf( v.mPosition.y - out.mVertices[ j ].mPosition.y ) < Math::MACHINE_EPSILON_1000 ) &&
+ ( fabsf( v.mTexCoords.x - out.mVertices[ j ].mTexCoords.x ) < Math::MACHINE_EPSILON_1000 ) &&
+ ( fabsf( v.mTexCoords.y - out.mVertices[ j ].mTexCoords.y ) < Math::MACHINE_EPSILON_1000 ) )
{
// Yes, so store this down as the vertex to use
out.mIndices.PushBack( j );
mUploadedImages.PushBack( const_cast< BufferImage& >( image ).GetBuffer() );
}
- // If this is the first block then we need to keep the first pixel free for underline texture
- if ( block )
+ // Blit top strip
+ if ( !mAtlasList[ atlas ].mAtlas.Upload( mAtlasList[ atlas ].mHorizontalStrip,
+ blockOffsetX,
+ blockOffsetY ) )
{
+ DALI_LOG_ERROR("Uploading top strip to Atlas Failed!\n");
+ }
+ else
+ {
+ mUploadedImages.PushBack( NULL );
+ }
- // Blit top strip
- if ( !mAtlasList[ atlas ].mAtlas.Upload( mAtlasList[ atlas ].mHorizontalStrip,
- blockOffsetX,
- blockOffsetY ) )
- {
- DALI_LOG_ERROR("Uploading top strip to Atlas Failed!\n");
- }
- else
- {
- mUploadedImages.PushBack( NULL );
- }
-
- // Blit left strip
- if ( !mAtlasList[ atlas ].mAtlas.Upload( mAtlasList[ atlas ].mVerticalStrip,
- blockOffsetX,
- blockOffsetY + SINGLE_PIXEL_PADDING ) )
- {
- DALI_LOG_ERROR("Uploading left strip to Atlas Failed!\n");
- }
- else
- {
- mUploadedImages.PushBack( NULL );
- }
+ // Blit left strip
+ if ( !mAtlasList[ atlas ].mAtlas.Upload( mAtlasList[ atlas ].mVerticalStrip,
+ blockOffsetX,
+ blockOffsetY + SINGLE_PIXEL_PADDING ) )
+ {
+ DALI_LOG_ERROR("Uploading left strip to Atlas Failed!\n");
+ }
+ else
+ {
+ mUploadedImages.PushBack( NULL );
}
// Blit bottom strip
AtlasManager::SizeType AtlasManager::GetFreeBlocks( AtlasId atlas ) const
{
- if ( atlas && atlas <= mAtlasList.size() )
+ if ( atlas && atlas-- <= mAtlasList.size() )
{
- uint32_t index = atlas - 1u;
- uint32_t width = mAtlasList[ index ].mSize.mWidth;
- uint32_t height = mAtlasList[ index ].mSize.mHeight;
- uint32_t blockWidth = mAtlasList[ index ].mSize.mBlockWidth;
- uint32_t blockHeight = mAtlasList[ index ].mSize.mBlockHeight;
-
- SizeType widthInBlocks = width / blockWidth;
- SizeType heightInBlocks = height / blockHeight;
- uint32_t blockCount = widthInBlocks * heightInBlocks;
-
- // Check free previously unallocated blocks and any free blocks
- if ( mAtlasList[ index ].mNextFreeBlock )
- {
- blockCount -= mAtlasList[ index ].mNextFreeBlock -1u - mAtlasList[ index ].mFreeBlocksList.Size();
- }
- else
- {
- blockCount = mAtlasList[ index ].mFreeBlocksList.Size();
- }
- return blockCount;
+ return ( mAtlasList[ atlas ].mAvailableBlocks + mAtlasList[ atlas ].mFreeBlocksList.Size() );
}
else
{
DALI_LOG_ERROR("Cannot get Atlas from AtlasID ( doesn't exist ).\n");
return Pixel::L8;
}
- return mAtlasList[ atlas -1u ].mPixelFormat;
+ return mAtlasList[ --atlas].mPixelFormat;
}
void AtlasManager::GetMetrics( Toolkit::AtlasManager::Metrics& metrics )
for ( uint32_t i = 0; i < atlasCount; ++i )
{
entry.mSize = mAtlasList[ i ].mSize;
- entry.mTotalBlocks = ( entry.mSize.mWidth / entry.mSize.mBlockWidth ) * ( entry.mSize.mHeight / entry.mSize.mBlockHeight );
- uint32_t reuseBlocks = mAtlasList[ i ].mFreeBlocksList.Size();
- entry.mBlocksUsed = mAtlasList[ i ].mNextFreeBlock ? mAtlasList[ i ].mNextFreeBlock - reuseBlocks - 1u: entry.mTotalBlocks - reuseBlocks;
+ entry.mTotalBlocks = mAtlasList[ i ].mTotalBlocks;
+ entry.mBlocksUsed = entry.mTotalBlocks - mAtlasList[ i ].mAvailableBlocks + mAtlasList[ i ].mFreeBlocksList.Size();
entry.mPixelFormat = GetPixelFormat( i + 1 );
- metrics.mAtlasMetrics.PushBack( entry );
+ metrics.mAtlasMetrics.PushBack( entry );
uint32_t size = entry.mSize.mWidth * entry.mSize.mHeight;
if ( entry.mPixelFormat == Pixel::BGRA8888 )
Material AtlasManager::GetMaterial( AtlasId atlas ) const
{
- if ( atlas && atlas <= mAtlasList.size() )
+ if ( atlas && atlas-- <= mAtlasList.size() )
{
- return mAtlasList[ atlas -1u ].mMaterial;
+ return mAtlasList[ atlas ].mMaterial;
}
Material null;
return null;
Sampler AtlasManager::GetSampler( AtlasId atlas ) const
{
- if ( atlas && atlas <= mAtlasList.size() )
+ if ( atlas && atlas-- <= mAtlasList.size() )
{
- return mAtlasList[ atlas -1u ].mSampler;
+ return mAtlasList[ atlas ].mSampler;
}
Sampler null;
return null;
PixelBuffer* mStripBuffer; // Blank image buffer used to pad upload
Material mMaterial; // material used for atlas texture
Sampler mSampler; // sampler used for atlas texture
- SizeType mNextFreeBlock; // next free block will be placed here ( actually +1 )
+ SizeType mTotalBlocks; // total number of blocks in atlas
+ SizeType mAvailableBlocks; // number of blocks available in atlas
Dali::Vector< SizeType > mFreeBlocksList; // unless there are any previously freed blocks
};
SizeType width,
SizeType height,
Pixel::Format pixelFormat,
- SizeType& blockArea,
- SizeType& totalBlocks );
+ SizeType& blockArea );
void CreateMesh( SizeType atlas,
SizeType imageWidth,
namespace
{
+#define TOKEN_STRING(x) #x
+
const std::string KEYNAME_STYLES = "styles";
const std::string KEYNAME_TYPE = "type";
const std::string KEYNAME_ACTORS = "actors";
: mSlotDelegate( this )
{
mParser = Dali::Toolkit::JsonParser::New();
+
+ Property::Map defaultDirs;
+ defaultDirs[ TOKEN_STRING(DALI_IMAGE_DIR) ] = DALI_IMAGE_DIR;
+ defaultDirs[ TOKEN_STRING(DALI_SOUND_DIR) ] = DALI_SOUND_DIR;
+ defaultDirs[ TOKEN_STRING(DALI_STYLE_DIR) ] = DALI_STYLE_DIR;
+
+ AddConstants( defaultDirs );
}
Builder::~Builder()
/**
* Button states and contents
* (3) mSelectedContent
- * (2) mButtonContent (2) mSelectedBackgroundContent
+ * (2) mUnselectedContent (2) mSelectedBackgroundContent
* (1) mBackgroundContent (1) mBackgroundContent
* < unselected > ----------------------- < selected >
* | OnSelect() |
* The drawing order of child actors is as follows.
*
* Top mLabel
- * | mButtonContent / mSelectedContent / mDisabledContent / mDisabledSelectedContent
+ * | mUnselectedContent / mSelectedContent / mDisabledContent / mDisabledSelectedContent
* | mSelectedBackgroundContent
* Bottom mBackgroundContent / mDisabledBackgroundContent
*
Button::~Button()
{
- if( mAutoRepeatingTimer )
- {
- mAutoRepeatingTimer.Reset();
- }
}
void Button::SetDisabled( bool disabled )
{
- if( disabled != mDisabled )
+ if( disabled == mDisabled )
{
- unsigned int backgroundIndex;
- unsigned int buttonIndex;
-
- bool animationStarted = false;
-
- mDisabled = disabled;
-
- switch( mPaintState )
- {
- case UnselectedState:
- {
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mDisabledContent );
-
- if( mBackgroundContent )
- {
- backgroundIndex = 1;
- }
- else
- {
- backgroundIndex = 0;
- }
-
- InsertChild( backgroundIndex, mDisabledBackgroundContent );
-
- animationStarted = OnDisabled();
-
- if( animationStarted )
- {
- mPaintState = UnselectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledUnselectedState;
- }
- break;
- }
- case SelectedState:
- {
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mDisabledSelectedContent );
-
- if( mBackgroundContent )
- {
- backgroundIndex = 1;
- }
- else
- {
- backgroundIndex = 0;
- }
-
- InsertChild( backgroundIndex, mDisabledBackgroundContent );
-
- animationStarted = OnDisabled();
-
- if( animationStarted )
- {
- mPaintState = SelectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledSelectedState;
- }
- break;
- }
- case DisabledUnselectedState:
- {
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mButtonContent );
-
- if( mDisabledBackgroundContent )
- {
- backgroundIndex = 1;
- }
- else
- {
- backgroundIndex = 0;
- }
-
- InsertChild( backgroundIndex, mBackgroundContent );
-
- animationStarted = OnDisabled();
-
- if( animationStarted )
- {
- mPaintState = DisabledUnselectedTransition;
- }
- else
- {
- mPaintState = UnselectedState;
- }
- break;
- }
- case DisabledSelectedState:
- {
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mSelectedContent );
-
- if( mDisabledBackgroundContent )
- {
- backgroundIndex = 1;
- }
- else
- {
- backgroundIndex = 0;
- }
-
- InsertChild( backgroundIndex, mSelectedBackgroundContent );
- InsertChild( backgroundIndex, mBackgroundContent );
+ return;
+ }
- animationStarted = OnDisabled();
+ StopTransitionAnimation();
- if( animationStarted )
- {
- mPaintState = DisabledSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
- break;
- }
- case UnselectedSelectedTransition:
- {
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mDisabledSelectedContent );
+ mDisabled = disabled;
- if( mBackgroundContent )
- {
- backgroundIndex = 1;
- }
- else
- {
- backgroundIndex = 0;
- }
+ // Notifies the derived class the button has been disabled.
+ OnDisabled();
- InsertChild( backgroundIndex, mDisabledBackgroundContent );
+ switch( mPaintState )
+ {
+ case UnselectedState:
+ {
+ //Layer Order
+ //(3) mDisabledContent (Inserted)
+ //(4) mUnselectedContent
+ //(2) mDisabledBackgroundContent (Inserted)
+ //(1) mBackgroundContent
- animationStarted = OnDisabled();
+ TransitionInBetween( mUnselectedContent, mLabel, mDisabledContent );
+ TransitionInAbove( mBackgroundContent, mDisabledBackgroundContent );
- if( animationStarted )
- {
- mPaintState = SelectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledSelectedState;
- }
- break;
- }
- case SelectedUnselectedTransition:
- {
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mDisabledContent );
+ TransitionOut( mUnselectedContent );
+ TransitionOut( mSelectedContent );
+ TransitionOut( mBackgroundContent );
+ TransitionOut( mSelectedBackgroundContent );
+ TransitionOut( mDisabledSelectedContent );
- if( mBackgroundContent )
- {
- backgroundIndex = 1;
- }
- else
- {
- backgroundIndex = 0;
- }
+ mPaintState = DisabledUnselectedState;
+ break;
+ }
+ case SelectedState:
+ {
+ //Layer Order
+ //(5) mDisabledSelectedContent (Inserted)
+ //(4) mSelectedContent
+ //(3) mDisabledBackgroundContent (Inserted)
+ //(2) mSelectedBackgroundContent
+ //(1) mBackgroundContent
+
+ TransitionInBetween( mSelectedContent, mLabel, mDisabledSelectedContent );
+ TransitionInAbove( mSelectedBackgroundContent, mDisabledBackgroundContent );
+
+ TransitionOut( mUnselectedContent );
+ TransitionOut( mSelectedContent );
+ TransitionOut( mBackgroundContent );
+ TransitionOut( mSelectedBackgroundContent );
+ TransitionOut( mDisabledContent );
- InsertChild( backgroundIndex, mDisabledBackgroundContent );
+ mPaintState = DisabledSelectedState;
+ break;
+ }
+ case DisabledUnselectedState:
+ {
+ //Layer Order
+ //(3) mUnselectedContent (Inserted)
+ //(4) mDisabledContent
+ //(2) mBackgroundContent (Inserted)
+ //(1) mDisabledBackgroundContent
- animationStarted = OnDisabled();
+ TransitionInBetween( mDisabledContent, mLabel, mUnselectedContent );
+ TransitionInAbove( mDisabledBackgroundContent, mBackgroundContent );
- if( animationStarted )
- {
- mPaintState = UnselectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledUnselectedState;
- }
- break;
- }
- case UnselectedDisabledTransition:
- {
- animationStarted = OnDisabled();
+ TransitionOut( mSelectedContent );
+ TransitionOut( mSelectedBackgroundContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
- if( animationStarted )
- {
- mPaintState = DisabledUnselectedTransition;
- }
- else
- {
- mPaintState = UnselectedState;
- }
- break;
- }
- case DisabledUnselectedTransition:
- {
- animationStarted = OnDisabled();
-
- if( animationStarted )
- {
- mPaintState = UnselectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledUnselectedState;
- }
- break;
- }
- case SelectedDisabledTransition:
- {
- animationStarted = OnDisabled();
-
- if( animationStarted )
- {
- mPaintState = DisabledSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
- break;
- }
- case DisabledSelectedTransition:
- {
- animationStarted = OnDisabled();
+ mPaintState = UnselectedState;
+ break;
+ }
+ case DisabledSelectedState:
+ {
+ //Layer Order
+ //(4) mSelectedContent (Inserted)
+ //(5) mDisabledSelectedContent
+ //(3) mSelectedBackgroundContent (Inserted)
+ //(2) mBackgroundContent (Inserted)
+ //(1) mDisabledBackgroundContent
+
+ TransitionInBetween( mDisabledSelectedContent, mLabel, mSelectedContent );
+ TransitionInAbove( mDisabledBackgroundContent, mSelectedBackgroundContent );
+ TransitionInAbove( mDisabledBackgroundContent, mBackgroundContent );
+
+ TransitionOut( mUnselectedContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
- if( animationStarted )
- {
- mPaintState = SelectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledSelectedState;
- }
- break;
- }
+ mPaintState = SelectedState;
+ break;
}
}
+
+ StartTransitionAnimation();
}
bool Button::IsDisabled() const
void Button::SetSelected( bool selected, bool emitSignal )
{
- unsigned int buttonIndex, backgroundIndex;
- bool animationStarted = false;
+ StopTransitionAnimation();
mSelected = selected;
+ // Notifies the derived class the button has been selected.
+ OnSelected();
+
switch( mPaintState )
{
case UnselectedState:
{
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mSelectedContent );
+ //Layer Order
+ //(3) mSelectedContent (Inserted)
+ //(4) mUnselectedContent
+ //(2) mSelectedBackgroundContent (Inserted)
+ //(1) mBackgroundContent
- if( mBackgroundContent )
- {
- backgroundIndex = 1;
- }
- else
- {
- backgroundIndex = 0;
- }
-
- InsertChild( backgroundIndex, mSelectedBackgroundContent );
+ TransitionInBetween( mUnselectedContent, mLabel, mSelectedContent );
+ TransitionInAbove( mBackgroundContent, mSelectedBackgroundContent );
+ TransitionInAtIndex( 0, mBackgroundContent );
- // Notifies the derived class the button has been selected.
- animationStarted = OnSelected();
+ TransitionOut( mUnselectedContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
- if( animationStarted )
- {
- mPaintState = UnselectedSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
+ mPaintState = SelectedState;
break;
}
case SelectedState:
{
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mButtonContent );
+ //Layer Order
+ //(3) mUnselectedContent (Inserted)
+ //(2) mSelectedContent
+ //(1) mBackgroundContent
- // Notifies the derived class the button has been selected.
- animationStarted = OnSelected();
+ TransitionInBetween( mSelectedContent, mLabel, mUnselectedContent );
+ TransitionInAtIndex( 0, mBackgroundContent );
- if( animationStarted )
- {
- mPaintState = SelectedUnselectedTransition;
- }
- else
- {
- mPaintState = UnselectedState;
- }
- break;
- }
- case UnselectedSelectedTransition:
- {
- // Notifies the derived class the button has been selected.
- animationStarted = OnSelected();
+ TransitionOut( mSelectedContent );
+ TransitionOut( mSelectedBackgroundContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
- if( animationStarted )
- {
- mPaintState = SelectedUnselectedTransition;
- }
- else
- {
- mPaintState = UnselectedState;
- }
- break;
- }
- case SelectedUnselectedTransition:
- {
- // Notifies the derived class the button has been selected.
- animationStarted = OnSelected();
-
- if( animationStarted )
- {
- mPaintState = UnselectedSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
- break;
- }
- case DisabledUnselectedTransition:
- {
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mSelectedContent );
-
- if( mDisabledBackgroundContent )
- {
- if( mBackgroundContent )
- {
- backgroundIndex = 2;
- }
- else
- {
- backgroundIndex = 1;
- }
- }
- else if( mBackgroundContent )
- {
- backgroundIndex = 1;
- }
- else
- {
- backgroundIndex = 0;
- }
-
- InsertChild( backgroundIndex, mSelectedBackgroundContent );
-
- // Notifies the derived class the button has been selected.
- animationStarted = OnSelected();
-
- if( animationStarted )
- {
- mPaintState = UnselectedSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
- break;
- }
- case DisabledSelectedTransition:
- {
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mButtonContent );
-
- // Notifies the derived class the button has been selected.
- animationStarted = OnSelected();
-
- if( animationStarted )
- {
- mPaintState = SelectedUnselectedTransition;
- }
- else
- {
- mPaintState = UnselectedState;
- }
+ mPaintState = UnselectedState;
break;
}
- default:
+ case DisabledUnselectedState:
+ case DisabledSelectedState:
{
+ DALI_ASSERT_DEBUG( 0 && "Shouldn't be able to change paint state if the button is disabled." );
break;
}
}
+ StartTransitionAnimation();
+
if( emitSignal )
{
Toolkit::Button handle( GetOwner() );
void Button::SetButtonImage( Actor image )
{
- StopAllAnimations();
+ StopTransitionAnimation();
- if( mButtonContent && mButtonContent.GetParent() )
+ if( mUnselectedContent && mUnselectedContent.GetParent() )
{
- Self().Remove( mButtonContent );
+ Self().Remove( mUnselectedContent );
}
- mButtonContent = image;
-
- mButtonContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mButtonContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mButtonContent.SetPosition( 0.f, 0.f );
-
- if( mPaintState == UnselectedState )
+ mUnselectedContent = image;
+ if( mUnselectedContent )
{
- unsigned int index = FindChildIndex( mLabel );
-
- Self().Insert( index, mButtonContent );
+ mUnselectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mUnselectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mUnselectedContent.SetPosition( 0.f, 0.f );
}
-
+ ResetImageLayers();
OnButtonImageSet();
RelayoutRequest();
Actor Button::GetButtonImage() const
{
- return mButtonContent;
+ return mUnselectedContent;
}
Actor& Button::GetButtonImage()
{
- return mButtonContent;
+ return mUnselectedContent;
}
void Button::SetSelectedImage( Actor image )
{
- StopAllAnimations();
+ StopTransitionAnimation();
if( mSelectedContent && mSelectedContent.GetParent() )
{
}
mSelectedContent = image;
-
- mSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mSelectedContent.SetPosition( 0.f, 0.f );
-
- if( mPaintState == SelectedState )
+ if( mSelectedContent )
{
- unsigned int index = FindChildIndex( mLabel );
-
- Self().Insert( index, mSelectedContent );
+ mSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mSelectedContent.SetPosition( 0.f, 0.f );
}
-
+ ResetImageLayers();
OnSelectedImageSet();
RelayoutRequest();
void Button::SetBackgroundImage( Actor image )
{
- StopAllAnimations();
+ StopTransitionAnimation();
if( mBackgroundContent && mBackgroundContent.GetParent() )
{
}
mBackgroundContent = image;
-
- mBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mBackgroundContent.SetPosition( 0.f, 0.f );
-
- if( mPaintState == UnselectedState || mPaintState == SelectedState )
+ if( mBackgroundContent )
{
- Self().Insert( 0, mBackgroundContent );
+ mBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mBackgroundContent.SetPosition( 0.f, 0.f );
}
-
+ ResetImageLayers();
OnBackgroundImageSet();
RelayoutRequest();
void Button::SetSelectedBackgroundImage( Actor image )
{
- StopAllAnimations();
+ StopTransitionAnimation();
if( mSelectedBackgroundContent && mSelectedBackgroundContent.GetParent() )
{
}
mSelectedBackgroundContent = image;
-
- mSelectedBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mSelectedBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mSelectedBackgroundContent.SetPosition( 0.f, 0.f );
-
- if( mPaintState == SelectedState )
+ if( mSelectedBackgroundContent )
{
- if( mBackgroundContent )
- {
- Self().Insert( 1, mSelectedBackgroundContent );
- }
- else
- {
- Self().Insert( 0, mSelectedBackgroundContent );
- }
+ mSelectedBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mSelectedBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mSelectedBackgroundContent.SetPosition( 0.f, 0.f );
}
-
+ ResetImageLayers();
OnSelectedBackgroundImageSet();
RelayoutRequest();
void Button::SetDisabledImage( Actor image )
{
- StopAllAnimations();
+ StopTransitionAnimation();
if( mDisabledContent && mDisabledContent.GetParent() )
{
}
mDisabledContent = image;
-
- mDisabledContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mDisabledContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mDisabledContent.SetPosition( 0.f, 0.f );
-
- if( mPaintState == DisabledUnselectedState || mPaintState == DisabledSelectedState )
+ if( mDisabledContent )
{
- unsigned int index = FindChildIndex( mLabel );
-
- Self().Insert( index, mDisabledContent );
+ mDisabledContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mDisabledContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mDisabledContent.SetPosition( 0.f, 0.f );
}
+ ResetImageLayers();
OnDisabledImageSet();
}
void Button::SetDisabledSelectedImage( Actor image )
{
- StopAllAnimations();
+ StopTransitionAnimation();
if( mDisabledSelectedContent && mDisabledSelectedContent.GetParent() )
{
}
mDisabledSelectedContent = image;
-
- mDisabledSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mDisabledSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mDisabledSelectedContent.SetPosition( 0.f, 0.f );
-
- if( mPaintState == DisabledSelectedState )
+ if( mDisabledSelectedContent )
{
- unsigned int index = FindChildIndex( mLabel );
-
- Self().Insert( index, mDisabledSelectedContent );
+ mDisabledSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mDisabledSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mDisabledSelectedContent.SetPosition( 0.f, 0.f );
}
+ ResetImageLayers();
OnDisabledSelectedImageSet();
}
void Button::SetDisabledBackgroundImage( Actor image )
{
- StopAllAnimations();
+ StopTransitionAnimation();
if( mDisabledBackgroundContent && mDisabledBackgroundContent.GetParent() )
{
}
mDisabledBackgroundContent = image;
-
- mDisabledBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mDisabledBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mDisabledBackgroundContent.SetPosition( 0.f, 0.f );
-
- if( mPaintState == DisabledUnselectedState || mPaintState == DisabledSelectedState )
+ if( mDisabledBackgroundContent )
{
- Self().Insert( 0, mDisabledBackgroundContent );
+ mDisabledBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mDisabledBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mDisabledBackgroundContent.SetPosition( 0.f, 0.f );
}
-
+ ResetImageLayers();
OnDisabledBackgroundImageSet();
}
return false;
}
-void Button::UpdatePaintTransitionState()
-{
- switch( mPaintState )
- {
- case UnselectedSelectedTransition:
- {
- RemoveChild( mButtonContent );
- mPaintState = SelectedState;
- break;
- }
- case SelectedUnselectedTransition:
- {
- RemoveChild( mSelectedBackgroundContent );
- RemoveChild( mSelectedContent );
- mPaintState = UnselectedState;
- break;
- }
- case UnselectedDisabledTransition:
- {
- RemoveChild( mBackgroundContent );
- RemoveChild( mButtonContent );
- mPaintState = DisabledUnselectedState;
- break;
- }
- case DisabledUnselectedTransition:
- {
- RemoveChild( mDisabledBackgroundContent );
- RemoveChild( mDisabledContent );
- mPaintState = UnselectedState;
- break;
- }
- case SelectedDisabledTransition:
- {
- RemoveChild( mBackgroundContent );
- RemoveChild( mSelectedBackgroundContent );
- RemoveChild( mSelectedContent );
- mPaintState = DisabledSelectedState;
- break;
- }
- case DisabledSelectedTransition:
- {
- RemoveChild( mDisabledBackgroundContent );
- RemoveChild( mDisabledSelectedContent );
- mPaintState = SelectedState;
- break;
- }
- default:
- {
- break;
- }
- }
-}
-
void Button::OnButtonStageDisconnection()
{
if( ButtonDown == mState )
void Button::Pressed()
{
- unsigned int buttonIndex, backgroundIndex;
- bool animationStarted = false;
+ if( mPaintState == UnselectedState )
+ {
+ StopTransitionAnimation();
- switch( mPaintState )
+ // Notifies the derived class the button has been pressed.
+ OnPressed();
+
+ //Layer Order
+ //(4) mSelectedContent (Inserted)
+ //(3) mUnselectedContent
+ //(2) mSelectedBackgroundContent (Inserted)
+ //(1) mBackgroundContent
+
+ TransitionInBetween( mUnselectedContent, mLabel, mSelectedContent );
+ TransitionInAbove( mBackgroundContent, mSelectedBackgroundContent );
+ TransitionInAtIndex( 0, mBackgroundContent );
+
+ TransitionOut( mUnselectedContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
+
+ mPaintState = SelectedState;
+
+ StartTransitionAnimation();
+ }
+}
+
+void Button::Released()
+{
+ if( mPaintState == SelectedState )
{
- case UnselectedState:
- {
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mSelectedContent );
+ StopTransitionAnimation();
- if( mBackgroundContent )
- {
- backgroundIndex = 1;
- }
- else
- {
- backgroundIndex = 0;
- }
+ // Notifies the derived class the button has been released.
+ OnReleased();
- InsertChild( backgroundIndex, mSelectedBackgroundContent );
+ //Layer Order
+ //(3) mUnselectedContent (Inserted)
+ //(2) mSelectedContent
+ //(1) mBackgroundContent
- // Notifies the derived class the button has been pressed.
- animationStarted = OnPressed();
+ TransitionInBetween( mSelectedContent, mLabel, mUnselectedContent );
+ TransitionInAtIndex( 0, mBackgroundContent );
- if( animationStarted )
- {
- mPaintState = UnselectedSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
- break;
- }
- case SelectedUnselectedTransition:
- {
- // Notifies the derived class the button has been pressed.
- animationStarted = OnPressed();
+ TransitionOut( mSelectedContent );
+ TransitionOut( mSelectedBackgroundContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
- if( animationStarted )
- {
- mPaintState = UnselectedSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
- break;
+ mPaintState = UnselectedState;
+
+ StartTransitionAnimation();
+ }
+}
+
+Button::ButtonState Button::GetState()
+{
+ return mState;
+}
+
+Button::PaintState Button::GetPaintState()
+{
+ return mPaintState;
+}
+
+bool Button::InsertButtonImage( unsigned int index, Actor& actor )
+{
+ if( actor )
+ {
+ Self().Insert( index, actor );
+ PrepareForTranstionOut( actor );
+ return true;
+ }
+
+ return false;
+}
+
+void Button::RemoveButtonImage( Actor& actor )
+{
+ if( actor )
+ {
+ if( actor.GetParent() )
+ {
+ Self().Remove( actor );
}
- case DisabledUnselectedTransition:
+ PrepareForTranstionIn( actor );
+ }
+}
+
+unsigned int Button::FindChildIndex( Actor& actor )
+{
+ Actor self = Self();
+ unsigned int childrenNum = self.GetChildCount();
+
+ for( unsigned int i = 0; i < childrenNum; i++ )
+ {
+ Actor child = self.GetChildAt( i );
+ if( child == actor )
{
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mSelectedContent );
+ return i;
+ }
+ }
- if( mDisabledBackgroundContent )
- {
- if( mBackgroundContent )
- {
- backgroundIndex = 2;
- }
- else
- {
- backgroundIndex = 1;
- }
- }
- else if( mBackgroundContent )
- {
- backgroundIndex = 1;
- }
- else
- {
- backgroundIndex = 0;
- }
+ return childrenNum;
+}
- InsertChild( backgroundIndex, mSelectedBackgroundContent );
+void Button::TransitionInBetween( Actor childLower, Actor childUpper, Actor actor )
+{
+ unsigned int index = childLower ? FindChildIndex( childLower ) + 1 : FindChildIndex( childUpper );
+ TransitionInAtIndex( index, actor );
+}
- // Notifies the derived class the button has been pressed.
- animationStarted = OnPressed();
+void Button::TransitionInAbove( Actor child, Actor actor )
+{
+ unsigned int index = child ? FindChildIndex( child ) + 1 : 0;
+ TransitionInAtIndex( index, actor );
+}
- if( animationStarted )
- {
- mPaintState = UnselectedSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
- break;
+void Button::TransitionInAtIndex( unsigned int index, Actor actor )
+{
+ if( actor )
+ {
+ if( !actor.GetParent() )
+ {
+ Self().Insert( index, actor );
}
- default:
- break;
+
+ OnTransitionIn( actor );
}
}
-void Button::Released()
+void Button::TransitionOut( Actor actor )
+{
+ OnTransitionOut( actor );
+}
+
+void Button::ResetImageLayers()
{
- unsigned int buttonIndex;
- bool animationStarted = false;
+ //ensure that all layers are in the correct order and state according to the paint state
+ int index = 0;
switch( mPaintState )
{
- case SelectedState:
+ case UnselectedState:
{
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mButtonContent );
+ //Layer Order
+ //(2) mUnselectedContent
+ //(1) mBackgroundContent
- // Notifies the derived class the button has been released.
- animationStarted = OnReleased();
+ RemoveButtonImage( mSelectedContent );
+ RemoveButtonImage( mSelectedBackgroundContent );
+ RemoveButtonImage( mDisabledContent );
+ RemoveButtonImage( mDisabledSelectedContent );
+ RemoveButtonImage( mDisabledBackgroundContent );
- if( animationStarted )
+ if( InsertButtonImage( index, mBackgroundContent ) )
{
- mPaintState = SelectedUnselectedTransition;
+ ++index;
}
- else
+ if( InsertButtonImage( index, mUnselectedContent ) )
{
- mPaintState = UnselectedState;
+ ++index;
}
break;
}
- case UnselectedSelectedTransition:
+ case SelectedState:
{
- // Notifies the derived class the button has been released.
- animationStarted = OnReleased();
+ //Layer Order
+ //(3) mSelectedContent
+ //(2) mSelectedBackgroundContent
+ //(1) mBackgroundContent
- if( animationStarted )
+ RemoveButtonImage( mUnselectedContent );
+ RemoveButtonImage( mDisabledContent );
+ RemoveButtonImage( mDisabledSelectedContent );
+ RemoveButtonImage( mDisabledBackgroundContent );
+
+ if( InsertButtonImage( index, mBackgroundContent ) )
{
- mPaintState = SelectedUnselectedTransition;
+ ++index;
}
- else
+ if( InsertButtonImage( index, mSelectedBackgroundContent ) )
+ {
+ ++index;
+ }
+ if( InsertButtonImage( index, mSelectedContent ) )
{
- mPaintState = UnselectedState;
+ ++index;
}
break;
}
- case DisabledSelectedTransition:
+ case DisabledUnselectedState:
{
- buttonIndex = FindChildIndex( mLabel );
- InsertChild( buttonIndex, mButtonContent );
+ //Layer Order
+ //(2) mDisabledContent
+ //(1) mDisabledBackgroundContent
- // Notifies the derived class the button has been released.
- animationStarted = OnReleased();
+ RemoveButtonImage( mUnselectedContent );
+ RemoveButtonImage( mBackgroundContent );
+ RemoveButtonImage( mSelectedContent );
+ RemoveButtonImage( mDisabledSelectedContent );
+ RemoveButtonImage( mSelectedBackgroundContent );
- if( animationStarted )
+ if( InsertButtonImage( index, mDisabledBackgroundContent ? mDisabledBackgroundContent : mBackgroundContent ) )
{
- mPaintState = SelectedUnselectedTransition;
+ ++index;
}
- else
+ if( InsertButtonImage( index, mDisabledContent ? mDisabledContent : mUnselectedContent ) )
{
- mPaintState = UnselectedState;
+ ++index;
}
break;
}
- default:
+ case DisabledSelectedState:
{
+ //Layer Order
+ // (2) mDisabledSelectedContent
+ // (1) mDisabledBackgroundContent
+
+ RemoveButtonImage( mUnselectedContent );
+ RemoveButtonImage( mSelectedContent );
+ RemoveButtonImage( mBackgroundContent );
+ RemoveButtonImage( mSelectedBackgroundContent );
+ RemoveButtonImage( mDisabledContent );
+
+ if( mDisabledBackgroundContent )
+ {
+ if( InsertButtonImage( index, mDisabledBackgroundContent) )
+ {
+ ++index;
+ }
+ }
+ else
+ {
+ if( InsertButtonImage( index, mBackgroundContent ) )
+ {
+ ++index;
+ }
+ if( InsertButtonImage( index, mSelectedBackgroundContent ) )
+ {
+ ++index;
+ }
+ }
+
+ if( InsertButtonImage( index, mDisabledSelectedContent ? mDisabledSelectedContent : mSelectedContent) )
+ {
+ ++index;
+ }
break;
}
}
}
-Button::ButtonState Button::GetState()
-{
- return mState;
-}
-
-Button::PaintState Button::GetPaintState()
-{
- return mPaintState;
-}
-
-void Button::InsertChild( unsigned int index, Actor& actor )
+void Button::StartTransitionAnimation()
{
- if( actor )
+ if( mTransitionAnimation )
{
- Self().Insert( index, actor);
+ mTransitionAnimation.Play();
+ }
+ else
+ {
+ ResetImageLayers();
}
}
-void Button::RemoveChild( Actor& actor )
+void Button::StopTransitionAnimation()
{
- if( actor && actor.GetParent() )
+ if( mTransitionAnimation )
{
- Self().Remove( actor );
+ mTransitionAnimation.Clear();
+ mTransitionAnimation.Reset();
}
}
-unsigned int Button::FindChildIndex( Actor& actor )
+Dali::Animation Button::GetTransitionAnimation()
{
- Actor self = Self();
- unsigned int childrenNum = self.GetChildCount();
-
- for( unsigned int i = 0; i < childrenNum; i++ )
+ if( !mTransitionAnimation )
{
- Actor child = self.GetChildAt( i );
- if( child == actor )
- {
- return i;
- }
+ mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
+ mTransitionAnimation.FinishedSignal().Connect( this, &Button::TransitionAnimationFinished );
}
- return childrenNum;
+ return mTransitionAnimation;
+}
+
+void Button::TransitionAnimationFinished( Dali::Animation& source )
+{
+ StopTransitionAnimation();
+ ResetImageLayers();
}
void Button::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
{
case Toolkit::Button::Property::DISABLED:
{
- GetImplementation( button ).SetDisabled( value.Get<bool>() );
+ GetImplementation( button ).SetDisabled( value.Get< bool >() );
break;
}
case Toolkit::Button::Property::NORMAL_STATE_ACTOR:
{
Property::Map map;
- Scripting::CreatePropertyMap( GetImplementation( button ).mButtonContent, map );
+ Scripting::CreatePropertyMap( GetImplementation( button ).mUnselectedContent, map );
value = map;
break;
}
// EXTERNAL INCLUDES
#include <dali/public-api/adaptor-framework/timer.h>
+#include <dali/public-api/animation/animation.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/buttons/button.h>
*/
Actor& GetLabel();
- /**
- * It changes the transition state of the push button.
- */
- void UpdatePaintTransitionState();
-
private:
/**
/**
* This method is called when the \e selected property is changed.
- * @return true if the transition animation is started.
*/
- virtual bool OnSelected() { return false; }
+ virtual void OnSelected() {}
/**
* This method is called when the \e disabled property is changed.
- * @return true if the transition animation is started.
*/
- virtual bool OnDisabled() { return false; }
+ virtual void OnDisabled() {}
/**
* This method is called when the button is pressed.
- * @return true if the transition animation is started.
*/
- virtual bool OnPressed() { return false; }
+ virtual void OnPressed() {}
/**
* This method is called when the button is released.
- * @return true if the transition animation is started.
*/
- virtual bool OnReleased() { return false; }
-
- /**
- * This method stops all animations
- */
- virtual void StopAllAnimations() {}
+ virtual void OnReleased() {}
public:
SelectedState, ///< The button is selected.
DisabledUnselectedState, ///< The button is disabled and unselected.
DisabledSelectedState, ///< The button is disabled and selected.
- UnselectedSelectedTransition, ///< The button is in transition from unselected to selected.
- SelectedUnselectedTransition, ///< The button is in transition from selected to unselected.
- UnselectedDisabledTransition, ///< The button is in transition from unselected to disabled.
- DisabledUnselectedTransition, ///< The button is in transition from disabled to unselected.
- SelectedDisabledTransition, ///< The button is in transition from selected to disabled.
- DisabledSelectedTransition ///< The button is in transition from disabled to selected.
};
ButtonState GetState();
PaintState GetPaintState();
/**
- * Inserts the actor to the button.
+ * Returns the animation to be used for transitioning creating the animation if needed.
+ * @return The initialised transition animation.
+ */
+ Dali::Animation GetTransitionAnimation();
+
+ /**
+ * Prepares the actor to be transitioned in.
+ * @param[in] actor The actor that will be transitioned in.
+ */
+ virtual void PrepareForTranstionIn( Actor actor ) {}
+
+ /**
+ * Prepares the actor to be transitioned in.
+ * @param[in] actor The actor that will be transitioned out.
+ */
+ virtual void PrepareForTranstionOut( Actor actor ) {}
+
+ /**
+ * Transitions the actor in, allowing derived classes to configure
+ * the GetTransitionAnimation() animation ready.
+ * Button is in charge of calling Dali::Animation::Play and so derived classes
+ * only need to add the animation.
+ */
+ virtual void OnTransitionIn( Actor actor ) {}
+
+ /**
+ * Transitions the actor out, allowing derived classes to configure
+ * the GetTransitionAnimation() animation ready.
+ * Button is in charge of calling Dali::Animation::Play and so derived classes
+ * only need to add the animation.
+ */
+ virtual void OnTransitionOut( Actor actor ) {}
+
+private:
+ /**
+ * Starts the transition animation.
+ * Button::TransitionFinished is called when the animation finishes.
+ */
+ void StartTransitionAnimation();
+
+ /**
+ * This method stops all transition animations
*/
- void InsertChild( unsigned int index, Actor& actor );
+ void StopTransitionAnimation();
/**
- * Removes the actor from the button.
+ * Called when the transition animation finishes.
*/
- void RemoveChild( Actor& actor );
+ void TransitionAnimationFinished( Dali::Animation& source );
+
+ /**
+ * Resets the Button to the base state for the current paint state.
+ * Any additionally inserted images needed for transitions that are
+ * no longer needed and the removed.
+ */
+ void ResetImageLayers();
+
+ /**
+ * Transitions in the actor, inserting the actor above childLower below the childUpper.
+ * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor)
+ */
+ void TransitionInBetween( Actor childLower, Actor childUpper, Actor actor );
+
+ /**
+ * Transitions in the actor, inserting the actor above the child if the child exists or at the bottom otherwise
+ * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor)
+ */
+ void TransitionInAbove( Actor child, Actor actor );
+
+ /**
+ * Transitions in the actor, inserting the actor at the index
+ * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor)
+ */
+ void TransitionInAtIndex( unsigned int index, Actor actor );
+
+ /**
+ * Transitions out the actor
+ */
+ void TransitionOut( Actor actor );
+
+ /**
+ * Inserts the actor to the button and prepares it to be transitioned out
+ * @return true if the child was inserted, false otherwise
+ */
+ bool InsertButtonImage( unsigned int index, Actor& actor );
+
+ /**
+ * Removes the actor from the button and prepares it to be transitioned out
+ */
+ void RemoveButtonImage( Actor& actor );
/**
* Finds the index of the actor.
*/
unsigned int FindChildIndex( Actor& actor );
-private:
// Undefined
Button( const Button& );
Actor mLabel; ///< Stores the button label.
- Actor mButtonContent; ///< Stores the unselected content.
+ Actor mUnselectedContent; ///< Stores the unselected content.
Actor mSelectedContent; ///< Stores the selected content.
Actor mBackgroundContent; ///< Stores the background content.
Actor mSelectedBackgroundContent; ///< Stores the selected background content.
Actor mDisabledSelectedContent; ///< Stores the disabled selected content.
Actor mDisabledBackgroundContent; ///< Stores the disabled background content.
+ Animation mTransitionAnimation; ///< Animation used in the state transitions.
+
TapGestureDetector mTapDetector;
bool mDisabled; ///< Stores the disabled property.
bool mSelected; ///< Stores the selected state.
float mInitialAutoRepeatingDelay; ///< Stores the initial autorepeating delay in seconds.
float mNextAutoRepeatingDelay; ///< Stores the next autorepeating delay in seconds.
+
float mAnimationTime; ///< The animation time.
// Actions
// EXTERNAL INCLUDES
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/images/resource-image.h>
//INTERNAL INCLUDES
#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
TypeRegistration mType( typeid(Toolkit::CheckBoxButton), typeid(Toolkit::Button), Create );
+const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-unselected.png";
+const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-selected.png";
+const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-unselected-disabled.png";
+const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-selected-diabled.png";
}
Dali::Toolkit::CheckBoxButton CheckBoxButton::New()
CheckBoxButton::~CheckBoxButton()
{
- if( mTransitionAnimation )
- {
- mTransitionAnimation.Clear();
- }
}
void CheckBoxButton::OnButtonInitialize()
{
// Wrap around all children
Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
+
+ Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+ Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+ Image disabledImage = Dali::ResourceImage::New( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+ Image disabledSelectedImage = Dali::ResourceImage::New( DISABLED_SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+
+ SetButtonImage( ImageActor::New( buttonImage ) );
+ SetSelectedImage( ImageActor::New( selectedImage ) );
+ SetDisabledImage( ImageActor::New( disabledImage ) );
+ SetDisabledSelectedImage( ImageActor::New( disabledSelectedImage ) );
}
void CheckBoxButton::OnLabelSet()
{
label.SetX( GetBackgroundImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
- else
+ else if( IsSelected() && GetSelectedImage())
{
- label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+ label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
- }
-}
-
-bool CheckBoxButton::OnSelected()
-{
- Actor& selectedImage = GetSelectedImage();
-
- PaintState paintState = GetPaintState();
-
- switch( paintState )
- {
- case UnselectedState:
- {
- StartTransitionAnimation( selectedImage );
- break;
- }
- case SelectedState:
+ else if( GetButtonImage() )
{
- RemoveChild( selectedImage );
- break;
+ label.SetX( GetButtonImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
- case UnselectedSelectedTransition:
- {
- StopTransitionAnimation( false );
- RemoveChild( selectedImage );
- break;
- }
- default:
+ else
{
- break;
+ label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
}
-
- if( mTransitionAnimation )
- {
- return true;
- }
-
- return false;
}
-bool CheckBoxButton::OnDisabled()
+void CheckBoxButton::OnDisabled()
{
Actor& backgroundImage = GetBackgroundImage();
- Actor& selectedImage = GetSelectedImage();
Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
- Actor& disabledSelectedImage = GetDisabledSelectedImage();
-
- PaintState paintState = GetPaintState();
-
- switch( paintState )
- {
- case UnselectedState:
- {
- RemoveChild( backgroundImage );
- break;
- }
- case SelectedState:
- {
- RemoveChild( backgroundImage );
- RemoveChild( selectedImage );
- break;
- }
- case DisabledUnselectedState:
- {
- RemoveChild( disabledBackgroundImage );
- break;
- }
- case DisabledSelectedState:
- {
- RemoveChild( disabledBackgroundImage );
- RemoveChild( disabledSelectedImage );
- break;
- }
- case UnselectedSelectedTransition:
- {
- StopTransitionAnimation();
-
- RemoveChild( backgroundImage );
- RemoveChild( selectedImage );
- break;
- }
- default:
- {
- break;
- }
- }
Actor& label = GetLabel();
-
if( label )
{
- if( IsDisabled() && disabledBackgroundImage)
+ if( IsDisabled() && disabledBackgroundImage )
{
label.SetX( disabledBackgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
{
label.SetX( backgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
+ else if( IsSelected() && GetSelectedImage())
+ {
+ label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+ }
+ else if( GetButtonImage() )
+ {
+ label.SetX( GetButtonImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+ }
else
{
label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
}
-
- if( mTransitionAnimation )
- {
- return true;
- }
-
- return false;
}
-void CheckBoxButton::StopAllAnimations()
+void CheckBoxButton::PrepareForTranstionIn( Actor actor )
{
- StopTransitionAnimation();
-}
-
-void CheckBoxButton::StartTransitionAnimation( Actor& actor )
-{
- if( actor )
+ Actor& selectedImage = GetSelectedImage();
+ if( actor == selectedImage )
{
+ actor.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
+
if( !mTickUVEffect )
{
- ImageActor imageActor = ImageActor::DownCast( actor );
mTickUVEffect = CreateImageRegionEffect();
- imageActor.SetShaderEffect( mTickUVEffect );
}
-
- actor.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
-
mTickUVEffect.SetUniform("uBottomRight", Vector2( 0.0f, 1.0f ) );
- if( !mTransitionAnimation )
+ ImageActor imageActor = ImageActor::DownCast( actor );
+ if( imageActor )
{
- mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
+ imageActor.SetShaderEffect( mTickUVEffect );
}
-
- // UV anim
- mTransitionAnimation.AnimateTo( Property( mTickUVEffect, "uBottomRight" ), Vector2( 1.0f, 1.0f ) );
-
- // Actor size anim
- mTransitionAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f );
-
- mTransitionAnimation.FinishedSignal().Connect( this, &CheckBoxButton::TransitionAnimationFinished );
- mTransitionAnimation.Play();
}
}
-void CheckBoxButton::StopTransitionAnimation( bool remove )
+void CheckBoxButton::PrepareForTranstionOut( Actor actor )
{
- if( mTransitionAnimation )
+ Actor& selectedImage = GetSelectedImage();
+ if( actor == selectedImage )
{
- mTransitionAnimation.Clear();
- mTransitionAnimation.Reset();
- }
+ actor.SetScale( Vector3::ONE );
- if( remove )
- {
- UpdatePaintTransitionState();
+ if( !mTickUVEffect )
+ {
+ mTickUVEffect = CreateImageRegionEffect();
+ }
+ mTickUVEffect.SetUniform("uBottomRight", Vector2::ONE );
+
+ ImageActor imageActor = ImageActor::DownCast( actor );
+ if( imageActor )
+ {
+ imageActor.SetShaderEffect( mTickUVEffect );
+ }
}
}
-void CheckBoxButton::TransitionAnimationFinished( Dali::Animation& source )
+void CheckBoxButton::OnTransitionIn( Actor actor )
{
- StopTransitionAnimation();
+ Actor& selectedImage = GetSelectedImage();
+ if( actor && actor == selectedImage )
+ {
+ if( GetPaintState() == UnselectedState )
+ {
+ Dali::Animation transitionAnimation = GetTransitionAnimation();
+ if( transitionAnimation )
+ {
+ DALI_ASSERT_DEBUG( mTickUVEffect );
+ if( mTickUVEffect )
+ {
+ // UV anim
+ transitionAnimation.AnimateTo( Property( mTickUVEffect, "uBottomRight" ), Vector2::ONE );
+ }
+ // Actor size anim
+ transitionAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f );
+ }
+ }
+ else
+ {
+ //explicitly end the swipe animation
+ actor.SetScale( Vector3::ONE );
+ if( mTickUVEffect )
+ {
+ mTickUVEffect.SetUniform("uBottomRight", Vector2::ONE );
+ }
+ }
+ }
}
} // namespace Internal
// EXTERNAL INCLUDES
#include <dali/public-api/common/dali-vector.h>
-#include <dali/public-api/animation/animation.h>
#include <dali/public-api/shader-effects/shader-effect.h>
-
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
virtual void OnLabelSet();
/**
- * @copydoc Toolkit::Internal::Button::OnSelected()
- */
- virtual bool OnSelected();
-
- /**
* @copydoc Toolkit::Internal::Button::OnDisabled()
*/
- virtual bool OnDisabled();
-
- /**
- * @copydoc Toolkit::Internal::Button::StopAllAnimations()
- */
- virtual void StopAllAnimations();
-
-private:
+ virtual void OnDisabled();
/**
- * Adds the actor to the transition animation.
- * It creates a transition animation if needed and starts the animation.
- * @param[in] actor The actor.
+ * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor )
*/
- void StartTransitionAnimation( Actor& actor );
+ virtual void PrepareForTranstionIn( Actor actor );
/**
- * Stops the transition animation.
- * @param[in] remove If true, removes the fadeout actor from root.
+ * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor )
*/
- void StopTransitionAnimation( bool remove = true );
-
- // slots
+ virtual void PrepareForTranstionOut( Actor actor );
/**
- * Called when the transition animation finishes.
+ * @copydoc Toolkit::Internal::Button::OnTransitionInImage( Actor actor )
*/
- void TransitionAnimationFinished( Dali::Animation& source );
+ virtual void OnTransitionIn( Actor actor );
private:
CheckBoxButton& operator=( const CheckBoxButton& );
private:
- Animation mTransitionAnimation; ///< Animation used in the state transitions.
ShaderEffect mTickUVEffect; ///< ImageRegionEffect to expand the tick across
};
// EXTERNAL INCLUDES
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/images/resource-image.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
TypeRegistration typeRegistration( typeid(Toolkit::PushButton), typeid(Toolkit::Button), Create );
+const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-up.9.png";
+const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-down.9.png";
+const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-disabled.9.png";
+const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-down-disabled.9.png";
+
} // unnamed namespace
namespace
// Set resize policy to natural size so that buttons will resize to background images
self.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+
+ Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+ Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+ Image disabledImage = Dali::ResourceImage::New( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+ Image disabledSelectedImage = Dali::ResourceImage::New( DISABLED_SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+
+ SetButtonImage( ImageActor::New( buttonImage ) );
+ SetSelectedImage( ImageActor::New( selectedImage ) );
+ SetDisabledImage( ImageActor::New( disabledImage ) );
+ SetDisabledSelectedImage( ImageActor::New( disabledSelectedImage ) );
}
void PushButton::OnLabelSet()
RelayoutRequest();
}
-void PushButton::OnDisabledBackgroundImageSet()
+void PushButton::OnDisabledSelectedImageSet()
{
ConfigureSizeNegotiation();
RelayoutRequest();
}
-bool PushButton::OnSelected()
-{
- Actor& buttonImage = GetButtonImage();
- Actor& selectedImage = GetSelectedImage();
- Actor& selectedBackgroundImage = GetSelectedBackgroundImage();
-
- PaintState paintState = GetPaintState();
-
- switch( paintState )
- {
- case UnselectedState:
- {
- FadeOutImage( buttonImage );
- FadeInImage( selectedBackgroundImage );
- FadeInImage( selectedImage );
- StartTransitionAnimation();
- break;
- }
- case SelectedState:
- {
- FadeOutImage( selectedBackgroundImage );
- FadeOutImage( selectedImage );
- FadeInImage( buttonImage );
- StartTransitionAnimation();
- break;
- }
- case UnselectedSelectedTransition:
- {
- float opacity = 1.f;
- if( selectedImage )
- {
- opacity = selectedImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation( false );
- FadeOutImage( selectedBackgroundImage, opacity );
- FadeOutImage( selectedImage, opacity );
- FadeInImage( buttonImage, 1.f - opacity );
- StartTransitionAnimation();
- break;
- }
- case SelectedUnselectedTransition:
- {
- float opacity = 0.f;
- if( selectedImage )
- {
- opacity = selectedImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation( false );
- FadeOutImage( buttonImage, 1.f - opacity );
- FadeInImage( selectedBackgroundImage, opacity );
- FadeInImage( selectedImage, opacity );
- StartTransitionAnimation();
- break;
- }
- case DisabledUnselectedTransition:
- {
- StopTransitionAnimation();
- FadeOutImage( buttonImage );
- FadeInImage( selectedBackgroundImage );
- FadeInImage( selectedImage );
- StartTransitionAnimation();
- break;
- }
- case DisabledSelectedTransition:
- {
- StopTransitionAnimation();
- FadeOutImage( selectedBackgroundImage );
- FadeOutImage( selectedImage );
- FadeInImage( buttonImage );
- StartTransitionAnimation();
- break;
- }
- default:
- {
- break;
- }
- }
-
- if( mTransitionAnimation )
- {
- return true;
- }
-
- return false;
-}
-
-bool PushButton::OnDisabled()
-{
- Actor& buttonImage = GetButtonImage();
- Actor& selectedImage = GetSelectedImage();
- Actor& selectedBackgroundImage = GetSelectedBackgroundImage();
- Actor& backgroundImage = GetBackgroundImage();
- Actor& disabledImage = GetDisabledImage();
- Actor& disabledSelectedImage = GetDisabledSelectedImage();
- Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
-
- PaintState paintState = GetPaintState();
-
- switch( paintState )
- {
- case UnselectedState:
- {
- FadeOutImage( backgroundImage );
- FadeOutImage( buttonImage );
- FadeInImage( disabledBackgroundImage );
- FadeInImage( disabledImage );
- StartTransitionAnimation();
- break;
- }
- case SelectedState:
- {
- FadeOutImage( backgroundImage );
- FadeOutImage( selectedBackgroundImage );
- FadeOutImage( selectedImage );
- FadeInImage( disabledBackgroundImage );
- FadeInImage( disabledSelectedImage );
- StartTransitionAnimation();
- break;
- }
- case DisabledUnselectedState:
- {
- FadeOutImage( disabledBackgroundImage );
- FadeOutImage( disabledImage );
- FadeInImage( backgroundImage );
- FadeInImage( buttonImage );
- StartTransitionAnimation();
- break;
- }
- case DisabledSelectedState:
- {
- FadeOutImage( disabledBackgroundImage );
- FadeOutImage( disabledSelectedImage );
- FadeInImage( backgroundImage );
- FadeInImage( selectedBackgroundImage );
- FadeInImage( selectedImage );
- StartTransitionAnimation();
- break;
- }
- case UnselectedSelectedTransition:
- {
- float opacity = 1.f;
- if( selectedImage )
- {
- opacity = selectedImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation();
- FadeOutImage( backgroundImage );
- FadeOutImage( selectedBackgroundImage, opacity );
- FadeOutImage( selectedImage, opacity );
- FadeInImage( disabledBackgroundImage );
- FadeInImage( disabledSelectedImage );
- StartTransitionAnimation();
- break;
- }
- case SelectedUnselectedTransition:
- {
- float opacity = 1.f;
- if( buttonImage )
- {
- opacity = buttonImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation();
- FadeOutImage( backgroundImage );
- FadeOutImage( buttonImage, opacity );
- FadeInImage( disabledBackgroundImage );
- FadeInImage( disabledImage );
- StartTransitionAnimation();
- break;
- }
- case UnselectedDisabledTransition:
- {
- float opacity = 1.f;
- if( disabledImage )
- {
- opacity = disabledImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation( false );
- FadeOutImage( disabledBackgroundImage, opacity );
- FadeOutImage( disabledImage, opacity );
- FadeInImage( backgroundImage, 1.f - opacity );
- FadeInImage( buttonImage, 1.f - opacity );
- StartTransitionAnimation();
- break;
- }
- case DisabledUnselectedTransition:
- {
- float opacity = 1.f;
- if( buttonImage )
- {
- opacity = buttonImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation( false );
- FadeOutImage( backgroundImage, opacity );
- FadeOutImage( buttonImage, opacity );
- FadeInImage( disabledBackgroundImage, 1.f - opacity );
- FadeInImage( disabledImage, 1.f - opacity );
- StartTransitionAnimation();
- break;
- }
- case SelectedDisabledTransition:
- {
- float opacity = 1.f;
- if( disabledSelectedImage )
- {
- opacity = disabledSelectedImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation( false );
- FadeOutImage( disabledBackgroundImage, opacity );
- FadeOutImage( disabledSelectedImage, opacity );
- FadeInImage( backgroundImage, 1.f - opacity );
- FadeInImage( selectedBackgroundImage, 1.f - opacity );
- FadeInImage( selectedImage, 1.f - opacity );
- StartTransitionAnimation();
- break;
- }
- case DisabledSelectedTransition:
- {
- float opacity = 1.f;
- if( selectedImage )
- {
- opacity = selectedImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation( false );
- FadeOutImage( backgroundImage, opacity );
- FadeOutImage( selectedBackgroundImage, opacity );
- FadeOutImage( selectedImage, opacity );
- FadeInImage( disabledBackgroundImage, 1.f - opacity );
- FadeInImage( disabledSelectedImage, 1.f - opacity );
- StartTransitionAnimation();
- break;
- }
- }
-
- if( mTransitionAnimation )
- {
- return true;
- }
-
- return false;
-}
-
-bool PushButton::OnPressed()
-{
- Actor& buttonImage = GetButtonImage();
- Actor& selectedImage = GetSelectedImage();
- Actor& selectedBackgroundImage = GetSelectedBackgroundImage();
-
- PaintState paintState = GetPaintState();
-
- switch( paintState )
- {
- case UnselectedState:
- {
- FadeOutImage( buttonImage );
- FadeInImage( selectedBackgroundImage );
- FadeInImage( selectedImage );
- StartTransitionAnimation();
- break;
- }
- case SelectedUnselectedTransition:
- {
- float opacity = 1.f;
- if( buttonImage )
- {
- opacity = buttonImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation( false );
- FadeOutImage( buttonImage, opacity );
- FadeInImage( selectedBackgroundImage, 1.f - opacity );
- FadeInImage( selectedImage, 1.f - opacity );
- StartTransitionAnimation();
- break;
- }
- case DisabledUnselectedTransition:
- {
- float opacity = 1.f;
- if( buttonImage )
- {
- opacity = buttonImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation();
- FadeOutImage( buttonImage, opacity );
- FadeInImage( selectedBackgroundImage );
- FadeInImage( selectedImage );
- StartTransitionAnimation();
- break;
- }
- default:
- break;
- }
-
- if( mTransitionAnimation )
- {
- return true;
- }
-
- return false;
-}
-
-bool PushButton::OnReleased()
-{
- Actor& buttonImage = GetButtonImage();
- Actor& selectedImage = GetSelectedImage();
- Actor& selectedBackgroundImage = GetSelectedBackgroundImage();
-
- PaintState paintState = GetPaintState();
-
- switch( paintState )
- {
- case SelectedState:
- {
- FadeOutImage( selectedBackgroundImage );
- FadeOutImage( selectedImage );
- FadeInImage( buttonImage );
- StartTransitionAnimation();
- break;
- }
- case UnselectedSelectedTransition:
- {
- float opacity = 1.f;
- if( selectedImage )
- {
- opacity = selectedImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation( false );
- FadeOutImage( selectedBackgroundImage, opacity );
- FadeOutImage( selectedImage, opacity );
- FadeInImage( buttonImage, 1.f - opacity );
- StartTransitionAnimation();
- break;
- }
- case DisabledSelectedTransition:
- {
- float opacity = 1.f;
- if( selectedImage )
- {
- opacity = selectedImage.GetCurrentOpacity();
- }
-
- StopTransitionAnimation();
- FadeOutImage( selectedBackgroundImage, opacity );
- FadeOutImage( selectedImage, opacity );
- FadeInImage( buttonImage );
- StartTransitionAnimation();
- break;
- }
- default:
- {
- break;
- }
- }
-
- if( mTransitionAnimation )
- {
- return true;
- }
-
- return false;
-}
-
-void PushButton::StopAllAnimations()
+void PushButton::OnDisabledBackgroundImageSet()
{
- StopTransitionAnimation();
+ ConfigureSizeNegotiation();
+ RelayoutRequest();
}
void PushButton::OnSizeSet( const Vector3& targetSize )
}
}
-void PushButton::StartTransitionAnimation()
+void PushButton::PrepareForTranstionIn( Actor actor )
{
- if( mTransitionAnimation )
- {
- mTransitionAnimation.FinishedSignal().Connect( this, &PushButton::TransitionAnimationFinished );
- mTransitionAnimation.Play();
- }
+ actor.SetOpacity( 0.0f );
}
-void PushButton::StopTransitionAnimation( bool remove )
+void PushButton::PrepareForTranstionOut( Actor actor )
{
- if( mTransitionAnimation )
- {
- mTransitionAnimation.Clear();
- mTransitionAnimation.Reset();
- }
-
- if( remove )
- {
- UpdatePaintTransitionState();
- }
+ actor.SetOpacity( 1.0f );
}
-void PushButton::FadeInImage( Actor& image, float opacity, Vector3 scale )
+void PushButton::OnTransitionIn( Actor actor )
{
- if( image )
- {
- image.SetOpacity( opacity );
- image.SetScale( scale );
-
- if( !mTransitionAnimation )
- {
- mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
- }
+ FadeImageTo( actor, 1.f );
+}
- mTransitionAnimation.AnimateTo( Property( image, Actor::Property::COLOR_ALPHA ), 1.f );
- }
+void PushButton::OnTransitionOut( Actor actor )
+{
+ FadeImageTo( actor, 0.0f );
}
-void PushButton::FadeOutImage( Actor& image, float opacity, Vector3 scale )
+void PushButton::FadeImageTo( Actor actor, float opacity )
{
- if( image )
+ if( actor )
{
- image.SetOpacity( opacity );
- image.SetScale( scale );
+ Dali::Animation transitionAnimation = GetTransitionAnimation();
+ DALI_ASSERT_DEBUG( transitionAnimation );
- if( !mTransitionAnimation )
+ if( transitionAnimation )
{
- mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
+ transitionAnimation.AnimateTo( Property( actor, Actor::Property::COLOR_ALPHA ), opacity );
}
-
- mTransitionAnimation.AnimateTo( Property( image, Actor::Property::COLOR_ALPHA ), 0.f );
}
}
-void PushButton::TransitionAnimationFinished( Dali::Animation& source )
-{
- StopTransitionAnimation();
-}
-
Vector3 PushButton::GetNaturalSize()
{
Vector3 size;
// EXTERNAL INCLUDES
#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/animation/animation.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/buttons/push-button.h>
virtual void OnDisabledImageSet();
/**
- * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet()
+ * @copydoc Toolkit::Internal::Button::OnDisabledSelectedImageSet()
*/
- virtual void OnDisabledBackgroundImageSet();
+ virtual void OnDisabledSelectedImageSet();
/**
- * @copydoc Toolkit::Internal::Button::OnSelected()
+ * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet()
*/
- virtual bool OnSelected();
+ virtual void OnDisabledBackgroundImageSet();
/**
- * @copydoc Toolkit::Internal::Button::OnDisabled()
+ * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor )
*/
- virtual bool OnDisabled();
+ virtual void PrepareForTranstionIn( Actor actor );
/**
- * @copydoc Toolkit::Internal::Button::OnPressed()
+ * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor )
*/
- virtual bool OnPressed();
+ virtual void PrepareForTranstionOut( Actor actor );
/**
- * @copydoc Toolkit::Internal::Button::OnReleased()
+ * @copydoc Toolkit::Internal::Button::OnTransitionIn( Actor actor )
*/
- virtual bool OnReleased();
+ virtual void OnTransitionIn( Actor actor );
/**
- * @copydoc Toolkit::Internal::Button::StopAllAnimations()
+ * @copydoc Toolkit::Internal::Button::OnTransitionOut( Actor actor )
*/
- virtual void StopAllAnimations();
+ virtual void OnTransitionOut( Actor actor );
private: // From Control
private:
/**
- * Starts the transition animation.
- * PushButton::TransitionAnimationFinished slot is called when the animation finishes.
- */
- void StartTransitionAnimation();
-
- /**
- * Stops the transition animation.
- * @param[in] remove If true, removes the fadeout actor from root.
- */
- void StopTransitionAnimation( bool remove = true );
-
- /**
* It adds the actor to the root actor and to the fade in animation.
- * @param[inout] image The actor.
- * @param[in] opacity The initial opacity.
- * @param[in] scale The initial scale.
- */
- void FadeInImage( Actor& image, float opacity = 0.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) );
-
- /**
- * It adds the actor fade out animation and stores it to be removed when the animation finishes.
- * @param[in] layer Defines if the actor is going to be stored in the mFadeOutBackgroundImage or mFadeOutCheckedImage member.
- * @param[inout] image The actor.
- * @param[in] opacity The initial opacity.
- * @param[in] scale The initial scale.
+ * @param[inout] actor The actor.
+ * @param[in] opacity The opacity to fade to
*/
- void FadeOutImage( Actor& image, float opacity = 1.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) );
+ void FadeImageTo( Actor actor, float opacity );
/**
* @brief Custom configuration for size negotiation
*/
void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label );
- // slots
-
- /**
- * Called when the transition animation finishes.
- */
- void TransitionAnimationFinished( Dali::Animation& source );
-
private:
// Undefined
private:
- Animation mTransitionAnimation; ///< Animation used in the state transitions.
Vector3 mSize; ///< The button's size.
};
const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-unselected.png";
const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-selected.png";
+const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-unselected-disabled.png";
+const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-selected-disabled.png";
const float DISTANCE_BETWEEN_IMAGE_AND_LABEL( 5.0f );
}
// Wrap size of radio button around all its children
self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
- Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR );
- Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR );
+ Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+ Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+ Image disabledImage = Dali::ResourceImage::New( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+ Image disabledSelectedImage = Dali::ResourceImage::New( DISABLED_SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
SetButtonImage( ImageActor::New( buttonImage ) );
SetSelectedImage( ImageActor::New( selectedImage ) );
+ SetDisabledImage( ImageActor::New( disabledImage ) );
+ SetDisabledSelectedImage( ImageActor::New( disabledSelectedImage ) );
RelayoutRequest();
}
label.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH );
}
- if( IsSelected() )
+ if( IsSelected() && GetSelectedImage() )
{
label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
- else
+ else if( GetButtonImage() )
{
label.SetX( GetButtonImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
+ else
+ {
+ label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+ }
}
}
-bool RadioButton::OnSelected()
+void RadioButton::OnSelected()
{
- Actor& buttonImage = GetButtonImage();
- Actor& selectedImage = GetSelectedImage();
Actor& label = GetLabel();
PaintState paintState = GetPaintState();
-
switch( paintState )
{
case UnselectedState:
}
}
- RemoveChild( buttonImage );
-
- if( label )
+ Actor& selectedImage = GetSelectedImage();
+ if( label && selectedImage )
{
label.SetX( selectedImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
}
case SelectedState:
{
- RemoveChild( selectedImage );
-
- if( label )
+ Actor& buttonImage = GetButtonImage();
+ if( label && buttonImage )
{
label.SetX( buttonImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
break;
}
}
-
- // there is no animation
- return false;
}
} // namespace Internal
/**
* @copydoc Toolkit::Internal::Button::OnSelected()
*/
- virtual bool OnSelected();
+ virtual void OnSelected();
/**
* @copydoc Toolkit::Internal::Button::OnLabelSet()
mShadowView.Activate();
}
-void PageTurnView::OnStageConnection( unsigned int depth )
+void PageTurnView::OnStageConnection( int depth )
{
SetupShadowView();
mTurningPageLayer.RaiseToTop();
/**
* @copydoc CustomActorImpl::OnStageConnection()
*/
- virtual void OnStageConnection( unsigned int depth );
+ virtual void OnStageConnection( int depth );
/**
* @copydoc CustomActorImpl::OnStageDisconnection()
SetInternalConstraints();
}
-void ScrollView::OnStageConnection( unsigned int depth )
+void ScrollView::OnStageConnection( int depth )
{
DALI_LOG_SCROLL_STATE("[0x%X]", this);
/**
* @copydoc CustomActorImpl::OnStageConnection()
*/
- virtual void OnStageConnection( unsigned int depth );
+ virtual void OnStageConnection( int depth );
/**
* @copydoc CustomActorImpl::OnStageDisconnection()
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursor-blink-interval", FLOAT, CURSOR_BLINK_INTERVAL )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursor-blink-duration", FLOAT, CURSOR_BLINK_DURATION )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grab-handle-image", STRING, GRAB_HANDLE_IMAGE )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grab-handle-pressed-image", VECTOR4, GRAB_HANDLE_PRESSED_IMAGE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grab-handle-pressed-image", STRING, GRAB_HANDLE_PRESSED_IMAGE )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scroll-threshold", FLOAT, SCROLL_THRESHOLD )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scroll-speed", FLOAT, SCROLL_SPEED )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-image-left", STRING, SELECTION_HANDLE_IMAGE_LEFT )
const Vector4 color = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_COLOR %f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
- impl.mDecorator->SetColor( PRIMARY_CURSOR, color );
+ impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
impl.RequestTextRelayout();
}
break;
const Vector4 color = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SECONDARY_CURSOR_COLOR %f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
- impl.mDecorator->SetColor( SECONDARY_CURSOR, color );
+ impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
impl.RequestTextRelayout();
}
break;
mController->EnableTextInput( mDecorator );
// Forward input events to controller
- EnableGestureDetection(Gesture::Tap);
+ EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan |Gesture::LongPress ) );
GetTapGestureDetector().SetMaximumTapsRequired( 2 );
- EnableGestureDetection(Gesture::Pan);
self.TouchedSignal().Connect( this, &TextField::OnTouched );
mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
}
- RenderText();
EnableClipping( (Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy), size );
+ RenderText();
}
}
void TextField::RenderText()
{
+ Actor self = Self();
Actor renderableActor;
if( mRenderer )
{
- renderableActor = mRenderer->Render( mController->GetView(), mDepth );
+ renderableActor = mRenderer->Render( mController->GetView(), self.GetHierarchyDepth() );
}
if( renderableActor != mRenderableActor )
mRenderableActor.SetPosition( offset.x, offset.y );
- // Make sure the actor is parented correctly with/without clipping
+ Actor clipRootActor;
if( mClipper )
{
- mClipper->GetRootActor().Add( mRenderableActor );
- }
- else
- {
- Self().Add( mRenderableActor );
+ clipRootActor = mClipper->GetRootActor();
}
for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
{
Actor actor = *it;
- if( mClipper )
+ if( clipRootActor )
{
- mClipper->GetRootActor().Add( actor );
+ clipRootActor.Add( actor );
}
else
{
- Self().Add( actor );
+ self.Add( actor );
}
}
mClippingDecorationActors.clear();
+
+ // Make sure the actor is parented correctly with/without clipping
+ if( clipRootActor )
+ {
+ clipRootActor.Add( mRenderableActor );
+ }
+ else
+ {
+ self.Add( mRenderableActor );
+ }
}
}
notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected );
}
- mController->KeyboardFocusGainEvent();
+ mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
}
mController->PanEvent( gesture.state, gesture.displacement );
}
+void TextField::OnLongPress( const LongPressGesture& gesture )
+{
+ mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y );
+}
+
bool TextField::OnKeyEvent( const KeyEvent& event )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
}
else
{
- mController->KeyboardFocusGainEvent();
+ mController->KeyboardFocusGainEvent(); // Initially called by OnKeyInputFocusGained
}
}
-void TextField::OnStageConnection( unsigned int depth )
+void TextField::OnStageConnection( int depth )
{
- mDepth = depth;
+ // Call the Control::OnStageConnection() to set the depth of the background.
+ Control::OnStageConnection( depth );
+
+ // Sets the depth to the renderers inside the text's decorator.
+ mDecorator->SetTextDepth( depth );
+
+ // The depth of the text renderer is set in the RenderText() called from OnRelayout().
}
bool TextField::OnTouched( Actor actor, const TouchEvent& event )
: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
mExceedPolicy( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ),
- mDepth( 0 ),
mHasBeenStaged( false )
{
}
virtual void OnPan( const PanGesture& gesture );
/**
+ * @copydoc Control::OnLongPress()
+ */
+ virtual void OnLongPress( const LongPressGesture& gesture );
+
+ /**
* @copydoc Control::OnStageConnection()
*/
- virtual void OnStageConnection( unsigned int depth );
+ virtual void OnStageConnection( int depth );
/**
* @copydoc Dali::CustomActorImpl::OnKeyEvent(const KeyEvent&)
int mRenderingBackend;
int mExceedPolicy;
- unsigned int mDepth;
bool mHasBeenStaged:1;
};
void TextLabel::RenderText()
{
+ Actor self = Self();
Actor renderableActor;
if( mRenderer )
{
- renderableActor = mRenderer->Render( mController->GetView(), mDepth );
+ renderableActor = mRenderer->Render( mController->GetView(), self.GetHierarchyDepth() );
}
if( renderableActor != mRenderableActor )
const Vector2& alignmentOffset = mController->GetAlignmentOffset();
renderableActor.SetPosition( alignmentOffset.x, alignmentOffset.y );
- Self().Add( renderableActor );
+ self.Add( renderableActor );
}
mRenderableActor = renderableActor;
}
// TextLabel does not show decorations
}
-void TextLabel::OnStageConnection( unsigned int depth )
+void TextLabel::OnStageConnection( int depth )
{
- mDepth = depth;
+ // Call the Control::OnStageConnection() to set the depth of the background.
+ Control::OnStageConnection( depth );
+
+ // The depth of the text renderer is set in the RenderText() called from OnRelayout().
}
void TextLabel::TextChanged()
TextLabel::TextLabel()
: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
- mDepth( 0 ),
mHasBeenStaged( false )
{
}
/**
* @copydoc Control::OnStageConnection()
*/
- virtual void OnStageConnection( unsigned int depth );
+ virtual void OnStageConnection( int depth );
/**
* @copydoc Text::ControlInterface::RequestTextRelayout()
Text::RendererPtr mRenderer;
Actor mRenderableActor;
int mRenderingBackend;
- unsigned int mDepth;
bool mHasBeenStaged:1;
};
// todo Move this to adaptor??
#define GET_LOCALE_TEXT(string) dgettext("elementary", string)
-const Dali::Vector4 DEFAULT_POPUP_LINE_COLOR( Dali::Vector4( 0.69f, 0.93f, 0.93f, 1.0f ) );
+const std::string TEXT_SELECTION_POPUP_LABEL = "textselectionpopuplabel";
+
+const Dali::Vector4 DEFAULT_POPUP_DIVIDER_COLOR( Dali::Vector4( 0.23f, 0.72f, 0.8f, 0.11f ) );
const Dali::Vector4 DEFAULT_OPTION_ICON( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
-const Dali::Vector4 DEFAULT_OPTION_ICON_PRESSED( Dali::Vector4( 0.12f, 0.56f, 1.0f, 1.0f ) );
+const Dali::Vector4 DEFAULT_OPTION_PRESSED_COLOR( Dali::Vector4( 0.24f, 0.72f, 0.8f, 0.11f ) );
+
+const float DEFAULT_CAPTION_POINT_SIZE = 8.0f; // todo This should be from the style sheet not fixed.
const std::string DEFAULT_POPUP_BACKGROUND_IMAGE( DALI_IMAGE_DIR "selection-popup-bg#.png" );
const std::string OPTION_ICON_CLIPBOARD( DALI_IMAGE_DIR "copy_paste_icon_clipboard.png" );
Dali::Toolkit::TextSelectionPopup handle( *impl );
impl->mEnabledButtons = buttonsToEnable;
-
// Second-phase init of the implementation
// This can only be done after the CustomActor connection has been made...
impl->Initialize();
return value;
}
+void TextSelectionPopup::RaiseAbove( Layer target )
+{
+ if( mToolbar )
+ {
+ mToolbar.RaiseAbove( target );
+ }
+}
+
void TextSelectionPopup::OnInitialize()
{
CreatePopup();
}
+void TextSelectionPopup::OnStageConnection( int depth )
+{
+ // Call the Control::OnStageConnection() to set the depth of the background.
+ Control::OnStageConnection( depth );
+
+ // TextSelectionToolbar::OnStageConnection() will set the depths of all the popup's components.
+}
+
bool TextSelectionPopup::OnCutButtonPressed( Toolkit::Button button )
{
if( mCallbackInterface )
void TextSelectionPopup::CreateOrderedListOfPopupOptions()
{
mOrderListOfButtons.clear();
+ mOrderListOfButtons.reserve( 8u );
// Create button for each possible option using Option priority
if ( !mCutIconImage )
void TextSelectionPopup::AddOption( const ButtonRequirement& button, bool showDivider, bool showIcons, bool showCaption )
{
-
const std::string& name = button.name;
const std::string& caption = button.caption;
Image iconImage = button.icon;
if ( showCaption )
{
Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New();
+ captionTextLabel.SetStyleName( TEXT_SELECTION_POPUP_LABEL );
captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
+ captionTextLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, DEFAULT_CAPTION_POINT_SIZE );
captionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New();
+ pressedCaptionTextLabel.SetStyleName( TEXT_SELECTION_POPUP_LABEL );
pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
+ pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, DEFAULT_CAPTION_POINT_SIZE );
pressedCaptionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
Padding padding;
optionPressedContainer.AddChild( pressedCaptionTextLabel, Toolkit::TableView::CellPosition(( showIcons&showCaption)?1:0, 0 ) );
}
+ int depth = Self().GetHierarchyDepth();
// 3. Create the icons
if ( showIcons )
{
ImageActor pressedIcon = ImageActor::New( iconImage );
ImageActor icon = ImageActor::New( iconImage );
- icon.SetSortModifier( DECORATION_DEPTH_INDEX - 1 );
- pressedIcon.SetSortModifier( DECORATION_DEPTH_INDEX - 1 );
+ icon.SetSortModifier( DECORATION_DEPTH_INDEX + depth - 1 );
+ pressedIcon.SetSortModifier( DECORATION_DEPTH_INDEX + depth - 1 );
icon.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
pressedIcon.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
const Size size( mOptionDividerSize.width, 0.0f ); // Height FILL_TO_PARENT
ImageActor divider = Toolkit::CreateSolidColorActor( Color::WHITE );
+#ifdef DECORATOR_DEBUG
+ divider.SetName("Text's popup divider");
+#endif
divider.SetSize( size );
divider.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
- divider.SetColor( mLineColor );
+ divider.SetColor( mDividerColor );
+ divider.SetSortModifier( DECORATION_DEPTH_INDEX + depth );
mToolbar.AddDivider( divider );
}
}
self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
SetBackgroundImage( NinePatchImage::New( DEFAULT_POPUP_BACKGROUND_IMAGE ) );
- if ( !mToolbar )
+ if( !mToolbar )
{
mToolbar = Toolkit::TextSelectionToolbar::New();
mToolbar.SetParentOrigin( ParentOrigin::CENTER );
mOptionDividerSize( Size( 2.0f, 0.0f) ),
mEnabledButtons( Toolkit::TextSelectionPopup::NONE ),
mCallbackInterface( callbackInterface ),
- mLineColor( DEFAULT_POPUP_LINE_COLOR ),
+ mDividerColor( DEFAULT_POPUP_DIVIDER_COLOR ),
mIconColor( DEFAULT_OPTION_ICON ),
- mPressedColor( DEFAULT_OPTION_ICON_PRESSED ),
+ mPressedColor( DEFAULT_OPTION_PRESSED_COLOR ),
mSelectOptionPriority( 1 ),
mSelectAllOptionPriority ( 2 ),
mCutOptionPriority ( 4 ),
*/
static Property::Value GetProperty( BaseObject* object, Property::Index index );
+ /**
+ * @copydoc Toolkit::TextSelectionPopup::RaiseAbove()
+ */
+ void RaiseAbove( Layer target );
+
private: // From Control
/**
*/
virtual void OnInitialize();
+ /**
+ * @copydoc Control::OnStageConnection()
+ */
+ virtual void OnStageConnection( int depth );
+
private: // Implementation
/**
Toolkit::TextSelectionPopup::Buttons mEnabledButtons; // stores enabled buttons
Toolkit::TextSelectionPopupCallbackInterface* mCallbackInterface;
- Vector4 mLineColor; // Color of the line around the text input popup
+ Vector4 mDividerColor; // Color of the divider between buttons
Vector4 mIconColor; // Color of the popup icon.
Vector4 mPressedColor; // Color of the popup option when pressed.
#include <dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
// EXTERNAL INCLUDES
mScrollView.SetRulerX( mRulerX );
}
+void TextSelectionToolbar::OnStageConnection( int depth )
+{
+ // Call the Control::OnStageConnection() to set the depth of the background.
+ Control::OnStageConnection( depth );
+
+ // Traverse the dividers and set the depth.
+ for( unsigned int i = 0; i < mDividerIndexes.Count(); ++i )
+ {
+ Actor divider = mTableOfButtons.GetChildAt( Toolkit::TableView::CellPosition( 0, mDividerIndexes[ i ] ) );
+
+ ImageActor dividerImageActor = ImageActor::DownCast( divider );
+ if( dividerImageActor )
+ {
+ dividerImageActor.SetSortModifier( DECORATION_DEPTH_INDEX + depth );
+ }
+ else
+ {
+ // TODO at the moment divider are image actors.
+ }
+ }
+
+ // Texts are controls, they have their own OnStageConnection() implementation.
+ // Icons are inside a TableView. It has it's own OnStageConnection() implementation.
+}
+
void TextSelectionToolbar::SetPopupMaxSize( const Size& maxSize )
{
mMaxSize = maxSize;
self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
// Create Layer and Stencil. Layer enable's clipping when content exceed maximum defined width.
- Layer stencilLayer = Layer::New();
- stencilLayer.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
- stencilLayer.SetParentOrigin( ParentOrigin::CENTER );
- stencilLayer.SetMaximumSize( mMaxSize );
+ mStencilLayer = Layer::New();
+ mStencilLayer.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
+ mStencilLayer.SetParentOrigin( ParentOrigin::CENTER );
+ mStencilLayer.SetMaximumSize( mMaxSize );
ImageActor stencil = CreateSolidColorActor( Color::RED );
stencil.SetDrawMode( DrawMode::STENCIL );
mTableOfButtons.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
- stencilLayer.Add( stencil );
- stencilLayer.Add( mScrollView );
+ mStencilLayer.Add( stencil );
+ mStencilLayer.Add( mScrollView );
mScrollView.Add( mTableOfButtons );
- self.Add( stencilLayer );
-
- stencilLayer.RaiseToTop();
+ self.Add( mStencilLayer );
}
void TextSelectionToolbar::OnScrollStarted( const Vector2& position )
void TextSelectionToolbar::AddDivider( Actor& divider )
{
AddOption( divider );
- mDividerIndexes.PushBack( mIndexInTable );
+ mDividerIndexes.PushBack( mIndexInTable - 1u );
}
void TextSelectionToolbar::ResizeDividers( Size& size )
RelayoutRequest();
}
+void TextSelectionToolbar::RaiseAbove( Layer target )
+{
+ mStencilLayer.RaiseAbove( target );
+}
+
TextSelectionToolbar::TextSelectionToolbar()
: Control( ControlBehaviour( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ) ),
mMaxSize ( DEFAULT_MAX_SIZE ),
mRulerX.Reset();
}
-
} // namespace Internal
} // namespace Toolkit
static Property::Value GetProperty( BaseObject* object, Property::Index index );
/**
- * @copydoc TextSelectionToolbar::AddOption
+ * @copydoc Toolkit::TextSelectionToolbar::AddOption()
*/
void AddOption( Actor& option );
/**
- * @copydoc TextSelectionToolbar::AddDivider
+ * @copydoc Toolkit::TextSelectionToolbar::AddDivider()
*/
void AddDivider( Actor& divider );
/**
- * @copydoc ResizeDividers
+ * @copydoc Toolkit::TextSelectionToolbar::ResizeDividers()
*/
void ResizeDividers( Size& size );
+ /**
+ * @copydoc Toolkit::TextSelectionToolbar::RaiseAbove()
+ */
+ void RaiseAbove( Layer target );
+
private: // From Control
/**
* @copydoc Control::OnRelayout()
*/
virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+ /**
+ * @copydoc Control::OnStageConnection()
+ */
+ virtual void OnStageConnection( int depth );
+
/**
* @brief Set max size of Popup
* @param[in] maxSize Size (Vector2)
private: // Data
- Toolkit::TableView mTableOfButtons; // Actor which holds all the buttons, sensitivity can be set on buttons via this actor
- Toolkit::ScrollView mScrollView; // Provides scrolling of Toolbar when content does not fit.
- RulerPtr mRulerX; // Ruler to clamp horizontal scrolling. Updates on Relayout
- Size mMaxSize; // Max size of the Toolbar
- unsigned int mIndexInTable; // Index in table to add option
- Dali::Vector< unsigned int > mDividerIndexes; // Vector of indexes in the Toolbar that contain dividers.
+ Layer mStencilLayer; ///< The stencil layer
+ Toolkit::TableView mTableOfButtons; ///< Actor which holds all the buttons, sensitivity can be set on buttons via this actor
+ Toolkit::ScrollView mScrollView; ///< Provides scrolling of Toolbar when content does not fit.
+ RulerPtr mRulerX; ///< Ruler to clamp horizontal scrolling. Updates on Relayout
+ Size mMaxSize; ///< Max size of the Toolbar
+ unsigned int mIndexInTable; ///< Index in table to add option
+ Dali::Vector< unsigned int > mDividerIndexes; ///< Vector of indexes in the Toolbar that contain dividers.
};
// The memory is freed after the visual to logical to visual conversion tables are built in the logical model.
lineInfoRun.visualToLogicalMap = reinterpret_cast<CharacterIndex*>( malloc( line.characterRun.numberOfCharacters * sizeof( CharacterIndex ) ) );
- // Reorders the line.
- bidirectionalSupport.Reorder( paragraphInfo.bidirectionalInfoIndex,
- line.characterRun.characterIndex - paragraphInfo.characterRun.characterIndex,
- line.characterRun.numberOfCharacters,
- lineInfoRun.visualToLogicalMap );
+ if( NULL != lineInfoRun.visualToLogicalMap )
+ {
+ // Reorders the line.
+ bidirectionalSupport.Reorder( paragraphInfo.bidirectionalInfoIndex,
+ line.characterRun.characterIndex - paragraphInfo.characterRun.characterIndex,
+ line.characterRun.numberOfCharacters,
+ lineInfoRun.visualToLogicalMap );
+ }
// Push the run into the vector.
lineInfoRuns.PushBack( lineInfoRun );
namespace
{
-const char* DEFAULT_GRAB_HANDLE_IMAGE_RELEASED( DALI_IMAGE_DIR "insertpoint-icon.png" );
-const char* DEFAULT_GRAB_HANDLE_IMAGE_PRESSED( DALI_IMAGE_DIR "insertpoint-icon-pressed.png" );
-const char* DEFAULT_SELECTION_HANDLE_ONE_RELEASED( DALI_IMAGE_DIR "text-input-selection-handle-left.png" );
-const char* DEFAULT_SELECTION_HANDLE_ONE_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-left-press.png" );
-const char* DEFAULT_SELECTION_HANDLE_TWO_RELEASED( DALI_IMAGE_DIR "text-input-selection-handle-right.png" );
-const char* DEFAULT_SELECTION_HANDLE_TWO_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-right-press.png" );
+const char* DEFAULT_GRAB_HANDLE_IMAGE_RELEASED( DALI_IMAGE_DIR "cursor_handler_center.png" );
+const char* DEFAULT_SELECTION_HANDLE_ONE_RELEASED( DALI_IMAGE_DIR "selection_handle_left.png" );
+const char* DEFAULT_SELECTION_HANDLE_TWO_RELEASED( DALI_IMAGE_DIR "selection_handle_right.png" );
const int DEFAULT_POPUP_OFFSET( -100.0f ); // Vertical offset of Popup from cursor or handles position.
const Dali::Vector3 DEFAULT_GRAB_HANDLE_RELATIVE_SIZE( 1.25f, 1.5f, 1.0f );
const Dali::Vector3 DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE( 1.25f, 1.5f, 1.0f );
-const Dali::Vector4 LIGHT_BLUE( (0xb2 / 255.0f), (0xeb / 255.0f), (0xf2 / 255.0f), 0.5f ); // The text highlight color.
+const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color. TODO: due some problems, maybe with the blending function in the text clipping, the color is fully opaque.
+
+const Dali::Vector4 HANDLE_COLOR( 0.0f, (183.0f / 255.0f), (229.0f / 255.0f), 1.0f );
const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
const float TO_MILLISECONDS = 1000.f;
const float TO_SECONDS = 1.f / TO_MILLISECONDS;
-const float DISPLAYED_HIGHLIGHT_Z_OFFSET( -0.05f );
-
const unsigned int SCROLL_TICK_INTERVAL = 50u;
const float SCROLL_THRESHOLD = 10.f;
: mController( controller ),
mEnabledPopupButtons( TextSelectionPopup::NONE ),
mTextSelectionPopupCallbackInterface( callbackInterface ),
+ mHandleColor( HANDLE_COLOR ),
mBoundingBox( Rect<int>() ),
mHighlightColor( LIGHT_BLUE ),
mHighlightPosition( Vector2::ZERO ),
}
else if( grabHandle.actor )
{
- UnparentAndReset( grabHandle.actor );
+ grabHandle.actor.Unparent();
}
// Show or hide the selection handles/highlight
primary.actor.SetVisible( isPrimaryVisible );
secondary.actor.SetVisible( isSecondaryVisible );
- // Shouldn't be needed......
- UnparentAndReset( mHighlightActor );
-
CreateHighlight();
UpdateHighlight();
}
else
{
- UnparentAndReset( primary.actor );
- UnparentAndReset( secondary.actor );
- UnparentAndReset( mHighlightActor );
+ if( primary.actor )
+ {
+ primary.actor.Unparent();
+ }
+ if( secondary.actor )
+ {
+ secondary.actor.Unparent();
+ }
+ if( mHighlightActor )
+ {
+ mHighlightActor.Unparent();
+ }
}
- if ( mActiveCopyPastePopup )
+ if( mActiveCopyPastePopup )
{
- // todo Swap UnparentAndReset for DeterminePositionPopup() if mCopyPastePopup.actor valid Once the issue with the labels disappearing is fixed.
- UnparentAndReset( mCopyPastePopup.actor );
- if ( !mCopyPastePopup.actor )
+ if( !mCopyPastePopup.actor.GetParent() )
{
- mCopyPastePopup.actor = TextSelectionPopup::New( mEnabledPopupButtons, &mTextSelectionPopupCallbackInterface );
-#ifdef DECORATOR_DEBUG
- mCopyPastePopup.actor.SetName("mCopyPastePopup");
-#endif
- mCopyPastePopup.actor.SetAnchorPoint( AnchorPoint::CENTER );
- mCopyPastePopup.actor.OnRelayoutSignal().Connect( this, &Decorator::Impl::PopupRelayoutComplete ); // Position popup after size negotiation
- mActiveLayer.Add ( mCopyPastePopup.actor );
+ mActiveLayer.Add( mCopyPastePopup.actor );
}
+
+ mCopyPastePopup.actor.RaiseAbove( mActiveLayer );
}
else
{
- if ( mCopyPastePopup.actor )
- {
- UnparentAndReset( mCopyPastePopup.actor );
- }
+ if( mCopyPastePopup.actor )
+ {
+ mCopyPastePopup.actor.Unparent();
+ }
}
}
mHandle[ LEFT_SELECTION_HANDLE ].position += scrollOffset;
mHandle[ RIGHT_SELECTION_HANDLE ].position += scrollOffset;
mHighlightPosition += scrollOffset;
+ DeterminePositionPopup();
}
void DeterminePositionPopup()
{
if( mActiveCursor == ACTIVE_CURSOR_NONE )
{
- UnparentAndReset( mPrimaryCursor );
- UnparentAndReset( mSecondaryCursor );
+ if( mPrimaryCursor )
+ {
+ mPrimaryCursor.Unparent();
+ }
+ if( mSecondaryCursor )
+ {
+ mSecondaryCursor.Unparent();
+ }
}
else
{
#ifdef DECORATOR_DEBUG
mPrimaryCursor.SetName( "PrimaryCursorActor" );
#endif
+ }
+
+ if( !mPrimaryCursor.GetParent() )
+ {
mActiveLayer.Add( mPrimaryCursor );
}
}
#ifdef DECORATOR_DEBUG
mSecondaryCursor.SetName( "SecondaryCursorActor" );
#endif
+ }
+
+ if( !mSecondaryCursor.GetParent() )
+ {
mActiveLayer.Add( mSecondaryCursor );
}
}
else
{
- UnparentAndReset( mSecondaryCursor );
+ if( mSecondaryCursor )
+ {
+ mSecondaryCursor.Unparent();
+ }
}
}
}
{
mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE_RELEASED );
}
- if( !mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED] )
- {
- mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED] = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE_PRESSED );
- }
grabHandle.actor = ImageActor::New( mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] );
grabHandle.actor.SetSortModifier( DECORATION_DEPTH_INDEX );
grabHandle.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
grabHandle.grabArea.SetSizeModeFactor( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE );
grabHandle.actor.Add( grabHandle.grabArea );
+ grabHandle.actor.SetColor( mHandleColor );
grabHandle.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnGrabHandleTouched );
mTapDetector.Attach( grabHandle.grabArea );
mActiveLayer.Add( grabHandle.actor );
}
+
+ if( !grabHandle.actor.GetParent() )
+ {
+ mActiveLayer.Add( grabHandle.actor );
+ }
}
void CreateSelectionHandles()
{
mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE_RELEASED );
}
- if( !mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] )
- {
- mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE_PRESSED );
- }
primary.actor = ImageActor::New( mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
#ifdef DECORATOR_DEBUG
primary.actor.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); // Change to BOTTOM_RIGHT if Look'n'Feel requires handle above text.
primary.actor.SetSortModifier( DECORATION_DEPTH_INDEX );
primary.flipped = false;
+ primary.actor.SetColor( mHandleColor );
primary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
#ifdef DECORATOR_DEBUG
primary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
primary.actor.Add( primary.grabArea );
+ }
+
+ if( !primary.actor.GetParent() )
+ {
mActiveLayer.Add( primary.actor );
}
{
mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO_RELEASED );
}
- if( !mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] )
- {
- mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO_PRESSED );
- }
secondary.actor = ImageActor::New( mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
#ifdef DECORATOR_DEBUG
secondary.actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // Change to BOTTOM_LEFT if Look'n'Feel requires handle above text.
secondary.actor.SetSortModifier( DECORATION_DEPTH_INDEX );
secondary.flipped = false;
+ secondary.actor.SetColor( mHandleColor );
secondary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
#ifdef DECORATOR_DEBUG
secondary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
secondary.actor.Add( secondary.grabArea );
+ }
+
+ if( !secondary.actor.GetParent() )
+ {
mActiveLayer.Add( secondary.actor );
}
}
void CreateHighlight()
{
- if ( !mHighlightActor )
+ if( !mHighlightActor )
{
mHighlightActor = Actor::New();
mHighlightActor.SetName( "HighlightActor" );
#endif
mHighlightActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mHighlightActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET );
mHighlightActor.SetSize( 1.0f, 1.0f );
mHighlightActor.SetColor( mHighlightColor );
mHighlightActor.SetColorMode( USE_OWN_COLOR );
-
- // Add the highlight box telling the controller it needs clipping.
- mController.AddDecoration( mHighlightActor, true );
}
+
+ // Add the highlight box telling the controller it needs clipping.
+ mController.AddDecoration( mHighlightActor, true );
}
void UpdateHighlight()
{
-
- if ( mHighlightActor && !mHighlightQuadList.empty() )
+ if ( mHighlightActor )
{
- Vector< Vector2 > vertices;
- Vector< unsigned int> indices;
- Vector2 vertex;
+ if( !mHighlightQuadList.empty() )
+ {
+ Vector< Vector2 > vertices;
+ Vector< unsigned int> indices;
+ Vector2 vertex;
- std::vector<QuadCoordinates>::iterator iter = mHighlightQuadList.begin();
- std::vector<QuadCoordinates>::iterator endIter = mHighlightQuadList.end();
+ std::vector<QuadCoordinates>::iterator iter = mHighlightQuadList.begin();
+ std::vector<QuadCoordinates>::iterator endIter = mHighlightQuadList.end();
- for(std::size_t v = 0; iter != endIter; ++iter,v+=4 )
- {
+ for( std::size_t v = 0; iter != endIter; ++iter,v+=4 )
+ {
+
+ QuadCoordinates& quad = *iter;
+
+ // top-left (v+0)
+ vertex.x = quad.min.x;
+ vertex.y = quad.min.y;
+ vertices.PushBack( vertex );
+
+ // top-right (v+1)
+ vertex.x = quad.max.x;
+ vertex.y = quad.min.y;
+ vertices.PushBack( vertex );
+
+ // bottom-left (v+2)
+ vertex.x = quad.min.x;
+ vertex.y = quad.max.y;
+ vertices.PushBack( vertex );
+
+ // bottom-right (v+3)
+ vertex.x = quad.max.x;
+ vertex.y = quad.max.y;
+ vertices.PushBack( vertex );
+
+ // triangle A (3, 1, 0)
+ indices.PushBack( v + 3 );
+ indices.PushBack( v + 1 );
+ indices.PushBack( v );
+
+ // triangle B (0, 2, 3)
+ indices.PushBack( v );
+ indices.PushBack( v + 2 );
+ indices.PushBack( v + 3 );
+ }
+
+ if( mQuadVertices )
+ {
+ mQuadVertices.SetSize( vertices.Size() );
+ }
+ else
+ {
+ mQuadVertices = PropertyBuffer::New( mQuadVertexFormat, vertices.Size() );
+ }
+
+ if( mQuadIndices )
+ {
+ mQuadIndices.SetSize( indices.Size() );
+ }
+ else
+ {
+ mQuadIndices = PropertyBuffer::New( mQuadIndexFormat, indices.Size() );
+ }
+
+ mQuadVertices.SetData( &vertices[ 0 ] );
+ mQuadIndices.SetData( &indices[ 0 ] );
+
+ mQuadGeometry = Geometry::New();
+ mQuadGeometry.AddVertexBuffer( mQuadVertices );
+ mQuadGeometry.SetIndexBuffer( mQuadIndices );
- QuadCoordinates& quad = *iter;
-
- // top-left (v+0)
- vertex.x = quad.min.x;
- vertex.y = quad.min.y;
- vertices.PushBack( vertex );
-
- // top-right (v+1)
- vertex.x = quad.max.x;
- vertex.y = quad.min.y;
- vertices.PushBack( vertex );
-
- // bottom-left (v+2)
- vertex.x = quad.min.x;
- vertex.y = quad.max.y;
- vertices.PushBack( vertex );
-
- // bottom-right (v+3)
- vertex.x = quad.max.x;
- vertex.y = quad.max.y;
- vertices.PushBack( vertex );
-
- // triangle A (3, 1, 0)
- indices.PushBack( v + 3 );
- indices.PushBack( v + 1 );
- indices.PushBack( v );
-
- // triangle B (0, 2, 3)
- indices.PushBack( v );
- indices.PushBack( v + 2 );
- indices.PushBack( v + 3 );
+ if( mHighlightRenderer )
+ {
+ mHighlightRenderer.SetGeometry( mQuadGeometry );
+ }
+ else
+ {
+ mHighlightRenderer = Dali::Renderer::New( mQuadGeometry, mHighlightMaterial );
+ mHighlightActor.AddRenderer( mHighlightRenderer );
+ }
+
+ mHighlightActor.SetPosition( mHighlightPosition.x,
+ mHighlightPosition.y );
}
- PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat, vertices.Size() );
- PropertyBuffer quadIndices = PropertyBuffer::New( mQuadIndexFormat, indices.Size() );
-
- quadVertices.SetData( &vertices[ 0 ] );
- quadIndices.SetData( &indices[ 0 ] );
-
- Geometry quadGeometry = Geometry::New();
- quadGeometry.AddVertexBuffer( quadVertices );
- quadGeometry.SetIndexBuffer( quadIndices );
-
- // if ( mHighlightRenderer )
- // {
- // mHighlightRenderer.SetGeometry( quadGeometry );
- // }
- // else
- // {
- mHighlightRenderer = Dali::Renderer::New( quadGeometry, mHighlightMaterial );
- mHighlightRenderer.SetDepthIndex( DECORATION_DEPTH_INDEX - 1 );
- // }
- mHighlightActor.AddRenderer( mHighlightRenderer );
+ mHighlightRenderer.SetDepthIndex( mTextDepth - 2u ); // text is rendered at mTextDepth and text's shadow at mTextDepth -1u.
}
}
HandleImpl& leftHandle = mHandle[LEFT_SELECTION_HANDLE];
HandleImpl& rightHandle = mHandle[RIGHT_SELECTION_HANDLE];
- const HandleImageType leftImageType = leftHandle.pressed ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED;
- const HandleImageType rightImageType = rightHandle.pressed ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED;
+ // If handle pressed and pressed image exists then use pressed image else stick with released image
+ const HandleImageType leftImageType = ( leftHandle.pressed && mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] ) ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED;
+ const HandleImageType rightImageType = ( rightHandle.pressed && mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] ) ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED;
+
const bool leftFlipped = mSwapSelectionHandles != leftHandle.flipped;
const bool rightFlipped = mSwapSelectionHandles != rightHandle.flipped;
TextSelectionPopupCallbackInterface& mTextSelectionPopupCallbackInterface;
Image mHandleImages[HANDLE_TYPE_COUNT][HANDLE_IMAGE_TYPE_COUNT];
- Image mCursorImage;
+ Vector4 mHandleColor;
CursorImpl mCursor[CURSOR_COUNT];
HandleImpl mHandle[HANDLE_TYPE_COUNT];
+
+ PropertyBuffer mQuadVertices;
+ PropertyBuffer mQuadIndices;
+ Geometry mQuadGeometry;
QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight
Rect<int> mBoundingBox;
float mScrollThreshold; ///< Defines a square area inside the control, close to the edge. A cursor entering this area will trigger scroll events.
float mScrollSpeed; ///< The scroll speed in pixels per second.
float mScrollDistance; ///< Distance the text scrolls during a scroll interval.
+ int mTextDepth; ///< The depth used to render the text.
bool mActiveCopyPastePopup : 1;
bool mCursorBlinkStatus : 1; ///< Flag to switch between blink on and blink off.
return mImpl->mCursor[cursor].position;
}
-void Decorator::SetColor( Cursor cursor, const Dali::Vector4& color )
+void Decorator::SetCursorColor( Cursor cursor, const Dali::Vector4& color )
{
mImpl->mCursor[cursor].color = color;
}
return mImpl->mHandleImages[handleType][handleImageType];
}
+void Decorator::SetHandleColor( const Vector4& color )
+{
+ mImpl->mHandleColor = color;
+}
+
+const Vector4& Decorator::GetHandleColor() const
+{
+ return mImpl->mHandleColor;
+}
+
void Decorator::SetPosition( HandleType handleType, float x, float y, float height )
{
// Adjust grab handle displacement
return mImpl->mHighlightColor;
}
+void Decorator::SetTextDepth( int textDepth )
+{
+ mImpl->mTextDepth = textDepth;
+}
+
void Decorator::SetPopupActive( bool active )
{
mImpl->mActiveCopyPastePopup = active;
void Decorator::SetEnabledPopupButtons( TextSelectionPopup::Buttons& enabledButtonsBitMask )
{
mImpl->mEnabledPopupButtons = enabledButtonsBitMask;
+
+ UnparentAndReset( mImpl->mCopyPastePopup.actor );
+ mImpl->mCopyPastePopup.actor = TextSelectionPopup::New( mImpl->mEnabledPopupButtons,
+ &mImpl->mTextSelectionPopupCallbackInterface );
+#ifdef DECORATOR_DEBUG
+ mImpl->mCopyPastePopup.actor.SetName("mCopyPastePopup");
+#endif
+ mImpl->mCopyPastePopup.actor.SetAnchorPoint( AnchorPoint::CENTER );
+ mImpl->mCopyPastePopup.actor.OnRelayoutSignal().Connect( mImpl, &Decorator::Impl::PopupRelayoutComplete ); // Position popup after size negotiation
+
+ if( mImpl->mActiveLayer )
+ {
+ mImpl->mActiveLayer.Add( mImpl->mCopyPastePopup.actor );
+ }
}
TextSelectionPopup::Buttons& Decorator::GetEnabledPopupButtons()
* @param[in] cursor Whether this color is for the primary or secondary cursor.
* @param[in] color The color to use.
*/
- void SetColor( Cursor cursor, const Dali::Vector4& color );
+ void SetCursorColor( Cursor cursor, const Dali::Vector4& color );
/**
* @brief Retrieves the color for a cursor.
Dali::Image GetHandleImage( HandleType handleType, HandleImageType handleImageType ) const;
/**
+ * @brief Sets the color of the handles
+ *
+ * @param[in] color The color to use.
+ */
+ void SetHandleColor( const Vector4& color );
+
+ /**
+ * @brief Retrieves the handles color.
+ *
+ * @return The color of the handles.
+ */
+ const Vector4& GetHandleColor() const;
+
+ /**
* @brief Sets the position of a selection handle.
*
* @param[in] handleType The handle to set.
/**
* @brief Sets the selection highlight color.
*
- * @param[in] image The image to use.
+ * @param[in] color The color to use.
*/
void SetHighlightColor( const Vector4& color );
/**
* @brief Retrieves the selection highlight color.
*
- * @return The image.
+ * @return The color of the highlight
*/
const Vector4& GetHighlightColor() const;
/**
+ * @brief Sets into the decorator the depth used to render the text.
+ *
+ * @param[in] depth The text's depth.
+ */
+ void SetTextDepth( int textDepth );
+
+ /**
* @brief Set the Selection Popup to show or hide via the active flaf
* @param[in] active true to show, false to hide
*/
return internal;
}
-void AtlasGlyphManager::Add( Text::FontId fontId,
- const Text::GlyphInfo& glyph,
+void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph,
const BufferImage& bitmap,
Dali::Toolkit::AtlasManager::AtlasSlot& slot )
{
for ( std::vector< FontGlyphRecord >::iterator fontGlyphRecordIt = mFontGlyphRecords.begin();
fontGlyphRecordIt != mFontGlyphRecords.end(); ++fontGlyphRecordIt )
{
- if ( fontGlyphRecordIt->mFontId == fontId )
+ if ( fontGlyphRecordIt->mFontId == glyph.fontId )
{
fontGlyphRecordIt->mGlyphRecords.PushBack( record );
foundGlyph = true;
{
// We need to add a new font entry
FontGlyphRecord fontGlyphRecord;
- fontGlyphRecord.mFontId = fontId;
+ fontGlyphRecord.mFontId = glyph.fontId;
fontGlyphRecord.mGlyphRecords.PushBack( record );
mFontGlyphRecords.push_back( fontGlyphRecord );
}
const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
{
- mMetrics.mGlyphCount = mFontGlyphRecords.size();
+ mMetrics.mGlyphCount = 0u;
+ for ( std::vector< FontGlyphRecord >::iterator fontGlyphRecordIt = mFontGlyphRecords.begin();
+ fontGlyphRecordIt != mFontGlyphRecords.end();
+ ++fontGlyphRecordIt )
+ {
+ mMetrics.mGlyphCount += fontGlyphRecordIt->mGlyphRecords.Size();
+ }
mAtlasManager.GetMetrics( mMetrics.mAtlasMetrics );
return mMetrics;
}
/**
* @copydoc Toolkit::AtlasGlyphManager::Add
*/
- void Add( Text::FontId fontId,
- const Text::GlyphInfo& glyph,
+ void Add( const Text::GlyphInfo& glyph,
const BufferImage& bitmap,
Dali::Toolkit::AtlasManager::AtlasSlot& slot );
{
}
-void AtlasGlyphManager::Add( Text::FontId fontId,
- const Text::GlyphInfo& glyph,
+void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph,
const BufferImage& bitmap,
AtlasManager::AtlasSlot& slot )
{
- GetImplementation(*this).Add( fontId, glyph, bitmap, slot );
+ GetImplementation(*this).Add( glyph, bitmap, slot );
}
void AtlasGlyphManager::GenerateMeshData( uint32_t imageId,
*/
struct Metrics
{
+ Metrics()
+ : mGlyphCount( 0u )
+ {}
+
+ ~Metrics()
+ {}
+
uint32_t mGlyphCount; // number of glyphs being managed
AtlasManager::Metrics mAtlasMetrics; // metrics from the Atlas Manager
};
/**
* @brief Ask Atlas Manager to add a glyph
*
- * @param[in] fontId fontId glyph comes from
* @param[in] glyph glyph to add to an atlas
* @param[in] bitmap bitmap to use for glyph addition
* @param[out] slot information returned by atlas manager for addition
*/
- void Add( Text::FontId fontId,
- const Text::GlyphInfo& glyph,
+ void Add( const Text::GlyphInfo& glyph,
const BufferImage& bitmap,
AtlasManager::AtlasSlot& slot );
};
Impl()
+ : mDepth( 0 )
{
mGlyphManager = AtlasGlyphManager::Get();
mFontClient = TextAbstraction::FontClient::Get();
bool underlineEnabled,
const Vector4& underlineColor,
float underlineHeight,
- unsigned int depth )
+ int depth )
{
AtlasManager::AtlasSlot slot;
std::vector< MeshRecord > meshContainer;
Vector< Extent > extents;
TextCacheEntry textCacheEntry;
- mDepth = static_cast< int >( depth );
+ mDepth = depth;
float currentUnderlinePosition = ZERO;
float currentUnderlineThickness = underlineHeight;
}
// Locate a new slot for our glyph
- mGlyphManager.Add( glyph.fontId, glyph, bitmap, slot );
+ mGlyphManager.Add( glyph, bitmap, slot );
}
}
currentUnderlinePosition,
currentUnderlineThickness,
slot );
- lastFontId = glyph.fontId;
+ lastFontId = glyph.fontId;
}
}
actor.Add( GenerateShadow( *mIt, shadowOffset, shadowColor ) );
}
- if ( mActor )
+ if( mActor )
{
+ actor.SetParentOrigin( ParentOrigin::CENTER ); // Keep all of the origins aligned
mActor.Add( actor );
}
else
Material material = mGlyphManager.GetMaterial( meshRecord.mAtlasId );
Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
- renderer.SetDepthIndex( mDepth );
+ renderer.SetDepthIndex( CONTENT_DEPTH_INDEX + mDepth );
Actor actor = Actor::New();
+#if defined(DEBUG_ENABLED)
+ actor.SetName( "Text renderable actor" );
+#endif
actor.AddRenderer( renderer );
actor.SetSize( 1.0f, 1.0f );
actor.SetColor( meshRecord.mColor );
Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
// Ensure shadow is behind the text...
- renderer.SetDepthIndex( mDepth + CONTENT_DEPTH_INDEX - 1 );
+ renderer.SetDepthIndex( CONTENT_DEPTH_INDEX + mDepth - 1 );
Actor actor = Actor::New();
actor.AddRenderer( renderer );
actor.SetSize( 1.0f, 1.0f );
return Text::RendererPtr( new AtlasRenderer() );
}
-Actor AtlasRenderer::Render( Text::ViewInterface& view, unsigned int depth )
+Actor AtlasRenderer::Render( Text::ViewInterface& view, int depth )
{
UnparentAndReset( mImpl->mActor );
* @param[in] depth The depth in the tree of the parent.
* @return The Renderable actor used to position the text.
*/
- virtual Actor Render( ViewInterface& view, unsigned int depth );
+ virtual Actor Render( ViewInterface& view, int depth );
protected:
* @param[in] depth The depth in the tree of the parent.
* @return The Renderable actor used to position the text.
*/
- virtual Actor Render( ViewInterface& view, unsigned int depth ) = 0;
+ virtual Actor Render( ViewInterface& view, int depth ) = 0;
protected:
OnTapEvent( *iter );
break;
}
+ case Event::LONG_PRESS_EVENT:
+ {
+ OnLongPressEvent( *iter );
+ break;
+ }
case Event::PAN_EVENT:
{
OnPanEvent( *iter );
}
}
+float Controller::Impl::GetDefaultFontLineHeight()
+{
+ FontId defaultFontId = 0u;
+ if( NULL == mFontDefaults )
+ {
+ defaultFontId = mFontClient.GetFontId( EMPTY_STRING,
+ EMPTY_STRING );
+ }
+ else
+ {
+ defaultFontId = mFontDefaults->GetFontId( mFontClient );
+ }
+
+ Text::FontMetrics fontMetrics;
+ mFontClient.GetFontMetrics( defaultFontId, fontMetrics );
+
+ return( fontMetrics.ascender - fontMetrics.descender );
+}
+
void Controller::Impl::OnCursorKeyEvent( const Event& event )
{
if( NULL == mEventData )
}
}
+void Controller::Impl::OnLongPressEvent( const Event& event )
+{
+ if ( EventData::EDITING == mEventData->mState )
+ {
+ ChangeState ( EventData::EDITING_WITH_POPUP );
+ mEventData->mDecoratorUpdated = true;
+ }
+}
+
void Controller::Impl::OnHandleEvent( const Event& event )
{
if( NULL == mEventData )
}
else if ( EventData::EDITING_WITH_POPUP == mEventData->mState )
{
- buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL );
+ if ( mLogicalModel->mText.Count() && !IsShowingPlaceholderText())
+ {
+ buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL );
+ }
if ( !IsClipboardEmpty() )
{
mEventData->mDecoratorUpdated = true;
HideClipboard();
}
+ else if ( EventData::INTERRUPTED == mEventData->mState)
+ {
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetPopupActive( false );
+ mEventData->mDecoratorUpdated = true;
+ HideClipboard();
+ }
else if ( EventData::SELECTING == mEventData->mState )
{
mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
HideClipboard();
mEventData->mDecoratorUpdated = true;
}
+ else if( EventData::EDITING_WITH_GRAB_HANDLE == mEventData->mState )
+ {
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
+ if( mEventData->mCursorBlinkEnabled )
+ {
+ mEventData->mDecorator->StartCursorBlink();
+ }
+ // Grab handle is not shown until a tap is received whilst EDITING
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
+ if( mEventData->mGrabHandlePopupEnabled )
+ {
+ mEventData->mDecorator->SetPopupActive( false );
+ }
+ mEventData->mDecoratorUpdated = true;
+ HideClipboard();
+ }
else if ( EventData::SELECTION_HANDLE_PANNING == mEventData->mState )
{
mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
// Get the glyphs per character table.
const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin();
+ const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
// If the vector is void, there is no right to left characters.
const bool hasRightToLeftCharacters = NULL != visualToLogicalBuffer;
// The character in logical order.
const CharacterIndex characterLogicalOrderIndex = hasRightToLeftCharacters ? *( visualToLogicalBuffer + visualIndex ) : visualIndex;
+ // Get the script of the character.
+ const Script script = mLogicalModel->GetScript( characterLogicalOrderIndex );
+
// The first glyph for that character in logical order.
const GlyphIndex glyphLogicalOrderIndex = *( charactersToGlyphBuffer + characterLogicalOrderIndex );
-
// The number of glyphs for that character
const Length numberOfGlyphs = *( glyphsPerCharacterBuffer + characterLogicalOrderIndex );
const Vector2& position = *( positionsBuffer + glyphLogicalOrderIndex );
- // Find the mid-point of the area containing the glyph
- const float glyphCenter = -glyphMetrics.xBearing + position.x + 0.5f * glyphMetrics.advance;
+ // Prevents to jump the whole Latin ligatures like fi, ff, ...
+ const Length numberOfCharactersInLigature = ( TextAbstraction::LATIN == script ) ? *( charactersPerGlyphBuffer + glyphLogicalOrderIndex ) : 1u;
+ const float glyphAdvance = glyphMetrics.advance / static_cast<float>( numberOfCharactersInLigature );
- if( visualX < glyphCenter )
+ for( GlyphIndex index = 0u; !matched && ( index < numberOfCharactersInLigature ); ++index )
+ {
+ // Find the mid-point of the area containing the glyph
+ const float glyphCenter = -glyphMetrics.xBearing + position.x + ( static_cast<float>( index ) + 0.5f ) * glyphAdvance;
+
+ if( visualX < glyphCenter )
+ {
+ visualIndex += index;
+ matched = true;
+ break;
+ }
+ }
+
+ if( matched )
{
- matched = true;
break;
}
}
logicalIndex = hasRightToLeftCharacters ? *( visualToLogicalCursorBuffer + visualIndex ) : visualIndex;
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "%p closest visualIndex %d logicalIndex %d\n", this, visualIndex, logicalIndex );
+
return logicalIndex;
}
if( isFirstPosition && isLastPosition )
{
- // There is zero characters. Get the default font.
-
- FontId defaultFontId = 0u;
- if( NULL == mFontDefaults )
- {
- defaultFontId = mFontClient.GetFontId( EMPTY_STRING,
- EMPTY_STRING );
- }
- else
- {
- defaultFontId = mFontDefaults->GetFontId( mFontClient );
- }
-
- Text::FontMetrics fontMetrics;
- mFontClient.GetFontMetrics( defaultFontId, fontMetrics );
-
- cursorInfo.lineHeight = fontMetrics.ascender - fontMetrics.descender;
+ // There is zero characters. Get the default font's line height.
+ cursorInfo.lineHeight = GetDefaultFontLineHeight();
cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
cursorInfo.primaryPosition.x = 1.f;
if( cursorInfo.isSecondaryCursor )
{
- mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_BOTH );
mEventData->mDecorator->SetPosition( SECONDARY_CURSOR,
cursorInfo.secondaryPosition.x + offset.x,
cursorInfo.secondaryPosition.y + offset.y,
cursorInfo.lineHeight );
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + offset.x, cursorInfo.secondaryPosition.y + offset.y );
}
+
+ // Set which cursors are active according the state.
+ if( ( EventData::EDITING == mEventData->mState ) ||
+ ( EventData::EDITING_WITH_POPUP == mEventData->mState ) ||
+ ( EventData::GRAB_HANDLE_PANNING == mEventData->mState ) )
+ {
+ if( cursorInfo.isSecondaryCursor )
+ {
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_BOTH );
+ }
+ else
+ {
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
+ }
+ }
else
{
- mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
}
}
CURSOR_KEY_EVENT,
TAP_EVENT,
PAN_EVENT,
+ LONG_PRESS_EVENT,
GRAB_HANDLE_EVENT,
LEFT_SELECTION_HANDLE_EVENT,
RIGHT_SELECTION_HANDLE_EVENT,
enum State
{
INACTIVE,
+ INTERRUPTED,
SELECTING,
SELECTION_CHANGED,
EDITING,
EDITING_WITH_POPUP,
+ EDITING_WITH_GRAB_HANDLE,
GRAB_HANDLE_PANNING,
SELECTION_HANDLE_PANNING
};
*/
void GetDefaultFonts( Dali::Vector<FontRun>& fonts, Length numberOfCharacters );
+ /**
+ * @brief Retrieve the line height of the default font.
+ */
+ float GetDefaultFontLineHeight();
+
void OnCursorKeyEvent( const Event& event );
void OnTapEvent( const Event& event );
void OnPanEvent( const Event& event );
+ void OnLongPressEvent( const Event& event );
+
void OnHandleEvent( const Event& event );
void OnSelectEvent( const Event& event );
// Get the direction of the first character.
const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
- const Size& actualSize = mImpl->mVisualModel->GetActualSize();
+ Size actualSize = mImpl->mVisualModel->GetActualSize();
+ if( fabsf( actualSize.height ) < Math::MACHINE_EPSILON_1000 )
+ {
+ // Get the line height of the default font.
+ actualSize.height = mImpl->GetDefaultFontLineHeight();
+ }
// If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();
if( mImpl->mEventData )
{
- mImpl->ChangeState( EventData::INACTIVE );
-
- if( mImpl->IsShowingPlaceholderText() )
+ if ( EventData::INTERRUPTED != mImpl->mEventData->mState )
{
- // Revert to regular placeholder-text when not editing
- ShowPlaceholderText();
- }
+ mImpl->ChangeState( EventData::INACTIVE );
- mImpl->RequestRelayout();
+ if( mImpl->IsShowingPlaceholderText() )
+ {
+ // Revert to regular placeholder-text when not editing
+ ShowPlaceholderText();
+ }
+ }
}
+ mImpl->RequestRelayout();
}
bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
{
textChanged = BackspaceKeyEvent();
}
- else if ( IsKey( keyEvent, Dali::DALI_KEY_POWER ) || IsKey( keyEvent, Dali::DALI_KEY_MENU ) )
+ else if ( IsKey( keyEvent, Dali::DALI_KEY_POWER ) )
+ {
+ mImpl->ChangeState( EventData::INTERRUPTED ); // State is not INACTIVE as expect to return to edit mode.
+ // Avoids calling the InsertText() method which can delete selected text
+ }
+ else if ( IsKey( keyEvent, Dali::DALI_KEY_MENU ) ||
+ IsKey( keyEvent, Dali::DALI_KEY_HOME ) )
{
- // Do nothing when the Power or Menu Key is pressed.
- // It avoids call the InsertText() method and delete the selected text.
+ mImpl->ChangeState( EventData::INACTIVE );
+ // Menu/Home key behaviour does not allow edit mode to resume like Power key
+ // Avoids calling the InsertText() method which can delete selected text
}
else
{
textChanged = true;
}
- mImpl->ChangeState( EventData::EDITING ); // todo Confirm this is the best place to change the state of
+ if ( mImpl->mEventData->mState != EventData::INTERRUPTED && mImpl->mEventData->mState != EventData::INACTIVE )
+ {
+ mImpl->ChangeState( EventData::EDITING );
+ }
mImpl->RequestRelayout();
}
if( !isShowingPlaceholderText &&
( EventData::EDITING == mImpl->mEventData->mState ) )
{
- mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
- mImpl->mEventData->mDecorator->SetPopupActive( false );
+ mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
}
-
- mImpl->ChangeState( EventData::EDITING );
-
- // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
- if( mImpl->mEventData )
+ else if( EventData::EDITING_WITH_GRAB_HANDLE != mImpl->mEventData->mState )
{
- Event event( Event::TAP_EVENT );
- event.p1.mUint = tapCount;
- event.p2.mFloat = x;
- event.p3.mFloat = y;
- mImpl->mEventData->mEventQueue.push_back( event );
-
- mImpl->RequestRelayout();
+ // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
+ mImpl->ChangeState( EventData::EDITING );
}
+
+ Event event( Event::TAP_EVENT );
+ event.p1.mUint = tapCount;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+ mImpl->mEventData->mEventQueue.push_back( event );
+
+ mImpl->RequestRelayout();
}
else if( !isShowingPlaceholderText &&
mImpl->mEventData->mSelectionEnabled &&
}
}
+void Controller::LongPressEvent( Gesture::State state, float x, float y )
+{
+ DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" );
+
+ if ( mImpl->IsShowingPlaceholderText() || mImpl->mLogicalModel->mText.Count() == 0u )
+ {
+ if ( mImpl->mEventData )
+ {
+ Event event( Event::LONG_PRESS_EVENT );
+ event.p1.mInt = state;
+ mImpl->mEventData->mEventQueue.push_back( event );
+ mImpl->RequestRelayout();
+ }
+ }
+ else if( mImpl->mEventData )
+ {
+ SelectEvent( x, y, false );
+ }
+}
+
void Controller::SelectEvent( float x, float y, bool selectAll )
{
if( mImpl->mEventData )
void PanEvent( Gesture::State state, const Vector2& displacement );
/**
+ * @brief Called by editable UI controls when a long press gesture occurs.
+ *
+ * @param[in] state The state of the gesture.
+ * @param[in] x The x position relative to the top-left of the parent control.
+ * @param[in] y The y position relative to the top-left of the parent control.
+ */
+ void LongPressEvent( Gesture::State state, float x, float y );
+
+ /**
* @brief Creates a selection event.
*
* It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
return GetImpl(*this).GetFocusGroup(actor);
}
+Vector2 AccessibilityManager::GetReadPosition() const
+{
+ return GetImpl(*this).GetReadPosition();
+}
+
AccessibilityManager::FocusChangedSignalType& AccessibilityManager::FocusChangedSignal()
{
return GetImpl(*this).FocusChangedSignal();
*/
Actor GetFocusGroup(Actor actor);
+ /**
+ * @brief Returns the current position of the read action.
+ * @return The current event position.
+ */
+ Vector2 GetReadPosition() const;
+
public: // Signals
/**
//Create the renderer
Renderer renderer = Renderer::New( mesh, material );
- renderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
+ renderer.SetDepthIndex( parent.GetHierarchyDepth() + BACKGROUND_DEPTH_INDEX );
//Create the actor
Actor meshActor = Actor::New();
imageActor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
imageActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
imageActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ imageActor.SetSortModifier( parent.GetHierarchyDepth() + BACKGROUND_DEPTH_INDEX );
return imageActor;
}
{
mImpl->mStyleName = styleName;
- // Apply new style
+ // Apply new style, if stylemanager is available
Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
- GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+ if( styleManager )
+ {
+ GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+ }
}
}
if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
{
Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+ // if stylemanager is available
+ if( styleManager )
+ {
+ // Register for style changes
+ styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
- // Register for style changes
- styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
-
- // Apply the current style
- GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+ // Apply the current style
+ GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+ }
}
if( mImpl->mFlags & REQUIRES_KEYBOARD_NAVIGATION_SUPPORT )
}
}
-void Control::OnStageConnection( unsigned int depth )
+void Control::OnStageConnection( int depth )
{
unsigned int controlRendererCount = Self().GetRendererCount();
for( unsigned int i(0); i<controlRendererCount; ++i )
/**
* @copydoc CustomActorImpl::OnStageConnection()
*/
- virtual void OnStageConnection( unsigned int depth );
+ virtual void OnStageConnection( int depth );
/**
* @copydoc CustomActorImpl::OnStageDisconnection()
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 47;
+const unsigned int TOOLKIT_MICRO_VERSION = 48;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
"font-style":"Regular",
"point-size":18
},
+ "textselectionpopuplabel":
+ {
+ "point-size":18
+ },
"textselectionpopup":
{
"popup-max-size":[400,100],
- "popup-min-size":[100,65],
- "background-color":[0.0,0.0,0.0,1.0]
+ "popup-min-size":[100,65]
},
"textfield":
{
"font-family":"HelveticaNeue",
"font-style":"Regular",
- "point-size":18
+ "point-size":18,
+ "primary-cursor-color":[0.0,0.71,0.9,1.0],
+ "secondary-cursor-color":[0.0,0.71,0.9,1.0],
+ "selection-highlight-color":[0.75,0.96,1.0,1.0],
+ "grab-handle-image":"{DALI_IMAGE_DIR}cursor_handler_center.png",
+ "selection-handle-image-left":"{DALI_IMAGE_DIR}selection_handle_left.png",
+ "selection-handle-image-right":"{DALI_IMAGE_DIR}selection_handle_right.png"
},
"scrollview":
{
"textfield":
{
"font-family":"SamsungSans",
- "font-style":"Regular"
+ "font-style":"Regular",
+ "primary-cursor-color":[1.0,0.71,0.9,1.0],
+ "secondary-cursor-color":[1.0,0.71,0.9,1.0],
+ "selection-highlight-color":[0.75,0.96,1.0,1.0],
+ "grab-handle-image":"{DALI_IMAGE_DIR}cursor_handler_center.png",
+ "selection-handle-image-left":"{DALI_IMAGE_DIR}selection_handle_left.png",
+ "selection-handle-image-right":"{DALI_IMAGE_DIR}selection_handle_right.png"
},
"textfield-font-size-0":
{
"point-size":10
},
+ "textselectionpopuplabel":
+ {
+ "point-size":8
+ },
"textselectionpopup":
{
"popup-max-size":[400,100],
- "popup-min-size":[100,65],
- "background-color":[0.0,0.0,0.0,1.0]
+ "popup-min-size":[100,65]
},
"scrollview":
{
--- /dev/null
+{
+ "variables": {
+ 'DALI_JS_DIR%':'../plugins/dali-script-v8/src/'
+ },
+ "targets": [
+ {
+ 'target_name': 'dali',
+ 'include_dirs': ['<(DALI_JS_DIR)/',
+ '<(DALI_JS_DIR)/utils'],
+ 'sources': [ 'dali-addon.cpp',
+ 'javascript-application-options.cpp',
+ '<(DALI_JS_DIR)/utils/v8-utils.cpp',
+ '<(DALI_JS_DIR)/dali-wrapper.cpp',
+ '<(DALI_JS_DIR)/shared/base-wrapped-object.cpp',
+ '<(DALI_JS_DIR)/shared/object-template-helper.cpp',
+ '<(DALI_JS_DIR)/actors/actor-wrapper.cpp',
+ '<(DALI_JS_DIR)/actors/actor-api.cpp',
+ '<(DALI_JS_DIR)/actors/layer-api.cpp',
+ '<(DALI_JS_DIR)/actors/image-actor-api.cpp',
+ '<(DALI_JS_DIR)/actors/camera-actor-api.cpp',
+ '<(DALI_JS_DIR)/constants/constants-wrapper.cpp',
+ '<(DALI_JS_DIR)/animation/animation-api.cpp',
+ '<(DALI_JS_DIR)/animation/animation-wrapper.cpp',
+ '<(DALI_JS_DIR)/animation/constrainer-api.cpp',
+ '<(DALI_JS_DIR)/animation/linear-constrainer-wrapper.cpp',
+ '<(DALI_JS_DIR)/animation/path-api.cpp',
+ '<(DALI_JS_DIR)/animation/path-constrainer-wrapper.cpp',
+ '<(DALI_JS_DIR)/animation/path-wrapper.cpp',
+ '<(DALI_JS_DIR)/stage/stage-wrapper.cpp',
+ '<(DALI_JS_DIR)/events/event-object-generator.cpp',
+ '<(DALI_JS_DIR)/events/pan-gesture-detector-api.cpp',
+ '<(DALI_JS_DIR)/events/pan-gesture-detector-wrapper.cpp',
+ '<(DALI_JS_DIR)/stage/stage-api.cpp',
+ '<(DALI_JS_DIR)/shader-effects/shader-effect-api.cpp',
+ '<(DALI_JS_DIR)/shader-effects/shader-effect-wrapper.cpp',
+ '<(DALI_JS_DIR)/image/image-wrapper.cpp',
+ '<(DALI_JS_DIR)/image/image-api.cpp',
+ '<(DALI_JS_DIR)/image/buffer-image-api.cpp',
+ '<(DALI_JS_DIR)/image/native-image-api.cpp',
+ '<(DALI_JS_DIR)/image/frame-buffer-image-api.cpp',
+ '<(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-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)/toolkit/builder/builder-api.cpp',
+ '<(DALI_JS_DIR)/toolkit/builder/builder-wrapper.cpp',
+ '<(DALI_JS_DIR)/toolkit/focus-manager/keyboard-focus-manager-api.cpp',
+ '<(DALI_JS_DIR)/toolkit/focus-manager/keyboard-focus-manager-wrapper.cpp',
+ '<(DALI_JS_DIR)/signals/dali-any-javascript-converter.cpp',
+ '<(DALI_JS_DIR)/garbage-collector/garbage-collector.cpp',
+ '<(DALI_JS_DIR)/module-loader/module.cpp',
+ '<(DALI_JS_DIR)/module-loader/module-loader.cpp'
+ ],
+ 'cflags': [
+ '-fPIC',
+ '-frtti',
+ '<!@(pkg-config --cflags dali dali-toolkit)'
+ ],
+
+ 'cflags_cc': [
+ '-fexceptions', # Enable exception handler
+ '-frtti' # needed for typeinfo with dali-any
+ ],
+ 'ldflags': [
+ '<!@(pkg-config --libs-only-L --libs-only-other dali dali-toolkit)'
+ ],
+ 'libraries': [
+ '<!@(pkg-config --libs-only-l dali dali-toolkit)'
+ ]
+ }]
+}
--- /dev/null
+# This file is generated by gyp; do not edit.
+
+export builddir_name ?= ./build/.
+.PHONY: all
+all:
+ $(MAKE) dali
--- /dev/null
+# Do not edit. File was generated by node-gyp's "configure" step
+{
+ "target_defaults": {
+ "cflags": [],
+ "default_configuration": "Release",
+ "defines": [],
+ "include_dirs": [],
+ "libraries": []
+ },
+ "variables": {
+ "clang": 0,
+ "gcc_version": 46,
+ "host_arch": "x64",
+ "icu_small": "false",
+ "node_install_npm": "true",
+ "node_prefix": "",
+ "node_shared_cares": "false",
+ "node_shared_http_parser": "false",
+ "node_shared_libuv": "false",
+ "node_shared_openssl": "false",
+ "node_shared_v8": "false",
+ "node_shared_zlib": "false",
+ "node_tag": "",
+ "node_use_dtrace": "false",
+ "node_use_etw": "false",
+ "node_use_mdb": "false",
+ "node_use_openssl": "true",
+ "node_use_perfctr": "false",
+ "openssl_no_asm": 0,
+ "python": "/usr/bin/python",
+ "target_arch": "x64",
+ "uv_library": "static_library",
+ "uv_parent_path": "/deps/uv/",
+ "uv_use_dtrace": "false",
+ "v8_enable_gdbjit": 0,
+ "v8_enable_i18n_support": 0,
+ "v8_no_strict_aliasing": 1,
+ "v8_optimized_debug": 0,
+ "v8_random_seed": 0,
+ "v8_use_snapshot": "true",
+ "want_separate_host_toolset": 0,
+ "nodedir": "/home/likewise-open/SERILOCAL/nick.holland/.node-gyp/0.12.4",
+ "copy_dev_lib": "true",
+ "standalone_static_library": 1
+ }
+}
--- /dev/null
+# This file is generated by gyp; do not edit.
+
+TOOLSET := target
+TARGET := dali
+DEFS_Debug := \
+ '-DNODE_GYP_MODULE_NAME=dali' \
+ '-D_LARGEFILE_SOURCE' \
+ '-D_FILE_OFFSET_BITS=64' \
+ '-DBUILDING_NODE_EXTENSION' \
+ '-DDEBUG' \
+ '-D_DEBUG'
+
+# Flags passed to all source files.
+CFLAGS_Debug := \
+ -fPIC \
+ -pthread \
+ -Wall \
+ -Wextra \
+ -Wno-unused-parameter \
+ -m64 \
+ -fPIC \
+ -frtti \
+ -I/home/likewise-open/SERILOCAL/nick.holland/dali-env/opt/include/dali \
+ -I/home/likewise-open/SERILOCAL/nick.holland/dali-env/opt/include \
+ -g \
+ -O0
+
+# Flags passed to only C files.
+CFLAGS_C_Debug :=
+
+# Flags passed to only C++ files.
+CFLAGS_CC_Debug := \
+ -fno-rtti \
+ -fno-exceptions \
+ -fexceptions \
+ -frtti
+
+INCS_Debug := \
+ -I/home/likewise-open/SERILOCAL/nick.holland/.node-gyp/0.12.4/src \
+ -I/home/likewise-open/SERILOCAL/nick.holland/.node-gyp/0.12.4/deps/uv/include \
+ -I/home/likewise-open/SERILOCAL/nick.holland/.node-gyp/0.12.4/deps/v8/include \
+ -I$(srcdir)/../plugins/dali-script-v8/src \
+ -I$(srcdir)/../plugins/dali-script-v8/src/utils
+
+DEFS_Release := \
+ '-DNODE_GYP_MODULE_NAME=dali' \
+ '-D_LARGEFILE_SOURCE' \
+ '-D_FILE_OFFSET_BITS=64' \
+ '-DBUILDING_NODE_EXTENSION'
+
+# Flags passed to all source files.
+CFLAGS_Release := \
+ -fPIC \
+ -pthread \
+ -Wall \
+ -Wextra \
+ -Wno-unused-parameter \
+ -m64 \
+ -fPIC \
+ -frtti \
+ -I/home/likewise-open/SERILOCAL/nick.holland/dali-env/opt/include/dali \
+ -I/home/likewise-open/SERILOCAL/nick.holland/dali-env/opt/include \
+ -O3 \
+ -ffunction-sections \
+ -fdata-sections \
+ -fno-tree-vrp \
+ -fno-omit-frame-pointer
+
+# Flags passed to only C files.
+CFLAGS_C_Release :=
+
+# Flags passed to only C++ files.
+CFLAGS_CC_Release := \
+ -fno-rtti \
+ -fno-exceptions \
+ -fexceptions \
+ -frtti
+
+INCS_Release := \
+ -I/home/likewise-open/SERILOCAL/nick.holland/.node-gyp/0.12.4/src \
+ -I/home/likewise-open/SERILOCAL/nick.holland/.node-gyp/0.12.4/deps/uv/include \
+ -I/home/likewise-open/SERILOCAL/nick.holland/.node-gyp/0.12.4/deps/v8/include \
+ -I$(srcdir)/../plugins/dali-script-v8/src \
+ -I$(srcdir)/../plugins/dali-script-v8/src/utils
+
+OBJS := \
+ $(obj).target/$(TARGET)/dali-addon.o \
+ $(obj).target/$(TARGET)/javascript-application-options.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/utils/v8-utils.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/dali-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/shared/base-wrapped-object.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/shared/object-template-helper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/actors/actor-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/actors/actor-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/actors/layer-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/actors/image-actor-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/actors/camera-actor-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/constants/constants-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/animation/animation-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/animation/animation-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/animation/constrainer-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/animation/linear-constrainer-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/animation/path-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/animation/path-constrainer-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/animation/path-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/stage/stage-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/events/event-object-generator.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/events/pan-gesture-detector-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/events/pan-gesture-detector-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/stage/stage-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/shader-effects/shader-effect-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/shader-effects/shader-effect-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/image/image-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/image/image-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/image/buffer-image-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/image/native-image-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/image/frame-buffer-image-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/image/resource-image-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/image/nine-patch-image-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/object/handle-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/object/property-value-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/signals/signal-manager.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/render-tasks/render-task-list-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/render-tasks/render-task-list-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/render-tasks/render-task-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/render-tasks/render-task-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/toolkit/builder/builder-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/toolkit/builder/builder-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/toolkit/focus-manager/keyboard-focus-manager-api.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/toolkit/focus-manager/keyboard-focus-manager-wrapper.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/signals/dali-any-javascript-converter.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/garbage-collector/garbage-collector.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/module-loader/module.o \
+ $(obj).target/$(TARGET)/../plugins/dali-script-v8/src/module-loader/module-loader.o
+
+# Add to the list of files we specially track dependencies for.
+all_deps += $(OBJS)
+
+# CFLAGS et al overrides must be target-local.
+# See "Target-specific Variable Values" in the GNU Make manual.
+$(OBJS): TOOLSET := $(TOOLSET)
+$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
+$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
+
+# Suffix rules, putting all outputs into $(obj).
+
+$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+
+# Try building from generated source, too.
+
+$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+
+$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cpp FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+
+# End of this set of suffix rules
+### Rules for final target.
+LDFLAGS_Debug := \
+ -pthread \
+ -rdynamic \
+ -m64 \
+ -L/home/likewise-open/SERILOCAL/nick.holland/dali-env/opt/lib
+
+LDFLAGS_Release := \
+ -pthread \
+ -rdynamic \
+ -m64 \
+ -L/home/likewise-open/SERILOCAL/nick.holland/dali-env/opt/lib
+
+LIBS := \
+ -ldali-adaptor \
+ -ldali-toolkit \
+ -ldali-core
+
+$(obj).target/dali.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
+$(obj).target/dali.node: LIBS := $(LIBS)
+$(obj).target/dali.node: TOOLSET := $(TOOLSET)
+$(obj).target/dali.node: $(OBJS) FORCE_DO_CMD
+ $(call do_cmd,solink_module)
+
+all_deps += $(obj).target/dali.node
+# Add target alias
+.PHONY: dali
+dali: $(builddir)/dali.node
+
+# Copy this to the executable output path.
+$(builddir)/dali.node: TOOLSET := $(TOOLSET)
+$(builddir)/dali.node: $(obj).target/dali.node FORCE_DO_CMD
+ $(call do_cmd,copy)
+
+all_deps += $(builddir)/dali.node
+# Short alias for building this executable.
+.PHONY: dali.node
+dali.node: $(obj).target/dali.node $(builddir)/dali.node
+
+# Add executable to "all" target.
+.PHONY: all
+all: $(builddir)/dali.node
+
--- /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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <node.h>
+#include <public-api/dali-core.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <integration-api/core.h>
+#include <integration-api/adaptors/adaptor.h>
+#include <public-api/adaptor-framework/window.h>
+#include <devel-api/adaptor-framework/singleton-service.h>
+
+// INTERNAL INCLUDES
+#include <dali-wrapper.h>
+#include "javascript-application-options.h"
+
+using namespace Dali;
+
+namespace DaliNodeAddon
+{
+
+class DaliApplication
+{
+public:
+
+ DaliApplication()
+ : mInitialized( false),
+ mSingletonService(SingletonService::New()),
+ mAdaptor( NULL )
+ {
+ }
+
+ ~DaliApplication()
+ {
+ mSingletonService.UnregisterAll();
+ delete mAdaptor;
+ mWindow.Reset();
+ }
+
+ bool Initialized() const
+ {
+ return mInitialized;
+ }
+
+ void Initialize( ApplicationOptions options )
+ {
+ if( mInitialized )
+ {
+ return;
+ }
+
+ // 1. Create the window ( adaptor requires a window)
+ const WindowOptions& window( options.window);
+
+ mWindow = Window::New( window.positionSize, window.name, window.transparent );
+
+ // 2. create the adaptor
+ Adaptor* adaptor = &Adaptor::New( mWindow );
+
+ // 3. start the adaptor
+ adaptor->Start();
+
+ // Set the view modes
+
+ if( options.stereo.viewMode > Dali::MONO )
+ {
+ adaptor->SetStereoBase( options.stereo.stereoBase );
+ adaptor->SetViewMode( options.stereo.viewMode );
+ }
+
+ // fire the scene create signal
+ adaptor->SceneCreated();
+
+ mInitialized = true;
+ }
+private:
+
+ bool mInitialized;
+ SingletonService mSingletonService;
+ Adaptor* mAdaptor;
+ Window mWindow;
+
+};
+
+DaliApplication app;
+
+void CreateDali(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope scope(isolate);
+
+ ApplicationOptions options;
+
+ bool ok = GetApplicationOptions( args, options);
+ if (!ok )
+ {
+ isolate->ThrowException( v8::Exception::TypeError( v8::String::NewFromUtf8(isolate, "Please check arguments passed to DALi require") ) );
+ return;
+ }
+
+ app.Initialize( options );
+
+ // the return value from calling the function require('dali.js)( options )
+ // is the dali object
+ args.GetReturnValue().Set( V8Plugin::DaliWrapper::CreateWrapperForNodeJS( isolate ) );
+}
+
+
+/**
+ * We make module.exports a function so that the developer can pass to
+ * parameters to DALi when it's 'required'
+ * E.g
+ *
+ *
+ * var window= {
+ * x:10,
+ * y:10,
+ * width:800,
+ * height: 600,
+ * transparent: false,
+ * name:'my-first-dali-app'
+ * };
+ *
+ * var viewMode {
+ * 'stereoscopic-mode':'stereo-vertical', // 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,
+ * 'style-sheet': 'my-theme.json'
+ * }
+ *
+ * var dali = require('dali.js')( options )
+ *
+ *
+ */
+void ExportDaliModule(v8::Handle<v8::Object> exports, v8::Handle<v8::Object> module)
+{
+ NODE_SET_METHOD(module, "exports", CreateDali);
+}
+
+} // namespace DaliNodeAddon
+
+NODE_MODULE(dali, DaliNodeAddon::ExportDaliModule)
+
+
+
+
--- /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.
+ *
+ */
+
+// HEADER
+#include "javascript-application-options.h"
+
+// EXTERNAL INCLUDES
+#include <cstring>
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+
+namespace DaliNodeAddon
+{
+
+namespace
+{
+
+struct StereoInfo
+{
+ const char* const name;
+ Dali::ViewMode mode;
+};
+StereoInfo StereoModeTable[] = {
+ { "mono", Dali::MONO},
+ { "stereo-horizontal", Dali::STEREO_HORIZONTAL },
+ { "stereo-vertical", Dali::STEREO_VERTICAL },
+ { "stereo-interlaced", Dali::STEREO_INTERLACED },
+};
+
+const unsigned int numberViewModes = sizeof( StereoModeTable ) / sizeof( StereoModeTable[0] );
+
+bool GetViewMode( const std::string& modeString, Dali::ViewMode& mode )
+{
+ for( unsigned int i = 0; i < numberViewModes; ++i )
+ {
+ const StereoInfo& info (StereoModeTable[i]);
+
+ if( strcmp ( modeString.c_str() , info.name ) == 0 )
+ {
+ mode = info.mode;
+ return true;
+ }
+ }
+ // mode not found
+ mode = Dali::MONO;
+ return false;
+}
+
+
+// Note we can't parse the enviroment options for window width / height because
+// adaptor which holds the environment option class has not been created
+// and we can't create it, until we have a window
+bool ParseWindowOptions( v8::Isolate* isolate, const v8::Local<v8::Object>& obj, WindowOptions& window )
+{
+ v8::HandleScope scope(isolate);
+
+ v8::Local<v8::Value> xValue = obj->Get( v8::String::NewFromUtf8( isolate, "x" ) );
+ v8::Local<v8::Value> yValue = obj->Get( v8::String::NewFromUtf8( isolate, "y" ) );
+ v8::Local<v8::Value> widthValue = obj->Get( v8::String::NewFromUtf8( isolate, "width" ) );
+ v8::Local<v8::Value> heightValue = obj->Get( v8::String::NewFromUtf8( isolate, "height" ) );
+ v8::Local<v8::Value> nameValue = obj->Get( v8::String::NewFromUtf8( isolate, "name" ) );
+ v8::Local<v8::Value> transparencyValue = obj->Get( v8::String::NewFromUtf8( isolate, "transparent" ) );
+
+ // if x,y are optional
+ if( xValue->IsUint32() )
+ {
+ window.positionSize.x = xValue->ToUint32()->Value();
+ }
+ if( yValue->IsUint32() )
+ {
+ window.positionSize.y = yValue->ToUint32()->Value();
+ }
+
+ // width and height are optional but will only accept them if they are both set
+ if( widthValue->IsUint32() && heightValue->IsUint32() )
+ {
+ window.positionSize.width = widthValue->ToUint32()->Value();
+ window.positionSize.height = heightValue->ToUint32()->Value();
+ }
+
+ // get the window name
+ if( nameValue->IsString() )
+ {
+ window.name = Dali::V8Plugin::V8Utils::v8StringToStdString( nameValue );
+ }
+ else
+ {
+ window.name ="DALi application";
+ }
+
+ if( transparencyValue->IsBoolean() )
+ {
+ window.transparent = transparencyValue->ToBoolean()->Value();
+ }
+ return true;
+}
+
+bool ParseStereoScopicOptions( v8::Isolate* isolate, const v8::Local<v8::Object>& stereoObject, StereoScopicOptions& options )
+{
+ v8::HandleScope scope(isolate);
+
+ v8::Local<v8::Value> modeValue = stereoObject->Get( v8::String::NewFromUtf8( isolate, "stereoscopic-mode" ) );
+ v8::Local<v8::Value> stereoBaseValue = stereoObject->Get( v8::String::NewFromUtf8( isolate, "stereo-base" ) );
+
+ if( !modeValue->IsString() )
+ {
+ return true;
+ }
+
+ std::string mode = Dali::V8Plugin::V8Utils::v8StringToStdString( modeValue );
+ bool ok = GetViewMode( mode, options.viewMode);
+ if( !ok )
+ {
+ return false;
+ }
+ if( stereoBaseValue->IsNumber() )
+ {
+ options.stereoBase = stereoBaseValue->ToNumber()->Value();
+ }
+
+ return true;
+}
+
+} // unnamed namespace
+
+bool GetApplicationOptions(const v8::FunctionCallbackInfo<v8::Value>& args, ApplicationOptions& options )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope scope(isolate);
+ bool ok( false );
+
+ if( !args[ 0 ]->IsObject() )
+ {
+ return false;
+ }
+
+ v8::Local<v8::Object> object = args[ 0 ]->ToObject();
+
+ // get the window settings
+ v8::Local<v8::Value> windowValue= object->Get( v8::String::NewFromUtf8( isolate, "window" ) );
+ if( windowValue->IsObject() )
+ {
+ ok = ParseWindowOptions( isolate, windowValue->ToObject(), options.window );
+ if( !ok )
+ {
+ return false; // missing window size
+ }
+ }
+
+ // get the stereoscopic settings
+ v8::Local<v8::Value> stereoValue= object->Get( v8::String::NewFromUtf8( isolate, "view-mode" ) );
+ if( stereoValue->IsObject() )
+ {
+ ok = ParseStereoScopicOptions( isolate, stereoValue->ToObject(), options.stereo );
+ if( !ok )
+ {
+ return false; // incorrect stereoscopic mode
+ }
+ }
+
+ // get the style sheet
+ v8::Local<v8::Value> stylesheetValue= object->Get( v8::String::NewFromUtf8( isolate, "style-sheet" ) );
+ if( stylesheetValue->IsString() )
+ {
+ options.stylesheet = Dali::V8Plugin::V8Utils::v8StringToStdString( stylesheetValue );
+ }
+
+ return true;
+}
+
+} // namespace DaliNodeAddon
--- /dev/null
+#ifndef __DALI_JAVASCRIPT_APPLICATION_OPTIONS_H__
+#define __DALI_JAVASCRIPT_APPLICATION_OPTIONS_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.
+ *
+ */
+
+#include <public-api/dali-core.h>
+#include <public-api/adaptor-framework/window.h>
+#include <v8.h>
+
+namespace DaliNodeAddon
+{
+
+struct WindowOptions
+{
+ WindowOptions()
+ : positionSize(0,0,0,0)
+ {
+ }
+
+ std::string name;
+ Dali::PositionSize positionSize;
+ bool transparent:1;
+};
+
+struct StereoScopicOptions
+{
+ StereoScopicOptions()
+ : viewMode(Dali::MONO),
+ stereoBase(65.f)
+ {
+ }
+
+ Dali::ViewMode viewMode;
+ float stereoBase;
+};
+
+struct ApplicationOptions
+{
+ WindowOptions window;
+ StereoScopicOptions stereo;
+ std::string stylesheet;
+};
+
+/**
+ * @brief parse the dali JavaScript application options
+ * The options are passed to dali when require is called.
+ * E.g. var dali.require('dali.js)( {options object} )
+ *
+ * @param[in] args JavaScript arguments
+ * @param[out] options assigned Dali options
+ * @return true on success, false on failure
+ *
+ */
+bool GetApplicationOptions( const v8::FunctionCallbackInfo<v8::Value>& args, ApplicationOptions& options );
+
+
+} // namespace DaliNodeAddon
+
+
+
+#endif // __DALI_JAVASCRIPT_APPLICATION_OPTIONS_H__
--- /dev/null
+{
+ "name": "dali",
+ "version": "0.0.0",
+ "description": "DALi 3D Engine addon",
+ "main": "index.js",
+ "gypfile": "true",
+ "scripts": {
+ "preinstall" : "./configure",
+ "install" : "make && make install",
+ "test" : "node test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "review.tizen.org:29418/platform/core/uifw/dali-core"
+ },
+ "keywords": [
+ "dali",
+ "3D",
+ "engine",
+ "OpenGL",
+ "user interface"
+ ],
+ "author": "Samsung",
+ "license": "http://www.apache.org/licenses/LICENSE-2.0"
+}
--- /dev/null
+ var window= {
+ x:800,
+ y:500,
+ width:880,
+ height: 1020,
+ transparent: false,
+ name:'my-first-dali-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 netflixRoulette = require('netflix-roulette');
+
+
+var NUMBER_OF_IMAGES = 40; // for now use 16 ( demo files go up to 30)
+var DEMO_IMAGES = []; // array to store Dali Images
+var VIDEO_WALL_ACTORS = []; // array to store Image actors
+var VIDEO_WALL_ROWS = 5; // use 3 rows for the video wall
+var VIDEO_WALL_COLUMNS = 6; // use 12 columns for the video wall
+var VIDEO_WALL_TOTAL_ITEMS = VIDEO_WALL_COLUMNS * VIDEO_WALL_ROWS; // total items
+var VIDEO_WALL_ITEM_SIZE = 128; // width / height of a item in the video wall
+var BORDER_SIZE = 5;
+var VIDEO_WALL_ITEM_SIZE_NO_BORDER = VIDEO_WALL_ITEM_SIZE - BORDER_SIZE;
+var VIDEO_WALL_WIDTH = VIDEO_WALL_COLUMNS * VIDEO_WALL_ITEM_SIZE;
+var VIDEO_WALL_HEIGHT = VIDEO_WALL_ROWS * VIDEO_WALL_ITEM_SIZE;
+var daliApp = {};
+var posters = [];
+
+var wallRootActor; // the root actor of the video wall
+
+
+daliApp.loadNetflixImages = function() {
+
+ if( NUMBER_OF_IMAGES >= VIDEO_WALL_TOTAL_ITEMS)
+ {
+ NUMBER_OF_IMAGES = VIDEO_WALL_TOTAL_ITEMS-1;
+ }
+
+ for (index = 0; index < NUMBER_OF_IMAGES; ++index) {
+
+ fileName = posters[ index % (posters.length-1) ];
+ if ( fileName )
+ {
+ DEMO_IMAGES[index] = new dali.ResourceImage( { url:fileName } );
+ }
+ }
+}
+
+
+daliApp.createRootActor = function() {
+ wallRootActor = new dali.Actor();
+ wallRootActor.parentOrigin = dali.CENTER;
+ wallRootActor.anchorPoint = dali.CENTER;
+ dali.stage.add(wallRootActor);
+
+ var field = new dali.Control("TextField");
+ field.parentOrigin = dali.CENTER;
+ field.anchorPoint = dali.CENTER;
+
+ field.placeholderText = "DALi netflix netflix-roulette demo";
+ dali.stage.add( field );
+}
+
+
+
+daliApp.getWallActorIndex = function(x, y) {
+ return x + y * VIDEO_WALL_COLUMNS;
+}
+
+daliApp.createActors = function() {
+ daliApp.createRootActor();
+
+ var anim = new dali.Animation(1);
+ var animOptions = {
+ alpha: "linear",
+ delay: 0.0, // used to delay the start of the animation
+ duration: 1, // duration of the animation
+ };
+
+ for (y = 0; y < VIDEO_WALL_ROWS; ++y) {
+ for (x = 0; x < VIDEO_WALL_COLUMNS; ++x) {
+
+ var actorIndex = daliApp.getWallActorIndex(x, y);
+ var imageActor = new dali.ImageActor();
+
+ // wrap image index between 0 and NUMBER_OF_IMAGES
+ var imageIndex = actorIndex % NUMBER_OF_IMAGES;
+
+ imageActor.setImage(DEMO_IMAGES[imageIndex]);
+
+ imageActor.parentOrigin = dali.CENTER;
+ imageActor.anchorPoint = dali.CENTER;
+ imageActor.size = [VIDEO_WALL_ITEM_SIZE_NO_BORDER, VIDEO_WALL_ITEM_SIZE_NO_BORDER, 1.0]; // start with zero size so it zooms up
+
+ var xPosition = x * VIDEO_WALL_ITEM_SIZE;
+ // as the middle the wall is at zero (relative to wallRootActor), we need to subtract half the wall width.
+ // + add half item size because the item anchor point is the center of the wallRootActor.
+ xPosition = xPosition - (VIDEO_WALL_WIDTH / 2) + (VIDEO_WALL_ITEM_SIZE / 2);
+
+ var yPosition = y * VIDEO_WALL_ITEM_SIZE;
+ yPosition = yPosition - (VIDEO_WALL_HEIGHT / 2) + (VIDEO_WALL_ITEM_SIZE / 2);
+
+ imageActor.position = [0,0,0];
+
+ animOptions.delay+=0.25;
+ anim.animateTo( imageActor,"position",[xPosition, yPosition, 0.0],animOptions);
+ // store the actor
+ VIDEO_WALL_ACTORS[actorIndex] = imageActor;
+
+ // Add to the video wall root actor.
+ wallRootActor.add(imageActor);
+ }
+ }
+ anim.play();
+}
+
+function Initialise() {
+
+ daliApp.loadNetflixImages();
+
+ daliApp.createActors();
+}
+
+function actorLoaded( error, data )
+{
+ for( i = 0; i < data.length; ++i )
+ {
+ var entry = data[i];
+
+ if( entry.poster )
+ {
+ posters.push(entry.poster);
+ //console.log(" entry = " + entry.poster );
+ }
+ }
+ Initialise();
+
+}
+
+
+netflixRoulette.actor('nicolas', actorLoaded );
+
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.0.47
+Version: 1.0.48
Release: 1
Group: System/Libraries
License: Apache-2.0
BuildRequires: pkgconfig(dali)
BuildRequires: pkgconfig(dali-core)
+#############################
+# profile setup
+#############################
+
+%define dali_toolkit_profile MOBILE
+
+# Further resource locations profiles can be provided here otherwise MOBILE will be used
+%if "%{tizen_profile_name}" == "mobile"
+ %define dali_toolkit_profile MOBILE
+%endif
+
%description
The OpenGLES Canvas Core Library Toolkit - a set of controls that provide
user interface functionality.
autoreconf --install
DALI_DATA_RW_DIR="%{dali_data_rw_dir}" ; export DALI_DATA_RW_DIR
DALI_DATA_RO_DIR="%{dali_data_ro_dir}" ; export DALI_DATA_RO_DIR
-%configure
+%configure --enable-profile=%{dali_toolkit_profile}
make %{?jobs:-j%jobs}
##############################
v8::Persistent<v8::ObjectTemplate> ActorWrapper::mImageActorTemplate;
v8::Persistent<v8::ObjectTemplate> ActorWrapper::mCameraActorTemplate;
v8::Persistent<v8::ObjectTemplate> ActorWrapper::mLayerActorTemplate;
-v8::Persistent<v8::ObjectTemplate> ActorWrapper::mTextLabelTemplate;
namespace
{
{ &ActorWrapper::mActorTemplate }, // ACTOR
{ &ActorWrapper::mImageActorTemplate }, // IMAGE_ACTOR
{ &ActorWrapper::mLayerActorTemplate }, // LAYER_ACTOR
- { &ActorWrapper::mCameraActorTemplate}, // CAMERA_ACTOR
- { &ActorWrapper::mTextLabelTemplate }
+ { &ActorWrapper::mCameraActorTemplate} // CAMERA_ACTOR
};
/**
/**
* Lookup table to match a actor type with a constructor and supported API's.
+ * HandleWrapper::ActorType is used to index this table
*/
const ActorApiStruct ActorApiLookup[]=
{
{"ImageActor", ActorWrapper::IMAGE_ACTOR, ImageActorApi::New, ACTOR_API | IMAGE_ACTOR_API },
{"Layer", ActorWrapper::LAYER_ACTOR, LayerApi::New, ACTOR_API | LAYER_API },
{"CameraActor",ActorWrapper::CAMERA_ACTOR, CameraActorApi::New, ACTOR_API | CAMERA_ACTOR_API },
- {"TextLabel", ActorWrapper::TEXT_LABEL, TextLabelApi::New, ACTOR_API },
-
};
const unsigned int ActorApiLookupCount = sizeof(ActorApiLookup)/sizeof(ActorApiLookup[0]);
// if we don't currently support the actor type, then use type registry to create it
if( actorType == ActorWrapper::UNKNOWN_ACTOR )
{
- Dali::TypeInfo typeInfo = Dali::TypeRegistry::Get().GetTypeInfo( typeName );
- if( typeInfo ) // handle, check if it has a value
- {
- Dali::BaseHandle handle = typeInfo.CreateInstance();
- if( handle )
- {
- actor = Actor::DownCast( handle );
- }
- }
- else
- {
- DALI_SCRIPT_EXCEPTION(args.GetIsolate(),"Unknown actor type");
+ DALI_SCRIPT_EXCEPTION( args.GetIsolate(), "Unknown actor type" );
return Actor();
- }
}
else
{
args.GetReturnValue().Set( localObject );
}
+void ActorWrapper::NewControl( const v8::FunctionCallbackInfo< v8::Value >& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ if( !args.IsConstructCall() )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "constructor called without 'new" );
+ return;
+ }
+
+ bool found( false );
+ std::string controlName = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args );
+
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing control name" );
+ return;
+ }
+ Actor control;
+ Dali::TypeInfo typeInfo = Dali::TypeRegistry::Get().GetTypeInfo( controlName );
+ if( typeInfo ) // handle, check if it has a value
+ {
+ Dali::BaseHandle handle = typeInfo.CreateInstance();
+ if( handle )
+ {
+ control = Actor::DownCast( handle );
+ }
+ }
+
+ v8::Local<v8::Object> localObject = WrapActor( isolate, control, ACTOR );
+
+ args.GetReturnValue().Set( localObject );
+}
+
+
/**
* given an actor type name, e.g. ImageActor returns the type, e.g. ActorWrapper::IMAGE_ACTOR
*/
public:
/**
- * Actor type used an index
+ * Actor type used an index.
+ * These enums are used to index the ActorApiLookup table in actor-wrapper.cpp.
+ * Any changes made must be reflected in the ActorApiLookup otherwise it may segfault when creating an actor
*/
enum ActorType
{
UNKNOWN_ACTOR = -1,
- ACTOR = 0,
- IMAGE_ACTOR =1,
- MESH_ACTOR =2,
- LAYER_ACTOR =3,
- CAMERA_ACTOR =4,
- TEXT_LABEL =5
+ ACTOR = 0,
+ IMAGE_ACTOR = 1,
+ LAYER_ACTOR = 2,
+ CAMERA_ACTOR = 3
};
/**
static void NewActor( const v8::FunctionCallbackInfo< v8::Value >& args);
/**
+ * @brief Creates a new Control wrapped inside a Javascript Object.
+ * @note: the control type is passed as a parameter e.g. 'TextField'
+ * @param[in] args v8 function call arguments interpreted
+ */
+ static void NewControl( const v8::FunctionCallbackInfo< v8::Value >& args);
+
+ /**
* @brief Wraps an actor of a given type
*/
static v8::Handle<v8::Object> WrapActor(v8::Isolate* isolate, Dali::Actor actor,ActorType actorType);
// The Actor ObjectTemplates.
static v8::Persistent<v8::ObjectTemplate> mActorTemplate;
static v8::Persistent<v8::ObjectTemplate> mImageActorTemplate;
- static v8::Persistent<v8::ObjectTemplate> mMeshActorTemplate;
static v8::Persistent<v8::ObjectTemplate> mCameraActorTemplate;
static v8::Persistent<v8::ObjectTemplate> mLayerActorTemplate;
- static v8::Persistent<v8::ObjectTemplate> mTextLabelTemplate;
/**
* @return the wrapped actor
{ "MeshActor", ActorWrapper::NewActor },
{ "CameraActor", ActorWrapper::NewActor },
{ "Layer", ActorWrapper::NewActor },
- { "TextView", ActorWrapper::NewActor },
+ { "Control", ActorWrapper::NewControl },
{ "ResourceImage", ImageWrapper::NewImage },
{ "BufferImage", ImageWrapper::NewImage },
{ "NinePatchImage", ImageWrapper::NewImage },
bool DaliWrapper::mInstanceCreated = false;
DaliWrapper* DaliWrapper::mWrapper = NULL;
-DaliWrapper::DaliWrapper()
-:mIsolate( NULL )
+DaliWrapper::DaliWrapper( RunMode runMode, v8::Isolate* isolate )
+:mIsolate( isolate ),
+ mRunMode(runMode)
{
}
DaliWrapper& DaliWrapper::Get()
{
- if(!mInstanceCreated)
+ if( !mInstanceCreated )
{
- mWrapper = new DaliWrapper();
+ mWrapper = new DaliWrapper( RUNNING_STANDALONE, NULL );
+
mInstanceCreated = true;
- if(mWrapper)
- {
- mWrapper->Initialize();
- }
- }
+ mWrapper->InitializeStandAlone();
+ }
return *mWrapper;
}
+v8::Local<v8::Object> DaliWrapper::CreateWrapperForNodeJS( v8::Isolate* isolate )
+{
+ v8::EscapableHandleScope handleScope( isolate);
+
+ mInstanceCreated = true;
+
+ mWrapper = new DaliWrapper( RUNNING_IN_NODE_JS, isolate );
+
+ v8::Local<v8::Object> dali = mWrapper->CreateDaliObject();
+
+ // As we running inside node, we already have an isolate and context
+ return handleScope.Escape( dali );
+}
+
+v8::Local<v8::Object> DaliWrapper::CreateDaliObject()
+{
+ v8::EscapableHandleScope handleScope( mIsolate );
+
+ // Create dali object used for creating objects, and accessing constant values
+ // e.g. var x = new dali.Actor(), or var col = dali.COLOR_RED;
+
+ v8::Local<v8::ObjectTemplate> daliObjectTemplate = NewDaliObjectTemplate( mIsolate );
+
+ // add dali.staqe
+ v8::Local<v8::Object> stageObject = StageWrapper::WrapStage( mIsolate, Stage::GetCurrent() );
+ daliObjectTemplate->Set( v8::String::NewFromUtf8( mIsolate, "stage") , stageObject );
+
+ v8::Local<v8::Object> keyboardObject = KeyboardFocusManagerWrapper::WrapKeyboardFocusManager( mIsolate,Toolkit::KeyboardFocusManager::Get() );
+ daliObjectTemplate->Set( v8::String::NewFromUtf8( mIsolate, "keyboardFocusManager") , keyboardObject );
+
+
+ //create an instance of the template
+ v8::Local<v8::Object> daliObject = daliObjectTemplate->NewInstance();
+
+ ConstantsWrapper::AddDaliConstants( mIsolate, daliObject);
+
+ daliObject->Set( v8::String::NewFromUtf8( mIsolate, "V8_VERSION") ,v8::String::NewFromUtf8( mIsolate, v8::V8::GetVersion() ));
+
+ return handleScope.Escape( daliObject );
+}
+
+
void DaliWrapper::SetFlagsFromString(const std::string &flags)
{
v8::V8::SetFlagsFromString(flags.c_str(), flags.size());
void DaliWrapper::Shutdown()
{
+ // if we're running inside node then we don't have ownership of the context
+ if( mRunMode == RUNNING_IN_NODE_JS )
+ {
+ return;
+ }
+
DALI_LOG_WARNING("Destroying V8 DALi context\n");
if( !mContext.IsEmpty())
return mGarbageCollector;
}
-void DaliWrapper::CreateContext( )
+void DaliWrapper::ApplyGlobalObjectsToContext( v8::Local<v8::Context> context )
{
v8::HandleScope handleScope( mIsolate );
- // Create a global JavaScript object so we can set built-in global functions, like Log.
- v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New( mIsolate );
+ // Add global objects ( functions/ values ) e.g. log function
+ // create a console.log and console.error functions
+ v8::Local<v8::ObjectTemplate> consoleObjectTemplate = v8::ObjectTemplate::New( mIsolate );
+ consoleObjectTemplate->Set( v8::String::NewFromUtf8( mIsolate, "log"), v8::FunctionTemplate::New( mIsolate, V8Utils::Log));
+ consoleObjectTemplate->Set( v8::String::NewFromUtf8( mIsolate, "error"), v8::FunctionTemplate::New( mIsolate, V8Utils::LogError));
- // Add global objects ( functions/ values ) e.g. log function and V8_VERSION
- global->Set( v8::String::NewFromUtf8( mIsolate, "log"), v8::FunctionTemplate::New( mIsolate, V8Utils::Log) );
- global->Set( v8::String::NewFromUtf8( mIsolate, "logError"), v8::FunctionTemplate::New( mIsolate, V8Utils::LogError) );
- global->Set( v8::String::NewFromUtf8( mIsolate, "require"), v8::FunctionTemplate::New( mIsolate, DaliWrapper::Require));
- global->Set( v8::String::NewFromUtf8( mIsolate, "V8_VERSION") ,v8::String::NewFromUtf8( mIsolate, v8::V8::GetVersion() ));
+ context->Global()->Set( v8::String::NewFromUtf8( mIsolate, "console"), consoleObjectTemplate->NewInstance() );
- // add the dali object to it, assume it won't be garbage collected until global is deleted
- global->Set(v8::String::NewFromUtf8( mIsolate, DALI_API_NAME) , NewDaliObjectTemplate( mIsolate ));
+ // add require functionality
+ context->Global()->Set( v8::String::NewFromUtf8( mIsolate, "require"), v8::FunctionTemplate::New( mIsolate, DaliWrapper::Require)->GetFunction());
+ // Create the Dali object
+ // @todo consider forcing developers to perform require('dali') if we want to avoid polluting the global namespace
+ v8::Local<v8::Object> daliObject = CreateDaliObject();
- // create a new context.
- // Isolate = isolated copy of the V8 including a heap manager, a garbage collector
- // Only 1 thread can access a single Isolate at a given time. However, multiple Isolates can be run in parallel.
- // Context = multiple contexts can exist in a given Isolate, and share data between contexts
- v8::Handle<v8::Context> context = v8::Context::New( mIsolate, NULL, global);
+ // allow developers to require('dali'); // this is to maintain compatibility with node.js where dali is not part of the global namespace
+ mModuleLoader.StorePreBuiltModule( mIsolate, daliObject, DALI_API_NAME );
- mGlobalObjectTemplate.Reset( mIsolate, global);
+ context->Global()->Set( v8::String::NewFromUtf8( mIsolate, DALI_API_NAME),daliObject );
- mContext.Reset( mIsolate, context);
}
-void DaliWrapper::Initialize()
+void DaliWrapper::InitializeStandAlone()
{
if( !mIsolate )
{
// default isolate removed from V8 version 3.27.1 and beyond.
mIsolate = v8::Isolate::New();
+
mIsolate->Enter();
v8::V8::SetFatalErrorHandler( FatalErrorCallback );
-
}
+
// if context is null, create it and add dali object to the global object.
if( mContext.IsEmpty())
{
v8::HandleScope handleScope( mIsolate );
- CreateContext();
- v8::Local<v8::Context> context = v8::Local<v8::Context>::New(mIsolate, mContext);
-
- context->Enter();
- // Add the dali global object. Used for creating objects, and accessing constant values
- // e.g. var x = new dali.ImageActor(), or var col = dali.COLOR_RED;
+ // create a new context.
+ // Isolate = isolated copy of the V8 including a heap manager, a garbage collector
+ // Only 1 thread can access a single Isolate at a given time. However, multiple Isolates can be run in parallel.
+ // Context = multiple contexts can exist in a given Isolate, and share data between contexts
+ v8::Local<v8::Context> context = v8::Context::New( mIsolate );
- v8::Local<v8::Object> daliObject = v8::Local<v8::Object>::Cast( context->Global()->Get( v8::String::NewFromUtf8( mIsolate, DALI_API_NAME)));
-
- v8::Local<v8::Object> stageObject = StageWrapper::WrapStage( mIsolate, Stage::GetCurrent() );
- daliObject->Set( v8::String::NewFromUtf8( mIsolate, "stage") , stageObject );
-
- // keyboard focus manager is a singleton
- v8::Local<v8::Object> keyboardObject = KeyboardFocusManagerWrapper::WrapKeyboardFocusManager( mIsolate,Toolkit::KeyboardFocusManager::Get() );
- daliObject->Set( v8::String::NewFromUtf8( mIsolate, "keyboardFocusManager") , keyboardObject );
+ context->Enter();
- ConstantsWrapper::AddDaliConstants( mIsolate, daliObject);
+ // Apply global objects like dali and console to the context
+ ApplyGlobalObjectsToContext(context);
+ mContext.Reset( mIsolate, context);
}
+
DALI_LOG_INFO( gLogExecuteFilter, Debug::Verbose, "V8 Library %s loaded \n", v8::V8::GetVersion() );
}
+
v8::Handle<v8::ObjectTemplate> DaliWrapper::NewDaliObjectTemplate( v8::Isolate* isolate )
{
v8::EscapableHandleScope handleScope( isolate );
objTemplate->Set( v8::String::NewFromUtf8( isolate, "BUILD"),
v8::String::NewFromUtf8( isolate, "Dali binary built on:" __DATE__ ", at " __TIME__));
-
+#ifdef DALI_DATA_READ_ONLY_DIR
// add the data data directory,
objTemplate->Set( v8::String::NewFromUtf8( isolate, "DALI_DATA_DIRECTORY"),
- v8::String::NewFromUtf8( isolate, DALI_DATA_READ_ONLY_DIR));
-
+ v8::String::NewFromUtf8( isolate, DALI_DATA_READ_ONLY_DIR));
+#endif
// add our constructor functions
ObjectTemplateHelper::InstallFunctions( isolate,
objTemplate,
void DaliWrapper::Require(const v8::FunctionCallbackInfo< v8::Value >& args)
{
DaliWrapper& wrapper( DaliWrapper::Get() );
- wrapper.mModuleLoader.Require( args, wrapper.mGlobalObjectTemplate );
+ wrapper.mModuleLoader.Require( args );
}
-
-
} // namespace V8Plugin
} // namespace Dali
// INTERNAL INCLUDES
#include <garbage-collector/garbage-collector.h>
+
#include <module-loader/module-loader.h>
namespace Dali
*/
class DALI_INTERNAL DaliWrapper
{
+
public:
/**
- * Constructor
+ * @brief whether the wrapper is running in standalone using V8,
+ * or inside Node.JS using V8
*/
- DaliWrapper();
+ enum RunMode
+ {
+ RUNNING_STANDALONE,
+ RUNNING_IN_NODE_JS
+ };
+
+ /**
+ * @brief Constructor
+ * @param[in] runMode whether the wrapper is running standalone or inside Node.JS
+ * @param[in] isolate v8 isolate ( can be null if running standalone )
+ */
+ DaliWrapper( RunMode runMode, v8::Isolate* isolate );
/**
* non virtual destructor, not intended as a base class
static DaliWrapper& Get();
/**
+ * Intialize DaliWrapper for running inside NodeJS
+ */
+ static v8::Local<v8::Object> CreateWrapperForNodeJS( v8::Isolate* isolate);
+
+
+ /**
* Set V8 engine configuration flags
*
* @param[in] flags Configruation flags (See v8 documentation)
private:
/**
- * Create V8 context
+ * @brief Apply global objects like console.log and require() to the context
*/
- void CreateContext();
+ void ApplyGlobalObjectsToContext( v8::Local<v8::Context> context );
/**
- * Initialize DaliWrapper
+ * @brief Initialize DaliWrapper for running standalone
+ * Creates a new isolate
+ *
*/
- void Initialize();
+ void InitializeStandAlone();
+
+ /**
+ * @brief create dali namespace/object
+ */
+ v8::Local<v8::Object> CreateDaliObject();
/**
* Create Dali ObjectTemplate
GarbageCollector mGarbageCollector; ///< DALi garbage collector
ModuleLoader mModuleLoader; ///< Module loader
v8::Persistent<v8::Context> mContext; ///< A sandboxed execution context with its own set of built-in objects and functions.
- v8::Persistent<v8::ObjectTemplate> mGlobalObjectTemplate; ///< Global object template for storing things like dali global object
v8::Isolate* mIsolate; ///< represents an isolated instance of the V8 engine.
-
+ RunMode mRunMode;
};
ModuleLoader::ModuleLoader()
{
-
}
ModuleLoader::~ModuleLoader()
* @for ModuleLoader
*
*/
-void ModuleLoader::Require(const v8::FunctionCallbackInfo< v8::Value >& args,
-
- v8::Persistent<v8::ObjectTemplate>& globalObjectTemplate )
+void ModuleLoader::Require(const v8::FunctionCallbackInfo< v8::Value >& args )
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate );
args.GetReturnValue().Set( moduleExports );
}
+
+void ModuleLoader::StorePreBuiltModule( v8::Isolate* isolate, v8::Local<v8::Object>& exportObject, const std::string& name )
+{
+ StoreModule( "", name, name, isolate, exportObject );
+}
+
void ModuleLoader::StoreScriptInfo( const std::string& sourceFileName )
{
V8Utils::GetFileDirectory( sourceFileName, mCurrentScriptPath);
public:
/**
- * Constructor
+ * @brief Constructor
+ * @param[in] isolate v8 isolate
+ * @param[in] daliObject dali exports object, used when developer does require('dali');
*/
ModuleLoader();
/**
- * non virtual destructor, not intended as a base class
+ * @brief non virtual destructor, not intended as a base class
*/
~ModuleLoader();
/**
- * Execute a script from a file
+ * @brief Execute a script from a file
+ * @param[in] isolate v8 isolate
* @param[in] fileName file name
* @return true on success, false on failure
*
/**
- * Execute a script
+ * @brief Execute a script
+ * @param[in] isolate v8 isolate
* @param[in] sourceCode source code to run
* @param[in] sourceFileName source file name
* @return true on success, false on failure
/**
- * Implements JavaScript Require functionality
+ * @brief Implements JavaScript Require functionality
+ * @param[in] args arguments passed to require. The return value is set using args.GetReturnValue().Set(
*/
- void Require(const v8::FunctionCallbackInfo< v8::Value >& args, v8::Persistent<v8::ObjectTemplate>& globalObjectTemplate );
+ void Require( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * @brief
+ * Stores a pre compiled object as a module.
+ * Currently used for storing the Dali object, so the developer can
+ * perform var dali = require('dali');
+ * @param[in] isolate v8 isolate
+ * @param[in] exportObject export object
+ * @param[in] name module name, used for the require('name') lookup
+ */
+ void StorePreBuiltModule( v8::Isolate* isolate, v8::Local<v8::Object>& exportObject, const std::string& name );
private:
const std::string& sourceFileName );
/**
- * Store information about the current script
+ * @brief Store information about the current script
* @param[in] sourceFileName source file name
*/
void StoreScriptInfo( const std::string& sourceFileName );
/**
- * Store module information
+ * @brief Store module information
* @param[in] sourceFileName source file name
* @return module object
*/
v8::Local<v8::Object>& moduleExportsObject );
/**
- * Find a module
+ * @brief Find a module
* @param[in] moduleName module name
* @return module
*/
std::cout << " ";
}
v8::String::Utf8Value utf8_value( args[i] );
- std::cout << *utf8_value;
+ std::cout << *utf8_value << "\n";
}
}
}
v8::String::Utf8Value utf8_value( args[i] );
output += *utf8_value;
+ output +="\n";
}
DALI_LOG_ERROR_NOFN( "JavaScript: %s",output.c_str() );
}