Refactor dali-csharp-binder source files
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / common / slim-custom-view-impl.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include "slim-custom-view-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/object/handle-devel.h>
23 #include <dali/public-api/object/type-registry.h>
24 #include <dali-toolkit/dali-toolkit.h>
25
26 // INTERNAL INCLUDES
27 #include "nui-view-accessible.h"
28
29 SlimCustomViewImpl::SlimCustomViewImpl(ControlBehaviour behaviourFlags) : Control(behaviourFlags)
30 {
31 }
32
33 Dali::Toolkit::Control SlimCustomViewImpl::New(ControlBehaviour additionalBehaviour)
34 {
35   // Create the implementation, temporarily owned on stack
36   Dali::IntrusivePtr<SlimCustomViewImpl> controlImpl = new SlimCustomViewImpl(Control::ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehaviour));
37
38   // Pass ownership to handle
39   Dali::Toolkit::Control handle(*controlImpl);
40
41   // Second-phase init of the implementation
42   // This can only be done after the CustomActor connection has been made...
43   controlImpl->Initialize();
44
45   // Impersonate Control by adopting its TypeInfo. Without this, many things don't work.
46   Dali::TypeInfo typeInfo = Dali::TypeRegistry::Get().GetTypeInfo(typeid(Control));
47   if(typeInfo)
48   {
49     Dali::DevelHandle::SetTypeInfo(handle, typeInfo);
50   }
51
52   return handle;
53 }
54
55 Dali::Toolkit::DevelControl::ControlAccessible* SlimCustomViewImpl::CreateAccessibleObject()
56 {
57   return new NUIViewAccessible(Self());
58 }