2 * Copyright (c) 2018 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>
33 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
34 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
35 #include <dali-toolkit/public-api/visuals/visual-properties.h>
36 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
37 #include <dali-toolkit/devel-api/controls/control-devel.h>
38 #include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
39 #include <dali-toolkit/devel-api/layouting/bin-layout.h>
40 #include <dali-toolkit/devel-api/layouting/layout-item.h>
41 #include <dali-toolkit/internal/styling/style-manager-impl.h>
42 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
53 extern const Dali::Scripting::StringEnum ControlStateTable[];
54 extern const unsigned int ControlStateTableCount;
57 // Not static or anonymous - shared with other translation units
58 const Scripting::StringEnum ControlStateTable[] = {
59 { "NORMAL", Toolkit::DevelControl::NORMAL },
60 { "FOCUSED", Toolkit::DevelControl::FOCUSED },
61 { "DISABLED", Toolkit::DevelControl::DISABLED },
63 const unsigned int ControlStateTableCount = sizeof( ControlStateTable ) / sizeof( ControlStateTable[0] );
70 #if defined(DEBUG_ENABLED)
71 Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CONTROL_VISUALS");
72 Debug::Filter* gLogFilterLayout = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT");
77 void Remove( Dictionary<T>& keyValues, const std::string& name )
79 keyValues.Remove(name);
82 void Remove( DictionaryKeys& keys, const std::string& name )
84 DictionaryKeys::iterator iter = std::find( keys.begin(), keys.end(), name );
85 if( iter != keys.end())
91 Toolkit::Visual::Type GetVisualTypeFromMap( const Property::Map& map )
93 Property::Value* typeValue = map.Find( Toolkit::Visual::Property::TYPE, VISUAL_TYPE );
94 Toolkit::Visual::Type type = Toolkit::Visual::IMAGE;
97 Scripting::GetEnumerationProperty( *typeValue, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT, type );
103 * Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
105 bool FindVisual( Property::Index targetIndex, const RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter )
107 for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
109 if ( (*iter)->index == targetIndex )
117 void FindChangableVisuals( Dictionary<Property::Map>& stateVisualsToAdd,
118 Dictionary<Property::Map>& stateVisualsToChange,
119 DictionaryKeys& stateVisualsToRemove)
121 DictionaryKeys copyOfStateVisualsToRemove = stateVisualsToRemove;
123 for( DictionaryKeys::iterator iter = copyOfStateVisualsToRemove.begin();
124 iter != copyOfStateVisualsToRemove.end(); ++iter )
126 const std::string& visualName = (*iter);
127 Property::Map* toMap = stateVisualsToAdd.Find( visualName );
130 stateVisualsToChange.Add( visualName, *toMap );
131 stateVisualsToAdd.Remove( visualName );
132 Remove( stateVisualsToRemove, visualName );
137 Toolkit::Visual::Base GetVisualByName(
138 const RegisteredVisualContainer& visuals,
139 const std::string& visualName )
141 Toolkit::Visual::Base visualHandle;
143 RegisteredVisualContainer::Iterator iter;
144 for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
146 Toolkit::Visual::Base visual = (*iter)->visual;
147 if( visual && visual.GetName() == visualName )
149 visualHandle = visual;
157 * Move visual from source to destination container
159 void MoveVisual( RegisteredVisualContainer::Iterator sourceIter, RegisteredVisualContainer& source, RegisteredVisualContainer& destination )
161 Toolkit::Visual::Base visual = (*sourceIter)->visual;
164 RegisteredVisual* rv = source.Release( sourceIter );
165 destination.PushBack( rv );
170 * Performs actions as requested using the action name.
171 * @param[in] object The object on which to perform the action.
172 * @param[in] actionName The action to perform.
173 * @param[in] attributes The attributes with which to perfrom this action.
174 * @return true if action has been accepted by this control
176 const char* ACTION_ACCESSIBILITY_ACTIVATED = "accessibilityActivated";
177 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
181 if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) ) )
183 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
186 // if cast succeeds there is an implementation so no need to check
187 ret = Internal::GetImplementation( control ).OnAccessibilityActivated();
195 * Connects a callback function with the object's signals.
196 * @param[in] object The object providing the signal.
197 * @param[in] tracker Used to disconnect the signal.
198 * @param[in] signalName The signal to connect to.
199 * @param[in] functor A newly allocated FunctorDelegate.
200 * @return True if the signal was connected.
201 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
203 const char* SIGNAL_KEY_EVENT = "keyEvent";
204 const char* SIGNAL_KEY_INPUT_FOCUS_GAINED = "keyInputFocusGained";
205 const char* SIGNAL_KEY_INPUT_FOCUS_LOST = "keyInputFocusLost";
206 const char* SIGNAL_TAPPED = "tapped";
207 const char* SIGNAL_PANNED = "panned";
208 const char* SIGNAL_PINCHED = "pinched";
209 const char* SIGNAL_LONG_PRESSED = "longPressed";
210 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
212 Dali::BaseHandle handle( object );
214 bool connected( false );
215 Toolkit::Control control = Toolkit::Control::DownCast( handle );
218 Internal::Control& controlImpl( Internal::GetImplementation( control ) );
221 if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
223 controlImpl.KeyEventSignal().Connect( tracker, functor );
225 else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_GAINED ) )
227 controlImpl.KeyInputFocusGainedSignal().Connect( tracker, functor );
229 else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_LOST ) )
231 controlImpl.KeyInputFocusLostSignal().Connect( tracker, functor );
233 else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
235 controlImpl.EnableGestureDetection( Gesture::Tap );
236 controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
238 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
240 controlImpl.EnableGestureDetection( Gesture::Pan );
241 controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
243 else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
245 controlImpl.EnableGestureDetection( Gesture::Pinch );
246 controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
248 else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
250 controlImpl.EnableGestureDetection( Gesture::LongPress );
251 controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
258 * Creates control through type registry
262 return Internal::Control::New();
264 // Setup signals and actions using the type-registry.
265 DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
267 // Note: Properties are registered separately below.
269 SignalConnectorType registerSignal1( typeRegistration, SIGNAL_KEY_EVENT, &DoConnectSignal );
270 SignalConnectorType registerSignal2( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_GAINED, &DoConnectSignal );
271 SignalConnectorType registerSignal3( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_LOST, &DoConnectSignal );
272 SignalConnectorType registerSignal4( typeRegistration, SIGNAL_TAPPED, &DoConnectSignal );
273 SignalConnectorType registerSignal5( typeRegistration, SIGNAL_PANNED, &DoConnectSignal );
274 SignalConnectorType registerSignal6( typeRegistration, SIGNAL_PINCHED, &DoConnectSignal );
275 SignalConnectorType registerSignal7( typeRegistration, SIGNAL_LONG_PRESSED, &DoConnectSignal );
277 TypeAction registerAction( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &DoAction );
279 DALI_TYPE_REGISTRATION_END()
282 * @brief Iterate through given container and setOffStage any visual found
284 * @param[in] container Container of visuals
285 * @param[in] parent Parent actor to remove visuals from
287 void SetVisualsOffStage( const RegisteredVisualContainer& container, Actor parent )
289 for( auto iter = container.Begin(), end = container.End() ; iter!= end; iter++)
291 if( (*iter)->visual )
293 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::SetOffStage Setting visual(%d) off stage\n", (*iter)->index );
294 Toolkit::GetImplementation((*iter)->visual).SetOffStage( parent );
299 } // unnamed namespace
302 // Properties registered without macro to use specific member variables.
303 const PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "styleName", Toolkit::Control::Property::STYLE_NAME, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
304 const PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "backgroundColor", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
305 const PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "backgroundImage", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
306 const PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "keyInputFocus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
307 const PropertyRegistration Control::Impl::PROPERTY_5( typeRegistration, "background", Toolkit::Control::Property::BACKGROUND, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
308 const PropertyRegistration Control::Impl::PROPERTY_6( typeRegistration, "margin", Toolkit::Control::Property::MARGIN, Property::EXTENTS, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
309 const PropertyRegistration Control::Impl::PROPERTY_7( typeRegistration, "padding", Toolkit::Control::Property::PADDING, Property::EXTENTS, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
310 const PropertyRegistration Control::Impl::PROPERTY_8( typeRegistration, "tooltip", Toolkit::DevelControl::Property::TOOLTIP, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
311 const PropertyRegistration Control::Impl::PROPERTY_9( typeRegistration, "state", Toolkit::DevelControl::Property::STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
312 const PropertyRegistration Control::Impl::PROPERTY_10( typeRegistration, "subState", Toolkit::DevelControl::Property::SUB_STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
313 const PropertyRegistration Control::Impl::PROPERTY_11( typeRegistration, "leftFocusableActorId", Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
314 const PropertyRegistration Control::Impl::PROPERTY_12( typeRegistration, "rightFocusableActorId", Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID,Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
315 const PropertyRegistration Control::Impl::PROPERTY_13( typeRegistration, "upFocusableActorId", Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
316 const PropertyRegistration Control::Impl::PROPERTY_14( typeRegistration, "downFocusableActorId", Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
319 Control::Impl::Impl( Control& controlImpl )
320 : mControlImpl( controlImpl ),
321 mState( Toolkit::DevelControl::NORMAL ),
324 mLeftFocusableActorId( -1 ),
325 mRightFocusableActorId( -1 ),
326 mUpFocusableActorId( -1 ),
327 mDownFocusableActorId( -1 ),
329 mBackgroundColor(Color::TRANSPARENT),
330 mStartingPinchScale( NULL ),
331 mMargin( 0, 0, 0, 0 ),
332 mPadding( 0, 0, 0, 0 ),
334 mKeyInputFocusGainedSignal(),
335 mKeyInputFocusLostSignal(),
336 mResourceReadySignal(),
337 mVisualEventSignal(),
338 mPinchGestureDetector(),
339 mPanGestureDetector(),
340 mTapGestureDetector(),
341 mLongPressGestureDetector(),
343 mInputMethodContext(),
344 mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
345 mIsKeyboardNavigationSupported( false ),
346 mIsKeyboardFocusGroup( false ),
347 mIsLayoutingRequired( false )
351 Control::Impl::~Impl()
353 // All gesture detectors will be destroyed so no need to disconnect.
354 delete mStartingPinchScale;
357 Control::Impl& Control::Impl::Get( Internal::Control& internalControl )
359 return *internalControl.mImpl;
362 const Control::Impl& Control::Impl::Get( const Internal::Control& internalControl )
364 return *internalControl.mImpl;
367 // Gesture Detection Methods
368 void Control::Impl::PinchDetected(Actor actor, const PinchGesture& pinch)
370 mControlImpl.OnPinch(pinch);
373 void Control::Impl::PanDetected(Actor actor, const PanGesture& pan)
375 mControlImpl.OnPan(pan);
378 void Control::Impl::TapDetected(Actor actor, const TapGesture& tap)
380 mControlImpl.OnTap(tap);
383 void Control::Impl::LongPressDetected(Actor actor, const LongPressGesture& longPress)
385 mControlImpl.OnLongPress(longPress);
388 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
390 RegisterVisual( index, visual, VisualState::ENABLED, DepthIndexValue::NOT_SET );
393 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, int depthIndex )
395 RegisterVisual( index, visual, VisualState::ENABLED, DepthIndexValue::SET, depthIndex );
398 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
400 RegisterVisual( index, visual, ( enabled ? VisualState::ENABLED : VisualState::DISABLED ), DepthIndexValue::NOT_SET );
403 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex )
405 RegisterVisual( index, visual, ( enabled ? VisualState::ENABLED : VisualState::DISABLED ), DepthIndexValue::SET, depthIndex );
408 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, VisualState::Type enabled, DepthIndexValue::Type depthIndexValueSet, int depthIndex )
410 DALI_LOG_INFO( gLogFilter, Debug::Concise, "RegisterVisual:%d \n", index );
412 bool visualReplaced ( false );
413 Actor self = mControlImpl.Self();
415 // Set the depth index, if not set by caller this will be either the current visual depth, max depth of all visuals
417 int requiredDepthIndex = visual.GetDepthIndex();
419 if( depthIndexValueSet == DepthIndexValue::SET )
421 requiredDepthIndex = depthIndex;
424 // Visual replacement, existing visual should only be removed from stage when replacement ready.
425 if( !mVisuals.Empty() )
427 RegisteredVisualContainer::Iterator registeredVisualsiter;
428 // Check if visual (index) is already registered, this is the current visual.
429 if( FindVisual( index, mVisuals, registeredVisualsiter ) )
431 Toolkit::Visual::Base& currentRegisteredVisual = (*registeredVisualsiter)->visual;
432 if( currentRegisteredVisual )
434 // Store current visual depth index as may need to set the replacement visual to same depth
435 const int currentDepthIndex = (*registeredVisualsiter)->visual.GetDepthIndex();
437 // No longer required to know if the replaced visual's resources are ready
438 StopObservingVisual( currentRegisteredVisual );
440 // If control staged and visual enabled then visuals will be swapped once ready
441 if( self.OnStage() && enabled )
443 // Check if visual is currently in the process of being replaced ( is in removal container )
444 RegisteredVisualContainer::Iterator visualQueuedForRemoval;
445 if ( FindVisual( index, mRemoveVisuals, visualQueuedForRemoval ) )
447 // Visual with same index is already in removal container so current visual pending
448 // Only the the last requested visual will be displayed so remove current visual which is staged but not ready.
449 Toolkit::GetImplementation( currentRegisteredVisual ).SetOffStage( self );
450 mVisuals.Erase( registeredVisualsiter );
454 // current visual not already in removal container so add now.
455 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "RegisterVisual Move current registered visual to removal Queue: %d \n", index );
456 MoveVisual( registeredVisualsiter, mVisuals, mRemoveVisuals );
461 // Control not staged or visual disabled so can just erase from registered visuals and new visual will be added later.
462 mVisuals.Erase( registeredVisualsiter );
465 // 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
466 if( ( depthIndexValueSet == DepthIndexValue::NOT_SET ) &&
467 ( visual.GetDepthIndex() == 0 ) )
469 requiredDepthIndex = currentDepthIndex;
473 visualReplaced = true;
477 // If not set, set the name of the visual to the same name as the control's property.
478 // ( If the control has been type registered )
479 if( visual.GetName().empty() )
481 // returns empty string if index is not found as long as index is not -1
482 std::string visualName = self.GetPropertyName( index );
483 if( !visualName.empty() )
485 DALI_LOG_INFO( gLogFilter, Debug::Concise, "Setting visual name for property %d to %s\n",
486 index, visualName.c_str() );
487 visual.SetName( visualName );
491 if( !visualReplaced ) // New registration entry
493 // 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
494 if( ( depthIndexValueSet == DepthIndexValue::NOT_SET ) &&
495 ( mVisuals.Size() > 0 ) &&
496 ( visual.GetDepthIndex() == 0 ) )
498 int maxDepthIndex = std::numeric_limits< int >::min();
500 RegisteredVisualContainer::ConstIterator iter;
501 const RegisteredVisualContainer::ConstIterator endIter = mVisuals.End();
502 for ( iter = mVisuals.Begin(); iter != endIter; iter++ )
504 const int visualDepthIndex = (*iter)->visual.GetDepthIndex();
505 if ( visualDepthIndex > maxDepthIndex )
507 maxDepthIndex = visualDepthIndex;
510 ++maxDepthIndex; // Add one to the current maximum depth index so that our added visual appears on top
511 requiredDepthIndex = std::max( 0, maxDepthIndex ); // Start at zero if maxDepth index belongs to a background
517 // Set determined depth index
518 visual.SetDepthIndex( requiredDepthIndex );
520 // Monitor when the visual resources are ready
521 StartObservingVisual( visual );
523 DALI_LOG_INFO( gLogFilter, Debug::Concise, "New Visual registration index[%d] depth[%d]\n", index, requiredDepthIndex );
524 RegisteredVisual* newRegisteredVisual = new RegisteredVisual( index, visual,
525 ( enabled == VisualState::ENABLED ? true : false ),
526 ( visualReplaced && enabled ) ) ;
527 mVisuals.PushBack( newRegisteredVisual );
529 Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
530 // Put on stage if enabled and the control is already on the stage
531 if( ( enabled == VisualState::ENABLED ) && self.OnStage() )
533 visualImpl.SetOnStage( self );
535 else if( visualImpl.IsResourceReady() ) // When not being staged, check if visual already 'ResourceReady' before it was Registered. ( Resource may have been loaded already )
537 ResourceReady( visualImpl );
542 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual() Registered %s(%d), enabled:%s\n", visual.GetName().c_str(), index, enabled?"true":"false" );
545 void Control::Impl::UnregisterVisual( Property::Index index )
547 RegisteredVisualContainer::Iterator iter;
548 if ( FindVisual( index, mVisuals, iter ) )
550 // stop observing visual
551 StopObservingVisual( (*iter)->visual );
553 Actor self( mControlImpl.Self() );
554 Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
555 (*iter)->visual.Reset();
556 mVisuals.Erase( iter );
559 if( FindVisual( index, mRemoveVisuals, iter ) )
561 Actor self( mControlImpl.Self() );
562 Toolkit::GetImplementation( (*iter)->visual ).SetOffStage( self );
563 (*iter)->pending = false;
564 (*iter)->visual.Reset();
565 mRemoveVisuals.Erase( iter );
569 Toolkit::Visual::Base Control::Impl::GetVisual( Property::Index index ) const
571 RegisteredVisualContainer::Iterator iter;
572 if ( FindVisual( index, mVisuals, iter ) )
574 return (*iter)->visual;
577 return Toolkit::Visual::Base();
580 void Control::Impl::EnableVisual( Property::Index index, bool enable )
582 DALI_LOG_INFO( gLogFilter, Debug::General, "Control::EnableVisual(%d, %s)\n", index, enable?"T":"F");
584 RegisteredVisualContainer::Iterator iter;
585 if ( FindVisual( index, mVisuals, iter ) )
587 if ( (*iter)->enabled == enable )
589 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Visual %s(%d) already %s\n", (*iter)->visual.GetName().c_str(), index, enable?"enabled":"disabled");
593 (*iter)->enabled = enable;
594 Actor parentActor = mControlImpl.Self();
595 if ( mControlImpl.Self().OnStage() ) // If control not on Stage then Visual will be added when StageConnection is called.
599 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting %s(%d) on stage \n", (*iter)->visual.GetName().c_str(), index );
600 Toolkit::GetImplementation((*iter)->visual).SetOnStage( parentActor );
604 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting %s(%d) off stage \n", (*iter)->visual.GetName().c_str(), index );
605 Toolkit::GetImplementation((*iter)->visual).SetOffStage( parentActor ); // No need to call if control not staged.
611 DALI_LOG_WARNING( "Control::EnableVisual(%d, %s) FAILED - NO SUCH VISUAL\n", index, enable?"T":"F" );
615 bool Control::Impl::IsVisualEnabled( Property::Index index ) const
617 RegisteredVisualContainer::Iterator iter;
618 if ( FindVisual( index, mVisuals, iter ) )
620 return (*iter)->enabled;
625 void Control::Impl::StopObservingVisual( Toolkit::Visual::Base& visual )
627 Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
629 // Stop observing the visual
630 visualImpl.RemoveEventObserver( *this );
633 void Control::Impl::StartObservingVisual( Toolkit::Visual::Base& visual)
635 Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
637 // start observing the visual for events
638 visualImpl.AddEventObserver( *this );
641 // Called by a Visual when it's resource is ready
642 void Control::Impl::ResourceReady( Visual::Base& object)
644 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::Impl::ResourceReady() replacements pending[%d]\n", mRemoveVisuals.Count() );
646 Actor self = mControlImpl.Self();
648 // A resource is ready, find resource in the registered visuals container and get its index
649 for( auto registeredIter = mVisuals.Begin(), end = mVisuals.End(); registeredIter != end; ++registeredIter )
651 Internal::Visual::Base& registeredVisualImpl = Toolkit::GetImplementation( (*registeredIter)->visual );
653 if( &object == ®isteredVisualImpl )
655 RegisteredVisualContainer::Iterator visualToRemoveIter;
656 // Find visual with the same index in the removal container
657 // Set if off stage as it's replacement is now ready.
658 // Remove if from removal list as now removed from stage.
659 // Set Pending flag on the ready visual to false as now ready.
660 if( FindVisual( (*registeredIter)->index, mRemoveVisuals, visualToRemoveIter ) )
662 (*registeredIter)->pending = false;
663 Toolkit::GetImplementation( (*visualToRemoveIter)->visual ).SetOffStage( self );
664 mRemoveVisuals.Erase( visualToRemoveIter );
670 // A visual is ready so control may need relayouting if staged
671 if ( self.OnStage() )
673 mControlImpl.RelayoutRequest();
676 // Emit signal if all enabled visuals registered by the control are ready.
677 if( IsResourceReady() )
679 Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
680 mResourceReadySignal.Emit( handle );
684 void Control::Impl::NotifyVisualEvent( Visual::Base& object, Property::Index signalId )
686 for( auto registeredIter = mVisuals.Begin(), end = mVisuals.End(); registeredIter != end; ++registeredIter )
688 Internal::Visual::Base& registeredVisualImpl = Toolkit::GetImplementation( (*registeredIter)->visual );
689 if( &object == ®isteredVisualImpl )
691 Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
692 mVisualEventSignal.Emit( handle, (*registeredIter)->index, signalId );
698 bool Control::Impl::IsResourceReady() const
700 // Iterate through and check all the enabled visuals are ready
701 for( auto visualIter = mVisuals.Begin();
702 visualIter != mVisuals.End(); ++visualIter )
704 const Toolkit::Visual::Base visual = (*visualIter)->visual;
705 const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
707 // one of the enabled visuals is not ready
708 if( !visualImpl.IsResourceReady() && (*visualIter)->enabled )
716 Toolkit::Visual::ResourceStatus Control::Impl::GetVisualResourceStatus( Property::Index index ) const
718 RegisteredVisualContainer::Iterator iter;
719 if ( FindVisual( index, mVisuals, iter ) )
721 const Toolkit::Visual::Base visual = (*iter)->visual;
722 const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
723 return visualImpl.GetResourceStatus( );
726 return Toolkit::Visual::ResourceStatus::PREPARING;
731 void Control::Impl::AddTransitions( Dali::Animation& animation,
732 const Toolkit::TransitionData& handle,
733 bool createAnimation )
735 // Setup a Transition from TransitionData.
736 const Internal::TransitionData& transitionData = Toolkit::GetImplementation( handle );
737 TransitionData::Iterator end = transitionData.End();
738 for( TransitionData::Iterator iter = transitionData.Begin() ;
739 iter != end; ++iter )
741 TransitionData::Animator* animator = (*iter);
743 Toolkit::Visual::Base visual = GetVisualByName( mVisuals, animator->objectName );
747 #if defined(DEBUG_ENABLED)
748 Dali::TypeInfo typeInfo;
749 ControlWrapper* controlWrapperImpl = dynamic_cast<ControlWrapper*>(&mControlImpl);
750 if( controlWrapperImpl )
752 typeInfo = controlWrapperImpl->GetTypeInfo();
755 DALI_LOG_INFO( gLogFilter, Debug::Concise, "CreateTransition: Found %s visual for %s\n",
756 visual.GetName().c_str(), typeInfo?typeInfo.GetName().c_str():"Unknown" );
758 Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
759 visualImpl.AnimateProperty( animation, *animator );
763 DALI_LOG_INFO( gLogFilter, Debug::Concise, "CreateTransition: Could not find visual. Trying actors");
764 // Otherwise, try any actor children of control (Including the control)
765 Actor child = mControlImpl.Self().FindChildByName( animator->objectName );
768 Property::Index propertyIndex = DevelHandle::GetPropertyIndex( child, animator->propertyKey );
769 if( propertyIndex != Property::INVALID_INDEX )
771 if( animator->animate == false )
773 if( animator->targetValue.GetType() != Property::NONE )
775 child.SetProperty( propertyIndex, animator->targetValue );
778 else // animate the property
780 if( animator->initialValue.GetType() != Property::NONE )
782 child.SetProperty( propertyIndex, animator->initialValue );
785 if( createAnimation && !animation )
787 animation = Dali::Animation::New( 0.1f );
790 animation.AnimateTo( Property( child, propertyIndex ),
791 animator->targetValue,
792 animator->alphaFunction,
793 TimePeriod( animator->timePeriodDelay,
794 animator->timePeriodDuration ) );
802 Dali::Animation Control::Impl::CreateTransition( const Toolkit::TransitionData& transitionData )
804 Dali::Animation transition;
806 if( transitionData.Count() > 0 )
808 AddTransitions( transition, transitionData, true );
815 void Control::Impl::DoAction( Dali::Property::Index visualIndex, Dali::Property::Index actionId, const Dali::Property::Value attributes )
817 RegisteredVisualContainer::Iterator iter;
818 if ( FindVisual( visualIndex, mVisuals, iter ) )
820 Toolkit::GetImplementation((*iter)->visual).DoAction( actionId, attributes );
824 void Control::Impl::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
826 Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
830 Control& controlImpl( GetImplementation( control ) );
834 case Toolkit::Control::Property::STYLE_NAME:
836 controlImpl.SetStyleName( value.Get< std::string >() );
840 case Toolkit::DevelControl::Property::STATE:
842 bool withTransitions=true;
843 const Property::Value* valuePtr=&value;
844 Property::Map* map = value.GetMap();
847 Property::Value* value2 = map->Find("withTransitions");
850 withTransitions = value2->Get<bool>();
853 valuePtr = map->Find("state");
858 Toolkit::DevelControl::State state( controlImpl.mImpl->mState );
859 if( Scripting::GetEnumerationProperty< Toolkit::DevelControl::State >( *valuePtr, ControlStateTable, ControlStateTableCount, state ) )
861 controlImpl.mImpl->SetState( state, withTransitions );
867 case Toolkit::DevelControl::Property::SUB_STATE:
869 std::string subState;
870 if( value.Get( subState ) )
872 controlImpl.mImpl->SetSubState( subState );
877 case Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID:
880 if( value.Get( focusId ) )
882 controlImpl.mImpl->mLeftFocusableActorId = focusId;
887 case Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID:
890 if( value.Get( focusId ) )
892 controlImpl.mImpl->mRightFocusableActorId = focusId;
897 case Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID:
900 if( value.Get( focusId ) )
902 controlImpl.mImpl->mUpFocusableActorId = focusId;
907 case Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID:
910 if( value.Get( focusId ) )
912 controlImpl.mImpl->mDownFocusableActorId = focusId;
917 case Toolkit::Control::Property::BACKGROUND_COLOR:
919 DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" );
920 controlImpl.SetBackgroundColor( value.Get< Vector4 >() );
924 case Toolkit::Control::Property::BACKGROUND_IMAGE:
926 DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" );
927 Image image = Scripting::NewImage( value );
930 controlImpl.SetBackgroundImage( image );
934 // An empty image means the background is no longer required
935 controlImpl.ClearBackground();
940 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
942 if ( value.Get< bool >() )
944 controlImpl.SetKeyInputFocus();
948 controlImpl.ClearKeyInputFocus();
953 case Toolkit::Control::Property::BACKGROUND:
957 const Property::Map* map = value.GetMap();
958 if( map && !map->Empty() )
960 controlImpl.SetBackground( *map );
962 else if( value.Get( url ) )
964 // don't know the size to load
965 Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( url, ImageDimensions() );
968 controlImpl.mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual, DepthIndex::BACKGROUND );
971 else if( value.Get( color ) )
973 controlImpl.SetBackgroundColor(color);
977 // The background is an empty property map, so we should clear the background
978 controlImpl.ClearBackground();
983 case Toolkit::Control::Property::MARGIN:
986 if( value.Get( margin ) )
988 controlImpl.mImpl->SetMargin( margin );
993 case Toolkit::Control::Property::PADDING:
996 if( value.Get( padding ) )
998 controlImpl.mImpl->SetPadding( padding );
1003 case Toolkit::DevelControl::Property::TOOLTIP:
1005 TooltipPtr& tooltipPtr = controlImpl.mImpl->mTooltip;
1008 tooltipPtr = Tooltip::New( control );
1010 tooltipPtr->SetProperties( value );
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::BACKGROUND_COLOR:
1074 DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" );
1075 value = controlImpl.GetBackgroundColor();
1079 case Toolkit::Control::Property::BACKGROUND_IMAGE:
1081 DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" );
1083 Toolkit::Visual::Base visual = controlImpl.mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
1086 visual.CreatePropertyMap( map );
1092 case Toolkit::Control::Property::KEY_INPUT_FOCUS:
1094 value = controlImpl.HasKeyInputFocus();
1098 case Toolkit::Control::Property::BACKGROUND:
1101 Toolkit::Visual::Base visual = controlImpl.mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
1104 visual.CreatePropertyMap( map );
1111 case Toolkit::Control::Property::MARGIN:
1113 value = controlImpl.mImpl->GetMargin();
1117 case Toolkit::Control::Property::PADDING:
1119 value = controlImpl.mImpl->GetPadding();
1123 case Toolkit::DevelControl::Property::TOOLTIP:
1126 if( controlImpl.mImpl->mTooltip )
1128 controlImpl.mImpl->mTooltip->CreatePropertyMap( map );
1140 void Control::Impl::CopyInstancedProperties( RegisteredVisualContainer& visuals, Dictionary<Property::Map>& instancedProperties )
1142 for(RegisteredVisualContainer::Iterator iter = visuals.Begin(); iter!= visuals.End(); iter++)
1144 if( (*iter)->visual )
1146 Property::Map instanceMap;
1147 Toolkit::GetImplementation((*iter)->visual).CreateInstancePropertyMap(instanceMap);
1148 instancedProperties.Add( (*iter)->visual.GetName(), instanceMap );
1154 void Control::Impl::RemoveVisual( RegisteredVisualContainer& visuals, const std::string& visualName )
1156 Actor self( mControlImpl.Self() );
1158 for ( RegisteredVisualContainer::Iterator visualIter = visuals.Begin();
1159 visualIter != visuals.End(); ++visualIter )
1161 Toolkit::Visual::Base visual = (*visualIter)->visual;
1162 if( visual && visual.GetName() == visualName )
1164 Toolkit::GetImplementation(visual).SetOffStage( self );
1165 (*visualIter)->visual.Reset();
1166 visuals.Erase( visualIter );
1172 void Control::Impl::RemoveVisuals( RegisteredVisualContainer& visuals, DictionaryKeys& removeVisuals )
1174 Actor self( mControlImpl.Self() );
1175 for( DictionaryKeys::iterator iter = removeVisuals.begin(); iter != removeVisuals.end(); ++iter )
1177 const std::string visualName = *iter;
1178 RemoveVisual( visuals, visualName );
1182 void Control::Impl::RecreateChangedVisuals( Dictionary<Property::Map>& stateVisualsToChange,
1183 Dictionary<Property::Map>& instancedProperties )
1185 Dali::CustomActor handle( mControlImpl.GetOwner() );
1186 for( Dictionary<Property::Map>::iterator iter = stateVisualsToChange.Begin();
1187 iter != stateVisualsToChange.End(); ++iter )
1189 const std::string& visualName = (*iter).key;
1190 const Property::Map& toMap = (*iter).entry;
1192 // is it a candidate for re-creation?
1193 bool recreate = false;
1195 Toolkit::Visual::Base visual = GetVisualByName( mVisuals, visualName );
1198 Property::Map fromMap;
1199 visual.CreatePropertyMap( fromMap );
1201 Toolkit::Visual::Type fromType = GetVisualTypeFromMap( fromMap );
1202 Toolkit::Visual::Type toType = GetVisualTypeFromMap( toMap );
1204 if( fromType != toType )
1210 if( fromType == Toolkit::Visual::IMAGE || fromType == Toolkit::Visual::N_PATCH
1211 || fromType == Toolkit::Visual::SVG || fromType == Toolkit::Visual::ANIMATED_IMAGE )
1213 Property::Value* fromUrl = fromMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
1214 Property::Value* toUrl = toMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
1216 if( fromUrl && toUrl )
1218 std::string fromUrlString;
1219 std::string toUrlString;
1220 fromUrl->Get(fromUrlString);
1221 toUrl->Get(toUrlString);
1223 if( fromUrlString != toUrlString )
1231 const Property::Map* instancedMap = instancedProperties.FindConst( visualName );
1232 if( recreate || instancedMap )
1234 RemoveVisual( mVisuals, visualName );
1235 Style::ApplyVisual( handle, visualName, toMap, instancedMap );
1239 // @todo check to see if we can apply toMap without recreating the visual
1240 // e.g. by setting only animatable properties
1241 // For now, recreate all visuals, but merge in instance data.
1242 RemoveVisual( mVisuals, visualName );
1243 Style::ApplyVisual( handle, visualName, toMap, instancedMap );
1249 void Control::Impl::ReplaceStateVisualsAndProperties( const StylePtr oldState, const StylePtr newState, const std::string& subState )
1251 // Collect all old visual names
1252 DictionaryKeys stateVisualsToRemove;
1255 oldState->visuals.GetKeys( stateVisualsToRemove );
1256 if( ! subState.empty() )
1258 const StylePtr* oldSubState = oldState->subStates.FindConst(subState);
1261 DictionaryKeys subStateVisualsToRemove;
1262 (*oldSubState)->visuals.GetKeys( subStateVisualsToRemove );
1263 Merge( stateVisualsToRemove, subStateVisualsToRemove );
1268 // Collect all new visual properties
1269 Dictionary<Property::Map> stateVisualsToAdd;
1272 stateVisualsToAdd = newState->visuals;
1273 if( ! subState.empty() )
1275 const StylePtr* newSubState = newState->subStates.FindConst(subState);
1278 stateVisualsToAdd.Merge( (*newSubState)->visuals );
1283 // If a name is in both add/remove, move it to change list.
1284 Dictionary<Property::Map> stateVisualsToChange;
1285 FindChangableVisuals( stateVisualsToAdd, stateVisualsToChange, stateVisualsToRemove);
1287 // Copy instanced properties (e.g. text label) of current visuals
1288 Dictionary<Property::Map> instancedProperties;
1289 CopyInstancedProperties( mVisuals, instancedProperties );
1291 // For each visual in remove list, remove from mVisuals
1292 RemoveVisuals( mVisuals, stateVisualsToRemove );
1294 // For each visual in add list, create and add to mVisuals
1295 Dali::CustomActor handle( mControlImpl.GetOwner() );
1296 Style::ApplyVisuals( handle, stateVisualsToAdd, instancedProperties );
1298 // For each visual in change list, if it requires a new visual,
1299 // remove old visual, create and add to mVisuals
1300 RecreateChangedVisuals( stateVisualsToChange, instancedProperties );
1303 void Control::Impl::SetState( DevelControl::State newState, bool withTransitions )
1305 DevelControl::State oldState = mState;
1306 Dali::CustomActor handle( mControlImpl.GetOwner() );
1307 DALI_LOG_INFO(gLogFilter, Debug::Concise, "Control::Impl::SetState: %s\n",
1308 (mState == DevelControl::NORMAL ? "NORMAL" :(
1309 mState == DevelControl::FOCUSED ?"FOCUSED" : (
1310 mState == DevelControl::DISABLED?"DISABLED":"NONE" ))));
1312 if( mState != newState )
1314 // If mState was Disabled, and new state is Focused, should probably
1315 // store that fact, e.g. in another property that FocusManager can access.
1318 // Trigger state change and transitions
1319 // Apply new style, if stylemanager is available
1320 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
1323 const StylePtr stylePtr = GetImpl( styleManager ).GetRecordedStyle( Toolkit::Control( mControlImpl.GetOwner() ) );
1327 std::string oldStateName = Scripting::GetEnumerationName< Toolkit::DevelControl::State >( oldState, ControlStateTable, ControlStateTableCount );
1328 std::string newStateName = Scripting::GetEnumerationName< Toolkit::DevelControl::State >( newState, ControlStateTable, ControlStateTableCount );
1330 const StylePtr* newStateStyle = stylePtr->subStates.Find( newStateName );
1331 const StylePtr* oldStateStyle = stylePtr->subStates.Find( oldStateName );
1332 if( oldStateStyle && newStateStyle )
1334 // Only change if both state styles exist
1335 ReplaceStateVisualsAndProperties( *oldStateStyle, *newStateStyle, mSubStateName );
1342 void Control::Impl::SetSubState( const std::string& subStateName, bool withTransitions )
1344 if( mSubStateName != subStateName )
1346 // Get existing sub-state visuals, and unregister them
1347 Dali::CustomActor handle( mControlImpl.GetOwner() );
1349 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
1352 const StylePtr stylePtr = GetImpl( styleManager ).GetRecordedStyle( Toolkit::Control( mControlImpl.GetOwner() ) );
1356 std::string stateName = Scripting::GetEnumerationName< Toolkit::DevelControl::State >( mState, ControlStateTable, ControlStateTableCount );
1358 const StylePtr* state = stylePtr->subStates.Find( stateName );
1361 StylePtr stateStyle(*state);
1363 const StylePtr* newStateStyle = stateStyle->subStates.Find( subStateName );
1364 const StylePtr* oldStateStyle = stateStyle->subStates.Find( mSubStateName );
1365 if( oldStateStyle && newStateStyle )
1368 ReplaceStateVisualsAndProperties( *oldStateStyle, *newStateStyle, empty );
1374 mSubStateName = subStateName;
1378 void Control::Impl::OnStageDisconnection()
1380 Actor self = mControlImpl.Self();
1382 // Any visuals set for replacement but not yet ready should still be registered.
1383 // Reason: If a request was made to register a new visual but the control removed from stage before visual was ready
1384 // then when this control appears back on stage it should use that new visual.
1386 // Iterate through all registered visuals and set off stage
1387 SetVisualsOffStage( mVisuals, self );
1389 // Visuals pending replacement can now be taken out of the removal list and set off stage
1390 // Iterate through all replacement visuals and add to a move queue then set off stage
1391 for( auto removalIter = mRemoveVisuals.Begin(), end = mRemoveVisuals.End(); removalIter != end; removalIter++ )
1393 Toolkit::GetImplementation((*removalIter)->visual).SetOffStage( self );
1396 for( auto replacedIter = mVisuals.Begin(), end = mVisuals.End(); replacedIter != end; replacedIter++ )
1398 (*replacedIter)->pending = false;
1401 mRemoveVisuals.Clear();
1404 void Control::Impl::SetMargin( Extents margin )
1406 mControlImpl.mImpl->mMargin = margin;
1408 // Trigger a size negotiation request that may be needed when setting a margin.
1409 mControlImpl.RelayoutRequest();
1412 Extents Control::Impl::GetMargin() const
1414 return mControlImpl.mImpl->mMargin;
1417 void Control::Impl::SetPadding( Extents padding )
1419 mControlImpl.mImpl->mPadding = padding;
1421 // Trigger a size negotiation request that may be needed when setting a padding.
1422 mControlImpl.RelayoutRequest();
1425 Extents Control::Impl::GetPadding() const
1427 return mControlImpl.mImpl->mPadding;
1430 void Control::Impl::SetInputMethodContext( InputMethodContext& inputMethodContext )
1432 mInputMethodContext = inputMethodContext;
1435 bool Control::Impl::FilterKeyEvent( const KeyEvent& event )
1437 bool consumed ( false );
1439 if ( mInputMethodContext )
1441 consumed = mInputMethodContext.FilterEventKey( event );
1446 Toolkit::Internal::LayoutItemPtr Control::Impl::GetLayout() const
1451 void Control::Impl::SetLayout( Toolkit::Internal::LayoutItem& layout )
1453 DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::SetLayout control:%s replacing existing layout:%s\n",
1454 mControlImpl.Self().GetName().c_str(),
1455 mLayout?"true":"false" );
1456 // Check if layout already has an owner.
1457 auto control = Toolkit::Control::DownCast( layout.GetOwner() );
1460 // If the owner is not this control then the owning control can no longer own it.
1461 Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
1462 if( control != handle )
1464 DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::SetLayout Layout already in use, %s will now have a BinLayout\n",
1465 control.GetName().c_str() );
1466 Toolkit::BinLayout binLayout = Toolkit::BinLayout::New();
1467 // Previous owner of the layout gets a BinLayout instead of the layout.
1468 DevelControl::SetLayout( control, binLayout ) ;
1472 return; // layout is already set to this control.
1478 mLayout->Unparent();
1484 auto controlHandle = Toolkit::Control::DownCast( mControlImpl.Self() ); // Get a handle of this control implementation without copying internals.
1485 mLayout->Initialize( controlHandle, controlHandle.GetTypeName() ); // LayoutGroup takes ownership of existing children
1488 void Control::Impl::RemoveLayout()
1490 DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::Impl::RemoveLayout\n");
1492 Toolkit::BinLayout binLayout = Toolkit::BinLayout::New();
1494 mControlImpl.mImpl->SetLayout( GetImplementation( binLayout ) ) ;
1497 void Control::Impl::SetLayoutingRequired( bool layoutingRequired )
1499 mControlImpl.mImpl->mIsLayoutingRequired = layoutingRequired;
1502 bool Control::Impl::IsLayoutingRequired()
1504 return mControlImpl.mImpl->mIsLayoutingRequired;
1507 DevelControl::VisualEventSignalType& Control::Impl::VisualEventSignal()
1509 return mVisualEventSignal;
1512 } // namespace Internal
1514 } // namespace Toolkit