2 * Copyright (c) 2017 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>
26 #include <dali/devel-api/actors/custom-actor-devel.h>
29 #include <dali-toolkit/public-api/controls/control-impl.h>
30 #include <dali-toolkit/devel-api/controls/control-devel.h>
31 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
32 #include <dali-toolkit/public-api/styling/style-manager.h>
33 #include <dali-toolkit/internal/styling/style-manager-impl.h>
49 // empty handle as we cannot create control wrapper
53 // Setup type-registry.
54 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ControlWrapper, Toolkit::Control, Create )
55 DALI_TYPE_REGISTRATION_END()
63 Dali::Toolkit::ControlWrapper ControlWrapper::New( const std::string& typeName, ControlWrapper* controlWrapper )
65 ControlWrapperPtr wrapper( controlWrapper );
67 // Pass ownership to CustomActor via derived handle.
68 Dali::Toolkit::ControlWrapper handle( *wrapper );
70 // Second-phase initialisation of the implementation.
71 // This can only be done after the CustomActor connection has been made.
72 wrapper->Initialize();
74 // Different types of C# custom view registered themselves using type registry,
75 // but their type names are registered per type not per instance, so they still
76 // have the same wrong type name in native side when type registry queries the
77 // unique type name of each instance using typeid() because of the binding.
78 // Therefore, we have to link each instance with its correct type info if already
81 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeName );
84 Dali::DevelHandle::SetTypeInfo( handle, typeInfo );
90 ControlWrapper::ControlWrapper( CustomControlBehaviour behaviourFlags )
91 : Control( static_cast< ControlBehaviour >( behaviourFlags ) )
95 ControlWrapper::~ControlWrapper()
99 void ControlWrapper::RelayoutRequest()
101 CustomActorImpl::RelayoutRequest();
104 float ControlWrapper::GetHeightForWidthBase( float width )
106 return CustomActorImpl::GetHeightForWidthBase( width );
109 float ControlWrapper::GetWidthForHeightBase( float height )
111 return CustomActorImpl::GetWidthForHeightBase( height );
114 float ControlWrapper::CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension )
116 return CustomActorImpl::CalculateChildSizeBase( child, dimension );
119 bool ControlWrapper::RelayoutDependentOnChildrenBase( Dimension::Type dimension )
121 return CustomActorImpl::RelayoutDependentOnChildrenBase( dimension );
124 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
126 DevelControl::RegisterVisual( *this, index, visual );
129 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, int depthIndex )
131 DevelControl::RegisterVisual( *this, index, visual, depthIndex );
134 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
136 DevelControl::RegisterVisual( *this, index, visual, enabled );
139 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex )
141 DevelControl::RegisterVisual( *this, index, visual, enabled, depthIndex );
144 void ControlWrapper::UnregisterVisual( Property::Index index )
146 DevelControl::UnregisterVisual( *this, index );
149 Toolkit::Visual::Base ControlWrapper::GetVisual( Property::Index index ) const
151 return DevelControl::GetVisual( *this, index );
154 void ControlWrapper::EnableVisual( Property::Index index, bool enable )
156 DevelControl::EnableVisual( *this, index, enable );
159 bool ControlWrapper::IsVisualEnabled( Property::Index index ) const
161 return DevelControl::IsVisualEnabled( *this, index );
164 Dali::Animation ControlWrapper::CreateTransition( const Toolkit::TransitionData& handle )
166 return DevelControl::CreateTransition( *this, handle );
169 void ControlWrapper::ApplyThemeStyle()
171 Toolkit::StyleManager styleManager = StyleManager::Get();
173 // if style manager is available
176 StyleManager& styleManagerImpl = GetImpl( styleManager );
178 // Apply the current style
179 styleManagerImpl.ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
183 Dali::TypeInfo ControlWrapper::GetTypeInfo()
185 return DevelCustomActor::GetTypeInfo(Self());
188 } // namespace Internal
190 } // namespace Toolkit