46f24d8adc5f48407d6156473a332b4fa31b63ff
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / control-impl.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/public-api/controls/control-impl.h>
20
21 // EXTERNAL INCLUDES
22 #include <cstring> // for strcmp
23 #include <limits>
24 #include <stack>
25 #include <typeinfo>
26 #include <dali/public-api/animation/constraint.h>
27 #include <dali/public-api/object/type-registry-helper.h>
28 #include <dali/public-api/size-negotiation/relayout-container.h>
29 #include <dali/devel-api/scripting/scripting.h>
30 #include <dali/integration-api/debug.h>
31
32 // INTERNAL INCLUDES
33 #include <dali-toolkit/public-api/align-enumerations.h>
34 #include <dali-toolkit/public-api/controls/control.h>
35 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
36 #include <dali-toolkit/public-api/styling/style-manager.h>
37 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
38 #include <dali-toolkit/public-api/visuals/visual-properties.h>
39 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
40 #include <dali-toolkit/devel-api/controls/control-devel.h>
41 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
42 #include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
43 #include <dali-toolkit/internal/styling/style-manager-impl.h>
44 #include <dali-toolkit/internal/visuals/color/color-visual.h>
45 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
46 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
47
48 namespace Dali
49 {
50
51 namespace Toolkit
52 {
53
54 namespace Internal
55 {
56
57 namespace
58 {
59
60 #if defined(DEBUG_ENABLED)
61 Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CONTROL_VISUALS");
62 #endif
63
64 /**
65  * @brief Replace the background visual if it's a color visual with the renderIfTransparent property set as required.
66  * @param[in] controlImpl The control implementation
67  * @param[in] renderIfTransaparent Whether we should render if the color is transparent
68  */
69 void ChangeBackgroundColorVisual( Control& controlImpl, bool renderIfTransparent )
70 {
71   Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
72
73   Toolkit::Visual::Base backgroundVisual = controlDataImpl.GetVisual( Toolkit::Control::Property::BACKGROUND );
74   if( backgroundVisual )
75   {
76     Property::Map map;
77     backgroundVisual.CreatePropertyMap( map );
78     Property::Value* typeValue = map.Find( Toolkit::Visual::Property::TYPE );
79     if( typeValue && typeValue->Get< int >() == Toolkit::Visual::COLOR )
80     {
81       // Only change it if it's a color visual
82       map[ Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = renderIfTransparent;
83       controlImpl.SetBackground( map );
84     }
85   }
86 }
87
88 /**
89  * @brief Creates a clipping renderer if required.
90  * (EG. If no renders exist and clipping is enabled).
91  * @param[in] controlImpl The control implementation.
92  */
93 void CreateClippingRenderer( Control& controlImpl )
94 {
95   // We want to add a transparent background if we do not have one for clipping.
96   Actor self( controlImpl.Self() );
97   int clippingMode = ClippingMode::DISABLED;
98   if( self.GetProperty( Actor::Property::CLIPPING_MODE ).Get( clippingMode ) )
99   {
100     switch( clippingMode )
101     {
102       case ClippingMode::CLIP_CHILDREN:
103       {
104         if( self.GetRendererCount() == 0u )
105         {
106           Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
107           if( controlDataImpl.mVisuals.Empty() )
108           {
109             controlImpl.SetBackgroundColor( Color::TRANSPARENT );
110           }
111           else
112           {
113             // We have visuals, check if we've set the background and re-create it to
114             // render even if transparent (only if it's a color visual)
115             ChangeBackgroundColorVisual( controlImpl, true );
116           }
117         }
118         break;
119       }
120
121       case ClippingMode::DISABLED:
122       case ClippingMode::CLIP_TO_BOUNDING_BOX:
123       {
124         // If we have a background visual, check if it's a color visual and remove the render if transparent flag
125         ChangeBackgroundColorVisual( controlImpl, false );
126         break;
127       }
128     }
129   }
130 }
131
132 } // unnamed namespace
133
134
135 Toolkit::Control Control::New()
136 {
137   // Create the implementation, temporarily owned on stack
138   IntrusivePtr<Control> controlImpl = new Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) );
139
140   // Pass ownership to handle
141   Toolkit::Control handle( *controlImpl );
142
143   // Second-phase init of the implementation
144   // This can only be done after the CustomActor connection has been made...
145   controlImpl->Initialize();
146
147   return handle;
148 }
149
150 void Control::SetStyleName( const std::string& styleName )
151 {
152   if( styleName != mImpl->mStyleName )
153   {
154     mImpl->mStyleName = styleName;
155
156     // Apply new style, if stylemanager is available
157     Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
158     if( styleManager )
159     {
160       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
161     }
162   }
163 }
164
165 const std::string& Control::GetStyleName() const
166 {
167   return mImpl->mStyleName;
168 }
169
170 void Control::SetBackgroundColor( const Vector4& color )
171 {
172   mImpl->mBackgroundColor = color;
173   Property::Map map;
174   map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR;
175   map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
176
177   int clippingMode = ClippingMode::DISABLED;
178   if( ( Self().GetProperty( Actor::Property::CLIPPING_MODE ).Get( clippingMode ) ) &&
179       ( clippingMode == ClippingMode::CLIP_CHILDREN ) )
180   {
181     // If clipping-mode is set to CLIP_CHILDREN, then force visual to add the render even if transparent
182     map[ Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = true;
183   }
184
185   SetBackground( map );
186 }
187
188 void Control::SetBackground( const Property::Map& map )
189 {
190   Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( map );
191   visual.SetName("background");
192   if( visual )
193   {
194     mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual, DepthIndex::BACKGROUND );
195
196     // Trigger a size negotiation request that may be needed by the new visual to relayout its contents.
197     RelayoutRequest();
198   }
199 }
200
201 void Control::ClearBackground()
202 {
203    mImpl->UnregisterVisual( Toolkit::Control::Property::BACKGROUND );
204    mImpl->mBackgroundColor = Color::TRANSPARENT;
205
206    // Trigger a size negotiation request that may be needed when unregistering a visual.
207    RelayoutRequest();
208 }
209
210 void Control::SetShadow( const Property::Map& map )
211 {
212   Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( map );
213   visual.SetName("shadow");
214
215   if( visual )
216   {
217     mImpl->RegisterVisual( Toolkit::DevelControl::Property::SHADOW, visual, DepthIndex::BACKGROUND_EFFECT );
218
219     RelayoutRequest();
220   }
221 }
222
223 void Control::ClearShadow()
224 {
225    mImpl->UnregisterVisual( Toolkit::DevelControl::Property::SHADOW );
226
227    // Trigger a size negotiation request that may be needed when unregistering a visual.
228    RelayoutRequest();
229 }
230
231
232 void Control::EnableGestureDetection(Gesture::Type type)
233 {
234   if ( (type & Gesture::Pinch) && !mImpl->mPinchGestureDetector )
235   {
236     mImpl->mPinchGestureDetector = PinchGestureDetector::New();
237     mImpl->mPinchGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PinchDetected);
238     mImpl->mPinchGestureDetector.Attach(Self());
239   }
240
241   if ( (type & Gesture::Pan) && !mImpl->mPanGestureDetector )
242   {
243     mImpl->mPanGestureDetector = PanGestureDetector::New();
244     mImpl->mPanGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PanDetected);
245     mImpl->mPanGestureDetector.Attach(Self());
246   }
247
248   if ( (type & Gesture::Tap) && !mImpl->mTapGestureDetector )
249   {
250     mImpl->mTapGestureDetector = TapGestureDetector::New();
251     mImpl->mTapGestureDetector.DetectedSignal().Connect(mImpl, &Impl::TapDetected);
252     mImpl->mTapGestureDetector.Attach(Self());
253   }
254
255   if ( (type & Gesture::LongPress) && !mImpl->mLongPressGestureDetector )
256   {
257     mImpl->mLongPressGestureDetector = LongPressGestureDetector::New();
258     mImpl->mLongPressGestureDetector.DetectedSignal().Connect(mImpl, &Impl::LongPressDetected);
259     mImpl->mLongPressGestureDetector.Attach(Self());
260   }
261 }
262
263 void Control::DisableGestureDetection(Gesture::Type type)
264 {
265   if ( (type & Gesture::Pinch) && mImpl->mPinchGestureDetector )
266   {
267     mImpl->mPinchGestureDetector.Detach(Self());
268     mImpl->mPinchGestureDetector.Reset();
269   }
270
271   if ( (type & Gesture::Pan) && mImpl->mPanGestureDetector )
272   {
273     mImpl->mPanGestureDetector.Detach(Self());
274     mImpl->mPanGestureDetector.Reset();
275   }
276
277   if ( (type & Gesture::Tap) && mImpl->mTapGestureDetector )
278   {
279     mImpl->mTapGestureDetector.Detach(Self());
280     mImpl->mTapGestureDetector.Reset();
281   }
282
283   if ( (type & Gesture::LongPress) && mImpl->mLongPressGestureDetector)
284   {
285     mImpl->mLongPressGestureDetector.Detach(Self());
286     mImpl->mLongPressGestureDetector.Reset();
287   }
288 }
289
290 PinchGestureDetector Control::GetPinchGestureDetector() const
291 {
292   return mImpl->mPinchGestureDetector;
293 }
294
295 PanGestureDetector Control::GetPanGestureDetector() const
296 {
297   return mImpl->mPanGestureDetector;
298 }
299
300 TapGestureDetector Control::GetTapGestureDetector() const
301 {
302   return mImpl->mTapGestureDetector;
303 }
304
305 LongPressGestureDetector Control::GetLongPressGestureDetector() const
306 {
307   return mImpl->mLongPressGestureDetector;
308 }
309
310 void Control::SetKeyboardNavigationSupport(bool isSupported)
311 {
312   mImpl->mIsKeyboardNavigationSupported = isSupported;
313 }
314
315 bool Control::IsKeyboardNavigationSupported()
316 {
317   return mImpl->mIsKeyboardNavigationSupported;
318 }
319
320 void Control::SetKeyInputFocus()
321 {
322   if( Self().OnStage() )
323   {
324     Toolkit::KeyInputFocusManager::Get().SetFocus(Toolkit::Control::DownCast(Self()));
325   }
326 }
327
328 bool Control::HasKeyInputFocus()
329 {
330   bool result = false;
331   if( Self().OnStage() )
332   {
333     Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
334     if( Self() == control )
335     {
336       result = true;
337     }
338   }
339   return result;
340 }
341
342 void Control::ClearKeyInputFocus()
343 {
344   if( Self().OnStage() )
345   {
346     Toolkit::KeyInputFocusManager::Get().RemoveFocus(Toolkit::Control::DownCast(Self()));
347   }
348 }
349
350 void Control::SetAsKeyboardFocusGroup(bool isFocusGroup)
351 {
352   mImpl->mIsKeyboardFocusGroup = isFocusGroup;
353
354   // The following line will be removed when the deprecated API in KeyboardFocusManager is deleted
355   Toolkit::KeyboardFocusManager::Get().SetAsFocusGroup(Self(), isFocusGroup);
356 }
357
358 bool Control::IsKeyboardFocusGroup()
359 {
360   return Toolkit::KeyboardFocusManager::Get().IsFocusGroup(Self());
361 }
362
363 void Control::AccessibilityActivate()
364 {
365   // Inform deriving classes
366   OnAccessibilityActivated();
367 }
368
369 void Control::KeyboardEnter()
370 {
371   // Inform deriving classes
372   OnKeyboardEnter();
373 }
374
375 bool Control::OnAccessibilityActivated()
376 {
377   return false; // Accessibility activation is not handled by default
378 }
379
380 bool Control::OnKeyboardEnter()
381 {
382   return false; // Keyboard enter is not handled by default
383 }
384
385 bool Control::OnAccessibilityPan(PanGesture gesture)
386 {
387   return false; // Accessibility pan gesture is not handled by default
388 }
389
390 bool Control::OnAccessibilityTouch(const TouchEvent& touchEvent)
391 {
392   return false; // Accessibility touch event is not handled by default
393 }
394
395 bool Control::OnAccessibilityValueChange(bool isIncrease)
396 {
397   return false; // Accessibility value change action is not handled by default
398 }
399
400 bool Control::OnAccessibilityZoom()
401 {
402   return false; // Accessibility zoom action is not handled by default
403 }
404
405 Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocus::Direction direction, bool loopEnabled)
406 {
407   return Actor();
408 }
409
410 void Control::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
411 {
412 }
413
414 Toolkit::Control::KeyEventSignalType& Control::KeyEventSignal()
415 {
416   return mImpl->mKeyEventSignal;
417 }
418
419 Toolkit::Control::KeyInputFocusSignalType& Control::KeyInputFocusGainedSignal()
420 {
421   return mImpl->mKeyInputFocusGainedSignal;
422 }
423
424 Toolkit::Control::KeyInputFocusSignalType& Control::KeyInputFocusLostSignal()
425 {
426   return mImpl->mKeyInputFocusLostSignal;
427 }
428
429 bool Control::EmitKeyEventSignal( const KeyEvent& event )
430 {
431   // Guard against destruction during signal emission
432   Dali::Toolkit::Control handle( GetOwner() );
433
434   bool consumed = false;
435
436   consumed = mImpl->FilterKeyEvent( event );
437
438   // signals are allocated dynamically when someone connects
439   if ( !consumed && !mImpl->mKeyEventSignal.Empty() )
440   {
441     consumed = mImpl->mKeyEventSignal.Emit( handle, event );
442   }
443
444   if ( !consumed )
445   {
446     // Notification for derived classes
447     consumed = OnKeyEvent(event);
448   }
449
450   return consumed;
451 }
452
453 Control::Control( ControlBehaviour behaviourFlags )
454 : CustomActorImpl( static_cast< ActorFlags >( behaviourFlags ) ),
455   mImpl(new Impl(*this))
456 {
457   mImpl->mFlags = behaviourFlags;
458 }
459
460 Control::~Control()
461 {
462   delete mImpl;
463 }
464
465 void Control::Initialize()
466 {
467   // Call deriving classes so initialised before styling is applied to them.
468   OnInitialize();
469
470   if( (mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS) ||
471       !(mImpl->mFlags & DISABLE_STYLE_CHANGE_SIGNALS) )
472   {
473     Toolkit::StyleManager styleManager = StyleManager::Get();
474
475     // if stylemanager is available
476     if( styleManager )
477     {
478       StyleManager& styleManagerImpl = GetImpl( styleManager );
479
480       // Register for style changes
481       styleManagerImpl.ControlStyleChangeSignal().Connect( this, &Control::OnStyleChange );
482
483       // Apply the current style
484       styleManagerImpl.ApplyThemeStyleAtInit( Toolkit::Control( GetOwner() ) );
485     }
486   }
487
488   if( mImpl->mFlags & REQUIRES_KEYBOARD_NAVIGATION_SUPPORT )
489   {
490     SetKeyboardNavigationSupport( true );
491   }
492 }
493
494 void Control::OnInitialize()
495 {
496 }
497
498 void Control::OnControlChildAdd( Actor& child )
499 {
500 }
501
502 void Control::OnControlChildRemove( Actor& child )
503 {
504 }
505
506 void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
507 {
508   // By default the control is only interested in theme (not font) changes
509   if( styleManager && change == StyleChange::THEME_CHANGE )
510   {
511     GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
512     RelayoutRequest();
513   }
514 }
515
516 void Control::OnPinch(const PinchGesture& pinch)
517 {
518   if( !( mImpl->mStartingPinchScale ) )
519   {
520     // lazy allocate
521     mImpl->mStartingPinchScale = new Vector3;
522   }
523
524   if( pinch.state == Gesture::Started )
525   {
526     *( mImpl->mStartingPinchScale ) = Self().GetCurrentScale();
527   }
528
529   Self().SetScale( *( mImpl->mStartingPinchScale ) * pinch.scale );
530 }
531
532 void Control::OnPan( const PanGesture& pan )
533 {
534 }
535
536 void Control::OnTap(const TapGesture& tap)
537 {
538 }
539
540 void Control::OnLongPress( const LongPressGesture& longPress )
541 {
542 }
543
544 void Control::EmitKeyInputFocusSignal( bool focusGained )
545 {
546   Dali::Toolkit::Control handle( GetOwner() );
547
548   if ( focusGained )
549   {
550     // signals are allocated dynamically when someone connects
551     if ( !mImpl->mKeyInputFocusGainedSignal.Empty() )
552     {
553       mImpl->mKeyInputFocusGainedSignal.Emit( handle );
554     }
555   }
556   else
557   {
558     // signals are allocated dynamically when someone connects
559     if ( !mImpl->mKeyInputFocusLostSignal.Empty() )
560     {
561       mImpl->mKeyInputFocusLostSignal.Emit( handle );
562     }
563   }
564 }
565
566 void Control::OnStageConnection( int depth )
567 {
568   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageConnection number of registered visuals(%d)\n",  mImpl->mVisuals.Size() );
569
570   Actor self( Self() );
571
572   for(RegisteredVisualContainer::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++)
573   {
574     // Check whether the visual is empty and enabled
575     if( (*iter)->visual && (*iter)->enabled )
576     {
577       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageConnection Setting visual(%d) on stage\n", (*iter)->index );
578       Toolkit::GetImplementation((*iter)->visual).SetOnStage( self );
579     }
580   }
581
582   // The clipping renderer is only created if required.
583   CreateClippingRenderer( *this );
584
585   // Request to be laid out when the control is connected to the Stage.
586   // Signal that a Relayout may be needed
587 }
588
589
590 void Control::OnStageDisconnection()
591 {
592   mImpl->OnStageDisconnection();
593 }
594
595 void Control::OnKeyInputFocusGained()
596 {
597   EmitKeyInputFocusSignal( true );
598 }
599
600 void Control::OnKeyInputFocusLost()
601 {
602   EmitKeyInputFocusSignal( false );
603 }
604
605 void Control::OnChildAdd(Actor& child)
606 {
607   // Notify derived classes.
608   OnControlChildAdd( child );
609 }
610
611 void Control::OnChildRemove(Actor& child)
612 {
613   // Notify derived classes.
614   OnControlChildRemove( child );
615 }
616
617 void Control::OnPropertySet( Property::Index index, Property::Value propertyValue )
618 {
619   // If the clipping mode has been set, we may need to create a renderer.
620   // Only do this if we are already on-stage as the OnStageConnection will handle the off-stage clipping controls.
621   if( ( index == Actor::Property::CLIPPING_MODE ) && Self().OnStage() )
622   {
623     // Note: This method will handle whether creation of the renderer is required.
624     CreateClippingRenderer( *this );
625   }
626 }
627
628 void Control::OnSizeSet(const Vector3& targetSize)
629 {
630   Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
631   if( visual )
632   {
633     Vector2 size( targetSize );
634     visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
635   }
636 }
637
638 void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
639 {
640   // @todo size negotiate background to new size, animate as well?
641 }
642
643 bool Control::OnTouchEvent(const TouchEvent& event)
644 {
645   return false; // Do not consume
646 }
647
648 bool Control::OnHoverEvent(const HoverEvent& event)
649 {
650   return false; // Do not consume
651 }
652
653 bool Control::OnKeyEvent(const KeyEvent& event)
654 {
655   return false; // Do not consume
656 }
657
658 bool Control::OnWheelEvent(const WheelEvent& event)
659 {
660   return false; // Do not consume
661 }
662
663 void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
664 {
665   for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i )
666   {
667     Actor child = Self().GetChildAt( i );
668     Vector2 newChildSize( size );
669
670     // When set the padding or margin on the control, child should be resized and repositioned.
671     if( ( mImpl->mPadding.start != 0 ) || ( mImpl->mPadding.end != 0 ) || ( mImpl->mPadding.top != 0 ) || ( mImpl->mPadding.bottom != 0 ) ||
672         ( mImpl->mMargin.start != 0 ) || ( mImpl->mMargin.end != 0 ) || ( mImpl->mMargin.top != 0 ) || ( mImpl->mMargin.bottom != 0 ) )
673     {
674       Extents padding = mImpl->mPadding;
675
676       Dali::CustomActor ownerActor(GetOwner());
677       Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( ownerActor.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
678
679       if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
680       {
681         std::swap( padding.start, padding.end );
682       }
683
684       newChildSize.width = size.width - ( padding.start + padding.end );
685       newChildSize.height = size.height - ( padding.top + padding.bottom );
686
687       // Cannot use childs Position property as it can already have padding and margin applied on it,
688       // so we end up cumulatively applying them over and over again.
689       Vector2 childOffset( 0.f, 0.f );
690       childOffset.x += ( mImpl->mMargin.start + padding.start );
691       childOffset.y += ( mImpl->mMargin.top + padding.top );
692
693       child.SetPosition( childOffset.x, childOffset.y );
694     }
695     container.Add( child, newChildSize );
696   }
697
698   Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
699   if( visual )
700   {
701     visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
702   }
703 }
704
705 void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
706 {
707 }
708
709 Vector3 Control::GetNaturalSize()
710 {
711   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::GetNaturalSize for %s\n", Self().GetName().c_str() );
712   Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
713   if( visual )
714   {
715     Vector2 naturalSize;
716     visual.GetNaturalSize( naturalSize );
717     naturalSize.width += ( mImpl->mPadding.start + mImpl->mPadding.end );
718     naturalSize.height += ( mImpl->mPadding.top + mImpl->mPadding.bottom );
719     return Vector3( naturalSize );
720   }
721   return Vector3::ZERO;
722 }
723
724 float Control::CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
725 {
726   return CalculateChildSizeBase( child, dimension );
727 }
728
729 float Control::GetHeightForWidth( float width )
730 {
731   return GetHeightForWidthBase( width );
732 }
733
734 float Control::GetWidthForHeight( float height )
735 {
736   return GetWidthForHeightBase( height );
737 }
738
739 bool Control::RelayoutDependentOnChildren( Dimension::Type dimension )
740 {
741   return RelayoutDependentOnChildrenBase( dimension );
742 }
743
744 void Control::OnCalculateRelayoutSize( Dimension::Type dimension )
745 {
746 }
747
748 void Control::OnLayoutNegotiated( float size, Dimension::Type dimension )
749 {
750 }
751
752 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
753 {
754   mImpl->SignalConnected( slotObserver, callback );
755 }
756
757 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
758 {
759   mImpl->SignalDisconnected( slotObserver, callback );
760 }
761
762 Control& GetImplementation( Dali::Toolkit::Control& handle )
763 {
764   CustomActorImpl& customInterface = handle.GetImplementation();
765   // downcast to control
766   Control& impl = dynamic_cast< Internal::Control& >( customInterface );
767   return impl;
768 }
769
770 const Control& GetImplementation( const Dali::Toolkit::Control& handle )
771 {
772   const CustomActorImpl& customInterface = handle.GetImplementation();
773   // downcast to control
774   const Control& impl = dynamic_cast< const Internal::Control& >( customInterface );
775   return impl;
776 }
777
778 } // namespace Internal
779
780 } // namespace Toolkit
781
782 } // namespace Dali