-namespace Internal
-{
-
-class Control::Impl : public ConnectionTracker
-{
-public:
-
- // Construction & Destruction
- Impl(Control& controlImpl)
- : mControlImpl( controlImpl ),
- mStyleName(""),
- mBackgroundColor(Color::TRANSPARENT),
- mStartingPinchScale( NULL ),
- mKeyEventSignal(),
- mPinchGestureDetector(),
- mPanGestureDetector(),
- mTapGestureDetector(),
- mLongPressGestureDetector(),
- mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
- mIsKeyboardNavigationSupported( false ),
- mIsKeyboardFocusGroup( false )
- {
- }
-
- ~Impl()
- {
- // All gesture detectors will be destroyed so no need to disconnect.
- delete mStartingPinchScale;
- }
-
- // Gesture Detection Methods
-
- void PinchDetected(Actor actor, const PinchGesture& pinch)
- {
- mControlImpl.OnPinch(pinch);
- }
-
- void PanDetected(Actor actor, const PanGesture& pan)
- {
- mControlImpl.OnPan(pan);
- }
-
- void TapDetected(Actor actor, const TapGesture& tap)
- {
- mControlImpl.OnTap(tap);
- }
-
- void LongPressDetected(Actor actor, const LongPressGesture& longPress)
- {
- mControlImpl.OnLongPress(longPress);
- }
-
- // Properties
-
- /**
- * Called when a property of an object of this type is set.
- * @param[in] object The object whose property is set.
- * @param[in] index The property index.
- * @param[in] value The new property value.
- */
- static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
- {
- Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
-
- if ( control )
- {
- Control& controlImpl( GetImplementation( control ) );
-
- switch ( index )
- {
- case Toolkit::Control::Property::STYLE_NAME:
- {
- controlImpl.SetStyleName( value.Get< std::string >() );
- break;
- }
-
- case Toolkit::Control::Property::BACKGROUND_COLOR:
- {
- DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" );
- controlImpl.SetBackgroundColor( value.Get< Vector4 >() );
- break;
- }
-
- case Toolkit::Control::Property::BACKGROUND_IMAGE:
- {
- DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" );
- Image image = Scripting::NewImage( value );
- if ( image )
- {
- controlImpl.SetBackgroundImage( image );
- }
- else
- {
- // An empty image means the background is no longer required
- controlImpl.ClearBackground();
- }
- break;
- }
-
- case Toolkit::Control::Property::KEY_INPUT_FOCUS:
- {
- if ( value.Get< bool >() )
- {
- controlImpl.SetKeyInputFocus();
- }
- else
- {
- controlImpl.ClearKeyInputFocus();
- }
- break;
- }
-
- case Toolkit::Control::Property::BACKGROUND:
- {
- const Property::Map* map = value.GetMap();
- if( map && !map->Empty() )
- {
- controlImpl.SetBackground( *map );
- }
- else
- {
- // The background is an empty property map, so we should clear the background
- controlImpl.ClearBackground();
- }
- break;
- }
- }
- }
- }
-
- /**
- * Called to retrieve a property of an object of this type.
- * @param[in] object The object whose property is to be retrieved.
- * @param[in] index The property index.
- * @return The current value of the property.
- */
- static Property::Value GetProperty( BaseObject* object, Property::Index index )
- {
- Property::Value value;
-
- Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
-
- if ( control )
- {
- Control& controlImpl( GetImplementation( control ) );
-
- switch ( index )
- {
- case Toolkit::Control::Property::STYLE_NAME:
- {
- value = controlImpl.GetStyleName();
- break;
- }
-
- case Toolkit::Control::Property::BACKGROUND_COLOR:
- {
- DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" );
- value = controlImpl.GetBackgroundColor();
- break;
- }
-
- case Toolkit::Control::Property::BACKGROUND_IMAGE:
- {
- DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" );
- Property::Map map;
- Toolkit::Visual::Base visual = controlImpl.GetVisual( Toolkit::Control::Property::BACKGROUND );
- if( visual )
- {
- visual.CreatePropertyMap( map );
- }
- value = map;
- break;
- }
-
- case Toolkit::Control::Property::KEY_INPUT_FOCUS:
- {
- value = controlImpl.HasKeyInputFocus();
- break;
- }
-
- case Toolkit::Control::Property::BACKGROUND:
- {
- Property::Map map;
- Toolkit::Visual::Base visual = controlImpl.GetVisual( Toolkit::Control::Property::BACKGROUND );
- if( visual )
- {
- visual.CreatePropertyMap( map );
- }
-
- value = map;
- break;
- }
-
- }
- }
-
- return value;
- }
-
- // Data
-
- Control& mControlImpl;
- RegisteredVisualContainer mVisuals; // Stores visuals needed by the control, non trivial type so std::vector used.
- std::string mStyleName;
- Vector4 mBackgroundColor; ///< The color of the background visual
- Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
- Toolkit::Control::KeyEventSignalType mKeyEventSignal;
- Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal;
- Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal;
-
- // Gesture Detection
- PinchGestureDetector mPinchGestureDetector;
- PanGestureDetector mPanGestureDetector;
- TapGestureDetector mTapGestureDetector;
- LongPressGestureDetector mLongPressGestureDetector;
-
- ControlBehaviour mFlags : CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor.
- bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
- bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
-
- // Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
- static const PropertyRegistration PROPERTY_1;
- static const PropertyRegistration PROPERTY_2;
- static const PropertyRegistration PROPERTY_3;
- static const PropertyRegistration PROPERTY_4;
- static const PropertyRegistration PROPERTY_5;
-};
-
-// Properties registered without macro to use specific member variables.
-const PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "styleName", Toolkit::Control::Property::STYLE_NAME, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "backgroundColor", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "backgroundImage", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "keyInputFocus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_5( typeRegistration, "background", Toolkit::Control::Property::BACKGROUND, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );