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>
28 #include <dali-toolkit/public-api/controls/control-impl.h>
29 #include <dali-toolkit/devel-api/controls/control-devel.h>
30 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
31 #include <dali-toolkit/public-api/styling/style-manager.h>
32 #include <dali-toolkit/internal/styling/style-manager-impl.h>
48 // empty handle as we cannot create control wrapper
52 // Setup type-registry.
53 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ControlWrapper, Toolkit::Control, Create )
54 DALI_TYPE_REGISTRATION_END()
62 Dali::Toolkit::ControlWrapper ControlWrapper::New( const std::string& typeName, ControlWrapper* controlWrapper )
64 ControlWrapperPtr wrapper( controlWrapper );
66 // Pass ownership to CustomActor via derived handle.
67 Dali::Toolkit::ControlWrapper handle( *wrapper );
69 // Second-phase initialisation of the implementation.
70 // This can only be done after the CustomActor connection has been made.
71 wrapper->Initialize();
73 // Different types of C# custom view registered themselves using type registry,
74 // but their type names are registered per type not per instance, so they still
75 // have the same wrong type name in native side when type registry queries the
76 // unique type name of each instance using typeid() because of the binding.
77 // Therefore, we have to link each instance with its correct type info if already
80 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeName );
83 Dali::DevelHandle::SetTypeInfo( handle, typeInfo );
89 ControlWrapper::ControlWrapper( CustomControlBehaviour behaviourFlags )
90 : Control( static_cast< ControlBehaviour >( behaviourFlags ) )
94 ControlWrapper::~ControlWrapper()
98 void ControlWrapper::RelayoutRequest()
100 CustomActorImpl::RelayoutRequest();
103 float ControlWrapper::GetHeightForWidthBase( float width )
105 return CustomActorImpl::GetHeightForWidthBase( width );
108 float ControlWrapper::GetWidthForHeightBase( float height )
110 return CustomActorImpl::GetWidthForHeightBase( height );
113 float ControlWrapper::CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension )
115 return CustomActorImpl::CalculateChildSizeBase( child, dimension );
118 bool ControlWrapper::RelayoutDependentOnChildrenBase( Dimension::Type dimension )
120 return CustomActorImpl::RelayoutDependentOnChildrenBase( dimension );
123 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
125 DevelControl::RegisterVisual( *this, index, visual );
128 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, int depthIndex )
130 DevelControl::RegisterVisual( *this, index, visual, depthIndex );
133 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
135 DevelControl::RegisterVisual( *this, index, visual, enabled );
138 void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex )
140 DevelControl::RegisterVisual( *this, index, visual, enabled, depthIndex );
143 void ControlWrapper::UnregisterVisual( Property::Index index )
145 DevelControl::UnregisterVisual( *this, index );
148 Toolkit::Visual::Base ControlWrapper::GetVisual( Property::Index index ) const
150 return DevelControl::GetVisual( *this, index );
153 void ControlWrapper::EnableVisual( Property::Index index, bool enable )
155 DevelControl::EnableVisual( *this, index, enable );
158 bool ControlWrapper::IsVisualEnabled( Property::Index index ) const
160 return DevelControl::IsVisualEnabled( *this, index );
163 Dali::Animation ControlWrapper::CreateTransition( const Toolkit::TransitionData& handle )
165 return DevelControl::CreateTransition( *this, handle );
168 void ControlWrapper::ApplyThemeStyle()
170 Toolkit::StyleManager styleManager = StyleManager::Get();
172 // if style manager is available
175 StyleManager& styleManagerImpl = GetImpl( styleManager );
177 // Apply the current style
178 styleManagerImpl.ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
182 } // namespace Internal
184 } // namespace Toolkit