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 ),
169 mStartingPinchScale( NULL ),
171 mPinchGestureDetector(),
172 mPanGestureDetector(),
173 mTapGestureDetector(),
174 mLongPressGestureDetector(),
177 mFlags( Control::CONTROL_BEHAVIOUR_NONE ),
178 mIsKeyboardNavigationSupported( false ),
179 mIsKeyboardFocusGroup( false ),
180 mInitialized( false )
186 // All gesture detectors will be destroyed so no need to disconnect.
188 delete mStartingPinchScale;
191 // Gesture Detection Methods
193 void PinchDetected(Actor actor, const PinchGesture& pinch)
195 mControlImpl.OnPinch(pinch);
198 void PanDetected(Actor actor, const PanGesture& pan)
200 mControlImpl.OnPan(pan);
203 void TapDetected(Actor actor, const TapGesture& tap)
205 mControlImpl.OnTap(tap);
208 void LongPressDetected(Actor actor, const LongPressGesture& longPress)
210 mControlImpl.OnLongPress(longPress);
213 // Background Methods
216 * Only creates an instance of the background if we actually use it.
217 * @return A reference to the Background structure.
219 Background& GetBackground()
223 mBackground = new Background;
231 * Called when a property of an object of this type is set.
232 * @param[in] object The object whose property is set.
233 * @param[in] index The property index.
234 * @param[in] value The new property value.
236 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
238 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
242 Control& controlImpl( control.GetImplementation() );
246 case Toolkit::Control::Property::STYLE_NAME:
248 controlImpl.SetStyleName( value.Get< std::string >() );
252 case Toolkit::Control::Property::BACKGROUND_COLOR:
254 controlImpl.SetBackgroundColor( value.Get< Vector4 >() );
258 case Toolkit::Control::Property::BACKGROUND_IMAGE:
260 if ( value.HasKey( "image" ) )
262 Property::Map imageMap = value.GetValue( "image" ).Get< Property::Map >();
263 Image image = Scripting::NewImage( imageMap );
267 controlImpl.SetBackgroundImage( image );
270 else if ( value.Get< Property::Map >().Empty() )
272 // An empty map means the background is no longer required
273 controlImpl.ClearBackground();
278 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
280 if ( value.Get< bool >() )
282 controlImpl.SetKeyInputFocus();
286 controlImpl.ClearKeyInputFocus();
295 * Called to retrieve a property of an object of this type.
296 * @param[in] object The object whose property is to be retrieved.
297 * @param[in] index The property index.
298 * @return The current value of the property.
300 static Property::Value GetProperty( BaseObject* object, Property::Index index )
302 Property::Value value;
304 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
308 Control& controlImpl( control.GetImplementation() );
312 case Toolkit::Control::Property::STYLE_NAME:
314 value = controlImpl.GetStyleName();
318 case Toolkit::Control::Property::BACKGROUND_COLOR:
320 value = controlImpl.GetBackgroundColor();
324 case Toolkit::Control::Property::BACKGROUND_IMAGE:
328 Actor actor = controlImpl.GetBackgroundActor();
331 ImageActor imageActor = ImageActor::DownCast( actor );
334 Image image = imageActor.GetImage();
335 Property::Map imageMap;
336 Scripting::CreatePropertyMap( image, imageMap );
337 map[ "image" ] = imageMap;
345 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
347 value = controlImpl.HasKeyInputFocus();
358 Control& mControlImpl;
359 std::string mStyleName;
360 Background* mBackground; ///< Only create the background if we use it
361 Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
362 Toolkit::Control::KeyEventSignalType mKeyEventSignal;
365 PinchGestureDetector mPinchGestureDetector;
366 PanGestureDetector mPanGestureDetector;
367 TapGestureDetector mTapGestureDetector;
368 LongPressGestureDetector mLongPressGestureDetector;
369 // @todo change all these to Vector2 when we have a chance to sanitize the public API as well
370 Vector3 mCurrentSize; ///< Stores the current control's size, this is the negotiated size
371 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.
373 ControlBehaviour mFlags :6; ///< Flags passed in from constructor. Need to increase this size when new enums are added
374 bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
375 bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
376 bool mInitialized :1;
378 // Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
379 static PropertyRegistration PROPERTY_1;
380 static PropertyRegistration PROPERTY_2;
381 static PropertyRegistration PROPERTY_3;
382 static PropertyRegistration PROPERTY_4;
385 // Properties registered without macro to use specific member variables.
386 PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "style-name", Toolkit::Control::Property::STYLE_NAME, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
387 PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background-color", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
388 PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "background-image", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
389 PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "key-input-focus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
391 Toolkit::Control Control::New()
393 // Create the implementation, temporarily owned on stack
394 IntrusivePtr<Control> controlImpl = new Control( CONTROL_BEHAVIOUR_NONE );
396 // Pass ownership to handle
397 Toolkit::Control handle( *controlImpl );
399 // Second-phase init of the implementation
400 // This can only be done after the CustomActor connection has been made...
401 controlImpl->Initialize();
411 Vector3 Control::GetNaturalSize()
413 // could be overridden in derived classes.
414 return mImpl->mNaturalSize;
417 float Control::CalculateChildSize( const Dali::Actor& child, Dimension dimension )
419 // Could be overridden in derived classes.
420 return CalculateChildSizeBase( child, dimension );
423 bool Control::RelayoutDependentOnChildren( Dimension dimension )
425 return RelayoutDependentOnChildrenBase( dimension );
428 float Control::GetHeightForWidth( float width )
430 // could be overridden in derived classes.
431 float height( 0.0f );
432 if ( mImpl->mNaturalSize.width > 0.0f )
434 height = mImpl->mNaturalSize.height * width / mImpl->mNaturalSize.width;
439 float Control::GetWidthForHeight( float height )
441 // could be overridden in derived classes.
443 if ( mImpl->mNaturalSize.height > 0.0f )
445 width = mImpl->mNaturalSize.width * height / mImpl->mNaturalSize.height;
450 const Vector3& Control::GetControlSize() const
452 return mImpl->mCurrentSize;
455 const Vector3& Control::GetSizeSet() const
457 return mImpl->mNaturalSize;
460 void Control::SetKeyInputFocus()
462 if( Self().OnStage() )
464 Toolkit::KeyInputFocusManager::Get().SetFocus(Toolkit::Control::DownCast(Self()));
468 bool Control::HasKeyInputFocus()
471 if( Self().OnStage() )
473 result = Toolkit::KeyInputFocusManager::Get().IsKeyboardListener(Toolkit::Control::DownCast(Self()));
478 void Control::ClearKeyInputFocus()
480 if( Self().OnStage() )
482 Toolkit::KeyInputFocusManager::Get().RemoveFocus(Toolkit::Control::DownCast(Self()));
486 PinchGestureDetector Control::GetPinchGestureDetector() const
488 return mImpl->mPinchGestureDetector;
491 PanGestureDetector Control::GetPanGestureDetector() const
493 return mImpl->mPanGestureDetector;
496 TapGestureDetector Control::GetTapGestureDetector() const
498 return mImpl->mTapGestureDetector;
501 LongPressGestureDetector Control::GetLongPressGestureDetector() const
503 return mImpl->mLongPressGestureDetector;
506 void Control::SetStyleName( const std::string& styleName )
508 if( styleName != mImpl->mStyleName )
510 mImpl->mStyleName = styleName;
513 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
514 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
518 const std::string& Control::GetStyleName() const
520 return mImpl->mStyleName;
523 void Control::SetBackgroundColor( const Vector4& color )
525 Background& background( mImpl->GetBackground() );
527 if ( background.actor )
529 // Just set the actor color
530 background.actor.SetColor( color );
535 MeshActor meshActor = MeshActor::New( CreateMesh() );
537 SetupBackgroundActor( meshActor, Actor::Property::SCALE, color );
539 // Set the background actor before adding so that we do not inform deriving classes
540 background.actor = meshActor;
541 Self().Add( meshActor );
544 background.color = color;
547 Vector4 Control::GetBackgroundColor() const
549 if ( mImpl->mBackground )
551 return mImpl->mBackground->color;
553 return Color::TRANSPARENT;
556 void Control::SetBackgroundImage( Image image )
558 Background& background( mImpl->GetBackground() );
560 if ( background.actor )
562 // Remove Current actor, unset AFTER removal so that we do not inform deriving classes
563 Self().Remove( background.actor );
564 background.actor.Reset();
567 ImageActor imageActor = ImageActor::New( image );
568 SetupBackgroundActor( imageActor, Actor::Property::SIZE, background.color );
570 // Set the background actor before adding so that we do not inform derived classes
571 background.actor = imageActor;
572 Self().Add( imageActor );
575 void Control::ClearBackground()
577 if ( mImpl->mBackground )
579 Background& background( mImpl->GetBackground() );
580 Self().Remove( background.actor );
582 delete mImpl->mBackground;
583 mImpl->mBackground = NULL;
587 Actor Control::GetBackgroundActor() const
589 if ( mImpl->mBackground )
591 return mImpl->mBackground->actor;
597 void Control::SetKeyboardNavigationSupport(bool isSupported)
599 mImpl->mIsKeyboardNavigationSupported = isSupported;
602 bool Control::IsKeyboardNavigationSupported()
604 return mImpl->mIsKeyboardNavigationSupported;
607 void Control::Activate()
609 // Inform deriving classes
613 bool Control::OnAccessibilityPan(PanGesture gesture)
615 return false; // Accessibility pan gesture is not handled by default
618 bool Control::OnAccessibilityTouch(const TouchEvent& touchEvent)
620 return false; // Accessibility touch event is not handled by default
623 bool Control::OnAccessibilityValueChange(bool isIncrease)
625 return false; // Accessibility value change action is not handled by default
628 void Control::SetAsKeyboardFocusGroup(bool isFocusGroup)
630 mImpl->mIsKeyboardFocusGroup = isFocusGroup;
632 // The following line will be removed when the deprecated API in KeyboardFocusManager is deleted
633 Toolkit::KeyboardFocusManager::Get().SetAsFocusGroup(Self(), isFocusGroup);
636 bool Control::IsKeyboardFocusGroup()
638 return Toolkit::KeyboardFocusManager::Get().IsFocusGroup(Self());
641 Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled)
646 void Control::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
650 bool Control::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes)
654 if( object && ( 0 == strcmp( actionName.c_str(), ACTION_CONTROL_ACTIVATED ) ) )
656 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
659 // if cast succeeds there is an implementation so no need to check
660 control.GetImplementation().OnActivated();
667 bool Control::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
669 Dali::BaseHandle handle( object );
671 bool connected( false );
672 Toolkit::Control control = Toolkit::Control::DownCast( handle );
675 Control& controlImpl( control.GetImplementation() );
678 if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
680 controlImpl.KeyEventSignal().Connect( tracker, functor );
682 else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
684 controlImpl.EnableGestureDetection( Gesture::Tap );
685 controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
687 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
689 controlImpl.EnableGestureDetection( Gesture::Pan );
690 controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
692 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
694 controlImpl.EnableGestureDetection( Gesture::Pinch );
695 controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
697 else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
699 controlImpl.EnableGestureDetection( Gesture::LongPress );
700 controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
704 // signalName does not match any signal
711 Toolkit::Control::KeyEventSignalType& Control::KeyEventSignal()
713 return mImpl->mKeyEventSignal;
716 bool Control::EmitKeyEventSignal( const KeyEvent& event )
718 // Guard against destruction during signal emission
719 Dali::Toolkit::Control handle( GetOwner() );
721 bool consumed = false;
723 // signals are allocated dynamically when someone connects
724 if ( !mImpl->mKeyEventSignal.Empty() )
726 consumed = mImpl->mKeyEventSignal.Emit( handle, event );
731 // Notification for derived classes
732 consumed = OnKeyEvent(event);
738 Control::Control( ControlBehaviour behaviourFlags )
739 : CustomActorImpl( behaviourFlags & REQUIRES_TOUCH_EVENTS ),
740 mImpl(new Impl(*this))
742 mImpl->mFlags = behaviourFlags;
745 void Control::Initialize()
747 // Calling deriving classes
750 // Test if the no size negotiation flag is not set
751 if( ( mImpl->mFlags & NO_SIZE_NEGOTIATION ) == 0 )
753 // Size negotiate disabled by default, so turn it on for this actor
754 Self().SetRelayoutEnabled( true );
757 if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
759 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
761 // Register for style changes
762 styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
765 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
768 SetRequiresHoverEvents(mImpl->mFlags & REQUIRES_HOVER_EVENTS);
769 SetRequiresMouseWheelEvents(mImpl->mFlags & REQUIRES_MOUSE_WHEEL_EVENTS);
771 mImpl->mInitialized = true;
774 void Control::EnableGestureDetection(Gesture::Type type)
776 if ( (type & Gesture::Pinch) && !mImpl->mPinchGestureDetector )
778 mImpl->mPinchGestureDetector = PinchGestureDetector::New();
779 mImpl->mPinchGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PinchDetected);
780 mImpl->mPinchGestureDetector.Attach(Self());
783 if ( (type & Gesture::Pan) && !mImpl->mPanGestureDetector )
785 mImpl->mPanGestureDetector = PanGestureDetector::New();
786 mImpl->mPanGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PanDetected);
787 mImpl->mPanGestureDetector.Attach(Self());
790 if ( (type & Gesture::Tap) && !mImpl->mTapGestureDetector )
792 mImpl->mTapGestureDetector = TapGestureDetector::New();
793 mImpl->mTapGestureDetector.DetectedSignal().Connect(mImpl, &Impl::TapDetected);
794 mImpl->mTapGestureDetector.Attach(Self());
797 if ( (type & Gesture::LongPress) && !mImpl->mLongPressGestureDetector )
799 mImpl->mLongPressGestureDetector = LongPressGestureDetector::New();
800 mImpl->mLongPressGestureDetector.DetectedSignal().Connect(mImpl, &Impl::LongPressDetected);
801 mImpl->mLongPressGestureDetector.Attach(Self());
805 void Control::DisableGestureDetection(Gesture::Type type)
807 if ( (type & Gesture::Pinch) && mImpl->mPinchGestureDetector )
809 mImpl->mPinchGestureDetector.Detach(Self());
810 mImpl->mPinchGestureDetector.Reset();
813 if ( (type & Gesture::Pan) && mImpl->mPanGestureDetector )
815 mImpl->mPanGestureDetector.Detach(Self());
816 mImpl->mPanGestureDetector.Reset();
819 if ( (type & Gesture::Tap) && mImpl->mTapGestureDetector )
821 mImpl->mTapGestureDetector.Detach(Self());
822 mImpl->mTapGestureDetector.Reset();
825 if ( (type & Gesture::LongPress) && mImpl->mLongPressGestureDetector)
827 mImpl->mLongPressGestureDetector.Detach(Self());
828 mImpl->mLongPressGestureDetector.Reset();
832 void Control::OnInitialize()
836 void Control::OnActivated()
840 void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
842 // By default the control is only interested in theme (not font) changes
843 if( change.themeChange )
845 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
849 void Control::OnPinch(const PinchGesture& pinch)
851 if( !( mImpl->mStartingPinchScale ) )
854 mImpl->mStartingPinchScale = new Vector3;
857 if( pinch.state == Gesture::Started )
859 *( mImpl->mStartingPinchScale ) = Self().GetCurrentScale();
862 Self().SetScale( *( mImpl->mStartingPinchScale ) * pinch.scale );
865 void Control::OnPan( const PanGesture& pan )
869 void Control::OnTap(const TapGesture& tap)
873 void Control::OnLongPress( const LongPressGesture& longPress )
877 void Control::OnControlStageConnection()
881 void Control::OnControlStageDisconnection()
885 void Control::OnControlChildAdd( Actor& child )
889 void Control::OnControlChildRemove( Actor& child )
893 void Control::OnControlSizeSet( const Vector3& size )
897 void Control::OnCalculateRelayoutSize( Dimension dimension )
901 void Control::OnLayoutNegotiated( float size, Dimension dimension )
905 void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
907 for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i )
909 container.Add( Self().GetChildAt( i ), size );
913 void Control::OnSetResizePolicy( ResizePolicy policy, Dimension dimension )
917 void Control::OnKeyInputFocusGained()
922 void Control::OnKeyInputFocusLost()
927 void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
929 // @todo consider animating negotiated child sizes to target size
932 bool Control::OnTouchEvent(const TouchEvent& event)
934 return false; // Do not consume
937 bool Control::OnHoverEvent(const HoverEvent& event)
939 return false; // Do not consume
942 bool Control::OnKeyEvent(const KeyEvent& event)
944 return false; // Do not consume
947 bool Control::OnMouseWheelEvent(const MouseWheelEvent& event)
949 return false; // Do not consume
952 void Control::OnStageConnection()
954 // Notify derived classes.
955 OnControlStageConnection();
958 void Control::OnStageDisconnection()
960 // Notify derived classes
961 OnControlStageDisconnection();
964 void Control::OnChildAdd(Actor& child)
966 // If this is the background actor, then we do not want to relayout or inform deriving classes
967 if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) )
972 // Notify derived classes.
973 OnControlChildAdd( child );
976 void Control::OnChildRemove(Actor& child)
978 // If this is the background actor, then we do not want to relayout or inform deriving classes
979 if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) )
984 // Notify derived classes.
985 OnControlChildRemove( child );
988 void Control::OnSizeSet(const Vector3& targetSize)
990 if( targetSize != mImpl->mNaturalSize )
992 // Only updates size if set through Actor's API
993 mImpl->mNaturalSize = targetSize;
996 if( targetSize != mImpl->mCurrentSize )
998 // Update control size.
999 mImpl->mCurrentSize = targetSize;
1001 // Notify derived classes.
1002 OnControlSizeSet( targetSize );
1006 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
1008 mImpl->SignalConnected( slotObserver, callback );
1011 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
1013 mImpl->SignalDisconnected( slotObserver, callback );
1016 } // namespace Internal
1018 } // namespace Toolkit