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/constraint.h>
26 #include <dali/public-api/animation/constraints.h>
27 #include <dali/public-api/geometry/mesh.h>
28 #include <dali/public-api/object/type-registry.h>
29 #include <dali/public-api/object/type-registry-helper.h>
30 #include <dali/public-api/scripting/scripting.h>
31 #include <dali/public-api/size-negotiation/relayout-container.h>
32 #include <dali/integration-api/debug.h>
35 #include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
36 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
37 #include <dali-toolkit/public-api/controls/control.h>
38 #include <dali-toolkit/public-api/styling/style-manager.h>
39 #include <dali-toolkit/internal/styling/style-manager-impl.h>
50 #if defined(DEBUG_ENABLED)
51 Integration::Log::Filter* gLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_CONTROL");
54 const float MAX_FLOAT_VALUE( std::numeric_limits<float>::max() );
55 const Vector3 MAX_SIZE( MAX_FLOAT_VALUE, MAX_FLOAT_VALUE, MAX_FLOAT_VALUE );
56 const float BACKGROUND_ACTOR_Z_POSITION( -0.1f );
60 return Internal::Control::New();
63 // Setup signals and actions using the type-registry.
64 DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
66 // Note: Properties are registered separately below,
68 DALI_SIGNAL_REGISTRATION( Control, "key-event", SIGNAL_KEY_EVENT )
69 DALI_SIGNAL_REGISTRATION( Control, "tapped", SIGNAL_TAPPED )
70 DALI_SIGNAL_REGISTRATION( Control, "panned", SIGNAL_PANNED )
71 DALI_SIGNAL_REGISTRATION( Control, "pinched", SIGNAL_PINCHED )
72 DALI_SIGNAL_REGISTRATION( Control, "long-pressed", SIGNAL_LONG_PRESSED )
74 DALI_ACTION_REGISTRATION( Control, "control-activated", ACTION_CONTROL_ACTIVATED )
76 DALI_TYPE_REGISTRATION_END()
79 * Structure which holds information about the background of a control
83 Actor actor; ///< Either a MeshActor or an ImageActor
84 Vector4 color; ///< The color of the actor.
97 * Creates a white coloured Mesh.
101 Vector3 white( Color::WHITE );
105 // Create vertices with a white color (actual color is set by actor color)
106 MeshData::VertexContainer vertices(4);
107 vertices[ 0 ] = MeshData::Vertex( Vector3( -0.5f, -0.5f, 0.0f ), Vector2::ZERO, white );
108 vertices[ 1 ] = MeshData::Vertex( Vector3( 0.5f, -0.5f, 0.0f ), Vector2::ZERO, white );
109 vertices[ 2 ] = MeshData::Vertex( Vector3( -0.5f, 0.5f, 0.0f ), Vector2::ZERO, white );
110 vertices[ 3 ] = MeshData::Vertex( Vector3( 0.5f, 0.5f, 0.0f ), Vector2::ZERO, white );
112 // Specify all the faces
113 MeshData::FaceIndices faces;
114 faces.reserve( 6 ); // 2 triangles in Quad
115 faces.push_back( 0 ); faces.push_back( 3 ); faces.push_back( 1 );
116 faces.push_back( 0 ); faces.push_back( 2 ); faces.push_back( 3 );
118 // Create the mesh data from the vertices and faces
119 meshData.SetMaterial( Material::New( "ControlMaterial" ) );
120 meshData.SetVertices( vertices );
121 meshData.SetFaceIndices( faces );
122 meshData.SetHasColor( true );
124 return Mesh::New( meshData );
128 * Sets all the required properties for the background actor.
130 * @param[in] actor The actor to set the properties on.
131 * @param[in] constrainingIndex The property index to constrain the parent's size on.
132 * @param[in] color The required color of the actor.
134 void SetupBackgroundActor( Actor actor, Property::Index constrainingIndex, const Vector4& color )
136 actor.SetColor( color );
137 actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
138 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
139 actor.SetZ( BACKGROUND_ACTOR_Z_POSITION );
140 actor.SetRelayoutEnabled( false );
142 Constraint constraint = Constraint::New<Vector3>( actor,
144 EqualToConstraint() );
145 constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
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 ),
173 mStartingPinchScale( NULL ),
175 mPinchGestureDetector(),
176 mPanGestureDetector(),
177 mTapGestureDetector(),
178 mLongPressGestureDetector(),
181 mFlags( Control::CONTROL_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;
369 PinchGestureDetector mPinchGestureDetector;
370 PanGestureDetector mPanGestureDetector;
371 TapGestureDetector mTapGestureDetector;
372 LongPressGestureDetector mLongPressGestureDetector;
373 // @todo change all these to Vector2 when we have a chance to sanitize the public API as well
374 Vector3 mCurrentSize; ///< Stores the current control's size, this is the negotiated size
375 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.
377 ControlBehaviour mFlags :6; ///< Flags passed in from constructor. Need to increase this size when new enums are added
378 bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
379 bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
380 bool mInitialized :1;
382 // Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
383 static PropertyRegistration PROPERTY_1;
384 static PropertyRegistration PROPERTY_2;
385 static PropertyRegistration PROPERTY_3;
386 static PropertyRegistration PROPERTY_4;
389 // Properties registered without macro to use specific member variables.
390 PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "style-name", Toolkit::Control::Property::STYLE_NAME, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
391 PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background-color", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
392 PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "background-image", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
393 PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "key-input-focus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
395 Toolkit::Control Control::New()
397 // Create the implementation, temporarily owned on stack
398 IntrusivePtr<Control> controlImpl = new Control( CONTROL_BEHAVIOUR_NONE );
400 // Pass ownership to handle
401 Toolkit::Control handle( *controlImpl );
403 // Second-phase init of the implementation
404 // This can only be done after the CustomActor connection has been made...
405 controlImpl->Initialize();
415 Vector3 Control::GetNaturalSize()
417 // could be overridden in derived classes.
418 return mImpl->mNaturalSize;
421 float Control::CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
423 // Could be overridden in derived classes.
424 return CalculateChildSizeBase( child, dimension );
427 bool Control::RelayoutDependentOnChildren( Dimension::Type dimension )
429 return RelayoutDependentOnChildrenBase( dimension );
432 float Control::GetHeightForWidth( float width )
434 // could be overridden in derived classes.
435 float height( 0.0f );
436 if ( mImpl->mNaturalSize.width > 0.0f )
438 height = mImpl->mNaturalSize.height * width / mImpl->mNaturalSize.width;
443 float Control::GetWidthForHeight( float height )
445 // could be overridden in derived classes.
447 if ( mImpl->mNaturalSize.height > 0.0f )
449 width = mImpl->mNaturalSize.width * height / mImpl->mNaturalSize.height;
454 const Vector3& Control::GetControlSize() const
456 return mImpl->mCurrentSize;
459 const Vector3& Control::GetSizeSet() const
461 return mImpl->mNaturalSize;
464 void Control::SetKeyInputFocus()
466 if( Self().OnStage() )
468 Toolkit::KeyInputFocusManager::Get().SetFocus(Toolkit::Control::DownCast(Self()));
472 bool Control::HasKeyInputFocus()
475 if( Self().OnStage() )
477 result = Toolkit::KeyInputFocusManager::Get().IsKeyboardListener(Toolkit::Control::DownCast(Self()));
482 void Control::ClearKeyInputFocus()
484 if( Self().OnStage() )
486 Toolkit::KeyInputFocusManager::Get().RemoveFocus(Toolkit::Control::DownCast(Self()));
490 PinchGestureDetector Control::GetPinchGestureDetector() const
492 return mImpl->mPinchGestureDetector;
495 PanGestureDetector Control::GetPanGestureDetector() const
497 return mImpl->mPanGestureDetector;
500 TapGestureDetector Control::GetTapGestureDetector() const
502 return mImpl->mTapGestureDetector;
505 LongPressGestureDetector Control::GetLongPressGestureDetector() const
507 return mImpl->mLongPressGestureDetector;
510 void Control::SetStyleName( const std::string& styleName )
512 if( styleName != mImpl->mStyleName )
514 mImpl->mStyleName = styleName;
517 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
518 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
522 const std::string& Control::GetStyleName() const
524 return mImpl->mStyleName;
527 void Control::SetBackgroundColor( const Vector4& color )
529 Background& background( mImpl->GetBackground() );
531 if ( background.actor )
533 // Just set the actor color
534 background.actor.SetColor( color );
539 MeshActor meshActor = MeshActor::New( CreateMesh() );
541 SetupBackgroundActor( meshActor, Actor::Property::SCALE, color );
543 // Set the background actor before adding so that we do not inform deriving classes
544 background.actor = meshActor;
545 Self().Add( meshActor );
548 background.color = color;
551 Vector4 Control::GetBackgroundColor() const
553 if ( mImpl->mBackground )
555 return mImpl->mBackground->color;
557 return Color::TRANSPARENT;
560 void Control::SetBackgroundImage( Image image )
562 Background& background( mImpl->GetBackground() );
564 if ( background.actor )
566 // Remove Current actor, unset AFTER removal so that we do not inform deriving classes
567 Self().Remove( background.actor );
568 background.actor.Reset();
571 ImageActor imageActor = ImageActor::New( image );
572 SetupBackgroundActor( imageActor, Actor::Property::SIZE, background.color );
574 // Set the background actor before adding so that we do not inform derived classes
575 background.actor = imageActor;
576 Self().Add( imageActor );
579 void Control::ClearBackground()
581 if ( mImpl->mBackground )
583 Background& background( mImpl->GetBackground() );
584 Self().Remove( background.actor );
586 delete mImpl->mBackground;
587 mImpl->mBackground = NULL;
591 Actor Control::GetBackgroundActor() const
593 if ( mImpl->mBackground )
595 return mImpl->mBackground->actor;
601 void Control::SetKeyboardNavigationSupport(bool isSupported)
603 mImpl->mIsKeyboardNavigationSupported = isSupported;
606 bool Control::IsKeyboardNavigationSupported()
608 return mImpl->mIsKeyboardNavigationSupported;
611 void Control::Activate()
613 // Inform deriving classes
617 bool Control::OnAccessibilityPan(PanGesture gesture)
619 return false; // Accessibility pan gesture is not handled by default
622 bool Control::OnAccessibilityTouch(const TouchEvent& touchEvent)
624 return false; // Accessibility touch event is not handled by default
627 bool Control::OnAccessibilityValueChange(bool isIncrease)
629 return false; // Accessibility value change action is not handled by default
632 void Control::SetAsKeyboardFocusGroup(bool isFocusGroup)
634 mImpl->mIsKeyboardFocusGroup = isFocusGroup;
636 // The following line will be removed when the deprecated API in KeyboardFocusManager is deleted
637 Toolkit::KeyboardFocusManager::Get().SetAsFocusGroup(Self(), isFocusGroup);
640 bool Control::IsKeyboardFocusGroup()
642 return Toolkit::KeyboardFocusManager::Get().IsFocusGroup(Self());
645 Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled)
650 void Control::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
654 bool Control::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes)
658 if( object && ( 0 == strcmp( actionName.c_str(), ACTION_CONTROL_ACTIVATED ) ) )
660 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
663 // if cast succeeds there is an implementation so no need to check
664 control.GetImplementation().OnActivated();
671 bool Control::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
673 Dali::BaseHandle handle( object );
675 bool connected( false );
676 Toolkit::Control control = Toolkit::Control::DownCast( handle );
679 Control& controlImpl( control.GetImplementation() );
682 if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
684 controlImpl.KeyEventSignal().Connect( tracker, functor );
686 else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
688 controlImpl.EnableGestureDetection( Gesture::Tap );
689 controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
691 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
693 controlImpl.EnableGestureDetection( Gesture::Pan );
694 controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
696 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
698 controlImpl.EnableGestureDetection( Gesture::Pinch );
699 controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
701 else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
703 controlImpl.EnableGestureDetection( Gesture::LongPress );
704 controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
708 // signalName does not match any signal
715 Toolkit::Control::KeyEventSignalType& Control::KeyEventSignal()
717 return mImpl->mKeyEventSignal;
720 bool Control::EmitKeyEventSignal( const KeyEvent& event )
722 // Guard against destruction during signal emission
723 Dali::Toolkit::Control handle( GetOwner() );
725 bool consumed = false;
727 // signals are allocated dynamically when someone connects
728 if ( !mImpl->mKeyEventSignal.Empty() )
730 consumed = mImpl->mKeyEventSignal.Emit( handle, event );
735 // Notification for derived classes
736 consumed = OnKeyEvent(event);
742 Control::Control( ControlBehaviour behaviourFlags )
743 : CustomActorImpl( behaviourFlags & REQUIRES_TOUCH_EVENTS ),
744 mImpl(new Impl(*this))
746 mImpl->mFlags = behaviourFlags;
749 void Control::Initialize()
751 // Calling deriving classes
754 // Test if the no size negotiation flag is not set
755 if( ( mImpl->mFlags & NO_SIZE_NEGOTIATION ) == 0 )
757 // Size negotiate disabled by default, so turn it on for this actor
758 Self().SetRelayoutEnabled( true );
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 SetRequiresHoverEvents(mImpl->mFlags & REQUIRES_HOVER_EVENTS);
773 SetRequiresMouseWheelEvents(mImpl->mFlags & REQUIRES_MOUSE_WHEEL_EVENTS);
775 mImpl->mInitialized = true;
778 void Control::EnableGestureDetection(Gesture::Type type)
780 if ( (type & Gesture::Pinch) && !mImpl->mPinchGestureDetector )
782 mImpl->mPinchGestureDetector = PinchGestureDetector::New();
783 mImpl->mPinchGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PinchDetected);
784 mImpl->mPinchGestureDetector.Attach(Self());
787 if ( (type & Gesture::Pan) && !mImpl->mPanGestureDetector )
789 mImpl->mPanGestureDetector = PanGestureDetector::New();
790 mImpl->mPanGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PanDetected);
791 mImpl->mPanGestureDetector.Attach(Self());
794 if ( (type & Gesture::Tap) && !mImpl->mTapGestureDetector )
796 mImpl->mTapGestureDetector = TapGestureDetector::New();
797 mImpl->mTapGestureDetector.DetectedSignal().Connect(mImpl, &Impl::TapDetected);
798 mImpl->mTapGestureDetector.Attach(Self());
801 if ( (type & Gesture::LongPress) && !mImpl->mLongPressGestureDetector )
803 mImpl->mLongPressGestureDetector = LongPressGestureDetector::New();
804 mImpl->mLongPressGestureDetector.DetectedSignal().Connect(mImpl, &Impl::LongPressDetected);
805 mImpl->mLongPressGestureDetector.Attach(Self());
809 void Control::DisableGestureDetection(Gesture::Type type)
811 if ( (type & Gesture::Pinch) && mImpl->mPinchGestureDetector )
813 mImpl->mPinchGestureDetector.Detach(Self());
814 mImpl->mPinchGestureDetector.Reset();
817 if ( (type & Gesture::Pan) && mImpl->mPanGestureDetector )
819 mImpl->mPanGestureDetector.Detach(Self());
820 mImpl->mPanGestureDetector.Reset();
823 if ( (type & Gesture::Tap) && mImpl->mTapGestureDetector )
825 mImpl->mTapGestureDetector.Detach(Self());
826 mImpl->mTapGestureDetector.Reset();
829 if ( (type & Gesture::LongPress) && mImpl->mLongPressGestureDetector)
831 mImpl->mLongPressGestureDetector.Detach(Self());
832 mImpl->mLongPressGestureDetector.Reset();
836 void Control::OnInitialize()
840 void Control::OnActivated()
844 void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
846 // By default the control is only interested in theme (not font) changes
847 if( change.themeChange )
849 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
853 void Control::OnPinch(const PinchGesture& pinch)
855 if( !( mImpl->mStartingPinchScale ) )
858 mImpl->mStartingPinchScale = new Vector3;
861 if( pinch.state == Gesture::Started )
863 *( mImpl->mStartingPinchScale ) = Self().GetCurrentScale();
866 Self().SetScale( *( mImpl->mStartingPinchScale ) * pinch.scale );
869 void Control::OnPan( const PanGesture& pan )
873 void Control::OnTap(const TapGesture& tap)
877 void Control::OnLongPress( const LongPressGesture& longPress )
881 void Control::OnControlStageConnection()
885 void Control::OnControlStageDisconnection()
889 void Control::OnControlChildAdd( Actor& child )
893 void Control::OnControlChildRemove( Actor& child )
897 void Control::OnControlSizeSet( const Vector3& size )
901 void Control::OnCalculateRelayoutSize( Dimension::Type dimension )
905 void Control::OnLayoutNegotiated( float size, Dimension::Type dimension )
909 void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
911 for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i )
913 container.Add( Self().GetChildAt( i ), size );
917 void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
921 void Control::OnKeyInputFocusGained()
926 void Control::OnKeyInputFocusLost()
931 void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
933 // @todo consider animating negotiated child sizes to target size
936 bool Control::OnTouchEvent(const TouchEvent& event)
938 return false; // Do not consume
941 bool Control::OnHoverEvent(const HoverEvent& event)
943 return false; // Do not consume
946 bool Control::OnKeyEvent(const KeyEvent& event)
948 return false; // Do not consume
951 bool Control::OnMouseWheelEvent(const MouseWheelEvent& event)
953 return false; // Do not consume
956 void Control::OnStageConnection()
958 // Notify derived classes.
959 OnControlStageConnection();
962 void Control::OnStageDisconnection()
964 // Notify derived classes
965 OnControlStageDisconnection();
968 void Control::OnChildAdd(Actor& child)
970 // If this is the background actor, then we do not want to relayout or inform deriving classes
971 if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) )
976 // Notify derived classes.
977 OnControlChildAdd( child );
980 void Control::OnChildRemove(Actor& child)
982 // If this is the background actor, then we do not want to relayout or inform deriving classes
983 if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) )
988 // Notify derived classes.
989 OnControlChildRemove( child );
992 void Control::OnSizeSet(const Vector3& targetSize)
994 if( targetSize != mImpl->mNaturalSize )
996 // Only updates size if set through Actor's API
997 mImpl->mNaturalSize = targetSize;
1000 if( targetSize != mImpl->mCurrentSize )
1002 // Update control size.
1003 mImpl->mCurrentSize = targetSize;
1005 // Notify derived classes.
1006 OnControlSizeSet( targetSize );
1010 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
1012 mImpl->SignalConnected( slotObserver, callback );
1015 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
1017 mImpl->SignalDisconnected( slotObserver, callback );
1020 } // namespace Internal
1022 } // namespace Toolkit