- // Find visualName in the control
- RegisteredVisualContainer::Iterator iter;
- for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
- {
- if ( (*iter)->visual.GetName() == visualName )
- {
- break;
- }
- }
-
- // Does it's renderer have an associated property?
- if( iter != visuals.End() )
- {
- Actor self = controlImpl.Self();
- Property::Index index = DevelHandle::GetPropertyIndex( self, propertyKey );
- if( index != Property::INVALID_INDEX )
- {
- // It's an actor property:
- return HandleIndex( self, index );
- }
- else
- {
- // Check if it is a renderer property:
- if( self.GetRendererCount() > 0 )
- {
- // @todo Need to use correct renderer index
- Renderer renderer = self.GetRendererAt(0);
- Property::Index index = DevelHandle::GetPropertyIndex( renderer, propertyKey );
- if( index != Property::INVALID_INDEX )
- {
- // It's a renderer property:
- return HandleIndex( renderer, index );
- }
- }
- else
- {
- std::ostringstream oss;
- oss << propertyKey;
- DALI_LOG_WARNING( "Control::GetHandleIndex(%s, %s) No renderers\n", visualName.c_str(), oss.str().c_str() );
- }
- }
- }
- Handle handle;
- return HandleIndex( handle, Property::INVALID_INDEX );
-}
-
-void SetDefaultTransform( Property::Map& propertyMap )
-{
- propertyMap.Clear();
- propertyMap
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
- .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
- .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
- .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
-}
-
-/**
- * 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;
-}
-
-// 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()