-/**
- * Struct used to store Visual within the control, index is a unique key for each visual.
- */
-struct RegisteredVisual
-{
- Property::Index index;
- Toolkit::Visual::Base visual;
- bool enabled;
-
- RegisteredVisual( Property::Index aIndex, Toolkit::Visual::Base &aVisual, bool aEnabled)
- : index(aIndex), visual(aVisual), enabled(aEnabled)
- {
- }
-};
-
-typedef Dali::OwnerContainer< RegisteredVisual* > RegisteredVisualContainer;
-
-/**
- * Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
- */
-bool FindVisual( Property::Index targetIndex, RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter )
-{
- for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
- {
- if ( (*iter)->index == targetIndex )
- {
- return true;
- }
- }
- return false;
-}
-
-Toolkit::Visual::Base GetVisualByName(
- RegisteredVisualContainer& visuals,
- const std::string& visualName )
-{
- Toolkit::Visual::Base visualHandle;
-
- RegisteredVisualContainer::Iterator iter;
- for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
- {
- Toolkit::Visual::Base visual = (*iter)->visual;
- if( visual && visual.GetName() == visualName )
- {
- visualHandle = visual;
- break;
- }
- }
- return visualHandle;
-}
-
-/**
- * Creates control through type registry
- */
-BaseHandle Create()
-{
- return Internal::Control::New();
-}
-
-/**
- * Performs actions as requested using the action name.
- * @param[in] object The object on which to perform the action.
- * @param[in] actionName The action to perform.
- * @param[in] attributes The attributes with which to perfrom this action.
- * @return true if action has been accepted by this control
- */
-const char* ACTION_ACCESSIBILITY_ACTIVATED = "accessibilityActivated";
-static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
-{
- bool ret = false;
-
- if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) ) )
- {
- Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
- if( control )
- {
- // if cast succeeds there is an implementation so no need to check
- ret = Internal::GetImplementation( control ).OnAccessibilityActivated();
- }
- }
-
- return ret;
-}
-
-/**
- * Connects a callback function with the object's signals.
- * @param[in] object The object providing the signal.
- * @param[in] tracker Used to disconnect the signal.
- * @param[in] signalName The signal to connect to.
- * @param[in] functor A newly allocated FunctorDelegate.
- * @return True if the signal was connected.
- * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
- */
-const char* SIGNAL_KEY_EVENT = "keyEvent";
-const char* SIGNAL_KEY_INPUT_FOCUS_GAINED = "keyInputFocusGained";
-const char* SIGNAL_KEY_INPUT_FOCUS_LOST = "keyInputFocusLost";
-const char* SIGNAL_TAPPED = "tapped";
-const char* SIGNAL_PANNED = "panned";
-const char* SIGNAL_PINCHED = "pinched";
-const char* SIGNAL_LONG_PRESSED = "longPressed";
-static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
-{
- Dali::BaseHandle handle( object );
-
- bool connected( false );
- Toolkit::Control control = Toolkit::Control::DownCast( handle );
- if ( control )
- {
- Internal::Control& controlImpl( Internal::GetImplementation( control ) );
- connected = true;
-
- if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
- {
- controlImpl.KeyEventSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_GAINED ) )
- {
- controlImpl.KeyInputFocusGainedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_LOST ) )
- {
- controlImpl.KeyInputFocusLostSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
- {
- controlImpl.EnableGestureDetection( Gesture::Tap );
- controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
- {
- controlImpl.EnableGestureDetection( Gesture::Pan );
- controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
- {
- controlImpl.EnableGestureDetection( Gesture::Pinch );
- controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
- {
- controlImpl.EnableGestureDetection( Gesture::LongPress );
- controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
- }
- }
- return connected;
-}
-
-const Scripting::StringEnum ControlStateTable[] = {
- { "NORMAL", Toolkit::DevelControl::NORMAL },
- { "FOCUSED", Toolkit::DevelControl::FOCUSED },
- { "DISABLED", Toolkit::DevelControl::DISABLED },
-}; const unsigned int ControlStateTableCount = sizeof( ControlStateTable ) / sizeof( ControlStateTable[0] );
-
-// Setup signals and actions using the type-registry.
-DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
-
-// Note: Properties are registered separately below.
-
-SignalConnectorType registerSignal1( typeRegistration, SIGNAL_KEY_EVENT, &DoConnectSignal );
-SignalConnectorType registerSignal2( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_GAINED, &DoConnectSignal );
-SignalConnectorType registerSignal3( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_LOST, &DoConnectSignal );
-SignalConnectorType registerSignal4( typeRegistration, SIGNAL_TAPPED, &DoConnectSignal );
-SignalConnectorType registerSignal5( typeRegistration, SIGNAL_PANNED, &DoConnectSignal );
-SignalConnectorType registerSignal6( typeRegistration, SIGNAL_PINCHED, &DoConnectSignal );
-SignalConnectorType registerSignal7( typeRegistration, SIGNAL_LONG_PRESSED, &DoConnectSignal );
-
-TypeAction registerAction( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &DoAction );
-
-DALI_TYPE_REGISTRATION_END()
-