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>
43 #include <dali-toolkit/internal/controls/renderers/image/image-renderer.h>
55 * Creates control through type registry
59 return Internal::Control::New();
63 * Performs actions as requested using the action name.
64 * @param[in] object The object on which to perform the action.
65 * @param[in] actionName The action to perform.
66 * @param[in] attributes The attributes with which to perfrom this action.
67 * @return true if action has been accepted by this control
69 const char* ACTION_ACCESSIBILITY_ACTIVATED = "accessibilityActivated";
70 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
74 if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) ) )
76 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
79 // if cast succeeds there is an implementation so no need to check
80 ret = Internal::GetImplementation( control ).OnAccessibilityActivated();
88 * Connects a callback function with the object's signals.
89 * @param[in] object The object providing the signal.
90 * @param[in] tracker Used to disconnect the signal.
91 * @param[in] signalName The signal to connect to.
92 * @param[in] functor A newly allocated FunctorDelegate.
93 * @return True if the signal was connected.
94 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
96 const char* SIGNAL_KEY_EVENT = "keyEvent";
97 const char* SIGNAL_KEY_INPUT_FOCUS_GAINED = "keyInputFocusGained";
98 const char* SIGNAL_KEY_INPUT_FOCUS_LOST = "keyInputFocusLost";
99 const char* SIGNAL_TAPPED = "tapped";
100 const char* SIGNAL_PANNED = "panned";
101 const char* SIGNAL_PINCHED = "pinched";
102 const char* SIGNAL_LONG_PRESSED = "longPressed";
103 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
105 Dali::BaseHandle handle( object );
107 bool connected( false );
108 Toolkit::Control control = Toolkit::Control::DownCast( handle );
111 Internal::Control& controlImpl( Internal::GetImplementation( control ) );
114 if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
116 controlImpl.KeyEventSignal().Connect( tracker, functor );
118 else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_GAINED ) )
120 controlImpl.KeyInputFocusGainedSignal().Connect( tracker, functor );
122 else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_LOST ) )
124 controlImpl.KeyInputFocusLostSignal().Connect( tracker, functor );
126 else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
128 controlImpl.EnableGestureDetection( Gesture::Tap );
129 controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
131 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
133 controlImpl.EnableGestureDetection( Gesture::Pan );
134 controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
136 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
138 controlImpl.EnableGestureDetection( Gesture::Pinch );
139 controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
141 else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
143 controlImpl.EnableGestureDetection( Gesture::LongPress );
144 controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
150 // Setup signals and actions using the type-registry.
151 DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
153 // Note: Properties are registered separately below.
155 SignalConnectorType registerSignal1( typeRegistration, SIGNAL_KEY_EVENT, &DoConnectSignal );
156 SignalConnectorType registerSignal2( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_GAINED, &DoConnectSignal );
157 SignalConnectorType registerSignal3( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_LOST, &DoConnectSignal );
158 SignalConnectorType registerSignal4( typeRegistration, SIGNAL_TAPPED, &DoConnectSignal );
159 SignalConnectorType registerSignal5( typeRegistration, SIGNAL_PANNED, &DoConnectSignal );
160 SignalConnectorType registerSignal6( typeRegistration, SIGNAL_PINCHED, &DoConnectSignal );
161 SignalConnectorType registerSignal7( typeRegistration, SIGNAL_LONG_PRESSED, &DoConnectSignal );
163 TypeAction registerAction( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &DoAction );
165 DALI_TYPE_REGISTRATION_END()
167 const char * const BACKGROUND_COLOR_NAME("color");
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();
407 if( mImpl->mBackgroundRenderer )
409 factory.ResetRenderer( mImpl->mBackgroundRenderer, self, color );
413 mImpl->mBackgroundRenderer = factory.GetControlRenderer( color );
417 mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
418 mImpl->mBackgroundRenderer.SetOnStage( self );
423 Vector4 Control::GetBackgroundColor() const
425 return Color::TRANSPARENT;
428 void Control::SetBackground(const Property::Map& map)
430 const Property::Value* colorValue = map.Find( BACKGROUND_COLOR_NAME );
432 if( colorValue && colorValue->Get(color))
434 SetBackgroundColor( color );
438 Actor self( Self() );
439 mImpl->mBackgroundRenderer.RemoveAndReset( self );
441 Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
442 mImpl->mBackgroundRenderer = factory.GetControlRenderer( map );
444 // mBackgroundRenderer might be empty, if an invalid map is provided, no background.
445 if( self.OnStage() && mImpl->mBackgroundRenderer)
447 mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
448 mImpl->mBackgroundRenderer.SetOnStage( self );
452 void Control::SetBackgroundImage( Image image )
454 Actor self( Self() );
455 Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
457 if( mImpl->mBackgroundRenderer )
459 factory.ResetRenderer( mImpl->mBackgroundRenderer, self, image );
463 mImpl->mBackgroundRenderer = factory.GetControlRenderer( image );
467 mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
468 mImpl->mBackgroundRenderer.SetOnStage( self );
473 void Control::ClearBackground()
475 Actor self( Self() );
476 mImpl->mBackgroundRenderer.RemoveAndReset( self );
479 void Control::EnableGestureDetection(Gesture::Type type)
481 if ( (type & Gesture::Pinch) && !mImpl->mPinchGestureDetector )
483 mImpl->mPinchGestureDetector = PinchGestureDetector::New();
484 mImpl->mPinchGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PinchDetected);
485 mImpl->mPinchGestureDetector.Attach(Self());
488 if ( (type & Gesture::Pan) && !mImpl->mPanGestureDetector )
490 mImpl->mPanGestureDetector = PanGestureDetector::New();
491 mImpl->mPanGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PanDetected);
492 mImpl->mPanGestureDetector.Attach(Self());
495 if ( (type & Gesture::Tap) && !mImpl->mTapGestureDetector )
497 mImpl->mTapGestureDetector = TapGestureDetector::New();
498 mImpl->mTapGestureDetector.DetectedSignal().Connect(mImpl, &Impl::TapDetected);
499 mImpl->mTapGestureDetector.Attach(Self());
502 if ( (type & Gesture::LongPress) && !mImpl->mLongPressGestureDetector )
504 mImpl->mLongPressGestureDetector = LongPressGestureDetector::New();
505 mImpl->mLongPressGestureDetector.DetectedSignal().Connect(mImpl, &Impl::LongPressDetected);
506 mImpl->mLongPressGestureDetector.Attach(Self());
510 void Control::DisableGestureDetection(Gesture::Type type)
512 if ( (type & Gesture::Pinch) && mImpl->mPinchGestureDetector )
514 mImpl->mPinchGestureDetector.Detach(Self());
515 mImpl->mPinchGestureDetector.Reset();
518 if ( (type & Gesture::Pan) && mImpl->mPanGestureDetector )
520 mImpl->mPanGestureDetector.Detach(Self());
521 mImpl->mPanGestureDetector.Reset();
524 if ( (type & Gesture::Tap) && mImpl->mTapGestureDetector )
526 mImpl->mTapGestureDetector.Detach(Self());
527 mImpl->mTapGestureDetector.Reset();
530 if ( (type & Gesture::LongPress) && mImpl->mLongPressGestureDetector)
532 mImpl->mLongPressGestureDetector.Detach(Self());
533 mImpl->mLongPressGestureDetector.Reset();
537 PinchGestureDetector Control::GetPinchGestureDetector() const
539 return mImpl->mPinchGestureDetector;
542 PanGestureDetector Control::GetPanGestureDetector() const
544 return mImpl->mPanGestureDetector;
547 TapGestureDetector Control::GetTapGestureDetector() const
549 return mImpl->mTapGestureDetector;
552 LongPressGestureDetector Control::GetLongPressGestureDetector() const
554 return mImpl->mLongPressGestureDetector;
557 void Control::SetKeyboardNavigationSupport(bool isSupported)
559 mImpl->mIsKeyboardNavigationSupported = isSupported;
562 bool Control::IsKeyboardNavigationSupported()
564 return mImpl->mIsKeyboardNavigationSupported;
567 void Control::SetKeyInputFocus()
569 if( Self().OnStage() )
571 Toolkit::KeyInputFocusManager::Get().SetFocus(Toolkit::Control::DownCast(Self()));
575 bool Control::HasKeyInputFocus()
578 if( Self().OnStage() )
580 result = Toolkit::KeyInputFocusManager::Get().IsKeyboardListener(Toolkit::Control::DownCast(Self()));
585 void Control::ClearKeyInputFocus()
587 if( Self().OnStage() )
589 Toolkit::KeyInputFocusManager::Get().RemoveFocus(Toolkit::Control::DownCast(Self()));
593 void Control::SetAsKeyboardFocusGroup(bool isFocusGroup)
595 mImpl->mIsKeyboardFocusGroup = isFocusGroup;
597 // The following line will be removed when the deprecated API in KeyboardFocusManager is deleted
598 Toolkit::KeyboardFocusManager::Get().SetAsFocusGroup(Self(), isFocusGroup);
601 bool Control::IsKeyboardFocusGroup()
603 return Toolkit::KeyboardFocusManager::Get().IsFocusGroup(Self());
606 void Control::AccessibilityActivate()
608 // Inform deriving classes
609 OnAccessibilityActivated();
612 void Control::KeyboardEnter()
614 // Inform deriving classes
618 bool Control::OnAccessibilityActivated()
620 return false; // Accessibility activation is not handled by default
623 bool Control::OnKeyboardEnter()
625 return false; // Keyboard enter is not handled by default
628 bool Control::OnAccessibilityPan(PanGesture gesture)
630 return false; // Accessibility pan gesture is not handled by default
633 bool Control::OnAccessibilityTouch(const TouchEvent& touchEvent)
635 return false; // Accessibility touch event is not handled by default
638 bool Control::OnAccessibilityValueChange(bool isIncrease)
640 return false; // Accessibility value change action is not handled by default
643 bool Control::OnAccessibilityZoom()
645 return false; // Accessibility zoom action is not handled by default
648 Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocus::Direction direction, bool loopEnabled)
653 void Control::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
657 Toolkit::Control::KeyEventSignalType& Control::KeyEventSignal()
659 return mImpl->mKeyEventSignal;
662 Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusGainedSignal()
664 return mImpl->mKeyInputFocusGainedSignal;
667 Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusLostSignal()
669 return mImpl->mKeyInputFocusLostSignal;
672 bool Control::EmitKeyEventSignal( const KeyEvent& event )
674 // Guard against destruction during signal emission
675 Dali::Toolkit::Control handle( GetOwner() );
677 bool consumed = false;
679 // signals are allocated dynamically when someone connects
680 if ( !mImpl->mKeyEventSignal.Empty() )
682 consumed = mImpl->mKeyEventSignal.Emit( handle, event );
687 // Notification for derived classes
688 consumed = OnKeyEvent(event);
694 Control::Control( ControlBehaviour behaviourFlags )
695 : CustomActorImpl( static_cast< ActorFlags >( behaviourFlags ) ),
696 mImpl(new Impl(*this))
698 mImpl->mFlags = behaviourFlags;
701 void Control::Initialize()
703 // Call deriving classes so initialised before styling is applied to them.
706 if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
708 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
709 // if stylemanager is available
712 // Register for style changes
713 styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
715 // Apply the current style
716 GetImpl( styleManager ).ApplyThemeStyleAtInit( Toolkit::Control( GetOwner() ) );
720 if( mImpl->mFlags & REQUIRES_KEYBOARD_NAVIGATION_SUPPORT )
722 SetKeyboardNavigationSupport( true );
726 void Control::OnInitialize()
730 void Control::OnControlChildAdd( Actor& child )
734 void Control::OnControlChildRemove( Actor& child )
738 void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
740 // By default the control is only interested in theme (not font) changes
741 if( styleManager && change == StyleChange::THEME_CHANGE )
743 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
747 void Control::OnPinch(const PinchGesture& pinch)
749 if( !( mImpl->mStartingPinchScale ) )
752 mImpl->mStartingPinchScale = new Vector3;
755 if( pinch.state == Gesture::Started )
757 *( mImpl->mStartingPinchScale ) = Self().GetCurrentScale();
760 Self().SetScale( *( mImpl->mStartingPinchScale ) * pinch.scale );
763 void Control::OnPan( const PanGesture& pan )
767 void Control::OnTap(const TapGesture& tap)
771 void Control::OnLongPress( const LongPressGesture& longPress )
775 void Control::EmitKeyInputFocusSignal( bool focusGained )
777 Dali::Toolkit::Control handle( GetOwner() );
781 // signals are allocated dynamically when someone connects
782 if ( !mImpl->mKeyInputFocusGainedSignal.Empty() )
784 mImpl->mKeyInputFocusGainedSignal.Emit( handle );
789 // signals are allocated dynamically when someone connects
790 if ( !mImpl->mKeyInputFocusLostSignal.Empty() )
792 mImpl->mKeyInputFocusLostSignal.Emit( handle );
797 void Control::OnStageConnection( int depth )
799 if( mImpl->mBackgroundRenderer)
801 mImpl->mBackgroundRenderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
803 mImpl->mBackgroundRenderer.SetOnStage( self );
807 void Control::OnStageDisconnection()
809 if( mImpl->mBackgroundRenderer)
812 mImpl->mBackgroundRenderer.SetOffStage( self );
816 void Control::OnKeyInputFocusGained()
818 EmitKeyInputFocusSignal( true );
821 void Control::OnKeyInputFocusLost()
823 EmitKeyInputFocusSignal( false );
826 void Control::OnChildAdd(Actor& child)
828 // If this is the background actor, then we do not want to inform deriving classes
829 if ( mImpl->mAddRemoveBackgroundChild )
834 // Notify derived classes.
835 OnControlChildAdd( child );
838 void Control::OnChildRemove(Actor& child)
840 // If this is the background actor, then we do not want to inform deriving classes
841 if ( mImpl->mAddRemoveBackgroundChild )
846 // Notify derived classes.
847 OnControlChildRemove( child );
850 void Control::OnSizeSet(const Vector3& targetSize)
852 // Background is resized through size negotiation
855 void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
857 // @todo size negotiate background to new size, animate as well?
860 bool Control::OnTouchEvent(const TouchEvent& event)
862 return false; // Do not consume
865 bool Control::OnHoverEvent(const HoverEvent& event)
867 return false; // Do not consume
870 bool Control::OnKeyEvent(const KeyEvent& event)
872 return false; // Do not consume
875 bool Control::OnWheelEvent(const WheelEvent& event)
877 return false; // Do not consume
880 void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
882 for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i )
884 container.Add( Self().GetChildAt( i ), size );
888 void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
892 Vector3 Control::GetNaturalSize()
894 if( mImpl->mBackgroundRenderer )
897 mImpl->mBackgroundRenderer.GetNaturalSize(naturalSize);
898 return Vector3(naturalSize);
900 return Vector3::ZERO;
903 float Control::CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
905 return CalculateChildSizeBase( child, dimension );
908 float Control::GetHeightForWidth( float width )
910 return GetHeightForWidthBase( width );
913 float Control::GetWidthForHeight( float height )
915 return GetWidthForHeightBase( height );
918 bool Control::RelayoutDependentOnChildren( Dimension::Type dimension )
920 return RelayoutDependentOnChildrenBase( dimension );
923 void Control::OnCalculateRelayoutSize( Dimension::Type dimension )
927 void Control::OnLayoutNegotiated( float size, Dimension::Type dimension )
931 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
933 mImpl->SignalConnected( slotObserver, callback );
936 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
938 mImpl->SignalDisconnected( slotObserver, callback );
941 Control& GetImplementation( Dali::Toolkit::Control& handle )
943 CustomActorImpl& customInterface = handle.GetImplementation();
944 // downcast to control
945 Control& impl = dynamic_cast< Internal::Control& >( customInterface );
949 const Control& GetImplementation( const Dali::Toolkit::Control& handle )
951 const CustomActorImpl& customInterface = handle.GetImplementation();
952 // downcast to control
953 const Control& impl = dynamic_cast< const Internal::Control& >( customInterface );
957 } // namespace Internal
959 } // namespace Toolkit