2 * Copyright (c) 2022 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/devel-api/actors/custom-actor-devel.h>
23 #include <dali/devel-api/object/handle-devel.h>
24 #include <dali/public-api/animation/animation.h>
25 #include <dali/public-api/object/type-registry-helper.h>
26 #include <dali/public-api/object/type-registry.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/internal/styling/style-manager-impl.h>
32 #include <dali-toolkit/public-api/controls/control-impl.h>
33 #include <dali-toolkit/public-api/styling/style-manager.h>
45 // empty handle as we cannot create control wrapper
49 // Setup type-registry.
50 DALI_TYPE_REGISTRATION_BEGIN(Toolkit::ControlWrapper, Toolkit::Control, Create)
51 DALI_TYPE_REGISTRATION_END()
59 Dali::Toolkit::ControlWrapper ControlWrapper::New(const std::string& typeName, ControlWrapper* controlWrapper)
61 ControlWrapperPtr wrapper(controlWrapper);
63 // Pass ownership to CustomActor via derived handle.
64 Dali::Toolkit::ControlWrapper handle(*wrapper);
66 // Second-phase initialisation of the implementation.
67 // This can only be done after the CustomActor connection has been made.
68 wrapper->Initialize();
70 // Different types of C# custom view registered themselves using type registry,
71 // but their type names are registered per type not per instance, so they still
72 // have the same wrong type name in native side when type registry queries the
73 // unique type name of each instance using typeid() because of the binding.
74 // Therefore, we have to link each instance with its correct type info if already
77 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo(typeName);
80 Dali::DevelHandle::SetTypeInfo(handle, typeInfo);
86 ControlWrapper::ControlWrapper(CustomControlBehaviour behaviourFlags)
87 : Control(static_cast<ControlBehaviour>(behaviourFlags | DISABLE_STYLE_CHANGE_SIGNALS))
91 ControlWrapper::~ControlWrapper()
95 void ControlWrapper::RelayoutRequest()
97 CustomActorImpl::RelayoutRequest();
100 float ControlWrapper::GetHeightForWidthBase(float width)
102 return CustomActorImpl::GetHeightForWidthBase(width);
105 float ControlWrapper::GetWidthForHeightBase(float height)
107 return CustomActorImpl::GetWidthForHeightBase(height);
110 float ControlWrapper::CalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension)
112 return CustomActorImpl::CalculateChildSizeBase(child, dimension);
115 bool ControlWrapper::RelayoutDependentOnChildrenBase(Dimension::Type dimension)
117 return CustomActorImpl::RelayoutDependentOnChildrenBase(dimension);
120 void ControlWrapper::RegisterVisual(Property::Index index, Toolkit::Visual::Base& visual)
122 DevelControl::RegisterVisual(*this, index, visual);
125 void ControlWrapper::RegisterVisual(Property::Index index, Toolkit::Visual::Base& visual, int depthIndex)
127 DevelControl::RegisterVisual(*this, index, visual, depthIndex);
130 void ControlWrapper::RegisterVisual(Property::Index index, Toolkit::Visual::Base& visual, bool enabled)
132 DevelControl::RegisterVisual(*this, index, visual, enabled);
135 void ControlWrapper::RegisterVisual(Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex)
137 DevelControl::RegisterVisual(*this, index, visual, enabled, depthIndex);
140 void ControlWrapper::UnregisterVisual(Property::Index index)
142 DevelControl::UnregisterVisual(*this, index);
145 Toolkit::Visual::Base ControlWrapper::GetVisual(Property::Index index) const
147 return DevelControl::GetVisual(*this, index);
150 void ControlWrapper::EnableVisual(Property::Index index, bool enable)
152 DevelControl::EnableVisual(*this, index, enable);
155 bool ControlWrapper::IsVisualEnabled(Property::Index index) const
157 return DevelControl::IsVisualEnabled(*this, index);
160 Dali::Animation ControlWrapper::CreateTransition(const Toolkit::TransitionData& handle)
162 return DevelControl::CreateTransition(*this, handle);
165 void ControlWrapper::ApplyThemeStyle()
167 Toolkit::StyleManager styleManager = StyleManager::Get();
169 // if style manager is available
172 StyleManager& styleManagerImpl = GetImpl(styleManager);
174 // Apply the current style
175 styleManagerImpl.ApplyThemeStyle(Toolkit::Control(GetOwner()));
179 Dali::TypeInfo ControlWrapper::GetTypeInfo()
181 return DevelCustomActor::GetTypeInfo(Self());
184 void ControlWrapper::EmitKeyInputFocusSignal(bool focusGained)
186 Control::EmitKeyInputFocusSignal(focusGained);
189 } // namespace Internal
191 } // namespace Toolkit