2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/public-api/controls/control-impl.h>
22 #include <cstring> // for strcmp
25 #include <dali/public-api/animation/constraint.h>
26 #include <dali/public-api/animation/constraints.h>
27 #include <dali/public-api/object/type-registry.h>
28 #include <dali/public-api/size-negotiation/relayout-container.h>
29 #include <dali/devel-api/object/type-registry-helper.h>
30 #include <dali/devel-api/rendering/renderer.h>
31 #include <dali/devel-api/scripting/scripting.h>
32 #include <dali/integration-api/debug.h>
35 #include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
36 #include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
37 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
38 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
39 #include <dali-toolkit/public-api/controls/control.h>
40 #include <dali-toolkit/devel-api/styling/style-manager.h>
41 #include <dali-toolkit/internal/styling/style-manager-impl.h>
42 #include <dali-toolkit/internal/controls/renderers/color/color-renderer.h>
54 * Creates control through type registry
58 return Internal::Control::New();
62 * Performs actions as requested using the action name.
63 * @param[in] object The object on which to perform the action.
64 * @param[in] actionName The action to perform.
65 * @param[in] attributes The attributes with which to perfrom this action.
66 * @return true if action has been accepted by this control
68 const char* ACTION_ACCESSIBILITY_ACTIVATED = "accessibilityActivated";
69 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
73 if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) ) )
75 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
78 // if cast succeeds there is an implementation so no need to check
79 ret = Internal::GetImplementation( control ).OnAccessibilityActivated();
87 * Connects a callback function with the object's signals.
88 * @param[in] object The object providing the signal.
89 * @param[in] tracker Used to disconnect the signal.
90 * @param[in] signalName The signal to connect to.
91 * @param[in] functor A newly allocated FunctorDelegate.
92 * @return True if the signal was connected.
93 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
95 const char* SIGNAL_KEY_EVENT = "keyEvent";
96 const char* SIGNAL_KEY_INPUT_FOCUS_GAINED = "keyInputFocusGained";
97 const char* SIGNAL_KEY_INPUT_FOCUS_LOST = "keyInputFocusLost";
98 const char* SIGNAL_TAPPED = "tapped";
99 const char* SIGNAL_PANNED = "panned";
100 const char* SIGNAL_PINCHED = "pinched";
101 const char* SIGNAL_LONG_PRESSED = "longPressed";
102 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
104 Dali::BaseHandle handle( object );
106 bool connected( false );
107 Toolkit::Control control = Toolkit::Control::DownCast( handle );
110 Internal::Control& controlImpl( Internal::GetImplementation( control ) );
113 if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
115 controlImpl.KeyEventSignal().Connect( tracker, functor );
117 else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_GAINED ) )
119 controlImpl.KeyInputFocusGainedSignal().Connect( tracker, functor );
121 else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_LOST ) )
123 controlImpl.KeyInputFocusLostSignal().Connect( tracker, functor );
125 else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
127 controlImpl.EnableGestureDetection( Gesture::Tap );
128 controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
130 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
132 controlImpl.EnableGestureDetection( Gesture::Pan );
133 controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
135 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
137 controlImpl.EnableGestureDetection( Gesture::Pinch );
138 controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
140 else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
142 controlImpl.EnableGestureDetection( Gesture::LongPress );
143 controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
149 // Setup signals and actions using the type-registry.
150 DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
152 // Note: Properties are registered separately below.
154 SignalConnectorType registerSignal1( typeRegistration, SIGNAL_KEY_EVENT, &DoConnectSignal );
155 SignalConnectorType registerSignal2( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_GAINED, &DoConnectSignal );
156 SignalConnectorType registerSignal3( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_LOST, &DoConnectSignal );
157 SignalConnectorType registerSignal4( typeRegistration, SIGNAL_TAPPED, &DoConnectSignal );
158 SignalConnectorType registerSignal5( typeRegistration, SIGNAL_PANNED, &DoConnectSignal );
159 SignalConnectorType registerSignal6( typeRegistration, SIGNAL_PINCHED, &DoConnectSignal );
160 SignalConnectorType registerSignal7( typeRegistration, SIGNAL_LONG_PRESSED, &DoConnectSignal );
162 TypeAction registerAction( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &DoAction );
164 DALI_TYPE_REGISTRATION_END()
166 const char * const BACKGROUND_COLOR_NAME("color");
167 const char * const COLOR_RENDERER_COLOR_NAME("blendColor");
169 } // unnamed namespace
174 class Control::Impl : public ConnectionTracker
178 // Construction & Destruction
179 Impl(Control& controlImpl)
180 : mControlImpl( controlImpl ),
182 mBackgroundRenderer(),
183 mStartingPinchScale( NULL ),
185 mPinchGestureDetector(),
186 mPanGestureDetector(),
187 mTapGestureDetector(),
188 mLongPressGestureDetector(),
189 mFlags( Control::ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
190 mIsKeyboardNavigationSupported( false ),
191 mIsKeyboardFocusGroup( false ),
192 mAddRemoveBackgroundChild( false )
198 // All gesture detectors will be destroyed so no need to disconnect.
199 delete mStartingPinchScale;
202 // Gesture Detection Methods
204 void PinchDetected(Actor actor, const PinchGesture& pinch)
206 mControlImpl.OnPinch(pinch);
209 void PanDetected(Actor actor, const PanGesture& pan)
211 mControlImpl.OnPan(pan);
214 void TapDetected(Actor actor, const TapGesture& tap)
216 mControlImpl.OnTap(tap);
219 void LongPressDetected(Actor actor, const LongPressGesture& longPress)
221 mControlImpl.OnLongPress(longPress);
227 * Called when a property of an object of this type is set.
228 * @param[in] object The object whose property is set.
229 * @param[in] index The property index.
230 * @param[in] value The new property value.
232 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
234 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
238 Control& controlImpl( GetImplementation( control ) );
242 case Toolkit::Control::Property::STYLE_NAME:
244 controlImpl.SetStyleName( value.Get< std::string >() );
247 case Toolkit::Control::Property::BACKGROUND:
249 Image image = Scripting::NewImage( value );
252 controlImpl.SetBackgroundImage( image );
255 const Property::Map* map = value.GetMap();
258 controlImpl.SetBackground( *map );
262 // The background is neither a valid image nor a property map, so it is no longer required
263 controlImpl.ClearBackground();
267 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
269 if ( value.Get< bool >() )
271 controlImpl.SetKeyInputFocus();
275 controlImpl.ClearKeyInputFocus();
284 * Called to retrieve a property of an object of this type.
285 * @param[in] object The object whose property is to be retrieved.
286 * @param[in] index The property index.
287 * @return The current value of the property.
289 static Property::Value GetProperty( BaseObject* object, Property::Index index )
291 Property::Value value;
293 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
297 Control& controlImpl( GetImplementation( control ) );
301 case Toolkit::Control::Property::STYLE_NAME:
303 value = controlImpl.GetStyleName();
307 case Toolkit::Control::Property::BACKGROUND:
310 if( controlImpl.mImpl->mBackgroundRenderer )
312 (controlImpl.mImpl->mBackgroundRenderer).CreatePropertyMap( map );
319 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
321 value = controlImpl.HasKeyInputFocus();
332 Control& mControlImpl;
333 std::string mStyleName;
334 Toolkit::ControlRenderer mBackgroundRenderer; ///< The control renderer to render the background
335 Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
336 Toolkit::Control::KeyEventSignalType mKeyEventSignal;
337 Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal;
338 Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal;
341 PinchGestureDetector mPinchGestureDetector;
342 PanGestureDetector mPanGestureDetector;
343 TapGestureDetector mTapGestureDetector;
344 LongPressGestureDetector mLongPressGestureDetector;
346 ControlBehaviour mFlags :CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor.
347 bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
348 bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
349 bool mAddRemoveBackgroundChild:1; ///< Flag to know when we are adding or removing our own actor to avoid call to OnControlChildAdd
351 // Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
352 static PropertyRegistration PROPERTY_1;
353 static PropertyRegistration PROPERTY_2;
354 static PropertyRegistration PROPERTY_3;
357 // Properties registered without macro to use specific member variables.
358 PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "styleName", Toolkit::Control::Property::STYLE_NAME, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
359 PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background", Toolkit::Control::Property::BACKGROUND, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
360 PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "keyInputFocus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
362 Toolkit::Control Control::New()
364 // Create the implementation, temporarily owned on stack
365 IntrusivePtr<Control> controlImpl = new Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) );
367 // Pass ownership to handle
368 Toolkit::Control handle( *controlImpl );
370 // Second-phase init of the implementation
371 // This can only be done after the CustomActor connection has been made...
372 controlImpl->Initialize();
382 void Control::SetStyleName( const std::string& styleName )
384 if( styleName != mImpl->mStyleName )
386 mImpl->mStyleName = styleName;
388 // Apply new style, if stylemanager is available
389 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
392 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
397 const std::string& Control::GetStyleName() const
399 return mImpl->mStyleName;
402 void Control::SetBackgroundColor( const Vector4& color )
404 Actor self( Self() );
405 Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
406 factory.ResetRenderer( mImpl->mBackgroundRenderer, self, color );
407 mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
410 Vector4 Control::GetBackgroundColor() const
412 if( mImpl->mBackgroundRenderer && ( &typeid( GetImplementation(mImpl->mBackgroundRenderer) ) == &typeid( ColorRenderer ) ) )
415 mImpl->mBackgroundRenderer.CreatePropertyMap( map );
416 const Property::Value* colorValue = map.Find( COLOR_RENDERER_COLOR_NAME );
418 if( colorValue && colorValue->Get(color))
424 return Color::TRANSPARENT;
427 void Control::SetBackground(const Property::Map& map)
429 const Property::Value* colorValue = map.Find( BACKGROUND_COLOR_NAME );
431 if( colorValue && colorValue->Get(color))
433 SetBackgroundColor( color );
437 Actor self( Self() );
438 mImpl->mBackgroundRenderer.RemoveAndReset( self );
439 Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
440 mImpl->mBackgroundRenderer = factory.GetControlRenderer( map );
441 if( mImpl->mBackgroundRenderer && self.OnStage() ) // Request control renderer with a property map might return an empty handle
443 mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
444 mImpl->mBackgroundRenderer.SetOnStage( self );
448 void Control::SetBackgroundImage( Image image )
450 Actor self( Self() );
451 Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
452 factory.ResetRenderer( mImpl->mBackgroundRenderer, self, image );
453 mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
456 void Control::ClearBackground()
458 Actor self( Self() );
459 mImpl->mBackgroundRenderer.RemoveAndReset( self );
462 void Control::EnableGestureDetection(Gesture::Type type)
464 if ( (type & Gesture::Pinch) && !mImpl->mPinchGestureDetector )
466 mImpl->mPinchGestureDetector = PinchGestureDetector::New();
467 mImpl->mPinchGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PinchDetected);
468 mImpl->mPinchGestureDetector.Attach(Self());
471 if ( (type & Gesture::Pan) && !mImpl->mPanGestureDetector )
473 mImpl->mPanGestureDetector = PanGestureDetector::New();
474 mImpl->mPanGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PanDetected);
475 mImpl->mPanGestureDetector.Attach(Self());
478 if ( (type & Gesture::Tap) && !mImpl->mTapGestureDetector )
480 mImpl->mTapGestureDetector = TapGestureDetector::New();
481 mImpl->mTapGestureDetector.DetectedSignal().Connect(mImpl, &Impl::TapDetected);
482 mImpl->mTapGestureDetector.Attach(Self());
485 if ( (type & Gesture::LongPress) && !mImpl->mLongPressGestureDetector )
487 mImpl->mLongPressGestureDetector = LongPressGestureDetector::New();
488 mImpl->mLongPressGestureDetector.DetectedSignal().Connect(mImpl, &Impl::LongPressDetected);
489 mImpl->mLongPressGestureDetector.Attach(Self());
493 void Control::DisableGestureDetection(Gesture::Type type)
495 if ( (type & Gesture::Pinch) && mImpl->mPinchGestureDetector )
497 mImpl->mPinchGestureDetector.Detach(Self());
498 mImpl->mPinchGestureDetector.Reset();
501 if ( (type & Gesture::Pan) && mImpl->mPanGestureDetector )
503 mImpl->mPanGestureDetector.Detach(Self());
504 mImpl->mPanGestureDetector.Reset();
507 if ( (type & Gesture::Tap) && mImpl->mTapGestureDetector )
509 mImpl->mTapGestureDetector.Detach(Self());
510 mImpl->mTapGestureDetector.Reset();
513 if ( (type & Gesture::LongPress) && mImpl->mLongPressGestureDetector)
515 mImpl->mLongPressGestureDetector.Detach(Self());
516 mImpl->mLongPressGestureDetector.Reset();
520 PinchGestureDetector Control::GetPinchGestureDetector() const
522 return mImpl->mPinchGestureDetector;
525 PanGestureDetector Control::GetPanGestureDetector() const
527 return mImpl->mPanGestureDetector;
530 TapGestureDetector Control::GetTapGestureDetector() const
532 return mImpl->mTapGestureDetector;
535 LongPressGestureDetector Control::GetLongPressGestureDetector() const
537 return mImpl->mLongPressGestureDetector;
540 void Control::SetKeyboardNavigationSupport(bool isSupported)
542 mImpl->mIsKeyboardNavigationSupported = isSupported;
545 bool Control::IsKeyboardNavigationSupported()
547 return mImpl->mIsKeyboardNavigationSupported;
550 void Control::SetKeyInputFocus()
552 if( Self().OnStage() )
554 Toolkit::KeyInputFocusManager::Get().SetFocus(Toolkit::Control::DownCast(Self()));
558 bool Control::HasKeyInputFocus()
561 if( Self().OnStage() )
563 result = Toolkit::KeyInputFocusManager::Get().IsKeyboardListener(Toolkit::Control::DownCast(Self()));
568 void Control::ClearKeyInputFocus()
570 if( Self().OnStage() )
572 Toolkit::KeyInputFocusManager::Get().RemoveFocus(Toolkit::Control::DownCast(Self()));
576 void Control::SetAsKeyboardFocusGroup(bool isFocusGroup)
578 mImpl->mIsKeyboardFocusGroup = isFocusGroup;
580 // The following line will be removed when the deprecated API in KeyboardFocusManager is deleted
581 Toolkit::KeyboardFocusManager::Get().SetAsFocusGroup(Self(), isFocusGroup);
584 bool Control::IsKeyboardFocusGroup()
586 return Toolkit::KeyboardFocusManager::Get().IsFocusGroup(Self());
589 void Control::AccessibilityActivate()
591 // Inform deriving classes
592 OnAccessibilityActivated();
595 void Control::KeyboardEnter()
597 // Inform deriving classes
601 bool Control::OnAccessibilityActivated()
603 return false; // Accessibility activation is not handled by default
606 bool Control::OnKeyboardEnter()
608 return false; // Keyboard enter is not handled by default
611 bool Control::OnAccessibilityPan(PanGesture gesture)
613 return false; // Accessibility pan gesture is not handled by default
616 bool Control::OnAccessibilityTouch(const TouchEvent& touchEvent)
618 return false; // Accessibility touch event is not handled by default
621 bool Control::OnAccessibilityValueChange(bool isIncrease)
623 return false; // Accessibility value change action is not handled by default
626 bool Control::OnAccessibilityZoom()
628 return false; // Accessibility zoom action is not handled by default
631 Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocus::Direction direction, bool loopEnabled)
636 void Control::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
640 Toolkit::Control::KeyEventSignalType& Control::KeyEventSignal()
642 return mImpl->mKeyEventSignal;
645 Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusGainedSignal()
647 return mImpl->mKeyInputFocusGainedSignal;
650 Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusLostSignal()
652 return mImpl->mKeyInputFocusLostSignal;
655 bool Control::EmitKeyEventSignal( const KeyEvent& event )
657 // Guard against destruction during signal emission
658 Dali::Toolkit::Control handle( GetOwner() );
660 bool consumed = false;
662 // signals are allocated dynamically when someone connects
663 if ( !mImpl->mKeyEventSignal.Empty() )
665 consumed = mImpl->mKeyEventSignal.Emit( handle, event );
670 // Notification for derived classes
671 consumed = OnKeyEvent(event);
677 Control::Control( ControlBehaviour behaviourFlags )
678 : CustomActorImpl( static_cast< ActorFlags >( behaviourFlags ) ),
679 mImpl(new Impl(*this))
681 mImpl->mFlags = behaviourFlags;
684 void Control::Initialize()
686 // Call deriving classes so initialised before styling is applied to them.
689 if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
691 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
692 // if stylemanager is available
695 // Register for style changes
696 styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
698 // Apply the current style
699 GetImpl( styleManager ).ApplyThemeStyleAtInit( Toolkit::Control( GetOwner() ) );
703 if( mImpl->mFlags & REQUIRES_KEYBOARD_NAVIGATION_SUPPORT )
705 SetKeyboardNavigationSupport( true );
709 void Control::OnInitialize()
713 void Control::OnControlChildAdd( Actor& child )
717 void Control::OnControlChildRemove( Actor& child )
721 void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
723 // By default the control is only interested in theme (not font) changes
724 if( styleManager && change == StyleChange::THEME_CHANGE )
726 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
730 void Control::OnPinch(const PinchGesture& pinch)
732 if( !( mImpl->mStartingPinchScale ) )
735 mImpl->mStartingPinchScale = new Vector3;
738 if( pinch.state == Gesture::Started )
740 *( mImpl->mStartingPinchScale ) = Self().GetCurrentScale();
743 Self().SetScale( *( mImpl->mStartingPinchScale ) * pinch.scale );
746 void Control::OnPan( const PanGesture& pan )
750 void Control::OnTap(const TapGesture& tap)
754 void Control::OnLongPress( const LongPressGesture& longPress )
758 void Control::EmitKeyInputFocusSignal( bool focusGained )
760 Dali::Toolkit::Control handle( GetOwner() );
764 // signals are allocated dynamically when someone connects
765 if ( !mImpl->mKeyInputFocusGainedSignal.Empty() )
767 mImpl->mKeyInputFocusGainedSignal.Emit( handle );
772 // signals are allocated dynamically when someone connects
773 if ( !mImpl->mKeyInputFocusLostSignal.Empty() )
775 mImpl->mKeyInputFocusLostSignal.Emit( handle );
780 void Control::OnStageConnection( int depth )
782 if( mImpl->mBackgroundRenderer)
784 Actor self( Self() );
785 mImpl->mBackgroundRenderer.SetOnStage( self );
789 void Control::OnStageDisconnection()
791 if( mImpl->mBackgroundRenderer )
793 Actor self( Self() );
794 mImpl->mBackgroundRenderer.SetOffStage( self );
798 void Control::OnKeyInputFocusGained()
800 EmitKeyInputFocusSignal( true );
803 void Control::OnKeyInputFocusLost()
805 EmitKeyInputFocusSignal( false );
808 void Control::OnChildAdd(Actor& child)
810 // If this is the background actor, then we do not want to inform deriving classes
811 if ( mImpl->mAddRemoveBackgroundChild )
816 // Notify derived classes.
817 OnControlChildAdd( child );
820 void Control::OnChildRemove(Actor& child)
822 // If this is the background actor, then we do not want to inform deriving classes
823 if ( mImpl->mAddRemoveBackgroundChild )
828 // Notify derived classes.
829 OnControlChildRemove( child );
832 void Control::OnSizeSet(const Vector3& targetSize)
834 // Background is resized through size negotiation
837 void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
839 // @todo size negotiate background to new size, animate as well?
842 bool Control::OnTouchEvent(const TouchEvent& event)
844 return false; // Do not consume
847 bool Control::OnHoverEvent(const HoverEvent& event)
849 return false; // Do not consume
852 bool Control::OnKeyEvent(const KeyEvent& event)
854 return false; // Do not consume
857 bool Control::OnWheelEvent(const WheelEvent& event)
859 return false; // Do not consume
862 void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
864 for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i )
866 container.Add( Self().GetChildAt( i ), size );
870 void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
874 Vector3 Control::GetNaturalSize()
876 if( mImpl->mBackgroundRenderer )
879 mImpl->mBackgroundRenderer.GetNaturalSize(naturalSize);
880 return Vector3(naturalSize);
882 return Vector3::ZERO;
885 float Control::CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
887 return CalculateChildSizeBase( child, dimension );
890 float Control::GetHeightForWidth( float width )
892 return GetHeightForWidthBase( width );
895 float Control::GetWidthForHeight( float height )
897 return GetWidthForHeightBase( height );
900 bool Control::RelayoutDependentOnChildren( Dimension::Type dimension )
902 return RelayoutDependentOnChildrenBase( dimension );
905 void Control::OnCalculateRelayoutSize( Dimension::Type dimension )
909 void Control::OnLayoutNegotiated( float size, Dimension::Type dimension )
913 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
915 mImpl->SignalConnected( slotObserver, callback );
918 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
920 mImpl->SignalDisconnected( slotObserver, callback );
923 Control& GetImplementation( Dali::Toolkit::Control& handle )
925 CustomActorImpl& customInterface = handle.GetImplementation();
926 // downcast to control
927 Control& impl = dynamic_cast< Internal::Control& >( customInterface );
931 const Control& GetImplementation( const Dali::Toolkit::Control& handle )
933 const CustomActorImpl& customInterface = handle.GetImplementation();
934 // downcast to control
935 const Control& impl = dynamic_cast< const Internal::Control& >( customInterface );
939 } // namespace Internal
941 } // namespace Toolkit