2 * Copyright (c) 2014 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>
23 #include <dali/public-api/actors/image-actor.h>
24 #include <dali/public-api/actors/mesh-actor.h>
25 #include <dali/public-api/animation/active-constraint.h>
26 #include <dali/public-api/animation/constraint.h>
27 #include <dali/public-api/animation/constraints.h>
28 #include <dali/public-api/geometry/mesh.h>
29 #include <dali/public-api/object/type-registry.h>
30 #include <dali/public-api/object/type-registry-helper.h>
31 #include <dali/public-api/scripting/scripting.h>
32 #include <dali/public-api/size-negotiation/relayout-container.h>
33 #include <dali/integration-api/debug.h>
36 #include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
37 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
38 #include <dali-toolkit/public-api/controls/control.h>
39 #include <dali-toolkit/public-api/styling/style-manager.h>
40 #include <dali-toolkit/internal/styling/style-manager-impl.h>
51 #if defined(DEBUG_ENABLED)
52 Integration::Log::Filter* gLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_CONTROL");
55 const float MAX_FLOAT_VALUE( std::numeric_limits<float>::max() );
56 const Vector3 MAX_SIZE( MAX_FLOAT_VALUE, MAX_FLOAT_VALUE, MAX_FLOAT_VALUE );
57 const float BACKGROUND_ACTOR_Z_POSITION( -0.1f );
61 return Internal::Control::New();
64 // Setup signals and actions using the type-registry.
65 DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
67 // Note: Properties are registered separately below,
69 DALI_SIGNAL_REGISTRATION( Control, "key-event", SIGNAL_KEY_EVENT )
70 DALI_SIGNAL_REGISTRATION( Control, "tapped", SIGNAL_TAPPED )
71 DALI_SIGNAL_REGISTRATION( Control, "panned", SIGNAL_PANNED )
72 DALI_SIGNAL_REGISTRATION( Control, "pinched", SIGNAL_PINCHED )
73 DALI_SIGNAL_REGISTRATION( Control, "long-pressed", SIGNAL_LONG_PRESSED )
75 DALI_ACTION_REGISTRATION( Control, "control-activated", ACTION_CONTROL_ACTIVATED )
77 DALI_TYPE_REGISTRATION_END()
80 * Structure which holds information about the background of a control
84 Actor actor; ///< Either a MeshActor or an ImageActor
85 Vector4 color; ///< The color of the actor.
98 * Creates a white coloured Mesh.
102 Vector3 white( Color::WHITE );
106 // Create vertices with a white color (actual color is set by actor color)
107 MeshData::VertexContainer vertices(4);
108 vertices[ 0 ] = MeshData::Vertex( Vector3( -0.5f, -0.5f, 0.0f ), Vector2::ZERO, white );
109 vertices[ 1 ] = MeshData::Vertex( Vector3( 0.5f, -0.5f, 0.0f ), Vector2::ZERO, white );
110 vertices[ 2 ] = MeshData::Vertex( Vector3( -0.5f, 0.5f, 0.0f ), Vector2::ZERO, white );
111 vertices[ 3 ] = MeshData::Vertex( Vector3( 0.5f, 0.5f, 0.0f ), Vector2::ZERO, white );
113 // Specify all the faces
114 MeshData::FaceIndices faces;
115 faces.reserve( 6 ); // 2 triangles in Quad
116 faces.push_back( 0 ); faces.push_back( 3 ); faces.push_back( 1 );
117 faces.push_back( 0 ); faces.push_back( 2 ); faces.push_back( 3 );
119 // Create the mesh data from the vertices and faces
120 meshData.SetMaterial( Material::New( "ControlMaterial" ) );
121 meshData.SetVertices( vertices );
122 meshData.SetFaceIndices( faces );
123 meshData.SetHasColor( true );
125 return Mesh::New( meshData );
129 * Sets all the required properties for the background actor.
131 * @param[in] actor The actor to set the properties on.
132 * @param[in] constrainingIndex The property index to constrain the parent's size on.
133 * @param[in] color The required color of the actor.
135 void SetupBackgroundActor( Actor actor, Property::Index constrainingIndex, const Vector4& color )
137 actor.SetColor( color );
138 actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
139 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
140 actor.SetZ( BACKGROUND_ACTOR_Z_POSITION );
141 actor.SetRelayoutEnabled( false );
143 Constraint constraint = Constraint::New<Vector3>( constrainingIndex,
144 ParentSource( Actor::Property::SIZE ),
145 EqualToConstraint() );
146 actor.ApplyConstraint( constraint );
149 } // unnamed namespace
154 class Control::Impl : public ConnectionTracker
159 * Size indices for mMinMaxSize array
168 // Construction & Destruction
169 Impl(Control& controlImpl)
170 : mControlImpl( controlImpl ),
172 mStartingPinchScale( NULL ),
174 mPinchGestureDetector(),
175 mPanGestureDetector(),
176 mTapGestureDetector(),
177 mLongPressGestureDetector(),
180 mFlags( Control::CONTROL_BEHAVIOUR_NONE ),
181 mIsKeyboardNavigationSupported( false ),
182 mIsKeyboardFocusGroup( false ),
183 mInitialized( false )
189 // All gesture detectors will be destroyed so no need to disconnect.
191 delete mStartingPinchScale;
194 // Gesture Detection Methods
196 void PinchDetected(Actor actor, const PinchGesture& pinch)
198 mControlImpl.OnPinch(pinch);
201 void PanDetected(Actor actor, const PanGesture& pan)
203 mControlImpl.OnPan(pan);
206 void TapDetected(Actor actor, const TapGesture& tap)
208 mControlImpl.OnTap(tap);
211 void LongPressDetected(Actor actor, const LongPressGesture& longPress)
213 mControlImpl.OnLongPress(longPress);
216 // Background Methods
219 * Only creates an instance of the background if we actually use it.
220 * @return A reference to the Background structure.
222 Background& GetBackground()
226 mBackground = new Background;
234 * Called when a property of an object of this type is set.
235 * @param[in] object The object whose property is set.
236 * @param[in] index The property index.
237 * @param[in] value The new property value.
239 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
241 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
245 Control& controlImpl( control.GetImplementation() );
249 case Toolkit::Control::Property::BACKGROUND_COLOR:
251 controlImpl.SetBackgroundColor( value.Get< Vector4 >() );
255 case Toolkit::Control::Property::BACKGROUND_IMAGE:
257 if ( value.HasKey( "image" ) )
259 Property::Map imageMap = value.GetValue( "image" ).Get< Property::Map >();
260 Image image = Scripting::NewImage( imageMap );
264 controlImpl.SetBackgroundImage( image );
267 else if ( value.Get< Property::Map >().Empty() )
269 // An empty map means the background is no longer required
270 controlImpl.ClearBackground();
275 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
277 if ( value.Get< bool >() )
279 controlImpl.SetKeyInputFocus();
283 controlImpl.ClearKeyInputFocus();
292 * Called to retrieve a property of an object of this type.
293 * @param[in] object The object whose property is to be retrieved.
294 * @param[in] index The property index.
295 * @return The current value of the property.
297 static Property::Value GetProperty( BaseObject* object, Property::Index index )
299 Property::Value value;
301 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
305 Control& controlImpl( control.GetImplementation() );
309 case Toolkit::Control::Property::BACKGROUND_COLOR:
311 value = controlImpl.GetBackgroundColor();
315 case Toolkit::Control::Property::BACKGROUND_IMAGE:
319 Actor actor = controlImpl.GetBackgroundActor();
322 ImageActor imageActor = ImageActor::DownCast( actor );
325 Image image = imageActor.GetImage();
326 Property::Map imageMap;
327 Scripting::CreatePropertyMap( image, imageMap );
328 map[ "image" ] = imageMap;
336 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
338 value = controlImpl.HasKeyInputFocus();
349 Control& mControlImpl;
350 Background* mBackground; ///< Only create the background if we use it
351 Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
352 Toolkit::Control::KeyEventSignalType mKeyEventSignal;
355 PinchGestureDetector mPinchGestureDetector;
356 PanGestureDetector mPanGestureDetector;
357 TapGestureDetector mTapGestureDetector;
358 LongPressGestureDetector mLongPressGestureDetector;
359 // @todo change all these to Vector2 when we have a chance to sanitize the public API as well
360 Vector3 mCurrentSize; ///< Stores the current control's size, this is the negotiated size
361 Vector3 mNaturalSize; ///< Stores the size set through the Actor's API. This is size the actor wants to be. Useful when reset to the initial size is needed.
363 ControlBehaviour mFlags :6; ///< Flags passed in from constructor. Need to increase this size when new enums are added
364 bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
365 bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
366 bool mInitialized :1;
368 // Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
369 static PropertyRegistration PROPERTY_1;
370 static PropertyRegistration PROPERTY_2;
371 static PropertyRegistration PROPERTY_3;
374 // Properties registered without macro to use specific member variables.
375 PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "background-color", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
376 PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background-image", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
377 PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "key-input-focus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
379 Toolkit::Control Control::New()
381 // Create the implementation, temporarily owned on stack
382 IntrusivePtr<Control> controlImpl = new Control( CONTROL_BEHAVIOUR_NONE );
384 // Pass ownership to handle
385 Toolkit::Control handle( *controlImpl );
387 // Second-phase init of the implementation
388 // This can only be done after the CustomActor connection has been made...
389 controlImpl->Initialize();
399 Vector3 Control::GetNaturalSize()
401 // could be overridden in derived classes.
402 return mImpl->mNaturalSize;
405 float Control::CalculateChildSize( const Dali::Actor& child, Dimension dimension )
407 // Could be overridden in derived classes.
408 return CalculateChildSizeBase( child, dimension );
411 bool Control::RelayoutDependentOnChildren( Dimension dimension )
413 return RelayoutDependentOnChildrenBase( dimension );
416 float Control::GetHeightForWidth( float width )
418 // could be overridden in derived classes.
419 float height( 0.0f );
420 if ( mImpl->mNaturalSize.width > 0.0f )
422 height = mImpl->mNaturalSize.height * width / mImpl->mNaturalSize.width;
427 float Control::GetWidthForHeight( float height )
429 // could be overridden in derived classes.
431 if ( mImpl->mNaturalSize.height > 0.0f )
433 width = mImpl->mNaturalSize.width * height / mImpl->mNaturalSize.height;
438 const Vector3& Control::GetControlSize() const
440 return mImpl->mCurrentSize;
443 const Vector3& Control::GetSizeSet() const
445 return mImpl->mNaturalSize;
448 void Control::SetKeyInputFocus()
450 if( Self().OnStage() )
452 Toolkit::KeyInputFocusManager::Get().SetFocus(Toolkit::Control::DownCast(Self()));
456 bool Control::HasKeyInputFocus()
459 if( Self().OnStage() )
461 result = Toolkit::KeyInputFocusManager::Get().IsKeyboardListener(Toolkit::Control::DownCast(Self()));
466 void Control::ClearKeyInputFocus()
468 if( Self().OnStage() )
470 Toolkit::KeyInputFocusManager::Get().RemoveFocus(Toolkit::Control::DownCast(Self()));
474 PinchGestureDetector Control::GetPinchGestureDetector() const
476 return mImpl->mPinchGestureDetector;
479 PanGestureDetector Control::GetPanGestureDetector() const
481 return mImpl->mPanGestureDetector;
484 TapGestureDetector Control::GetTapGestureDetector() const
486 return mImpl->mTapGestureDetector;
489 LongPressGestureDetector Control::GetLongPressGestureDetector() const
491 return mImpl->mLongPressGestureDetector;
494 void Control::SetBackgroundColor( const Vector4& color )
496 Background& background( mImpl->GetBackground() );
498 if ( background.actor )
500 // Just set the actor color
501 background.actor.SetColor( color );
506 MeshActor meshActor = MeshActor::New( CreateMesh() );
508 SetupBackgroundActor( meshActor, Actor::Property::SCALE, color );
510 // Set the background actor before adding so that we do not inform deriving classes
511 background.actor = meshActor;
512 Self().Add( meshActor );
515 background.color = color;
518 Vector4 Control::GetBackgroundColor() const
520 if ( mImpl->mBackground )
522 return mImpl->mBackground->color;
524 return Color::TRANSPARENT;
527 void Control::SetBackgroundImage( Image image )
529 Background& background( mImpl->GetBackground() );
531 if ( background.actor )
533 // Remove Current actor, unset AFTER removal so that we do not inform deriving classes
534 Self().Remove( background.actor );
535 background.actor.Reset();
538 ImageActor imageActor = ImageActor::New( image );
539 SetupBackgroundActor( imageActor, Actor::Property::SIZE, background.color );
541 // Set the background actor before adding so that we do not inform derived classes
542 background.actor = imageActor;
543 Self().Add( imageActor );
546 void Control::ClearBackground()
548 if ( mImpl->mBackground )
550 Background& background( mImpl->GetBackground() );
551 Self().Remove( background.actor );
553 delete mImpl->mBackground;
554 mImpl->mBackground = NULL;
558 Actor Control::GetBackgroundActor() const
560 if ( mImpl->mBackground )
562 return mImpl->mBackground->actor;
568 void Control::SetKeyboardNavigationSupport(bool isSupported)
570 mImpl->mIsKeyboardNavigationSupported = isSupported;
573 bool Control::IsKeyboardNavigationSupported()
575 return mImpl->mIsKeyboardNavigationSupported;
578 void Control::Activate()
580 // Inform deriving classes
584 bool Control::OnAccessibilityPan(PanGesture gesture)
586 return false; // Accessibility pan gesture is not handled by default
589 bool Control::OnAccessibilityTouch(const TouchEvent& touchEvent)
591 return false; // Accessibility touch event is not handled by default
594 bool Control::OnAccessibilityValueChange(bool isIncrease)
596 return false; // Accessibility value change action is not handled by default
599 void Control::SetAsKeyboardFocusGroup(bool isFocusGroup)
601 mImpl->mIsKeyboardFocusGroup = isFocusGroup;
603 // The following line will be removed when the deprecated API in KeyboardFocusManager is deleted
604 Toolkit::KeyboardFocusManager::Get().SetAsFocusGroup(Self(), isFocusGroup);
607 bool Control::IsKeyboardFocusGroup()
609 return Toolkit::KeyboardFocusManager::Get().IsFocusGroup(Self());
612 Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled)
617 void Control::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
621 bool Control::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes)
625 if( object && ( 0 == strcmp( actionName.c_str(), ACTION_CONTROL_ACTIVATED ) ) )
627 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
630 // if cast succeeds there is an implementation so no need to check
631 control.GetImplementation().OnActivated();
638 bool Control::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
640 Dali::BaseHandle handle( object );
642 bool connected( false );
643 Toolkit::Control control = Toolkit::Control::DownCast( handle );
646 Control& controlImpl( control.GetImplementation() );
649 if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
651 controlImpl.KeyEventSignal().Connect( tracker, functor );
653 else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
655 controlImpl.EnableGestureDetection( Gesture::Tap );
656 controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
658 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
660 controlImpl.EnableGestureDetection( Gesture::Pan );
661 controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
663 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
665 controlImpl.EnableGestureDetection( Gesture::Pinch );
666 controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
668 else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
670 controlImpl.EnableGestureDetection( Gesture::LongPress );
671 controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
675 // signalName does not match any signal
682 Toolkit::Control::KeyEventSignalType& Control::KeyEventSignal()
684 return mImpl->mKeyEventSignal;
687 bool Control::EmitKeyEventSignal( const KeyEvent& event )
689 // Guard against destruction during signal emission
690 Dali::Toolkit::Control handle( GetOwner() );
692 bool consumed = false;
694 // signals are allocated dynamically when someone connects
695 if ( !mImpl->mKeyEventSignal.Empty() )
697 consumed = mImpl->mKeyEventSignal.Emit( handle, event );
702 // Notification for derived classes
703 consumed = OnKeyEvent(event);
709 Control::Control( ControlBehaviour behaviourFlags )
710 : CustomActorImpl( behaviourFlags & REQUIRES_TOUCH_EVENTS ),
711 mImpl(new Impl(*this))
713 mImpl->mFlags = behaviourFlags;
716 void Control::Initialize()
718 // Calling deriving classes
721 // Test if the no size negotiation flag is not set
722 if( ( mImpl->mFlags & NO_SIZE_NEGOTIATION ) == 0 )
724 // Size negotiate disabled by default, so turn it on for this actor
725 Self().SetRelayoutEnabled( true );
728 if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
730 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
732 // Register for style changes
733 styleManager.StyleChangeSignal().Connect( this, &Control::DoStyleChange );
736 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
739 SetRequiresHoverEvents(mImpl->mFlags & REQUIRES_HOVER_EVENTS);
740 SetRequiresMouseWheelEvents(mImpl->mFlags & REQUIRES_MOUSE_WHEEL_EVENTS);
742 mImpl->mInitialized = true;
745 void Control::EnableGestureDetection(Gesture::Type type)
747 if ( (type & Gesture::Pinch) && !mImpl->mPinchGestureDetector )
749 mImpl->mPinchGestureDetector = PinchGestureDetector::New();
750 mImpl->mPinchGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PinchDetected);
751 mImpl->mPinchGestureDetector.Attach(Self());
754 if ( (type & Gesture::Pan) && !mImpl->mPanGestureDetector )
756 mImpl->mPanGestureDetector = PanGestureDetector::New();
757 mImpl->mPanGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PanDetected);
758 mImpl->mPanGestureDetector.Attach(Self());
761 if ( (type & Gesture::Tap) && !mImpl->mTapGestureDetector )
763 mImpl->mTapGestureDetector = TapGestureDetector::New();
764 mImpl->mTapGestureDetector.DetectedSignal().Connect(mImpl, &Impl::TapDetected);
765 mImpl->mTapGestureDetector.Attach(Self());
768 if ( (type & Gesture::LongPress) && !mImpl->mLongPressGestureDetector )
770 mImpl->mLongPressGestureDetector = LongPressGestureDetector::New();
771 mImpl->mLongPressGestureDetector.DetectedSignal().Connect(mImpl, &Impl::LongPressDetected);
772 mImpl->mLongPressGestureDetector.Attach(Self());
776 void Control::DisableGestureDetection(Gesture::Type type)
778 if ( (type & Gesture::Pinch) && mImpl->mPinchGestureDetector )
780 mImpl->mPinchGestureDetector.Detach(Self());
781 mImpl->mPinchGestureDetector.Reset();
784 if ( (type & Gesture::Pan) && mImpl->mPanGestureDetector )
786 mImpl->mPanGestureDetector.Detach(Self());
787 mImpl->mPanGestureDetector.Reset();
790 if ( (type & Gesture::Tap) && mImpl->mTapGestureDetector )
792 mImpl->mTapGestureDetector.Detach(Self());
793 mImpl->mTapGestureDetector.Reset();
796 if ( (type & Gesture::LongPress) && mImpl->mLongPressGestureDetector)
798 mImpl->mLongPressGestureDetector.Detach(Self());
799 mImpl->mLongPressGestureDetector.Reset();
803 void Control::OnInitialize()
807 void Control::OnActivated()
811 void Control::OnThemeChange( Toolkit::StyleManager styleManager )
813 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
816 void Control::OnFontChange( bool defaultFontChange, bool defaultFontSizeChange )
820 void Control::OnPinch(const PinchGesture& pinch)
822 if( !( mImpl->mStartingPinchScale ) )
825 mImpl->mStartingPinchScale = new Vector3;
828 if( pinch.state == Gesture::Started )
830 *( mImpl->mStartingPinchScale ) = Self().GetCurrentScale();
833 Self().SetScale( *( mImpl->mStartingPinchScale ) * pinch.scale );
836 void Control::OnPan( const PanGesture& pan )
840 void Control::OnTap(const TapGesture& tap)
844 void Control::OnLongPress( const LongPressGesture& longPress )
848 void Control::OnControlStageConnection()
852 void Control::OnControlStageDisconnection()
856 void Control::OnControlChildAdd( Actor& child )
860 void Control::OnControlChildRemove( Actor& child )
864 void Control::OnControlSizeSet( const Vector3& size )
868 void Control::OnCalculateRelayoutSize( Dimension dimension )
872 void Control::OnLayoutNegotiated( float size, Dimension dimension )
876 void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
878 for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i )
880 container.Add( Self().GetChildAt( i ), size );
884 void Control::OnSetResizePolicy( ResizePolicy policy, Dimension dimension )
888 void Control::OnKeyInputFocusGained()
893 void Control::OnKeyInputFocusLost()
898 void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
900 // @todo consider animating negotiated child sizes to target size
903 bool Control::OnTouchEvent(const TouchEvent& event)
905 return false; // Do not consume
908 bool Control::OnHoverEvent(const HoverEvent& event)
910 return false; // Do not consume
913 bool Control::OnKeyEvent(const KeyEvent& event)
915 return false; // Do not consume
918 bool Control::OnMouseWheelEvent(const MouseWheelEvent& event)
920 return false; // Do not consume
923 void Control::OnStageConnection()
925 // Notify derived classes.
926 OnControlStageConnection();
929 void Control::OnStageDisconnection()
931 // Notify derived classes
932 OnControlStageDisconnection();
935 void Control::OnChildAdd(Actor& child)
937 // If this is the background actor, then we do not want to relayout or inform deriving classes
938 if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) )
943 // Notify derived classes.
944 OnControlChildAdd( child );
947 void Control::OnChildRemove(Actor& child)
949 // If this is the background actor, then we do not want to relayout or inform deriving classes
950 if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) )
955 // Notify derived classes.
956 OnControlChildRemove( child );
959 void Control::OnSizeSet(const Vector3& targetSize)
961 if( targetSize != mImpl->mNaturalSize )
963 // Only updates size if set through Actor's API
964 mImpl->mNaturalSize = targetSize;
967 if( targetSize != mImpl->mCurrentSize )
969 // Update control size.
970 mImpl->mCurrentSize = targetSize;
972 // Notify derived classes.
973 OnControlSizeSet( targetSize );
977 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
979 mImpl->SignalConnected( slotObserver, callback );
982 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
984 mImpl->SignalDisconnected( slotObserver, callback );
987 void Control::DoStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
989 if( change.themeChange )
991 OnThemeChange( styleManager );
993 else if( change.defaultFontChange || change.defaultFontSizeChange )
995 OnFontChange( change.defaultFontChange, change.defaultFontSizeChange );
999 } // namespace Internal
1001 } // namespace Toolkit