2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "control-data-impl.h"
22 #include <dali-toolkit/public-api/dali-toolkit-common.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/devel-api/object/handle-devel.h>
25 #include <dali/devel-api/scripting/enum-helper.h>
26 #include <dali/devel-api/scripting/scripting.h>
27 #include <dali/integration-api/debug.h>
28 #include <dali/public-api/object/type-registry-helper.h>
29 #include <dali/integration-api/adaptor-framework/adaptor.h>
34 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
35 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
36 #include <dali-toolkit/public-api/visuals/visual-properties.h>
37 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
38 #include <dali-toolkit/devel-api/controls/control-devel.h>
39 #include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
40 #include <dali-toolkit/internal/styling/style-manager-impl.h>
41 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
52 extern const Dali::Scripting::StringEnum ControlStateTable[];
53 extern const unsigned int ControlStateTableCount;
56 // Not static or anonymous - shared with other translation units
57 const Scripting::StringEnum ControlStateTable[] = {
58 { "NORMAL", Toolkit::DevelControl::NORMAL },
59 { "FOCUSED", Toolkit::DevelControl::FOCUSED },
60 { "DISABLED", Toolkit::DevelControl::DISABLED },
62 const unsigned int ControlStateTableCount = sizeof( ControlStateTable ) / sizeof( ControlStateTable[0] );
69 #if defined(DEBUG_ENABLED)
70 Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CONTROL_VISUALS");
75 void Remove( Dictionary<T>& keyValues, const std::string& name )
77 keyValues.Remove(name);
80 void Remove( DictionaryKeys& keys, const std::string& name )
82 DictionaryKeys::iterator iter = std::find( keys.begin(), keys.end(), name );
83 if( iter != keys.end())
89 Toolkit::Visual::Type GetVisualTypeFromMap( const Property::Map& map )
91 Property::Value* typeValue = map.Find( Toolkit::Visual::Property::TYPE, VISUAL_TYPE );
92 Toolkit::Visual::Type type = Toolkit::Visual::IMAGE;
95 Scripting::GetEnumerationProperty( *typeValue, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT, type );
101 * Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
103 bool FindVisual( Property::Index targetIndex, const RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter )
105 for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
107 if ( (*iter)->index == targetIndex )
115 void FindChangableVisuals( Dictionary<Property::Map>& stateVisualsToAdd,
116 Dictionary<Property::Map>& stateVisualsToChange,
117 DictionaryKeys& stateVisualsToRemove)
119 DictionaryKeys copyOfStateVisualsToRemove = stateVisualsToRemove;
121 for( DictionaryKeys::iterator iter = copyOfStateVisualsToRemove.begin();
122 iter != copyOfStateVisualsToRemove.end(); ++iter )
124 const std::string& visualName = (*iter);
125 Property::Map* toMap = stateVisualsToAdd.Find( visualName );
128 stateVisualsToChange.Add( visualName, *toMap );
129 stateVisualsToAdd.Remove( visualName );
130 Remove( stateVisualsToRemove, visualName );
135 Toolkit::Visual::Base GetVisualByName(
136 const RegisteredVisualContainer& visuals,
137 const std::string& visualName )
139 Toolkit::Visual::Base visualHandle;
141 RegisteredVisualContainer::Iterator iter;
142 for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
144 Toolkit::Visual::Base visual = (*iter)->visual;
145 if( visual && visual.GetName() == visualName )
147 visualHandle = visual;
155 * Move visual from source to destination container
157 void MoveVisual( RegisteredVisualContainer::Iterator sourceIter, RegisteredVisualContainer& source, RegisteredVisualContainer& destination )
159 Toolkit::Visual::Base visual = (*sourceIter)->visual;
162 RegisteredVisual* rv = source.Release( sourceIter );
163 destination.PushBack( rv );
168 * Performs actions as requested using the action name.
169 * @param[in] object The object on which to perform the action.
170 * @param[in] actionName The action to perform.
171 * @param[in] attributes The attributes with which to perfrom this action.
172 * @return true if action has been accepted by this control
174 const char* ACTION_ACCESSIBILITY_ACTIVATED = "accessibilityActivated";
175 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
179 if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) ) )
181 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
184 // if cast succeeds there is an implementation so no need to check
185 ret = Internal::GetImplementation( control ).OnAccessibilityActivated();
193 * Connects a callback function with the object's signals.
194 * @param[in] object The object providing the signal.
195 * @param[in] tracker Used to disconnect the signal.
196 * @param[in] signalName The signal to connect to.
197 * @param[in] functor A newly allocated FunctorDelegate.
198 * @return True if the signal was connected.
199 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
201 const char* SIGNAL_KEY_EVENT = "keyEvent";
202 const char* SIGNAL_KEY_INPUT_FOCUS_GAINED = "keyInputFocusGained";
203 const char* SIGNAL_KEY_INPUT_FOCUS_LOST = "keyInputFocusLost";
204 const char* SIGNAL_TAPPED = "tapped";
205 const char* SIGNAL_PANNED = "panned";
206 const char* SIGNAL_PINCHED = "pinched";
207 const char* SIGNAL_LONG_PRESSED = "longPressed";
208 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
210 Dali::BaseHandle handle( object );
212 bool connected( false );
213 Toolkit::Control control = Toolkit::Control::DownCast( handle );
216 Internal::Control& controlImpl( Internal::GetImplementation( control ) );
219 if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
221 controlImpl.KeyEventSignal().Connect( tracker, functor );
223 else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_GAINED ) )
225 controlImpl.KeyInputFocusGainedSignal().Connect( tracker, functor );
227 else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_LOST ) )
229 controlImpl.KeyInputFocusLostSignal().Connect( tracker, functor );
231 else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
233 controlImpl.EnableGestureDetection( GestureType::TAP );
234 controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
236 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
238 controlImpl.EnableGestureDetection( GestureType::PAN );
239 controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
241 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
243 controlImpl.EnableGestureDetection( GestureType::PINCH );
244 controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
246 else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
248 controlImpl.EnableGestureDetection( GestureType::LONG_PRESS );
249 controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
256 * Creates control through type registry
260 return Internal::Control::New();
262 // Setup signals and actions using the type-registry.
263 DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
265 // Note: Properties are registered separately below.
267 SignalConnectorType registerSignal1( typeRegistration, SIGNAL_KEY_EVENT, &DoConnectSignal );
268 SignalConnectorType registerSignal2( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_GAINED, &DoConnectSignal );
269 SignalConnectorType registerSignal3( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_LOST, &DoConnectSignal );
270 SignalConnectorType registerSignal4( typeRegistration, SIGNAL_TAPPED, &DoConnectSignal );
271 SignalConnectorType registerSignal5( typeRegistration, SIGNAL_PANNED, &DoConnectSignal );
272 SignalConnectorType registerSignal6( typeRegistration, SIGNAL_PINCHED, &DoConnectSignal );
273 SignalConnectorType registerSignal7( typeRegistration, SIGNAL_LONG_PRESSED, &DoConnectSignal );
275 TypeAction registerAction( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &DoAction );
277 DALI_TYPE_REGISTRATION_END()
280 * @brief Iterate through given container and setOffScene any visual found
282 * @param[in] container Container of visuals
283 * @param[in] parent Parent actor to remove visuals from
285 void SetVisualsOffScene( const RegisteredVisualContainer& container, Actor parent )
287 for( auto iter = container.Begin(), end = container.End() ; iter!= end; iter++)
289 if( (*iter)->visual )
291 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::SetOffScene Setting visual(%d) off stage\n", (*iter)->index );
292 Toolkit::GetImplementation((*iter)->visual).SetOffScene( parent );
297 } // unnamed namespace
300 // Properties registered without macro to use specific member variables.
301 const PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "styleName", Toolkit::Control::Property::STYLE_NAME, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
302 const PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "keyInputFocus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
303 const PropertyRegistration Control::Impl::PROPERTY_5( typeRegistration, "background", Toolkit::Control::Property::BACKGROUND, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
304 const PropertyRegistration Control::Impl::PROPERTY_6( typeRegistration, "margin", Toolkit::Control::Property::MARGIN, Property::EXTENTS, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
305 const PropertyRegistration Control::Impl::PROPERTY_7( typeRegistration, "padding", Toolkit::Control::Property::PADDING, Property::EXTENTS, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
306 const PropertyRegistration Control::Impl::PROPERTY_8( typeRegistration, "tooltip", Toolkit::DevelControl::Property::TOOLTIP, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
307 const PropertyRegistration Control::Impl::PROPERTY_9( typeRegistration, "state", Toolkit::DevelControl::Property::STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
308 const PropertyRegistration Control::Impl::PROPERTY_10( typeRegistration, "subState", Toolkit::DevelControl::Property::SUB_STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
309 const PropertyRegistration Control::Impl::PROPERTY_11( typeRegistration, "leftFocusableActorId", Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
310 const PropertyRegistration Control::Impl::PROPERTY_12( typeRegistration, "rightFocusableActorId", Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID,Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
311 const PropertyRegistration Control::Impl::PROPERTY_13( typeRegistration, "upFocusableActorId", Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
312 const PropertyRegistration Control::Impl::PROPERTY_14( typeRegistration, "downFocusableActorId", Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
313 const PropertyRegistration Control::Impl::PROPERTY_15( typeRegistration, "shadow", Toolkit::DevelControl::Property::SHADOW, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
315 Control::Impl::Impl( Control& controlImpl )
316 : mControlImpl( controlImpl ),
317 mState( Toolkit::DevelControl::NORMAL ),
319 mLeftFocusableActorId( -1 ),
320 mRightFocusableActorId( -1 ),
321 mUpFocusableActorId( -1 ),
322 mDownFocusableActorId( -1 ),
324 mBackgroundColor(Color::TRANSPARENT),
325 mStartingPinchScale(nullptr),
326 mMargin( 0, 0, 0, 0 ),
327 mPadding( 0, 0, 0, 0 ),
329 mKeyInputFocusGainedSignal(),
330 mKeyInputFocusLostSignal(),
331 mResourceReadySignal(),
332 mVisualEventSignal(),
333 mPinchGestureDetector(),
334 mPanGestureDetector(),
335 mTapGestureDetector(),
336 mLongPressGestureDetector(),
338 mInputMethodContext(),
339 mIdleCallback(nullptr),
341 mAutofillContainer(),
342 mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
343 mIsKeyboardNavigationSupported( false ),
344 mIsKeyboardFocusGroup( false ),
345 mIsEmittingResourceReadySignal(false),
346 mNeedToEmitResourceReady(false),
347 mIsAutofillEnabled( false )
351 Control::Impl::~Impl()
353 // All gesture detectors will be destroyed so no need to disconnect.
354 delete mStartingPinchScale;
356 if(mIdleCallback && Adaptor::IsAvailable())
358 // Removes the callback from the callback manager in case the control is destroyed before the callback is executed.
359 Adaptor::Get().RemoveIdle(mIdleCallback);
363 Control::Impl& Control::Impl::Get( Internal::Control& internalControl )
365 return *internalControl.mImpl;
368 const Control::Impl& Control::Impl::Get( const Internal::Control& internalControl )
370 return *internalControl.mImpl;
373 // Gesture Detection Methods
374 void Control::Impl::PinchDetected(Actor actor, const PinchGesture& pinch)
376 mControlImpl.OnPinch(pinch);
379 void Control::Impl::PanDetected(Actor actor, const PanGesture& pan)
381 mControlImpl.OnPan(pan);
384 void Control::Impl::TapDetected(Actor actor, const TapGesture& tap)
386 mControlImpl.OnTap(tap);
389 void Control::Impl::LongPressDetected(Actor actor, const LongPressGesture& longPress)
391 mControlImpl.OnLongPress(longPress);
394 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
396 RegisterVisual( index, visual, VisualState::ENABLED, DepthIndexValue::NOT_SET );
399 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, int depthIndex )
401 RegisterVisual( index, visual, VisualState::ENABLED, DepthIndexValue::SET, depthIndex );
404 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
406 RegisterVisual( index, visual, ( enabled ? VisualState::ENABLED : VisualState::DISABLED ), DepthIndexValue::NOT_SET );
409 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex )
411 RegisterVisual( index, visual, ( enabled ? VisualState::ENABLED : VisualState::DISABLED ), DepthIndexValue::SET, depthIndex );
414 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, VisualState::Type enabled, DepthIndexValue::Type depthIndexValueSet, int depthIndex )
416 DALI_LOG_INFO( gLogFilter, Debug::Concise, "RegisterVisual:%d \n", index );
418 bool visualReplaced ( false );
419 Actor self = mControlImpl.Self();
421 // Set the depth index, if not set by caller this will be either the current visual depth, max depth of all visuals
423 int requiredDepthIndex = visual.GetDepthIndex();
425 if( depthIndexValueSet == DepthIndexValue::SET )
427 requiredDepthIndex = depthIndex;
430 // Visual replacement, existing visual should only be removed from stage when replacement ready.
431 if( !mVisuals.Empty() )
433 RegisteredVisualContainer::Iterator registeredVisualsiter;
434 // Check if visual (index) is already registered, this is the current visual.
435 if( FindVisual( index, mVisuals, registeredVisualsiter ) )
437 Toolkit::Visual::Base& currentRegisteredVisual = (*registeredVisualsiter)->visual;
438 if( currentRegisteredVisual )
440 // Store current visual depth index as may need to set the replacement visual to same depth
441 const int currentDepthIndex = (*registeredVisualsiter)->visual.GetDepthIndex();
443 // No longer required to know if the replaced visual's resources are ready
444 StopObservingVisual( currentRegisteredVisual );
446 // If control staged and visual enabled then visuals will be swapped once ready
447 if( self.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) && enabled )
449 // Check if visual is currently in the process of being replaced ( is in removal container )
450 RegisteredVisualContainer::Iterator visualQueuedForRemoval;
451 if ( FindVisual( index, mRemoveVisuals, visualQueuedForRemoval ) )
453 // Visual with same index is already in removal container so current visual pending
454 // Only the the last requested visual will be displayed so remove current visual which is staged but not ready.
455 Toolkit::GetImplementation( currentRegisteredVisual ).SetOffScene( self );
456 mVisuals.Erase( registeredVisualsiter );
460 // current visual not already in removal container so add now.
461 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "RegisterVisual Move current registered visual to removal Queue: %d \n", index );
462 MoveVisual( registeredVisualsiter, mVisuals, mRemoveVisuals );
467 // Control not staged or visual disabled so can just erase from registered visuals and new visual will be added later.
468 mVisuals.Erase( registeredVisualsiter );
471 // If we've not set the depth-index value and the new visual does not have a depth index applied to it, then use the previously set depth-index for this index
472 if( ( depthIndexValueSet == DepthIndexValue::NOT_SET ) &&
473 ( visual.GetDepthIndex() == 0 ) )
475 requiredDepthIndex = currentDepthIndex;
479 visualReplaced = true;
483 // If not set, set the name of the visual to the same name as the control's property.
484 // ( If the control has been type registered )
485 if( visual.GetName().empty() )
487 // returns empty string if index is not found as long as index is not -1
488 std::string visualName = self.GetPropertyName( index );
489 if( !visualName.empty() )
491 DALI_LOG_INFO( gLogFilter, Debug::Concise, "Setting visual name for property %d to %s\n",
492 index, visualName.c_str() );
493 visual.SetName( visualName );
497 if( !visualReplaced ) // New registration entry
499 // If we've not set the depth-index value, we have more than one visual and the visual does not have a depth index, then set it to be the highest
500 if( ( depthIndexValueSet == DepthIndexValue::NOT_SET ) &&
501 ( mVisuals.Size() > 0 ) &&
502 ( visual.GetDepthIndex() == 0 ) )
504 int maxDepthIndex = std::numeric_limits< int >::min();
506 RegisteredVisualContainer::ConstIterator iter;
507 const RegisteredVisualContainer::ConstIterator endIter = mVisuals.End();
508 for ( iter = mVisuals.Begin(); iter != endIter; iter++ )
510 const int visualDepthIndex = (*iter)->visual.GetDepthIndex();
511 if ( visualDepthIndex > maxDepthIndex )
513 maxDepthIndex = visualDepthIndex;
516 ++maxDepthIndex; // Add one to the current maximum depth index so that our added visual appears on top
517 requiredDepthIndex = std::max( 0, maxDepthIndex ); // Start at zero if maxDepth index belongs to a background
523 // Set determined depth index
524 visual.SetDepthIndex( requiredDepthIndex );
526 // Monitor when the visual resources are ready
527 StartObservingVisual( visual );
529 DALI_LOG_INFO( gLogFilter, Debug::Concise, "New Visual registration index[%d] depth[%d]\n", index, requiredDepthIndex );
530 RegisteredVisual* newRegisteredVisual = new RegisteredVisual( index, visual,
531 ( enabled == VisualState::ENABLED ? true : false ),
532 ( visualReplaced && enabled ) ) ;
533 mVisuals.PushBack( newRegisteredVisual );
535 Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
536 // Put on stage if enabled and the control is already on the stage
537 if( ( enabled == VisualState::ENABLED ) && self.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) )
539 visualImpl.SetOnScene( self );
541 else if( visualImpl.IsResourceReady() ) // When not being staged, check if visual already 'ResourceReady' before it was Registered. ( Resource may have been loaded already )
543 ResourceReady( visualImpl );
548 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual() Registered %s(%d), enabled:%s\n", visual.GetName().c_str(), index, enabled?"true":"false" );
551 void Control::Impl::UnregisterVisual( Property::Index index )
553 RegisteredVisualContainer::Iterator iter;
554 if ( FindVisual( index, mVisuals, iter ) )
556 // stop observing visual
557 StopObservingVisual( (*iter)->visual );
559 Actor self( mControlImpl.Self() );
560 Toolkit::GetImplementation((*iter)->visual).SetOffScene( self );
561 (*iter)->visual.Reset();
562 mVisuals.Erase( iter );
565 if( FindVisual( index, mRemoveVisuals, iter ) )
567 Actor self( mControlImpl.Self() );
568 Toolkit::GetImplementation( (*iter)->visual ).SetOffScene( self );
569 (*iter)->pending = false;
570 (*iter)->visual.Reset();
571 mRemoveVisuals.Erase( iter );
575 Toolkit::Visual::Base Control::Impl::GetVisual( Property::Index index ) const
577 RegisteredVisualContainer::Iterator iter;
578 if ( FindVisual( index, mVisuals, iter ) )
580 return (*iter)->visual;
583 return Toolkit::Visual::Base();
586 void Control::Impl::EnableVisual( Property::Index index, bool enable )
588 DALI_LOG_INFO( gLogFilter, Debug::General, "Control::EnableVisual(%d, %s)\n", index, enable?"T":"F");
590 RegisteredVisualContainer::Iterator iter;
591 if ( FindVisual( index, mVisuals, iter ) )
593 if ( (*iter)->enabled == enable )
595 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Visual %s(%d) already %s\n", (*iter)->visual.GetName().c_str(), index, enable?"enabled":"disabled");
599 (*iter)->enabled = enable;
600 Actor parentActor = mControlImpl.Self();
601 if ( mControlImpl.Self().GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) ) // If control not on Scene then Visual will be added when SceneConnection is called.
605 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting %s(%d) on stage \n", (*iter)->visual.GetName().c_str(), index );
606 Toolkit::GetImplementation((*iter)->visual).SetOnScene( parentActor );
610 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting %s(%d) off stage \n", (*iter)->visual.GetName().c_str(), index );
611 Toolkit::GetImplementation((*iter)->visual).SetOffScene( parentActor ); // No need to call if control not staged.
617 DALI_LOG_WARNING( "Control::EnableVisual(%d, %s) FAILED - NO SUCH VISUAL\n", index, enable?"T":"F" );
621 bool Control::Impl::IsVisualEnabled( Property::Index index ) const
623 RegisteredVisualContainer::Iterator iter;
624 if ( FindVisual( index, mVisuals, iter ) )
626 return (*iter)->enabled;
631 void Control::Impl::StopObservingVisual( Toolkit::Visual::Base& visual )
633 Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
635 // Stop observing the visual
636 visualImpl.RemoveEventObserver( *this );
639 void Control::Impl::StartObservingVisual( Toolkit::Visual::Base& visual)
641 Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
643 // start observing the visual for events
644 visualImpl.AddEventObserver( *this );
647 // Called by a Visual when it's resource is ready
648 void Control::Impl::ResourceReady( Visual::Base& object)
650 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::Impl::ResourceReady() replacements pending[%d]\n", mRemoveVisuals.Count() );
652 Actor self = mControlImpl.Self();
654 // A resource is ready, find resource in the registered visuals container and get its index
655 for( auto registeredIter = mVisuals.Begin(), end = mVisuals.End(); registeredIter != end; ++registeredIter )
657 Internal::Visual::Base& registeredVisualImpl = Toolkit::GetImplementation( (*registeredIter)->visual );
659 if( &object == ®isteredVisualImpl )
661 RegisteredVisualContainer::Iterator visualToRemoveIter;
662 // Find visual with the same index in the removal container
663 // Set if off stage as it's replacement is now ready.
664 // Remove if from removal list as now removed from stage.
665 // Set Pending flag on the ready visual to false as now ready.
666 if( FindVisual( (*registeredIter)->index, mRemoveVisuals, visualToRemoveIter ) )
668 (*registeredIter)->pending = false;
669 Toolkit::GetImplementation( (*visualToRemoveIter)->visual ).SetOffScene( self );
670 mRemoveVisuals.Erase( visualToRemoveIter );
676 // A visual is ready so control may need relayouting if staged
677 if ( self.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) )
679 mControlImpl.RelayoutRequest();
682 // Emit signal if all enabled visuals registered by the control are ready.
683 if( IsResourceReady() )
686 mNeedToEmitResourceReady = false;
688 EmitResourceReadySignal();
692 void Control::Impl::NotifyVisualEvent( Visual::Base& object, Property::Index signalId )
694 for( auto registeredIter = mVisuals.Begin(), end = mVisuals.End(); registeredIter != end; ++registeredIter )
696 Internal::Visual::Base& registeredVisualImpl = Toolkit::GetImplementation( (*registeredIter)->visual );
697 if( &object == ®isteredVisualImpl )
699 Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
700 mVisualEventSignal.Emit( handle, (*registeredIter)->index, signalId );
706 bool Control::Impl::IsResourceReady() const
708 // Iterate through and check all the enabled visuals are ready
709 for( auto visualIter = mVisuals.Begin();
710 visualIter != mVisuals.End(); ++visualIter )
712 const Toolkit::Visual::Base visual = (*visualIter)->visual;
713 const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
715 // one of the enabled visuals is not ready
716 if( !visualImpl.IsResourceReady() && (*visualIter)->enabled )
724 Toolkit::Visual::ResourceStatus Control::Impl::GetVisualResourceStatus( Property::Index index ) const
726 RegisteredVisualContainer::Iterator iter;
727 if ( FindVisual( index, mVisuals, iter ) )
729 const Toolkit::Visual::Base visual = (*iter)->visual;
730 const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
731 return visualImpl.GetResourceStatus( );
734 return Toolkit::Visual::ResourceStatus::PREPARING;
739 void Control::Impl::AddTransitions( Dali::Animation& animation,
740 const Toolkit::TransitionData& handle,
741 bool createAnimation )
743 // Setup a Transition from TransitionData.
744 const Internal::TransitionData& transitionData = Toolkit::GetImplementation( handle );
745 TransitionData::Iterator end = transitionData.End();
746 for( TransitionData::Iterator iter = transitionData.Begin() ;
747 iter != end; ++iter )
749 TransitionData::Animator* animator = (*iter);
751 Toolkit::Visual::Base visual = GetVisualByName( mVisuals, animator->objectName );
755 #if defined(DEBUG_ENABLED)
756 Dali::TypeInfo typeInfo;
757 ControlWrapper* controlWrapperImpl = dynamic_cast<ControlWrapper*>(&mControlImpl);
758 if( controlWrapperImpl )
760 typeInfo = controlWrapperImpl->GetTypeInfo();
763 DALI_LOG_INFO( gLogFilter, Debug::Concise, "CreateTransition: Found %s visual for %s\n",
764 visual.GetName().c_str(), typeInfo?typeInfo.GetName().c_str():"Unknown" );
766 Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
767 visualImpl.AnimateProperty( animation, *animator );
771 DALI_LOG_INFO( gLogFilter, Debug::Concise, "CreateTransition: Could not find visual. Trying actors");
772 // Otherwise, try any actor children of control (Including the control)
773 Actor child = mControlImpl.Self().FindChildByName( animator->objectName );
776 Property::Index propertyIndex = child.GetPropertyIndex( animator->propertyKey );
777 if( propertyIndex != Property::INVALID_INDEX )
779 if( animator->animate == false )
781 if( animator->targetValue.GetType() != Property::NONE )
783 child.SetProperty( propertyIndex, animator->targetValue );
786 else // animate the property
788 if( animator->initialValue.GetType() != Property::NONE )
790 child.SetProperty( propertyIndex, animator->initialValue );
793 if( createAnimation && !animation )
795 animation = Dali::Animation::New( 0.1f );
798 animation.AnimateTo( Property( child, propertyIndex ),
799 animator->targetValue,
800 animator->alphaFunction,
801 TimePeriod( animator->timePeriodDelay,
802 animator->timePeriodDuration ) );
810 Dali::Animation Control::Impl::CreateTransition( const Toolkit::TransitionData& transitionData )
812 Dali::Animation transition;
814 if( transitionData.Count() > 0 )
816 AddTransitions( transition, transitionData, true );
823 void Control::Impl::DoAction( Dali::Property::Index visualIndex, Dali::Property::Index actionId, const Dali::Property::Value attributes )
825 RegisteredVisualContainer::Iterator iter;
826 if ( FindVisual( visualIndex, mVisuals, iter ) )
828 Toolkit::GetImplementation((*iter)->visual).DoAction( actionId, attributes );
832 void Control::Impl::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
834 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
838 Control& controlImpl( GetImplementation( control ) );
842 case Toolkit::Control::Property::STYLE_NAME:
844 controlImpl.SetStyleName( value.Get< std::string >() );
848 case Toolkit::DevelControl::Property::STATE:
850 bool withTransitions=true;
851 const Property::Value* valuePtr=&value;
852 const Property::Map* map = value.GetMap();
855 Property::Value* value2 = map->Find("withTransitions");
858 withTransitions = value2->Get<bool>();
861 valuePtr = map->Find("state");
866 Toolkit::DevelControl::State state( controlImpl.mImpl->mState );
867 if( Scripting::GetEnumerationProperty< Toolkit::DevelControl::State >( *valuePtr, ControlStateTable, ControlStateTableCount, state ) )
869 controlImpl.mImpl->SetState( state, withTransitions );
875 case Toolkit::DevelControl::Property::SUB_STATE:
877 std::string subState;
878 if( value.Get( subState ) )
880 controlImpl.mImpl->SetSubState( subState );
885 case Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID:
888 if( value.Get( focusId ) )
890 controlImpl.mImpl->mLeftFocusableActorId = focusId;
895 case Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID:
898 if( value.Get( focusId ) )
900 controlImpl.mImpl->mRightFocusableActorId = focusId;
905 case Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID:
908 if( value.Get( focusId ) )
910 controlImpl.mImpl->mUpFocusableActorId = focusId;
915 case Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID:
918 if( value.Get( focusId ) )
920 controlImpl.mImpl->mDownFocusableActorId = focusId;
925 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
927 if ( value.Get< bool >() )
929 controlImpl.SetKeyInputFocus();
933 controlImpl.ClearKeyInputFocus();
938 case Toolkit::Control::Property::BACKGROUND:
942 const Property::Map* map = value.GetMap();
943 if( map && !map->Empty() )
945 controlImpl.SetBackground( *map );
947 else if( value.Get( url ) )
949 // don't know the size to load
950 Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( url, ImageDimensions() );
953 controlImpl.mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual, DepthIndex::BACKGROUND );
956 else if( value.Get( color ) )
958 controlImpl.SetBackgroundColor(color);
962 // The background is an empty property map, so we should clear the background
963 controlImpl.ClearBackground();
968 case Toolkit::Control::Property::MARGIN:
971 if( value.Get( margin ) )
973 controlImpl.mImpl->SetMargin( margin );
978 case Toolkit::Control::Property::PADDING:
981 if( value.Get( padding ) )
983 controlImpl.mImpl->SetPadding( padding );
988 case Toolkit::DevelControl::Property::TOOLTIP:
990 TooltipPtr& tooltipPtr = controlImpl.mImpl->mTooltip;
993 tooltipPtr = Tooltip::New( control );
995 tooltipPtr->SetProperties( value );
999 case Toolkit::DevelControl::Property::SHADOW:
1001 const Property::Map* map = value.GetMap();
1002 if( map && !map->Empty() )
1004 controlImpl.mImpl->SetShadow( *map );
1008 // The shadow is an empty property map, so we should clear the shadow
1009 controlImpl.mImpl->ClearShadow();
1018 Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index index )
1020 Property::Value value;
1022 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
1026 Control& controlImpl( GetImplementation( control ) );
1030 case Toolkit::Control::Property::STYLE_NAME:
1032 value = controlImpl.GetStyleName();
1036 case Toolkit::DevelControl::Property::STATE:
1038 value = controlImpl.mImpl->mState;
1042 case Toolkit::DevelControl::Property::SUB_STATE:
1044 value = controlImpl.mImpl->mSubStateName;
1048 case Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID:
1050 value = controlImpl.mImpl->mLeftFocusableActorId;
1054 case Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID:
1056 value = controlImpl.mImpl->mRightFocusableActorId;
1060 case Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID:
1062 value = controlImpl.mImpl->mUpFocusableActorId;
1066 case Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID:
1068 value = controlImpl.mImpl->mDownFocusableActorId;
1072 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
1074 value = controlImpl.HasKeyInputFocus();
1078 case Toolkit::Control::Property::BACKGROUND:
1081 Toolkit::Visual::Base visual = controlImpl.mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
1084 visual.CreatePropertyMap( map );
1091 case Toolkit::Control::Property::MARGIN:
1093 value = controlImpl.mImpl->GetMargin();
1097 case Toolkit::Control::Property::PADDING:
1099 value = controlImpl.mImpl->GetPadding();
1103 case Toolkit::DevelControl::Property::TOOLTIP:
1106 if( controlImpl.mImpl->mTooltip )
1108 controlImpl.mImpl->mTooltip->CreatePropertyMap( map );
1114 case Toolkit::DevelControl::Property::SHADOW:
1117 Toolkit::Visual::Base visual = controlImpl.mImpl->GetVisual( Toolkit::DevelControl::Property::SHADOW );
1120 visual.CreatePropertyMap( map );
1133 void Control::Impl::CopyInstancedProperties( RegisteredVisualContainer& visuals, Dictionary<Property::Map>& instancedProperties )
1135 for(RegisteredVisualContainer::Iterator iter = visuals.Begin(); iter!= visuals.End(); iter++)
1137 if( (*iter)->visual )
1139 Property::Map instanceMap;
1140 Toolkit::GetImplementation((*iter)->visual).CreateInstancePropertyMap(instanceMap);
1141 instancedProperties.Add( (*iter)->visual.GetName(), instanceMap );
1147 void Control::Impl::RemoveVisual( RegisteredVisualContainer& visuals, const std::string& visualName )
1149 Actor self( mControlImpl.Self() );
1151 for ( RegisteredVisualContainer::Iterator visualIter = visuals.Begin();
1152 visualIter != visuals.End(); ++visualIter )
1154 Toolkit::Visual::Base visual = (*visualIter)->visual;
1155 if( visual && visual.GetName() == visualName )
1157 Toolkit::GetImplementation(visual).SetOffScene( self );
1158 (*visualIter)->visual.Reset();
1159 visuals.Erase( visualIter );
1165 void Control::Impl::RemoveVisuals( RegisteredVisualContainer& visuals, DictionaryKeys& removeVisuals )
1167 Actor self( mControlImpl.Self() );
1168 for( DictionaryKeys::iterator iter = removeVisuals.begin(); iter != removeVisuals.end(); ++iter )
1170 const std::string visualName = *iter;
1171 RemoveVisual( visuals, visualName );
1175 void Control::Impl::RecreateChangedVisuals( Dictionary<Property::Map>& stateVisualsToChange,
1176 Dictionary<Property::Map>& instancedProperties )
1178 Dali::CustomActor handle( mControlImpl.GetOwner() );
1179 for( Dictionary<Property::Map>::iterator iter = stateVisualsToChange.Begin();
1180 iter != stateVisualsToChange.End(); ++iter )
1182 const std::string& visualName = (*iter).key;
1183 const Property::Map& toMap = (*iter).entry;
1185 // is it a candidate for re-creation?
1186 bool recreate = false;
1188 Toolkit::Visual::Base visual = GetVisualByName( mVisuals, visualName );
1191 Property::Map fromMap;
1192 visual.CreatePropertyMap( fromMap );
1194 Toolkit::Visual::Type fromType = GetVisualTypeFromMap( fromMap );
1195 Toolkit::Visual::Type toType = GetVisualTypeFromMap( toMap );
1197 if( fromType != toType )
1203 if( fromType == Toolkit::Visual::IMAGE || fromType == Toolkit::Visual::N_PATCH
1204 || fromType == Toolkit::Visual::SVG || fromType == Toolkit::Visual::ANIMATED_IMAGE )
1206 Property::Value* fromUrl = fromMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
1207 Property::Value* toUrl = toMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
1209 if( fromUrl && toUrl )
1211 std::string fromUrlString;
1212 std::string toUrlString;
1213 fromUrl->Get(fromUrlString);
1214 toUrl->Get(toUrlString);
1216 if( fromUrlString != toUrlString )
1224 const Property::Map* instancedMap = instancedProperties.FindConst( visualName );
1225 if( recreate || instancedMap )
1227 RemoveVisual( mVisuals, visualName );
1228 Style::ApplyVisual( handle, visualName, toMap, instancedMap );
1232 // @todo check to see if we can apply toMap without recreating the visual
1233 // e.g. by setting only animatable properties
1234 // For now, recreate all visuals, but merge in instance data.
1235 RemoveVisual( mVisuals, visualName );
1236 Style::ApplyVisual( handle, visualName, toMap, instancedMap );
1242 void Control::Impl::ReplaceStateVisualsAndProperties( const StylePtr oldState, const StylePtr newState, const std::string& subState )
1244 // Collect all old visual names
1245 DictionaryKeys stateVisualsToRemove;
1248 oldState->visuals.GetKeys( stateVisualsToRemove );
1249 if( ! subState.empty() )
1251 const StylePtr* oldSubState = oldState->subStates.FindConst(subState);
1254 DictionaryKeys subStateVisualsToRemove;
1255 (*oldSubState)->visuals.GetKeys( subStateVisualsToRemove );
1256 Merge( stateVisualsToRemove, subStateVisualsToRemove );
1261 // Collect all new visual properties
1262 Dictionary<Property::Map> stateVisualsToAdd;
1265 stateVisualsToAdd = newState->visuals;
1266 if( ! subState.empty() )
1268 const StylePtr* newSubState = newState->subStates.FindConst(subState);
1271 stateVisualsToAdd.Merge( (*newSubState)->visuals );
1276 // If a name is in both add/remove, move it to change list.
1277 Dictionary<Property::Map> stateVisualsToChange;
1278 FindChangableVisuals( stateVisualsToAdd, stateVisualsToChange, stateVisualsToRemove);
1280 // Copy instanced properties (e.g. text label) of current visuals
1281 Dictionary<Property::Map> instancedProperties;
1282 CopyInstancedProperties( mVisuals, instancedProperties );
1284 // For each visual in remove list, remove from mVisuals
1285 RemoveVisuals( mVisuals, stateVisualsToRemove );
1287 // For each visual in add list, create and add to mVisuals
1288 Dali::CustomActor handle( mControlImpl.GetOwner() );
1289 Style::ApplyVisuals( handle, stateVisualsToAdd, instancedProperties );
1291 // For each visual in change list, if it requires a new visual,
1292 // remove old visual, create and add to mVisuals
1293 RecreateChangedVisuals( stateVisualsToChange, instancedProperties );
1296 void Control::Impl::SetState( DevelControl::State newState, bool withTransitions )
1298 DevelControl::State oldState = mState;
1299 Dali::CustomActor handle( mControlImpl.GetOwner() );
1300 DALI_LOG_INFO(gLogFilter, Debug::Concise, "Control::Impl::SetState: %s\n",
1301 (mState == DevelControl::NORMAL ? "NORMAL" :(
1302 mState == DevelControl::FOCUSED ?"FOCUSED" : (
1303 mState == DevelControl::DISABLED?"DISABLED":"NONE" ))));
1305 if( mState != newState )
1307 // If mState was Disabled, and new state is Focused, should probably
1308 // store that fact, e.g. in another property that FocusManager can access.
1311 // Trigger state change and transitions
1312 // Apply new style, if stylemanager is available
1313 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
1316 const StylePtr stylePtr = GetImpl( styleManager ).GetRecordedStyle( Toolkit::Control( mControlImpl.GetOwner() ) );
1320 std::string oldStateName = Scripting::GetEnumerationName< Toolkit::DevelControl::State >( oldState, ControlStateTable, ControlStateTableCount );
1321 std::string newStateName = Scripting::GetEnumerationName< Toolkit::DevelControl::State >( newState, ControlStateTable, ControlStateTableCount );
1323 const StylePtr* newStateStyle = stylePtr->subStates.Find( newStateName );
1324 const StylePtr* oldStateStyle = stylePtr->subStates.Find( oldStateName );
1325 if( oldStateStyle && newStateStyle )
1327 // Only change if both state styles exist
1328 ReplaceStateVisualsAndProperties( *oldStateStyle, *newStateStyle, mSubStateName );
1335 void Control::Impl::SetSubState( const std::string& subStateName, bool withTransitions )
1337 if( mSubStateName != subStateName )
1339 // Get existing sub-state visuals, and unregister them
1340 Dali::CustomActor handle( mControlImpl.GetOwner() );
1342 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
1345 const StylePtr stylePtr = GetImpl( styleManager ).GetRecordedStyle( Toolkit::Control( mControlImpl.GetOwner() ) );
1349 std::string stateName = Scripting::GetEnumerationName< Toolkit::DevelControl::State >( mState, ControlStateTable, ControlStateTableCount );
1351 const StylePtr* state = stylePtr->subStates.Find( stateName );
1354 StylePtr stateStyle(*state);
1356 const StylePtr* newStateStyle = stateStyle->subStates.Find( subStateName );
1357 const StylePtr* oldStateStyle = stateStyle->subStates.Find( mSubStateName );
1358 if( oldStateStyle && newStateStyle )
1361 ReplaceStateVisualsAndProperties( *oldStateStyle, *newStateStyle, empty );
1367 mSubStateName = subStateName;
1371 void Control::Impl::OnSceneDisconnection()
1373 Actor self = mControlImpl.Self();
1375 // Any visuals set for replacement but not yet ready should still be registered.
1376 // Reason: If a request was made to register a new visual but the control removed from scene before visual was ready
1377 // then when this control appears back on stage it should use that new visual.
1379 // Iterate through all registered visuals and set off scene
1380 SetVisualsOffScene( mVisuals, self );
1382 // Visuals pending replacement can now be taken out of the removal list and set off scene
1383 // Iterate through all replacement visuals and add to a move queue then set off scene
1384 for( auto removalIter = mRemoveVisuals.Begin(), end = mRemoveVisuals.End(); removalIter != end; removalIter++ )
1386 Toolkit::GetImplementation((*removalIter)->visual).SetOffScene( self );
1389 for( auto replacedIter = mVisuals.Begin(), end = mVisuals.End(); replacedIter != end; replacedIter++ )
1391 (*replacedIter)->pending = false;
1394 mRemoveVisuals.Clear();
1397 void Control::Impl::SetMargin( Extents margin )
1399 mControlImpl.mImpl->mMargin = margin;
1401 // Trigger a size negotiation request that may be needed when setting a margin.
1402 mControlImpl.RelayoutRequest();
1405 Extents Control::Impl::GetMargin() const
1407 return mControlImpl.mImpl->mMargin;
1410 void Control::Impl::SetPadding( Extents padding )
1412 mControlImpl.mImpl->mPadding = padding;
1414 // Trigger a size negotiation request that may be needed when setting a padding.
1415 mControlImpl.RelayoutRequest();
1418 Extents Control::Impl::GetPadding() const
1420 return mControlImpl.mImpl->mPadding;
1423 void Control::Impl::SetInputMethodContext( InputMethodContext& inputMethodContext )
1425 mInputMethodContext = inputMethodContext;
1428 bool Control::Impl::FilterKeyEvent( const KeyEvent& event )
1430 bool consumed ( false );
1432 if ( mInputMethodContext )
1434 consumed = mInputMethodContext.FilterEventKey( event );
1439 DevelControl::VisualEventSignalType& Control::Impl::VisualEventSignal()
1441 return mVisualEventSignal;
1444 void Control::Impl::SetShadow( const Property::Map& map )
1446 Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( map );
1447 visual.SetName("shadow");
1451 mControlImpl.mImpl->RegisterVisual( Toolkit::DevelControl::Property::SHADOW, visual, DepthIndex::BACKGROUND_EFFECT );
1453 mControlImpl.RelayoutRequest();
1457 void Control::Impl::ClearShadow()
1459 mControlImpl.mImpl->UnregisterVisual( Toolkit::DevelControl::Property::SHADOW );
1461 // Trigger a size negotiation request that may be needed when unregistering a visual.
1462 mControlImpl.RelayoutRequest();
1465 void Control::Impl::EmitResourceReadySignal()
1467 if(!mIsEmittingResourceReadySignal)
1469 // Guard against calls to emit the signal during the callback
1470 mIsEmittingResourceReadySignal = true;
1472 // If the signal handler changes visual, it may become ready during this call & therefore this method will
1473 // get called again recursively. If so, mNeedToEmitResourceReady is set below, and we act on it after that secondary
1474 // invocation has completed by notifying in an Idle callback to prevent further recursion.
1475 Dali::Toolkit::Control handle(mControlImpl.GetOwner());
1476 mResourceReadySignal.Emit(handle);
1478 if(mNeedToEmitResourceReady)
1480 // Add idler to emit the signal again
1483 // The callback manager takes the ownership of the callback object.
1484 mIdleCallback = MakeCallback( this, &Control::Impl::OnIdleCallback);
1485 Adaptor::Get().AddIdle(mIdleCallback, false);
1489 mIsEmittingResourceReadySignal = false;
1493 mNeedToEmitResourceReady = true;
1497 void Control::Impl::OnIdleCallback()
1499 if(mNeedToEmitResourceReady)
1502 mNeedToEmitResourceReady = false;
1504 // A visual is ready so control may need relayouting if staged
1505 if(mControlImpl.Self().GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
1507 mControlImpl.RelayoutRequest();
1510 EmitResourceReadySignal();
1513 // Set the pointer to null as the callback manager deletes the callback after execute it.
1514 mIdleCallback = nullptr;
1517 void Control::Impl::SetAutofillEnabled( bool autofillEnabled )
1519 mIsAutofillEnabled = autofillEnabled;
1522 bool Control::Impl::IsAutofillEnabled()
1524 return mIsAutofillEnabled;
1527 void Control::Impl::SetAutofillItemHandle( Dali::AutofillItem item )
1529 mAutofillItem = item;
1532 Dali::AutofillItem Control::Impl::GetAutofillItemHandle()
1534 return mAutofillItem;
1537 void Control::Impl::SetAutofillContainer( Toolkit::AutofillContainer container )
1539 mAutofillContainer = container;
1542 Toolkit::AutofillContainer Control::Impl::GetAutofillContainer()
1544 return mAutofillContainer;
1547 } // namespace Internal
1549 } // namespace Toolkit