2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/public-api/controls/control-impl.h>
22 #include <cstring> // for strcmp
25 #include <dali/public-api/actors/image-actor.h>
26 #include <dali/devel-api/actors/mesh-actor.h>
27 #include <dali/public-api/animation/constraint.h>
28 #include <dali/public-api/animation/constraints.h>
29 #include <dali/devel-api/geometry/mesh.h>
30 #include <dali/public-api/object/type-registry.h>
31 #include <dali/devel-api/object/type-registry-helper.h>
32 #include <dali/devel-api/scripting/scripting.h>
33 #include <dali/public-api/size-negotiation/relayout-container.h>
34 #include <dali/integration-api/debug.h>
37 #include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
38 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
39 #include <dali-toolkit/public-api/controls/control.h>
40 #include <dali-toolkit/devel-api/styling/style-manager.h>
41 #include <dali-toolkit/internal/styling/style-manager-impl.h>
52 const float BACKGROUND_ACTOR_Z_POSITION( -0.1f );
56 return Internal::Control::New();
59 // Setup signals and actions using the type-registry.
60 DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
62 // Note: Properties are registered separately below.
64 DALI_SIGNAL_REGISTRATION( Toolkit, Control, "key-event", SIGNAL_KEY_EVENT )
65 DALI_SIGNAL_REGISTRATION( Toolkit, Control, "key-input-focus-gained", SIGNAL_KEY_INPUT_FOCUS_GAINED )
66 DALI_SIGNAL_REGISTRATION( Toolkit, Control, "key-input-focus-lost", SIGNAL_KEY_INPUT_FOCUS_LOST )
67 DALI_SIGNAL_REGISTRATION( Toolkit, Control, "tapped", SIGNAL_TAPPED )
68 DALI_SIGNAL_REGISTRATION( Toolkit, Control, "panned", SIGNAL_PANNED )
69 DALI_SIGNAL_REGISTRATION( Toolkit, Control, "pinched", SIGNAL_PINCHED )
70 DALI_SIGNAL_REGISTRATION( Toolkit, Control, "long-pressed", SIGNAL_LONG_PRESSED )
72 DALI_ACTION_REGISTRATION( Toolkit, Control, "control-activated", ACTION_CONTROL_ACTIVATED )
74 DALI_TYPE_REGISTRATION_END()
77 * Structure which holds information about the background of a control
81 Actor actor; ///< Either a MeshActor or an ImageActor
82 Vector4 color; ///< The color of the actor.
95 * Creates a white coloured Mesh.
99 Vector3 white( Color::WHITE );
103 // Create vertices with a white color (actual color is set by actor color)
104 MeshData::VertexContainer vertices(4);
105 vertices[ 0 ] = MeshData::Vertex( Vector3( -0.5f, -0.5f, 0.0f ), Vector2::ZERO, white );
106 vertices[ 1 ] = MeshData::Vertex( Vector3( 0.5f, -0.5f, 0.0f ), Vector2::ZERO, white );
107 vertices[ 2 ] = MeshData::Vertex( Vector3( -0.5f, 0.5f, 0.0f ), Vector2::ZERO, white );
108 vertices[ 3 ] = MeshData::Vertex( Vector3( 0.5f, 0.5f, 0.0f ), Vector2::ZERO, white );
110 // Specify all the faces
111 MeshData::FaceIndices faces;
112 faces.reserve( 6 ); // 2 triangles in Quad
113 faces.push_back( 0 ); faces.push_back( 3 ); faces.push_back( 1 );
114 faces.push_back( 0 ); faces.push_back( 2 ); faces.push_back( 3 );
116 // Create the mesh data from the vertices and faces
117 meshData.SetMaterial( Material::New( "ControlMaterial" ) );
118 meshData.SetVertices( vertices );
119 meshData.SetFaceIndices( faces );
120 meshData.SetHasColor( true );
122 return Mesh::New( meshData );
126 * Sets all the required properties for the background actor.
128 * @param[in] actor The actor to set the properties on.
129 * @param[in] color The required color of the actor.
131 void SetupBackgroundActor( Actor actor, const Vector4& color )
133 actor.SetColor( color );
134 actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
135 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
136 actor.SetZ( BACKGROUND_ACTOR_Z_POSITION );
137 actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
141 * Sets all the required properties for the background actor.
143 * @param[in] actor The actor to set the properties on.
144 * @param[in] constrainingIndex The property index to constrain the parent's size on.
145 * @param[in] color The required color of the actor.
147 void SetupBackgroundActorConstrained( Actor actor, Property::Index constrainingIndex, const Vector4& color )
149 actor.SetColor( color );
150 actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
151 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
152 actor.SetZ( BACKGROUND_ACTOR_Z_POSITION );
154 Constraint constraint = Constraint::New<Vector3>( actor,
156 EqualToConstraint() );
157 constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
161 } // unnamed namespace
166 class Control::Impl : public ConnectionTracker
170 // Construction & Destruction
171 Impl(Control& controlImpl)
172 : mControlImpl( controlImpl ),
175 mStartingPinchScale( NULL ),
177 mPinchGestureDetector(),
178 mPanGestureDetector(),
179 mTapGestureDetector(),
180 mLongPressGestureDetector(),
181 mFlags( Control::ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
182 mIsKeyboardNavigationSupported( false ),
183 mIsKeyboardFocusGroup( false ),
184 mInitialized( false )
190 // All gesture detectors will be destroyed so no need to disconnect.
192 delete mStartingPinchScale;
195 // Gesture Detection Methods
197 void PinchDetected(Actor actor, const PinchGesture& pinch)
199 mControlImpl.OnPinch(pinch);
202 void PanDetected(Actor actor, const PanGesture& pan)
204 mControlImpl.OnPan(pan);
207 void TapDetected(Actor actor, const TapGesture& tap)
209 mControlImpl.OnTap(tap);
212 void LongPressDetected(Actor actor, const LongPressGesture& longPress)
214 mControlImpl.OnLongPress(longPress);
217 // Background Methods
220 * Only creates an instance of the background if we actually use it.
221 * @return A reference to the Background structure.
223 Background& GetBackground()
227 mBackground = new Background;
235 * Called when a property of an object of this type is set.
236 * @param[in] object The object whose property is set.
237 * @param[in] index The property index.
238 * @param[in] value The new property value.
240 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
242 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
246 Control& controlImpl( control.GetImplementation() );
250 case Toolkit::Control::Property::STYLE_NAME:
252 controlImpl.SetStyleName( value.Get< std::string >() );
256 case Toolkit::Control::Property::BACKGROUND_COLOR:
258 controlImpl.SetBackgroundColor( value.Get< Vector4 >() );
262 case Toolkit::Control::Property::BACKGROUND_IMAGE:
264 if ( value.HasKey( "image" ) )
266 Property::Map imageMap = value.GetValue( "image" ).Get< Property::Map >();
267 Image image = Scripting::NewImage( imageMap );
271 controlImpl.SetBackgroundImage( image );
274 else if ( value.Get< Property::Map >().Empty() )
276 // An empty map means the background is no longer required
277 controlImpl.ClearBackground();
282 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
284 if ( value.Get< bool >() )
286 controlImpl.SetKeyInputFocus();
290 controlImpl.ClearKeyInputFocus();
299 * Called to retrieve a property of an object of this type.
300 * @param[in] object The object whose property is to be retrieved.
301 * @param[in] index The property index.
302 * @return The current value of the property.
304 static Property::Value GetProperty( BaseObject* object, Property::Index index )
306 Property::Value value;
308 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
312 Control& controlImpl( control.GetImplementation() );
316 case Toolkit::Control::Property::STYLE_NAME:
318 value = controlImpl.GetStyleName();
322 case Toolkit::Control::Property::BACKGROUND_COLOR:
324 value = controlImpl.GetBackgroundColor();
328 case Toolkit::Control::Property::BACKGROUND_IMAGE:
332 Actor actor = controlImpl.GetBackgroundActor();
335 ImageActor imageActor = ImageActor::DownCast( actor );
338 Image image = imageActor.GetImage();
339 Property::Map imageMap;
340 Scripting::CreatePropertyMap( image, imageMap );
341 map[ "image" ] = imageMap;
349 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
351 value = controlImpl.HasKeyInputFocus();
362 Control& mControlImpl;
363 std::string mStyleName;
364 Background* mBackground; ///< Only create the background if we use it
365 Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
366 Toolkit::Control::KeyEventSignalType mKeyEventSignal;
367 Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal;
368 Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal;
371 PinchGestureDetector mPinchGestureDetector;
372 PanGestureDetector mPanGestureDetector;
373 TapGestureDetector mTapGestureDetector;
374 LongPressGestureDetector mLongPressGestureDetector;
376 ControlBehaviour mFlags :CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor.
377 bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
378 bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
379 bool mInitialized :1;
381 // Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
382 static PropertyRegistration PROPERTY_1;
383 static PropertyRegistration PROPERTY_2;
384 static PropertyRegistration PROPERTY_3;
385 static PropertyRegistration PROPERTY_4;
388 // Properties registered without macro to use specific member variables.
389 PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "style-name", Toolkit::Control::Property::STYLE_NAME, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
390 PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background-color", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
391 PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "background-image", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
392 PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "key-input-focus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
394 Toolkit::Control Control::New()
396 // Create the implementation, temporarily owned on stack
397 IntrusivePtr<Control> controlImpl = new Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) );
399 // Pass ownership to handle
400 Toolkit::Control handle( *controlImpl );
402 // Second-phase init of the implementation
403 // This can only be done after the CustomActor connection has been made...
404 controlImpl->Initialize();
414 Vector3 Control::GetNaturalSize()
416 if( mImpl->mBackground )
418 Actor actor = mImpl->mBackground->actor;
421 return actor.GetNaturalSize();
427 float Control::GetHeightForWidth( float width )
429 if( mImpl->mBackground )
431 Actor actor = mImpl->mBackground->actor;
434 return actor.GetHeightForWidth( width );
437 return GetHeightForWidthBase( width );
440 float Control::GetWidthForHeight( float height )
442 if( mImpl->mBackground )
444 Actor actor = mImpl->mBackground->actor;
447 return actor.GetWidthForHeight( height );
450 return GetWidthForHeightBase( height );
453 void Control::SetKeyInputFocus()
455 if( Self().OnStage() )
457 Toolkit::KeyInputFocusManager::Get().SetFocus(Toolkit::Control::DownCast(Self()));
461 bool Control::HasKeyInputFocus()
464 if( Self().OnStage() )
466 result = Toolkit::KeyInputFocusManager::Get().IsKeyboardListener(Toolkit::Control::DownCast(Self()));
471 void Control::ClearKeyInputFocus()
473 if( Self().OnStage() )
475 Toolkit::KeyInputFocusManager::Get().RemoveFocus(Toolkit::Control::DownCast(Self()));
479 PinchGestureDetector Control::GetPinchGestureDetector() const
481 return mImpl->mPinchGestureDetector;
484 PanGestureDetector Control::GetPanGestureDetector() const
486 return mImpl->mPanGestureDetector;
489 TapGestureDetector Control::GetTapGestureDetector() const
491 return mImpl->mTapGestureDetector;
494 LongPressGestureDetector Control::GetLongPressGestureDetector() const
496 return mImpl->mLongPressGestureDetector;
499 void Control::SetStyleName( const std::string& styleName )
501 if( styleName != mImpl->mStyleName )
503 mImpl->mStyleName = styleName;
506 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
507 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
511 const std::string& Control::GetStyleName() const
513 return mImpl->mStyleName;
516 void Control::SetBackgroundColor( const Vector4& color )
518 Background& background( mImpl->GetBackground() );
520 if ( background.actor )
522 // Just set the actor color
523 background.actor.SetColor( color );
528 MeshActor meshActor = MeshActor::New( CreateMesh() );
530 SetupBackgroundActorConstrained( meshActor, Actor::Property::SCALE, color );
532 // Set the background actor before adding so that we do not inform deriving classes
533 background.actor = meshActor;
534 Self().Add( meshActor );
537 background.color = color;
540 Vector4 Control::GetBackgroundColor() const
542 if ( mImpl->mBackground )
544 return mImpl->mBackground->color;
546 return Color::TRANSPARENT;
549 void Control::SetBackgroundImage( Image image )
551 Background& background( mImpl->GetBackground() );
553 if ( background.actor )
555 // Remove Current actor, unset AFTER removal so that we do not inform deriving classes
556 Self().Remove( background.actor );
557 background.actor.Reset();
560 ImageActor imageActor = ImageActor::New( image );
561 SetupBackgroundActor( imageActor, background.color );
563 // Set the background actor before adding so that we do not inform derived classes
564 background.actor = imageActor;
565 Self().Add( imageActor );
568 void Control::ClearBackground()
570 if ( mImpl->mBackground )
572 Background& background( mImpl->GetBackground() );
573 Self().Remove( background.actor );
575 delete mImpl->mBackground;
576 mImpl->mBackground = NULL;
580 Actor Control::GetBackgroundActor() const
582 if ( mImpl->mBackground )
584 return mImpl->mBackground->actor;
590 void Control::SetKeyboardNavigationSupport(bool isSupported)
592 mImpl->mIsKeyboardNavigationSupported = isSupported;
595 bool Control::IsKeyboardNavigationSupported()
597 return mImpl->mIsKeyboardNavigationSupported;
600 void Control::Activate()
602 // Inform deriving classes
606 bool Control::OnAccessibilityPan(PanGesture gesture)
608 return false; // Accessibility pan gesture is not handled by default
611 bool Control::OnAccessibilityTouch(const TouchEvent& touchEvent)
613 return false; // Accessibility touch event is not handled by default
616 bool Control::OnAccessibilityValueChange(bool isIncrease)
618 return false; // Accessibility value change action is not handled by default
621 void Control::SetAsKeyboardFocusGroup(bool isFocusGroup)
623 mImpl->mIsKeyboardFocusGroup = isFocusGroup;
625 // The following line will be removed when the deprecated API in KeyboardFocusManager is deleted
626 Toolkit::KeyboardFocusManager::Get().SetAsFocusGroup(Self(), isFocusGroup);
629 bool Control::IsKeyboardFocusGroup()
631 return Toolkit::KeyboardFocusManager::Get().IsFocusGroup(Self());
634 Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled)
639 void Control::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
643 bool Control::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes)
647 if( object && ( 0 == strcmp( actionName.c_str(), ACTION_CONTROL_ACTIVATED ) ) )
649 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
652 // if cast succeeds there is an implementation so no need to check
653 control.GetImplementation().OnActivated();
660 bool Control::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
662 Dali::BaseHandle handle( object );
664 bool connected( false );
665 Toolkit::Control control = Toolkit::Control::DownCast( handle );
668 Control& controlImpl( control.GetImplementation() );
671 if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
673 controlImpl.KeyEventSignal().Connect( tracker, functor );
675 else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_GAINED ) )
677 controlImpl.KeyInputFocusGainedSignal().Connect( tracker, functor );
679 else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_LOST ) )
681 controlImpl.KeyInputFocusLostSignal().Connect( tracker, functor );
683 else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
685 controlImpl.EnableGestureDetection( Gesture::Tap );
686 controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
688 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
690 controlImpl.EnableGestureDetection( Gesture::Pan );
691 controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
693 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
695 controlImpl.EnableGestureDetection( Gesture::Pinch );
696 controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
698 else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
700 controlImpl.EnableGestureDetection( Gesture::LongPress );
701 controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
705 // signalName does not match any signal
712 Toolkit::Control::KeyEventSignalType& Control::KeyEventSignal()
714 return mImpl->mKeyEventSignal;
717 Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusGainedSignal()
719 return mImpl->mKeyInputFocusGainedSignal;
722 Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusLostSignal()
724 return mImpl->mKeyInputFocusLostSignal;
727 bool Control::EmitKeyEventSignal( const KeyEvent& event )
729 // Guard against destruction during signal emission
730 Dali::Toolkit::Control handle( GetOwner() );
732 bool consumed = false;
734 // signals are allocated dynamically when someone connects
735 if ( !mImpl->mKeyEventSignal.Empty() )
737 consumed = mImpl->mKeyEventSignal.Emit( handle, event );
742 // Notification for derived classes
743 consumed = OnKeyEvent(event);
749 Control::Control( ControlBehaviour behaviourFlags )
750 : CustomActorImpl( static_cast< ActorFlags >( behaviourFlags ) ),
751 mImpl(new Impl(*this))
753 mImpl->mFlags = behaviourFlags;
756 void Control::Initialize()
758 // Calling deriving classes
761 if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
763 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
765 // Register for style changes
766 styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
769 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
772 if( mImpl->mFlags & REQUIRES_KEYBOARD_NAVIGATION_SUPPORT )
774 SetKeyboardNavigationSupport( true );
777 mImpl->mInitialized = true;
780 void Control::EnableGestureDetection(Gesture::Type type)
782 if ( (type & Gesture::Pinch) && !mImpl->mPinchGestureDetector )
784 mImpl->mPinchGestureDetector = PinchGestureDetector::New();
785 mImpl->mPinchGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PinchDetected);
786 mImpl->mPinchGestureDetector.Attach(Self());
789 if ( (type & Gesture::Pan) && !mImpl->mPanGestureDetector )
791 mImpl->mPanGestureDetector = PanGestureDetector::New();
792 mImpl->mPanGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PanDetected);
793 mImpl->mPanGestureDetector.Attach(Self());
796 if ( (type & Gesture::Tap) && !mImpl->mTapGestureDetector )
798 mImpl->mTapGestureDetector = TapGestureDetector::New();
799 mImpl->mTapGestureDetector.DetectedSignal().Connect(mImpl, &Impl::TapDetected);
800 mImpl->mTapGestureDetector.Attach(Self());
803 if ( (type & Gesture::LongPress) && !mImpl->mLongPressGestureDetector )
805 mImpl->mLongPressGestureDetector = LongPressGestureDetector::New();
806 mImpl->mLongPressGestureDetector.DetectedSignal().Connect(mImpl, &Impl::LongPressDetected);
807 mImpl->mLongPressGestureDetector.Attach(Self());
811 void Control::DisableGestureDetection(Gesture::Type type)
813 if ( (type & Gesture::Pinch) && mImpl->mPinchGestureDetector )
815 mImpl->mPinchGestureDetector.Detach(Self());
816 mImpl->mPinchGestureDetector.Reset();
819 if ( (type & Gesture::Pan) && mImpl->mPanGestureDetector )
821 mImpl->mPanGestureDetector.Detach(Self());
822 mImpl->mPanGestureDetector.Reset();
825 if ( (type & Gesture::Tap) && mImpl->mTapGestureDetector )
827 mImpl->mTapGestureDetector.Detach(Self());
828 mImpl->mTapGestureDetector.Reset();
831 if ( (type & Gesture::LongPress) && mImpl->mLongPressGestureDetector)
833 mImpl->mLongPressGestureDetector.Detach(Self());
834 mImpl->mLongPressGestureDetector.Reset();
838 void Control::OnInitialize()
842 void Control::OnActivated()
846 void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
848 // By default the control is only interested in theme (not font) changes
849 if( change == StyleChange::THEME_CHANGE )
851 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
855 void Control::OnPinch(const PinchGesture& pinch)
857 if( !( mImpl->mStartingPinchScale ) )
860 mImpl->mStartingPinchScale = new Vector3;
863 if( pinch.state == Gesture::Started )
865 *( mImpl->mStartingPinchScale ) = Self().GetCurrentScale();
868 Self().SetScale( *( mImpl->mStartingPinchScale ) * pinch.scale );
871 void Control::OnPan( const PanGesture& pan )
875 void Control::OnTap(const TapGesture& tap)
879 void Control::OnLongPress( const LongPressGesture& longPress )
883 void Control::OnControlStageConnection()
887 void Control::OnControlStageDisconnection()
891 void Control::OnControlChildAdd( Actor& child )
895 void Control::OnControlChildRemove( Actor& child )
899 void Control::OnControlSizeSet( const Vector3& size )
903 void Control::OnCalculateRelayoutSize( Dimension::Type dimension )
907 void Control::OnLayoutNegotiated( float size, Dimension::Type dimension )
911 void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
913 for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i )
915 container.Add( Self().GetChildAt( i ), size );
919 void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
923 float Control::CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
925 return CalculateChildSizeBase( child, dimension );
928 bool Control::RelayoutDependentOnChildren( Dimension::Type dimension )
930 return RelayoutDependentOnChildrenBase( dimension );
933 void Control::EmitKeyInputFocusSignal( bool focusGained )
935 Dali::Toolkit::Control handle( GetOwner() );
939 // signals are allocated dynamically when someone connects
940 if ( !mImpl->mKeyInputFocusGainedSignal.Empty() )
942 mImpl->mKeyInputFocusGainedSignal.Emit( handle );
947 // signals are allocated dynamically when someone connects
948 if ( !mImpl->mKeyInputFocusLostSignal.Empty() )
950 mImpl->mKeyInputFocusLostSignal.Emit( handle );
955 void Control::OnKeyInputFocusGained()
957 EmitKeyInputFocusSignal( true );
960 void Control::OnKeyInputFocusLost()
962 EmitKeyInputFocusSignal( false );
965 void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
967 // @todo consider animating negotiated child sizes to target size
970 bool Control::OnTouchEvent(const TouchEvent& event)
972 return false; // Do not consume
975 bool Control::OnHoverEvent(const HoverEvent& event)
977 return false; // Do not consume
980 bool Control::OnKeyEvent(const KeyEvent& event)
982 return false; // Do not consume
985 bool Control::OnMouseWheelEvent(const MouseWheelEvent& event)
987 return false; // Do not consume
990 void Control::OnStageConnection()
992 // Notify derived classes.
993 OnControlStageConnection();
996 void Control::OnStageDisconnection()
998 // Notify derived classes
999 OnControlStageDisconnection();
1002 void Control::OnChildAdd(Actor& child)
1004 // If this is the background actor, then we do not want to relayout or inform deriving classes
1005 if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) )
1010 // Notify derived classes.
1011 OnControlChildAdd( child );
1014 void Control::OnChildRemove(Actor& child)
1016 // If this is the background actor, then we do not want to relayout or inform deriving classes
1017 if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) )
1022 // Notify derived classes.
1023 OnControlChildRemove( child );
1026 void Control::OnSizeSet(const Vector3& targetSize)
1028 // Background is resized through size negotiation
1030 // Notify derived classes.
1031 OnControlSizeSet( targetSize );
1034 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
1036 mImpl->SignalConnected( slotObserver, callback );
1039 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
1041 mImpl->SignalDisconnected( slotObserver, callback );
1044 } // namespace Internal
1046 } // namespace Toolkit