2 * Copyright (c) 2016 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 <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
22 #include <dali/public-api/animation/animation.h>
23 #include <dali/public-api/object/type-registry.h>
24 #include <dali/public-api/object/type-registry-helper.h>
25 #include <dali/devel-api/object/handle-devel.h>
28 #include <dali-toolkit/public-api/controls/control-impl.h>
29 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
30 #include <dali-toolkit/public-api/styling/style-manager.h>
31 #include <dali-toolkit/internal/styling/style-manager-impl.h>
47 // empty handle as we cannot create control wrapper
51 // Setup type-registry.
52 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ControlWrapper, Toolkit::Control, Create )
53 DALI_TYPE_REGISTRATION_END()
61 Dali::Toolkit::ControlWrapper ControlWrapper::New( const std::string& typeName, ControlWrapper* controlWrapper )
63 ControlWrapperPtr wrapper( controlWrapper );
65 // Pass ownership to CustomActor via derived handle.
66 Dali::Toolkit::ControlWrapper handle( *wrapper );
68 // Second-phase initialisation of the implementation.
69 // This can only be done after the CustomActor connection has been made.
70 wrapper->Initialize();
72 // Different types of C# custom view registered themselves using type registry,
73 // but their type names are registered per type not per instance, so they still
74 // have the same wrong type name in native side when type registry queries the
75 // unique type name of each instance using typeid() because of the binding.
76 // Therefore, we have to link each instance with its correct type info if already
79 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeName );
82 Dali::DevelHandle::SetTypeInfo( handle, typeInfo );
88 ControlWrapper::ControlWrapper( CustomControlBehaviour behaviourFlags )
89 : Control( static_cast< ControlBehaviour >( behaviourFlags ) )
93 ControlWrapper::~ControlWrapper()
97 void ControlWrapper::RelayoutRequest()
99 CustomActorImpl::RelayoutRequest();
102 float ControlWrapper::GetHeightForWidthBase( float width )
104 return CustomActorImpl::GetHeightForWidthBase( width );
107 float ControlWrapper::GetWidthForHeightBase( float height )
109 return CustomActorImpl::GetWidthForHeightBase( height );
112 float ControlWrapper::CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension )
114 return CustomActorImpl::CalculateChildSizeBase( child, dimension );
117 bool ControlWrapper::RelayoutDependentOnChildrenBase( Dimension::Type dimension )
119 return CustomActorImpl::RelayoutDependentOnChildrenBase( dimension );
122 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
124 Control::RegisterVisual( index, visual );
127 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
129 Control::RegisterVisual( index, visual, enabled );
132 void ControlWrapper::UnregisterVisual( Property::Index index )
134 Control::UnregisterVisual( index );
137 Toolkit::Visual::Base ControlWrapper::GetVisual( Property::Index index ) const
139 return Control::GetVisual( index );
142 void ControlWrapper::EnableVisual( Property::Index index, bool enable )
144 Control::EnableVisual( index, enable );
147 bool ControlWrapper::IsVisualEnabled( Property::Index index ) const
149 return Control::IsVisualEnabled( index );
152 Dali::Animation ControlWrapper::CreateTransition( const Toolkit::TransitionData& handle )
154 return Control::CreateTransition( handle );
157 void ControlWrapper::ApplyThemeStyle()
159 Toolkit::StyleManager styleManager = StyleManager::Get();
161 // if style manager is available
164 StyleManager& styleManagerImpl = GetImpl( styleManager );
166 // Apply the current style
167 styleManagerImpl.ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
171 } // namespace Internal
173 } // namespace Toolkit