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