Merge "Added nested TableView KeyboardFocus support" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / control-impl.cpp
1 /*
2  * Copyright (c) 2017 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/animation/constraints.h>
28 #include <dali/public-api/object/type-registry.h>
29 #include <dali/public-api/object/type-registry-helper.h>
30 #include <dali/public-api/rendering/renderer.h>
31 #include <dali/public-api/size-negotiation/relayout-container.h>
32 #include <dali/devel-api/common/owner-container.h>
33 #include <dali/devel-api/object/handle-devel.h>
34 #include <dali/devel-api/scripting/enum-helper.h>
35 #include <dali/devel-api/scripting/scripting.h>
36 #include <dali/integration-api/debug.h>
37
38 // INTERNAL INCLUDES
39 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
40 #include <dali-toolkit/public-api/controls/control.h>
41 #include <dali-toolkit/public-api/styling/style-manager.h>
42 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
43 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
44 #include <dali-toolkit/devel-api/controls/control-devel.h>
45 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
46 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
47 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
48 #include <dali-toolkit/internal/styling/style-manager-impl.h>
49 #include <dali-toolkit/internal/visuals/color/color-visual.h>
50 #include <dali-toolkit/internal/visuals/transition-data-impl.h>
51 #include <dali-toolkit/devel-api/align-enums.h>
52 #include <dali-toolkit/internal/controls/tooltip/tooltip.h>
53
54 namespace Dali
55 {
56
57 namespace Toolkit
58 {
59
60 namespace
61 {
62
63 #if defined(DEBUG_ENABLED)
64 Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CONTROL_VISUALS");
65 #endif
66
67 DALI_ENUM_TO_STRING_TABLE_BEGIN( CLIPPING_MODE )
68 DALI_ENUM_TO_STRING_WITH_SCOPE( ClippingMode, DISABLED )
69 DALI_ENUM_TO_STRING_WITH_SCOPE( ClippingMode, CLIP_CHILDREN )
70 DALI_ENUM_TO_STRING_TABLE_END( CLIPPING_MODE )
71
72 /**
73  * Struct used to store Visual within the control, index is a unique key for each visual.
74  */
75 struct RegisteredVisual
76 {
77   Property::Index index;
78   Toolkit::Visual::Base visual;
79   bool enabled;
80
81   RegisteredVisual( Property::Index aIndex, Toolkit::Visual::Base &aVisual, bool aEnabled) :
82                    index(aIndex), visual(aVisual), enabled(aEnabled) {}
83 };
84
85 struct HandleIndex
86 {
87   Handle handle; ///< a handle to the target object
88   Property::Index index; ///< The index of a property provided by the referenced object
89
90   HandleIndex( )
91   : handle(),
92     index( Property::INVALID_INDEX )
93   {
94   }
95
96   HandleIndex( Handle& handle, Property::Index index )
97   : handle( handle ),
98     index( index )
99   {
100   }
101 };
102
103
104 typedef Dali::OwnerContainer< RegisteredVisual* > RegisteredVisualContainer;
105
106 /**
107  *  Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
108  */
109 bool FindVisual( Property::Index targetIndex, RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter )
110 {
111   for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
112   {
113     if ( (*iter)->index ==  targetIndex )
114     {
115       return true;
116     }
117   }
118   return false;
119 }
120
121 HandleIndex GetVisualProperty(
122   Internal::Control& controlImpl,
123   RegisteredVisualContainer& visuals,
124   const std::string& visualName,
125   Property::Key propertyKey )
126 {
127 #if defined(DEBUG_ENABLED)
128   std::ostringstream oss;
129   oss << "Control::GetVisualProperty(" << visualName << ", " << propertyKey << ")" << std::endl;
130   DALI_LOG_INFO( gLogFilter, Debug::General, oss.str().c_str() );
131 #endif
132
133   // Find visualName in the control
134   RegisteredVisualContainer::Iterator iter;
135   for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
136   {
137     Toolkit::Visual::Base visual = (*iter)->visual;
138     if( visual && visual.GetName() == visualName )
139     {
140       Internal::Visual::Base& visualImpl = GetImplementation(visual);
141       Renderer renderer = visualImpl.GetRenderer();
142       if( renderer )
143       {
144         Property::Index index = DevelHandle::GetPropertyIndex( renderer, propertyKey );
145         if( index != Property::INVALID_INDEX )
146         {
147           return HandleIndex( renderer, index );
148         }
149       }
150     }
151   }
152
153   std::ostringstream noRenderers;
154   noRenderers << propertyKey;
155   DALI_LOG_WARNING( "Control::GetVisualProperty(%s, %s) No renderers\n", visualName.c_str(), noRenderers.str().c_str() );
156   Handle handle;
157   return HandleIndex( handle, Property::INVALID_INDEX );
158 }
159
160 void SetDefaultTransform( Property::Map& propertyMap )
161 {
162   propertyMap.Clear();
163   propertyMap
164     .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
165     .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
166     .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
167     .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
168     .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
169 }
170
171 /**
172  * Creates control through type registry
173  */
174 BaseHandle Create()
175 {
176   return Internal::Control::New();
177 }
178
179 /**
180  * Performs actions as requested using the action name.
181  * @param[in] object The object on which to perform the action.
182  * @param[in] actionName The action to perform.
183  * @param[in] attributes The attributes with which to perfrom this action.
184  * @return true if action has been accepted by this control
185  */
186 const char* ACTION_ACCESSIBILITY_ACTIVATED = "accessibilityActivated";
187 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
188 {
189   bool ret = false;
190
191   if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) ) )
192   {
193     Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
194     if( control )
195     {
196       // if cast succeeds there is an implementation so no need to check
197       ret = Internal::GetImplementation( control ).OnAccessibilityActivated();
198     }
199   }
200
201   return ret;
202 }
203
204 /**
205  * Connects a callback function with the object's signals.
206  * @param[in] object The object providing the signal.
207  * @param[in] tracker Used to disconnect the signal.
208  * @param[in] signalName The signal to connect to.
209  * @param[in] functor A newly allocated FunctorDelegate.
210  * @return True if the signal was connected.
211  * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
212  */
213 const char* SIGNAL_KEY_EVENT = "keyEvent";
214 const char* SIGNAL_KEY_INPUT_FOCUS_GAINED = "keyInputFocusGained";
215 const char* SIGNAL_KEY_INPUT_FOCUS_LOST = "keyInputFocusLost";
216 const char* SIGNAL_TAPPED = "tapped";
217 const char* SIGNAL_PANNED = "panned";
218 const char* SIGNAL_PINCHED = "pinched";
219 const char* SIGNAL_LONG_PRESSED = "longPressed";
220 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
221 {
222   Dali::BaseHandle handle( object );
223
224   bool connected( false );
225   Toolkit::Control control = Toolkit::Control::DownCast( handle );
226   if ( control )
227   {
228     Internal::Control& controlImpl( Internal::GetImplementation( control ) );
229     connected = true;
230
231     if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
232     {
233       controlImpl.KeyEventSignal().Connect( tracker, functor );
234     }
235     else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_GAINED ) )
236     {
237       controlImpl.KeyInputFocusGainedSignal().Connect( tracker, functor );
238     }
239     else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_LOST ) )
240     {
241       controlImpl.KeyInputFocusLostSignal().Connect( tracker, functor );
242     }
243     else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
244     {
245       controlImpl.EnableGestureDetection( Gesture::Tap );
246       controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
247     }
248     else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
249     {
250       controlImpl.EnableGestureDetection( Gesture::Pan );
251       controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
252     }
253     else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
254     {
255       controlImpl.EnableGestureDetection( Gesture::Pinch );
256       controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
257     }
258     else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
259     {
260       controlImpl.EnableGestureDetection( Gesture::LongPress );
261       controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
262     }
263   }
264   return connected;
265 }
266
267 // Setup signals and actions using the type-registry.
268 DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
269
270 // Note: Properties are registered separately below.
271
272 SignalConnectorType registerSignal1( typeRegistration, SIGNAL_KEY_EVENT, &DoConnectSignal );
273 SignalConnectorType registerSignal2( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_GAINED, &DoConnectSignal );
274 SignalConnectorType registerSignal3( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_LOST, &DoConnectSignal );
275 SignalConnectorType registerSignal4( typeRegistration, SIGNAL_TAPPED, &DoConnectSignal );
276 SignalConnectorType registerSignal5( typeRegistration, SIGNAL_PANNED, &DoConnectSignal );
277 SignalConnectorType registerSignal6( typeRegistration, SIGNAL_PINCHED, &DoConnectSignal );
278 SignalConnectorType registerSignal7( typeRegistration, SIGNAL_LONG_PRESSED, &DoConnectSignal );
279
280 TypeAction registerAction( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &DoAction );
281
282 DALI_TYPE_REGISTRATION_END()
283
284 } // unnamed namespace
285
286 namespace Internal
287 {
288
289 class Control::Impl : public ConnectionTracker
290 {
291 public:
292
293   // Construction & Destruction
294   Impl(Control& controlImpl)
295   : mControlImpl( controlImpl ),
296     mStyleName(""),
297     mBackgroundColor(Color::TRANSPARENT),
298     mStartingPinchScale( NULL ),
299     mKeyEventSignal(),
300     mPinchGestureDetector(),
301     mPanGestureDetector(),
302     mTapGestureDetector(),
303     mLongPressGestureDetector(),
304     mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
305     mIsKeyboardNavigationSupported( false ),
306     mIsKeyboardFocusGroup( false )
307   {
308   }
309
310   ~Impl()
311   {
312     // All gesture detectors will be destroyed so no need to disconnect.
313     delete mStartingPinchScale;
314   }
315
316   // Gesture Detection Methods
317
318   void PinchDetected(Actor actor, const PinchGesture& pinch)
319   {
320     mControlImpl.OnPinch(pinch);
321   }
322
323   void PanDetected(Actor actor, const PanGesture& pan)
324   {
325     mControlImpl.OnPan(pan);
326   }
327
328   void TapDetected(Actor actor, const TapGesture& tap)
329   {
330     mControlImpl.OnTap(tap);
331   }
332
333   void LongPressDetected(Actor actor, const LongPressGesture& longPress)
334   {
335     mControlImpl.OnLongPress(longPress);
336   }
337
338   // Properties
339
340   /**
341    * Called when a property of an object of this type is set.
342    * @param[in] object The object whose property is set.
343    * @param[in] index The property index.
344    * @param[in] value The new property value.
345    */
346   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
347   {
348     Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
349
350     if ( control )
351     {
352       Control& controlImpl( GetImplementation( control ) );
353
354       switch ( index )
355       {
356         case Toolkit::Control::Property::STYLE_NAME:
357         {
358           controlImpl.SetStyleName( value.Get< std::string >() );
359           break;
360         }
361
362         case Toolkit::Control::Property::BACKGROUND_COLOR:
363         {
364           DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" );
365           controlImpl.SetBackgroundColor( value.Get< Vector4 >() );
366           break;
367         }
368
369         case Toolkit::Control::Property::BACKGROUND_IMAGE:
370         {
371           DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" );
372           Image image = Scripting::NewImage( value );
373           if ( image )
374           {
375             controlImpl.SetBackgroundImage( image );
376           }
377           else
378           {
379             // An empty image means the background is no longer required
380             controlImpl.ClearBackground();
381           }
382           break;
383         }
384
385         case Toolkit::Control::Property::KEY_INPUT_FOCUS:
386         {
387           if ( value.Get< bool >() )
388           {
389             controlImpl.SetKeyInputFocus();
390           }
391           else
392           {
393             controlImpl.ClearKeyInputFocus();
394           }
395           break;
396         }
397
398         case Toolkit::Control::Property::BACKGROUND:
399         {
400           std::string url;
401           const Property::Map* map = value.GetMap();
402           if( map && !map->Empty() )
403           {
404             controlImpl.SetBackground( *map );
405           }
406           else if( value.Get( url ) )
407           {
408             // don't know the size to load
409             Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( url, ImageDimensions() );
410             if( visual )
411             {
412               controlImpl.RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
413               visual.SetDepthIndex( DepthIndex::BACKGROUND );
414             }
415           }
416           else
417           {
418             // The background is an empty property map, so we should clear the background
419             controlImpl.ClearBackground();
420           }
421           break;
422         }
423
424         case Toolkit::DevelControl::Property::TOOLTIP:
425         {
426           TooltipPtr& tooltipPtr = controlImpl.mImpl->mTooltip;
427           if( ! tooltipPtr )
428           {
429             tooltipPtr = Tooltip::New( control );
430           }
431           tooltipPtr->SetProperties( value );
432         }
433       }
434     }
435   }
436
437   /**
438    * Called to retrieve a property of an object of this type.
439    * @param[in] object The object whose property is to be retrieved.
440    * @param[in] index The property index.
441    * @return The current value of the property.
442    */
443   static Property::Value GetProperty( BaseObject* object, Property::Index index )
444   {
445     Property::Value value;
446
447     Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
448
449     if ( control )
450     {
451       Control& controlImpl( GetImplementation( control ) );
452
453       switch ( index )
454       {
455         case Toolkit::Control::Property::STYLE_NAME:
456         {
457           value = controlImpl.GetStyleName();
458           break;
459         }
460
461         case Toolkit::Control::Property::BACKGROUND_COLOR:
462         {
463           DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" );
464           value = controlImpl.GetBackgroundColor();
465           break;
466         }
467
468         case Toolkit::Control::Property::BACKGROUND_IMAGE:
469         {
470           DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" );
471           Property::Map map;
472           Toolkit::Visual::Base visual = controlImpl.GetVisual( Toolkit::Control::Property::BACKGROUND );
473           if( visual )
474           {
475             visual.CreatePropertyMap( map );
476           }
477           value = map;
478           break;
479         }
480
481         case Toolkit::Control::Property::KEY_INPUT_FOCUS:
482         {
483           value = controlImpl.HasKeyInputFocus();
484           break;
485         }
486
487         case Toolkit::Control::Property::BACKGROUND:
488         {
489           Property::Map map;
490           Toolkit::Visual::Base visual = controlImpl.GetVisual( Toolkit::Control::Property::BACKGROUND );
491           if( visual )
492           {
493             visual.CreatePropertyMap( map );
494           }
495
496           value = map;
497           break;
498         }
499
500         case Toolkit::DevelControl::Property::TOOLTIP:
501         {
502           Property::Map map;
503           if( controlImpl.mImpl->mTooltip )
504           {
505             controlImpl.mImpl->mTooltip->CreatePropertyMap( map );
506           }
507           value = map;
508           break;
509         }
510
511       }
512     }
513
514     return value;
515   }
516
517   // Data
518
519   Control& mControlImpl;
520   RegisteredVisualContainer mVisuals; // Stores visuals needed by the control, non trivial type so std::vector used.
521   std::string mStyleName;
522   Vector4 mBackgroundColor;                       ///< The color of the background visual
523   Vector3* mStartingPinchScale;      ///< The scale when a pinch gesture starts, TODO: consider removing this
524   Toolkit::Control::KeyEventSignalType mKeyEventSignal;
525   Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal;
526   Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal;
527
528   // Gesture Detection
529   PinchGestureDetector mPinchGestureDetector;
530   PanGestureDetector mPanGestureDetector;
531   TapGestureDetector mTapGestureDetector;
532   LongPressGestureDetector mLongPressGestureDetector;
533
534   // Tooltip
535   TooltipPtr mTooltip;
536
537   ControlBehaviour mFlags : CONTROL_BEHAVIOUR_FLAG_COUNT;    ///< Flags passed in from constructor.
538   bool mIsKeyboardNavigationSupported :1;  ///< Stores whether keyboard navigation is supported by the control.
539   bool mIsKeyboardFocusGroup :1;           ///< Stores whether the control is a focus group.
540
541   // Properties - these need to be members of Internal::Control::Impl as they access private methods/data of Internal::Control and Internal::Control::Impl.
542   static const PropertyRegistration PROPERTY_1;
543   static const PropertyRegistration PROPERTY_2;
544   static const PropertyRegistration PROPERTY_3;
545   static const PropertyRegistration PROPERTY_4;
546   static const PropertyRegistration PROPERTY_5;
547   static const PropertyRegistration PROPERTY_6;
548 };
549
550 // Properties registered without macro to use specific member variables.
551 const PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "styleName",       Toolkit::Control::Property::STYLE_NAME,       Property::STRING,  &Control::Impl::SetProperty, &Control::Impl::GetProperty );
552 const PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "backgroundColor", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
553 const PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "backgroundImage", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
554 const PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "keyInputFocus",   Toolkit::Control::Property::KEY_INPUT_FOCUS,  Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
555 const PropertyRegistration Control::Impl::PROPERTY_5( typeRegistration, "background",      Toolkit::Control::Property::BACKGROUND,       Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
556 const PropertyRegistration Control::Impl::PROPERTY_6( typeRegistration, "tooltip",         Toolkit::DevelControl::Property::TOOLTIP,     Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
557
558 Toolkit::Control Control::New()
559 {
560   // Create the implementation, temporarily owned on stack
561   IntrusivePtr<Control> controlImpl = new Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) );
562
563   // Pass ownership to handle
564   Toolkit::Control handle( *controlImpl );
565
566   // Second-phase init of the implementation
567   // This can only be done after the CustomActor connection has been made...
568   controlImpl->Initialize();
569
570   return handle;
571 }
572
573 void Control::SetStyleName( const std::string& styleName )
574 {
575   if( styleName != mImpl->mStyleName )
576   {
577     mImpl->mStyleName = styleName;
578
579     // Apply new style, if stylemanager is available
580     Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
581     if( styleManager )
582     {
583       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
584     }
585   }
586 }
587
588 const std::string& Control::GetStyleName() const
589 {
590   return mImpl->mStyleName;
591 }
592
593 void Control::SetBackgroundColor( const Vector4& color )
594 {
595   mImpl->mBackgroundColor = color;
596   Property::Map map;
597   map[ Toolkit::DevelVisual::Property::TYPE ] = Toolkit::Visual::COLOR;
598   map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
599
600   SetBackground( map );
601 }
602
603 Vector4 Control::GetBackgroundColor() const
604 {
605   return mImpl->mBackgroundColor;
606 }
607
608 void Control::SetBackground( const Property::Map& map )
609 {
610   Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( map );
611   if( visual )
612   {
613     RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
614     visual.SetDepthIndex( DepthIndex::BACKGROUND );
615
616     // Trigger a size negotiation request that may be needed by the new visual to relayout its contents.
617     RelayoutRequest();
618   }
619 }
620
621 void Control::SetBackgroundImage( Image image )
622 {
623   Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( image );
624   if( visual )
625   {
626     RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
627     visual.SetDepthIndex( DepthIndex::BACKGROUND );
628   }
629 }
630
631 void Control::ClearBackground()
632 {
633    UnregisterVisual( Toolkit::Control::Property::BACKGROUND );
634    mImpl->mBackgroundColor = Color::TRANSPARENT;
635
636    // Trigger a size negotiation request that may be needed when unregistering a visual.
637    RelayoutRequest();
638 }
639
640 void Control::EnableGestureDetection(Gesture::Type type)
641 {
642   if ( (type & Gesture::Pinch) && !mImpl->mPinchGestureDetector )
643   {
644     mImpl->mPinchGestureDetector = PinchGestureDetector::New();
645     mImpl->mPinchGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PinchDetected);
646     mImpl->mPinchGestureDetector.Attach(Self());
647   }
648
649   if ( (type & Gesture::Pan) && !mImpl->mPanGestureDetector )
650   {
651     mImpl->mPanGestureDetector = PanGestureDetector::New();
652     mImpl->mPanGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PanDetected);
653     mImpl->mPanGestureDetector.Attach(Self());
654   }
655
656   if ( (type & Gesture::Tap) && !mImpl->mTapGestureDetector )
657   {
658     mImpl->mTapGestureDetector = TapGestureDetector::New();
659     mImpl->mTapGestureDetector.DetectedSignal().Connect(mImpl, &Impl::TapDetected);
660     mImpl->mTapGestureDetector.Attach(Self());
661   }
662
663   if ( (type & Gesture::LongPress) && !mImpl->mLongPressGestureDetector )
664   {
665     mImpl->mLongPressGestureDetector = LongPressGestureDetector::New();
666     mImpl->mLongPressGestureDetector.DetectedSignal().Connect(mImpl, &Impl::LongPressDetected);
667     mImpl->mLongPressGestureDetector.Attach(Self());
668   }
669 }
670
671 void Control::DisableGestureDetection(Gesture::Type type)
672 {
673   if ( (type & Gesture::Pinch) && mImpl->mPinchGestureDetector )
674   {
675     mImpl->mPinchGestureDetector.Detach(Self());
676     mImpl->mPinchGestureDetector.Reset();
677   }
678
679   if ( (type & Gesture::Pan) && mImpl->mPanGestureDetector )
680   {
681     mImpl->mPanGestureDetector.Detach(Self());
682     mImpl->mPanGestureDetector.Reset();
683   }
684
685   if ( (type & Gesture::Tap) && mImpl->mTapGestureDetector )
686   {
687     mImpl->mTapGestureDetector.Detach(Self());
688     mImpl->mTapGestureDetector.Reset();
689   }
690
691   if ( (type & Gesture::LongPress) && mImpl->mLongPressGestureDetector)
692   {
693     mImpl->mLongPressGestureDetector.Detach(Self());
694     mImpl->mLongPressGestureDetector.Reset();
695   }
696 }
697
698 PinchGestureDetector Control::GetPinchGestureDetector() const
699 {
700   return mImpl->mPinchGestureDetector;
701 }
702
703 PanGestureDetector Control::GetPanGestureDetector() const
704 {
705   return mImpl->mPanGestureDetector;
706 }
707
708 TapGestureDetector Control::GetTapGestureDetector() const
709 {
710   return mImpl->mTapGestureDetector;
711 }
712
713 LongPressGestureDetector Control::GetLongPressGestureDetector() const
714 {
715   return mImpl->mLongPressGestureDetector;
716 }
717
718 void Control::SetKeyboardNavigationSupport(bool isSupported)
719 {
720   mImpl->mIsKeyboardNavigationSupported = isSupported;
721 }
722
723 bool Control::IsKeyboardNavigationSupported()
724 {
725   return mImpl->mIsKeyboardNavigationSupported;
726 }
727
728 void Control::SetKeyInputFocus()
729 {
730   if( Self().OnStage() )
731   {
732     Toolkit::KeyInputFocusManager::Get().SetFocus(Toolkit::Control::DownCast(Self()));
733   }
734 }
735
736 bool Control::HasKeyInputFocus()
737 {
738   bool result = false;
739   if( Self().OnStage() )
740   {
741     result = Toolkit::KeyInputFocusManager::Get().IsKeyboardListener(Toolkit::Control::DownCast(Self()));
742   }
743   return result;
744 }
745
746 void Control::ClearKeyInputFocus()
747 {
748   if( Self().OnStage() )
749   {
750     Toolkit::KeyInputFocusManager::Get().RemoveFocus(Toolkit::Control::DownCast(Self()));
751   }
752 }
753
754 void Control::SetAsKeyboardFocusGroup(bool isFocusGroup)
755 {
756   mImpl->mIsKeyboardFocusGroup = isFocusGroup;
757
758   // The following line will be removed when the deprecated API in KeyboardFocusManager is deleted
759   Toolkit::KeyboardFocusManager::Get().SetAsFocusGroup(Self(), isFocusGroup);
760 }
761
762 bool Control::IsKeyboardFocusGroup()
763 {
764   return Toolkit::KeyboardFocusManager::Get().IsFocusGroup(Self());
765 }
766
767 void Control::AccessibilityActivate()
768 {
769   // Inform deriving classes
770   OnAccessibilityActivated();
771 }
772
773 void Control::KeyboardEnter()
774 {
775   // Inform deriving classes
776   OnKeyboardEnter();
777 }
778
779 void Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
780 {
781   RegisterVisual( index, visual, true );
782 }
783
784 void Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
785 {
786   bool visualReplaced ( false );
787   Actor self = Self();
788
789   if( !mImpl->mVisuals.Empty() )
790   {
791     RegisteredVisualContainer::Iterator iter;
792     // Check if visual (index) is already registered.  Replace if so.
793     if ( FindVisual( index, mImpl->mVisuals, iter ) )
794     {
795       if( (*iter)->visual && self.OnStage() )
796       {
797         Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
798       }
799       (*iter)->visual = visual;
800       visualReplaced = true;
801     }
802   }
803
804   // If not set, set the name of the visual to the same name as the control's property.
805   // ( If the control has been type registered )
806   if( visual.GetName().empty() )
807   {
808     // Check if the control has been type registered:
809     TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(*this) );
810     if( typeInfo )
811     {
812       // Check if the property index has been registered:
813       Property::IndexContainer indices;
814       typeInfo.GetPropertyIndices( indices );
815       Property::IndexContainer::Iterator iter = std::find( indices.Begin(), indices.End(), index );
816       if( iter != indices.End() )
817       {
818         // If it has, then get it's name and use that for the visual
819         std::string visualName = typeInfo.GetPropertyName( index );
820         visual.SetName( visualName );
821       }
822     }
823   }
824
825   if( !visualReplaced ) // New registration entry
826   {
827     mImpl->mVisuals.PushBack( new RegisteredVisual( index, visual, enabled ) );
828   }
829
830   if( visual && self.OnStage() && enabled )
831   {
832     Toolkit::GetImplementation(visual).SetOnStage( self );
833   }
834   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual number of registered visuals(%d)\n",  mImpl->mVisuals.Size() );
835
836 }
837
838 void Control::UnregisterVisual( Property::Index index )
839 {
840    RegisteredVisualContainer::Iterator iter;
841    if ( FindVisual( index, mImpl->mVisuals, iter ) )
842    {
843      Actor self( Self() );
844      Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
845      (*iter)->visual.Reset();
846      mImpl->mVisuals.Erase( iter );
847    }
848 }
849
850 Toolkit::Visual::Base Control::GetVisual( Property::Index index ) const
851 {
852   RegisteredVisualContainer::Iterator iter;
853   if ( FindVisual( index, mImpl->mVisuals, iter ) )
854   {
855     return (*iter)->visual;
856   }
857
858   return Toolkit::Visual::Base();
859 }
860
861 void Control::EnableVisual( Property::Index index, bool enable )
862 {
863   RegisteredVisualContainer::Iterator iter;
864   if ( FindVisual( index, mImpl->mVisuals, iter ) )
865   {
866     if (  (*iter)->enabled == enable )
867     {
868       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Visual Already enabled set (%s) \n", enable?"enabled":"disabled");
869       return;
870     }
871
872     (*iter)->enabled = enable;
873     Actor parentActor = Self();
874     if ( Self().OnStage() ) // If control not on Stage then Visual will be added when StageConnection is called.
875     {
876       if ( enable )
877       {
878         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting Visual(%d) on stage \n", index );
879         Toolkit::GetImplementation((*iter)->visual).SetOnStage( parentActor );
880       }
881       else
882       {
883         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting Visual(%d) off stage \n", index );
884         Toolkit::GetImplementation((*iter)->visual).SetOffStage( parentActor );  // No need to call if control not staged.
885       }
886     }
887   }
888 }
889
890 bool Control::IsVisualEnabled( Property::Index index ) const
891 {
892   RegisteredVisualContainer::Iterator iter;
893   if ( FindVisual( index, mImpl->mVisuals, iter ) )
894   {
895     return (*iter)->enabled;
896   }
897   return false;
898 }
899
900 Dali::Animation Control::CreateTransition( const Toolkit::TransitionData& handle )
901 {
902   Dali::Animation transition;
903   const Internal::TransitionData& transitionData = Toolkit::GetImplementation( handle );
904
905   if( transitionData.Count() > 0 )
906   {
907     // Setup a Transition from TransitionData.
908     TransitionData::Iterator end = transitionData.End();
909     for( TransitionData::Iterator iter = transitionData.Begin() ;
910          iter != end; ++iter )
911     {
912       TransitionData::Animator* animator = (*iter);
913       HandleIndex handleIndex;
914
915       // Attempt to find the object name as a child actor
916       Actor child = Self().FindChildByName( animator->objectName );
917       if( child )
918       {
919         Property::Index propertyIndex = DevelHandle::GetPropertyIndex( child, animator->propertyKey );
920         handleIndex = HandleIndex( child, propertyIndex );
921       }
922       else
923       {
924         handleIndex = GetVisualProperty( *this, mImpl->mVisuals,
925                                             animator->objectName,
926                                             animator->propertyKey );
927       }
928
929       if( handleIndex.handle && handleIndex.index != Property::INVALID_INDEX )
930       {
931         if( animator->animate == false )
932         {
933           if( animator->targetValue.GetType() != Property::NONE )
934           {
935             handleIndex.handle.SetProperty( handleIndex.index, animator->targetValue );
936           }
937         }
938         else
939         {
940           if( animator->initialValue.GetType() != Property::NONE )
941           {
942             handleIndex.handle.SetProperty( handleIndex.index, animator->initialValue );
943           }
944
945           if( ! transition )
946           {
947             // Create an animation with a default .1 second duration - the animators
948             // will automatically force it to the 'right' duration.
949             transition = Dali::Animation::New( 0.1f );
950           }
951
952           transition.AnimateTo( Property( handleIndex.handle, handleIndex.index ),
953                                 animator->targetValue,
954                                 animator->alphaFunction,
955                                 TimePeriod( animator->timePeriodDelay,
956                                             animator->timePeriodDuration ) );
957         }
958       }
959     }
960   }
961
962   return transition;
963 }
964
965 bool Control::OnAccessibilityActivated()
966 {
967   return false; // Accessibility activation is not handled by default
968 }
969
970 bool Control::OnKeyboardEnter()
971 {
972   return false; // Keyboard enter is not handled by default
973 }
974
975 bool Control::OnAccessibilityPan(PanGesture gesture)
976 {
977   return false; // Accessibility pan gesture is not handled by default
978 }
979
980 bool Control::OnAccessibilityTouch(const TouchEvent& touchEvent)
981 {
982   return false; // Accessibility touch event is not handled by default
983 }
984
985 bool Control::OnAccessibilityValueChange(bool isIncrease)
986 {
987   return false; // Accessibility value change action is not handled by default
988 }
989
990 bool Control::OnAccessibilityZoom()
991 {
992   return false; // Accessibility zoom action is not handled by default
993 }
994
995 Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocus::Direction direction, bool loopEnabled)
996 {
997   return Actor();
998 }
999
1000 void Control::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
1001 {
1002 }
1003
1004 Toolkit::Control::KeyEventSignalType& Control::KeyEventSignal()
1005 {
1006   return mImpl->mKeyEventSignal;
1007 }
1008
1009 Toolkit::Control::KeyInputFocusSignalType& Control::KeyInputFocusGainedSignal()
1010 {
1011   return mImpl->mKeyInputFocusGainedSignal;
1012 }
1013
1014 Toolkit::Control::KeyInputFocusSignalType& Control::KeyInputFocusLostSignal()
1015 {
1016   return mImpl->mKeyInputFocusLostSignal;
1017 }
1018
1019 bool Control::EmitKeyEventSignal( const KeyEvent& event )
1020 {
1021   // Guard against destruction during signal emission
1022   Dali::Toolkit::Control handle( GetOwner() );
1023
1024   bool consumed = false;
1025
1026   // signals are allocated dynamically when someone connects
1027   if ( !mImpl->mKeyEventSignal.Empty() )
1028   {
1029     consumed = mImpl->mKeyEventSignal.Emit( handle, event );
1030   }
1031
1032   if (!consumed)
1033   {
1034     // Notification for derived classes
1035     consumed = OnKeyEvent(event);
1036   }
1037
1038   return consumed;
1039 }
1040
1041 Control::Control( ControlBehaviour behaviourFlags )
1042 : CustomActorImpl( static_cast< ActorFlags >( behaviourFlags ) ),
1043   mImpl(new Impl(*this))
1044 {
1045   mImpl->mFlags = behaviourFlags;
1046 }
1047
1048 Control::~Control()
1049 {
1050   delete mImpl;
1051 }
1052
1053 void Control::Initialize()
1054 {
1055   // Call deriving classes so initialised before styling is applied to them.
1056   OnInitialize();
1057
1058   if( (mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS) ||
1059       !(mImpl->mFlags & DISABLE_STYLE_CHANGE_SIGNALS) )
1060   {
1061     Toolkit::StyleManager styleManager = StyleManager::Get();
1062
1063     // if stylemanager is available
1064     if( styleManager )
1065     {
1066       StyleManager& styleManagerImpl = GetImpl( styleManager );
1067
1068       // Register for style changes
1069       styleManagerImpl.ControlStyleChangeSignal().Connect( this, &Control::OnStyleChange );
1070
1071       // Apply the current style
1072       styleManagerImpl.ApplyThemeStyleAtInit( Toolkit::Control( GetOwner() ) );
1073     }
1074   }
1075
1076   if( mImpl->mFlags & REQUIRES_KEYBOARD_NAVIGATION_SUPPORT )
1077   {
1078     SetKeyboardNavigationSupport( true );
1079   }
1080 }
1081
1082 void Control::OnInitialize()
1083 {
1084 }
1085
1086 void Control::OnControlChildAdd( Actor& child )
1087 {
1088 }
1089
1090 void Control::OnControlChildRemove( Actor& child )
1091 {
1092 }
1093
1094 void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
1095 {
1096   // By default the control is only interested in theme (not font) changes
1097   if( styleManager && change == StyleChange::THEME_CHANGE )
1098   {
1099     GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
1100   }
1101   RelayoutRequest();
1102 }
1103
1104 void Control::OnPinch(const PinchGesture& pinch)
1105 {
1106   if( !( mImpl->mStartingPinchScale ) )
1107   {
1108     // lazy allocate
1109     mImpl->mStartingPinchScale = new Vector3;
1110   }
1111
1112   if( pinch.state == Gesture::Started )
1113   {
1114     *( mImpl->mStartingPinchScale ) = Self().GetCurrentScale();
1115   }
1116
1117   Self().SetScale( *( mImpl->mStartingPinchScale ) * pinch.scale );
1118 }
1119
1120 void Control::OnPan( const PanGesture& pan )
1121 {
1122 }
1123
1124 void Control::OnTap(const TapGesture& tap)
1125 {
1126 }
1127
1128 void Control::OnLongPress( const LongPressGesture& longPress )
1129 {
1130 }
1131
1132 void Control::EmitKeyInputFocusSignal( bool focusGained )
1133 {
1134   Dali::Toolkit::Control handle( GetOwner() );
1135
1136   if ( focusGained )
1137   {
1138     // signals are allocated dynamically when someone connects
1139     if ( !mImpl->mKeyInputFocusGainedSignal.Empty() )
1140     {
1141       mImpl->mKeyInputFocusGainedSignal.Emit( handle );
1142     }
1143   }
1144   else
1145   {
1146     // signals are allocated dynamically when someone connects
1147     if ( !mImpl->mKeyInputFocusLostSignal.Empty() )
1148     {
1149       mImpl->mKeyInputFocusLostSignal.Emit( handle );
1150     }
1151   }
1152 }
1153
1154 void Control::OnStageConnection( int depth )
1155 {
1156   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageConnection number of registered visuals(%d)\n",  mImpl->mVisuals.Size() );
1157
1158   Actor self( Self() );
1159
1160   for(RegisteredVisualContainer::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++)
1161   {
1162     // Check whether the visual is empty and enabled
1163     if( (*iter)->visual && (*iter)->enabled )
1164     {
1165       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageConnection Setting visual(%d) on stage\n", (*iter)->index );
1166       Toolkit::GetImplementation((*iter)->visual).SetOnStage( self );
1167     }
1168   }
1169
1170   if( mImpl->mVisuals.Empty() && ! self.GetRendererCount() )
1171   {
1172     Property::Value clippingValue = self.GetProperty( Actor::Property::CLIPPING_MODE );
1173     int clippingMode = ClippingMode::DISABLED;
1174     if( clippingValue.Get( clippingMode ) )
1175     {
1176       // Add a transparent background if we do not have any renderers or visuals so we clip our children
1177
1178       if( clippingMode == ClippingMode::CLIP_CHILDREN )
1179       {
1180         // Create a transparent background visual which will also get staged.
1181         SetBackgroundColor( Color::TRANSPARENT );
1182       }
1183     }
1184   }
1185 }
1186
1187 void Control::OnStageDisconnection()
1188 {
1189   for(RegisteredVisualContainer::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++)
1190   {
1191     // Check whether the visual is empty
1192     if( (*iter)->visual )
1193     {
1194       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageDisconnection Setting visual(%d) off stage\n", (*iter)->index );
1195       Actor self( Self() );
1196       Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
1197     }
1198   }
1199 }
1200
1201 void Control::OnKeyInputFocusGained()
1202 {
1203   EmitKeyInputFocusSignal( true );
1204 }
1205
1206 void Control::OnKeyInputFocusLost()
1207 {
1208   EmitKeyInputFocusSignal( false );
1209 }
1210
1211 void Control::OnChildAdd(Actor& child)
1212 {
1213   // Notify derived classes.
1214   OnControlChildAdd( child );
1215 }
1216
1217 void Control::OnChildRemove(Actor& child)
1218 {
1219   // Notify derived classes.
1220   OnControlChildRemove( child );
1221 }
1222
1223 void Control::OnPropertySet( Property::Index index, Property::Value propertyValue )
1224 {
1225   Actor self( Self() );
1226   if( index == Actor::Property::CLIPPING_MODE )
1227   {
1228     // Only set the background if we're already on the stage and have no renderers or visuals
1229
1230     if( mImpl->mVisuals.Empty() && ! self.GetRendererCount() && self.OnStage() )
1231     {
1232       ClippingMode::Type clippingMode = ClippingMode::DISABLED;
1233       if( Scripting::GetEnumerationProperty< ClippingMode::Type >( propertyValue, CLIPPING_MODE_TABLE, CLIPPING_MODE_TABLE_COUNT, clippingMode ) )
1234       {
1235         // Add a transparent background if we do not have one so we clip children
1236
1237         if( clippingMode == ClippingMode::CLIP_CHILDREN )
1238         {
1239           SetBackgroundColor( Color::TRANSPARENT );
1240         }
1241       }
1242     }
1243   }
1244 }
1245
1246 void Control::OnSizeSet(const Vector3& targetSize)
1247 {
1248   Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND );
1249   if( visual )
1250   {
1251     Vector2 size( targetSize );
1252     Property::Map transformMap;
1253     SetDefaultTransform( transformMap );
1254     visual.SetTransformAndSize( transformMap, size );
1255   }
1256 }
1257
1258 void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
1259 {
1260   // @todo size negotiate background to new size, animate as well?
1261 }
1262
1263 bool Control::OnTouchEvent(const TouchEvent& event)
1264 {
1265   return false; // Do not consume
1266 }
1267
1268 bool Control::OnHoverEvent(const HoverEvent& event)
1269 {
1270   return false; // Do not consume
1271 }
1272
1273 bool Control::OnKeyEvent(const KeyEvent& event)
1274 {
1275   return false; // Do not consume
1276 }
1277
1278 bool Control::OnWheelEvent(const WheelEvent& event)
1279 {
1280   return false; // Do not consume
1281 }
1282
1283 void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
1284 {
1285   for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i )
1286   {
1287     container.Add( Self().GetChildAt( i ), size );
1288   }
1289
1290   Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND );
1291   if( visual )
1292   {
1293     Vector2 controlSize( size );
1294     Property::Map transformMap;
1295     SetDefaultTransform( transformMap );
1296     visual.SetTransformAndSize( transformMap, controlSize );
1297   }
1298 }
1299
1300 void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
1301 {
1302 }
1303
1304 Vector3 Control::GetNaturalSize()
1305 {
1306   Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND );
1307   if( visual )
1308   {
1309     Vector2 naturalSize;
1310     visual.GetNaturalSize( naturalSize );
1311     return Vector3( naturalSize );
1312   }
1313   return Vector3::ZERO;
1314 }
1315
1316 float Control::CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
1317 {
1318   return CalculateChildSizeBase( child, dimension );
1319 }
1320
1321 float Control::GetHeightForWidth( float width )
1322 {
1323   return GetHeightForWidthBase( width );
1324 }
1325
1326 float Control::GetWidthForHeight( float height )
1327 {
1328   return GetWidthForHeightBase( height );
1329 }
1330
1331 bool Control::RelayoutDependentOnChildren( Dimension::Type dimension )
1332 {
1333   return RelayoutDependentOnChildrenBase( dimension );
1334 }
1335
1336 void Control::OnCalculateRelayoutSize( Dimension::Type dimension )
1337 {
1338 }
1339
1340 void Control::OnLayoutNegotiated( float size, Dimension::Type dimension )
1341 {
1342 }
1343
1344 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
1345 {
1346   mImpl->SignalConnected( slotObserver, callback );
1347 }
1348
1349 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
1350 {
1351   mImpl->SignalDisconnected( slotObserver, callback );
1352 }
1353
1354 Control& GetImplementation( Dali::Toolkit::Control& handle )
1355 {
1356   CustomActorImpl& customInterface = handle.GetImplementation();
1357   // downcast to control
1358   Control& impl = dynamic_cast< Internal::Control& >( customInterface );
1359   return impl;
1360 }
1361
1362 const Control& GetImplementation( const Dali::Toolkit::Control& handle )
1363 {
1364   const CustomActorImpl& customInterface = handle.GetImplementation();
1365   // downcast to control
1366   const Control& impl = dynamic_cast< const Internal::Control& >( customInterface );
1367   return impl;
1368 }
1369
1370 } // namespace Internal
1371
1372 } // namespace Toolkit
1373
1374 } // namespace Dali