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( true );
142 actor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
145 } // unnamed namespace
150 class Control::Impl : public ConnectionTracker
155 * Size indices for mMinMaxSize array
164 // Construction & Destruction
165 Impl(Control& controlImpl)
166 : mControlImpl( controlImpl ),
168 mStartingPinchScale( NULL ),
170 mPinchGestureDetector(),
171 mPanGestureDetector(),
172 mTapGestureDetector(),
173 mLongPressGestureDetector(),
176 mFlags( Control::CONTROL_BEHAVIOUR_NONE ),
177 mIsKeyboardNavigationSupported( false ),
178 mIsKeyboardFocusGroup( false ),
179 mInitialized( false )
185 // All gesture detectors will be destroyed so no need to disconnect.
187 delete mStartingPinchScale;
190 // Gesture Detection Methods
192 void PinchDetected(Actor actor, const PinchGesture& pinch)
194 mControlImpl.OnPinch(pinch);
197 void PanDetected(Actor actor, const PanGesture& pan)
199 mControlImpl.OnPan(pan);
202 void TapDetected(Actor actor, const TapGesture& tap)
204 mControlImpl.OnTap(tap);
207 void LongPressDetected(Actor actor, const LongPressGesture& longPress)
209 mControlImpl.OnLongPress(longPress);
212 // Background Methods
215 * Only creates an instance of the background if we actually use it.
216 * @return A reference to the Background structure.
218 Background& GetBackground()
222 mBackground = new Background;
230 * Called when a property of an object of this type is set.
231 * @param[in] object The object whose property is set.
232 * @param[in] index The property index.
233 * @param[in] value The new property value.
235 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
237 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
241 Control& controlImpl( control.GetImplementation() );
245 case Toolkit::Control::Property::BACKGROUND_COLOR:
247 controlImpl.SetBackgroundColor( value.Get< Vector4 >() );
251 case Toolkit::Control::Property::BACKGROUND_IMAGE:
253 if ( value.HasKey( "image" ) )
255 Property::Map imageMap = value.GetValue( "image" ).Get< Property::Map >();
256 Image image = Scripting::NewImage( imageMap );
260 controlImpl.SetBackgroundImage( image );
263 else if ( value.Get< Property::Map >().Empty() )
265 // An empty map means the background is no longer required
266 controlImpl.ClearBackground();
271 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
273 if ( value.Get< bool >() )
275 controlImpl.SetKeyInputFocus();
279 controlImpl.ClearKeyInputFocus();
288 * Called to retrieve a property of an object of this type.
289 * @param[in] object The object whose property is to be retrieved.
290 * @param[in] index The property index.
291 * @return The current value of the property.
293 static Property::Value GetProperty( BaseObject* object, Property::Index index )
295 Property::Value value;
297 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
301 Control& controlImpl( control.GetImplementation() );
305 case Toolkit::Control::Property::BACKGROUND_COLOR:
307 value = controlImpl.GetBackgroundColor();
311 case Toolkit::Control::Property::BACKGROUND_IMAGE:
315 Actor actor = controlImpl.GetBackgroundActor();
318 ImageActor imageActor = ImageActor::DownCast( actor );
321 Image image = imageActor.GetImage();
322 Property::Map imageMap;
323 Scripting::CreatePropertyMap( image, imageMap );
324 map[ "image" ] = imageMap;
332 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
334 value = controlImpl.HasKeyInputFocus();
345 Control& mControlImpl;
346 Background* mBackground; ///< Only create the background if we use it
347 Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
348 Toolkit::Control::KeyEventSignalType mKeyEventSignal;
351 PinchGestureDetector mPinchGestureDetector;
352 PanGestureDetector mPanGestureDetector;
353 TapGestureDetector mTapGestureDetector;
354 LongPressGestureDetector mLongPressGestureDetector;
355 // @todo change all these to Vector2 when we have a chance to sanitize the public API as well
356 Vector3 mCurrentSize; ///< Stores the current control's size, this is the negotiated size
357 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.
359 ControlBehaviour mFlags :6; ///< Flags passed in from constructor. Need to increase this size when new enums are added
360 bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
361 bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
362 bool mInitialized :1;
364 // Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
365 static PropertyRegistration PROPERTY_1;
366 static PropertyRegistration PROPERTY_2;
367 static PropertyRegistration PROPERTY_3;
370 // Properties registered without macro to use specific member variables.
371 PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "background-color", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
372 PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background-image", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
373 PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "key-input-focus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
375 Toolkit::Control Control::New()
377 // Create the implementation, temporarily owned on stack
378 IntrusivePtr<Control> controlImpl = new Control( CONTROL_BEHAVIOUR_NONE );
380 // Pass ownership to handle
381 Toolkit::Control handle( *controlImpl );
383 // Second-phase init of the implementation
384 // This can only be done after the CustomActor connection has been made...
385 controlImpl->Initialize();
395 Vector3 Control::GetNaturalSize()
397 // could be overridden in derived classes.
398 return mImpl->mNaturalSize;
401 float Control::CalculateChildSize( const Dali::Actor& child, Dimension dimension )
403 // Could be overridden in derived classes.
404 return CalculateChildSizeBase( child, dimension );
407 bool Control::RelayoutDependentOnChildren( Dimension dimension )
409 return RelayoutDependentOnChildrenBase( dimension );
412 float Control::GetHeightForWidth( float width )
414 // could be overridden in derived classes.
415 float height( 0.0f );
416 if ( mImpl->mNaturalSize.width > 0.0f )
418 height = mImpl->mNaturalSize.height * width / mImpl->mNaturalSize.width;
423 float Control::GetWidthForHeight( float height )
425 // could be overridden in derived classes.
427 if ( mImpl->mNaturalSize.height > 0.0f )
429 width = mImpl->mNaturalSize.width * height / mImpl->mNaturalSize.height;
434 const Vector3& Control::GetControlSize() const
436 return mImpl->mCurrentSize;
439 const Vector3& Control::GetSizeSet() const
441 return mImpl->mNaturalSize;
444 void Control::SetKeyInputFocus()
446 if( Self().OnStage() )
448 Toolkit::KeyInputFocusManager::Get().SetFocus(Toolkit::Control::DownCast(Self()));
452 bool Control::HasKeyInputFocus()
455 if( Self().OnStage() )
457 result = Toolkit::KeyInputFocusManager::Get().IsKeyboardListener(Toolkit::Control::DownCast(Self()));
462 void Control::ClearKeyInputFocus()
464 if( Self().OnStage() )
466 Toolkit::KeyInputFocusManager::Get().RemoveFocus(Toolkit::Control::DownCast(Self()));
470 PinchGestureDetector Control::GetPinchGestureDetector() const
472 return mImpl->mPinchGestureDetector;
475 PanGestureDetector Control::GetPanGestureDetector() const
477 return mImpl->mPanGestureDetector;
480 TapGestureDetector Control::GetTapGestureDetector() const
482 return mImpl->mTapGestureDetector;
485 LongPressGestureDetector Control::GetLongPressGestureDetector() const
487 return mImpl->mLongPressGestureDetector;
490 void Control::SetBackgroundColor( const Vector4& color )
492 Background& background( mImpl->GetBackground() );
494 if ( background.actor )
496 // Just set the actor color
497 background.actor.SetColor( color );
502 MeshActor meshActor = MeshActor::New( CreateMesh() );
504 SetupBackgroundActor( meshActor, Actor::Property::SCALE, color );
506 // Set the background actor before adding so that we do not inform deriving classes
507 background.actor = meshActor;
508 Self().Add( meshActor );
511 background.color = color;
514 Vector4 Control::GetBackgroundColor() const
516 if ( mImpl->mBackground )
518 return mImpl->mBackground->color;
520 return Color::TRANSPARENT;
523 void Control::SetBackgroundImage( Image image )
525 Background& background( mImpl->GetBackground() );
527 if ( background.actor )
529 // Remove Current actor, unset AFTER removal so that we do not inform deriving classes
530 Self().Remove( background.actor );
531 background.actor.Reset();
534 ImageActor imageActor = ImageActor::New( image );
535 SetupBackgroundActor( imageActor, Actor::Property::SIZE, background.color );
537 // Set the background actor before adding so that we do not inform derived classes
538 background.actor = imageActor;
539 Self().Add( imageActor );
542 void Control::ClearBackground()
544 if ( mImpl->mBackground )
546 Background& background( mImpl->GetBackground() );
547 Self().Remove( background.actor );
549 delete mImpl->mBackground;
550 mImpl->mBackground = NULL;
554 Actor Control::GetBackgroundActor() const
556 if ( mImpl->mBackground )
558 return mImpl->mBackground->actor;
564 void Control::SetKeyboardNavigationSupport(bool isSupported)
566 mImpl->mIsKeyboardNavigationSupported = isSupported;
569 bool Control::IsKeyboardNavigationSupported()
571 return mImpl->mIsKeyboardNavigationSupported;
574 void Control::Activate()
576 // Inform deriving classes
580 bool Control::OnAccessibilityPan(PanGesture gesture)
582 return false; // Accessibility pan gesture is not handled by default
585 bool Control::OnAccessibilityTouch(const TouchEvent& touchEvent)
587 return false; // Accessibility touch event is not handled by default
590 bool Control::OnAccessibilityValueChange(bool isIncrease)
592 return false; // Accessibility value change action is not handled by default
595 void Control::SetAsKeyboardFocusGroup(bool isFocusGroup)
597 mImpl->mIsKeyboardFocusGroup = isFocusGroup;
599 // The following line will be removed when the deprecated API in KeyboardFocusManager is deleted
600 Toolkit::KeyboardFocusManager::Get().SetAsFocusGroup(Self(), isFocusGroup);
603 bool Control::IsKeyboardFocusGroup()
605 return Toolkit::KeyboardFocusManager::Get().IsFocusGroup(Self());
608 Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled)
613 void Control::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
617 bool Control::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes)
621 if( object && ( 0 == strcmp( actionName.c_str(), ACTION_CONTROL_ACTIVATED ) ) )
623 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
626 // if cast succeeds there is an implementation so no need to check
627 control.GetImplementation().OnActivated();
634 bool Control::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
636 Dali::BaseHandle handle( object );
638 bool connected( false );
639 Toolkit::Control control = Toolkit::Control::DownCast( handle );
642 Control& controlImpl( control.GetImplementation() );
645 if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
647 controlImpl.KeyEventSignal().Connect( tracker, functor );
649 else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
651 controlImpl.EnableGestureDetection( Gesture::Tap );
652 controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
654 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
656 controlImpl.EnableGestureDetection( Gesture::Pan );
657 controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
659 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
661 controlImpl.EnableGestureDetection( Gesture::Pinch );
662 controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
664 else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
666 controlImpl.EnableGestureDetection( Gesture::LongPress );
667 controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
671 // signalName does not match any signal
678 Toolkit::Control::KeyEventSignalType& Control::KeyEventSignal()
680 return mImpl->mKeyEventSignal;
683 bool Control::EmitKeyEventSignal( const KeyEvent& event )
685 // Guard against destruction during signal emission
686 Dali::Toolkit::Control handle( GetOwner() );
688 bool consumed = false;
690 // signals are allocated dynamically when someone connects
691 if ( !mImpl->mKeyEventSignal.Empty() )
693 consumed = mImpl->mKeyEventSignal.Emit( handle, event );
698 // Notification for derived classes
699 consumed = OnKeyEvent(event);
705 Control::Control( ControlBehaviour behaviourFlags )
706 : CustomActorImpl( behaviourFlags & REQUIRES_TOUCH_EVENTS ),
707 mImpl(new Impl(*this))
709 mImpl->mFlags = behaviourFlags;
712 void Control::Initialize()
714 // Calling deriving classes
717 // Test if the no size negotiation flag is not set
718 if( ( mImpl->mFlags & NO_SIZE_NEGOTIATION ) == 0 )
720 // Size negotiate disabled by default, so turn it on for this actor
721 Self().SetRelayoutEnabled( true );
724 if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
726 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
728 // Register for style changes
729 styleManager.StyleChangeSignal().Connect( this, &Control::DoStyleChange );
732 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
735 SetRequiresHoverEvents(mImpl->mFlags & REQUIRES_HOVER_EVENTS);
736 SetRequiresMouseWheelEvents(mImpl->mFlags & REQUIRES_MOUSE_WHEEL_EVENTS);
738 mImpl->mInitialized = true;
741 void Control::EnableGestureDetection(Gesture::Type type)
743 if ( (type & Gesture::Pinch) && !mImpl->mPinchGestureDetector )
745 mImpl->mPinchGestureDetector = PinchGestureDetector::New();
746 mImpl->mPinchGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PinchDetected);
747 mImpl->mPinchGestureDetector.Attach(Self());
750 if ( (type & Gesture::Pan) && !mImpl->mPanGestureDetector )
752 mImpl->mPanGestureDetector = PanGestureDetector::New();
753 mImpl->mPanGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PanDetected);
754 mImpl->mPanGestureDetector.Attach(Self());
757 if ( (type & Gesture::Tap) && !mImpl->mTapGestureDetector )
759 mImpl->mTapGestureDetector = TapGestureDetector::New();
760 mImpl->mTapGestureDetector.DetectedSignal().Connect(mImpl, &Impl::TapDetected);
761 mImpl->mTapGestureDetector.Attach(Self());
764 if ( (type & Gesture::LongPress) && !mImpl->mLongPressGestureDetector )
766 mImpl->mLongPressGestureDetector = LongPressGestureDetector::New();
767 mImpl->mLongPressGestureDetector.DetectedSignal().Connect(mImpl, &Impl::LongPressDetected);
768 mImpl->mLongPressGestureDetector.Attach(Self());
772 void Control::DisableGestureDetection(Gesture::Type type)
774 if ( (type & Gesture::Pinch) && mImpl->mPinchGestureDetector )
776 mImpl->mPinchGestureDetector.Detach(Self());
777 mImpl->mPinchGestureDetector.Reset();
780 if ( (type & Gesture::Pan) && mImpl->mPanGestureDetector )
782 mImpl->mPanGestureDetector.Detach(Self());
783 mImpl->mPanGestureDetector.Reset();
786 if ( (type & Gesture::Tap) && mImpl->mTapGestureDetector )
788 mImpl->mTapGestureDetector.Detach(Self());
789 mImpl->mTapGestureDetector.Reset();
792 if ( (type & Gesture::LongPress) && mImpl->mLongPressGestureDetector)
794 mImpl->mLongPressGestureDetector.Detach(Self());
795 mImpl->mLongPressGestureDetector.Reset();
799 void Control::OnInitialize()
803 void Control::OnActivated()
807 void Control::OnThemeChange( Toolkit::StyleManager styleManager )
809 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
812 void Control::OnFontChange( bool defaultFontChange, bool defaultFontSizeChange )
816 void Control::OnPinch(const PinchGesture& pinch)
818 if( !( mImpl->mStartingPinchScale ) )
821 mImpl->mStartingPinchScale = new Vector3;
824 if( pinch.state == Gesture::Started )
826 *( mImpl->mStartingPinchScale ) = Self().GetCurrentScale();
829 Self().SetScale( *( mImpl->mStartingPinchScale ) * pinch.scale );
832 void Control::OnPan( const PanGesture& pan )
836 void Control::OnTap(const TapGesture& tap)
840 void Control::OnLongPress( const LongPressGesture& longPress )
844 void Control::OnControlStageConnection()
848 void Control::OnControlStageDisconnection()
852 void Control::OnControlChildAdd( Actor& child )
856 void Control::OnControlChildRemove( Actor& child )
860 void Control::OnControlSizeSet( const Vector3& size )
864 void Control::OnCalculateRelayoutSize( Dimension dimension )
868 void Control::OnLayoutNegotiated( float size, Dimension dimension )
872 void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
874 for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i )
876 container.Add( Self().GetChildAt( i ), size );
880 void Control::OnSetResizePolicy( ResizePolicy policy, Dimension dimension )
884 void Control::OnKeyInputFocusGained()
889 void Control::OnKeyInputFocusLost()
894 void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
896 // @todo consider animating negotiated child sizes to target size
899 bool Control::OnTouchEvent(const TouchEvent& event)
901 return false; // Do not consume
904 bool Control::OnHoverEvent(const HoverEvent& event)
906 return false; // Do not consume
909 bool Control::OnKeyEvent(const KeyEvent& event)
911 return false; // Do not consume
914 bool Control::OnMouseWheelEvent(const MouseWheelEvent& event)
916 return false; // Do not consume
919 void Control::OnStageConnection()
921 // Notify derived classes.
922 OnControlStageConnection();
925 void Control::OnStageDisconnection()
927 // Notify derived classes
928 OnControlStageDisconnection();
931 void Control::OnChildAdd(Actor& child)
933 // If this is the background actor, then we do not want to relayout or inform deriving classes
934 if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) )
939 // Notify derived classes.
940 OnControlChildAdd( child );
943 void Control::OnChildRemove(Actor& child)
945 // If this is the background actor, then we do not want to relayout or inform deriving classes
946 if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) )
951 // Notify derived classes.
952 OnControlChildRemove( child );
955 void Control::OnSizeSet(const Vector3& targetSize)
957 if( targetSize != mImpl->mNaturalSize )
959 // Only updates size if set through Actor's API
960 mImpl->mNaturalSize = targetSize;
963 if( targetSize != mImpl->mCurrentSize )
965 // Update control size.
966 mImpl->mCurrentSize = targetSize;
968 // Notify derived classes.
969 OnControlSizeSet( targetSize );
973 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
975 mImpl->SignalConnected( slotObserver, callback );
978 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
980 mImpl->SignalDisconnected( slotObserver, callback );
983 void Control::DoStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
985 if( change.themeChange )
987 OnThemeChange( styleManager );
989 else if( change.defaultFontChange || change.defaultFontSizeChange )
991 OnFontChange( change.defaultFontChange, change.defaultFontSizeChange );
995 } // namespace Internal
997 } // namespace Toolkit