Merge branch 'devel/master' into sandbox/dkdk/tizen
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / widget-impl.cpp
1 /*
2  * Copyright (c) 2020 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 "widget-impl.h"
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/system/common/widget-controller.h>
23
24 namespace Dali
25 {
26 namespace Internal
27 {
28 namespace Adaptor
29 {
30 WidgetPtr Widget::New()
31 {
32   return new Widget();
33 }
34
35 Widget::Widget()
36 : mImpl(nullptr)
37 {
38 }
39
40 Widget::~Widget()
41 {
42   if(mImpl != nullptr)
43   {
44     delete mImpl;
45   }
46 }
47
48 void Widget::OnCreate(const std::string& contentInfo, Dali::Window window)
49 {
50 }
51
52 void Widget::OnTerminate(const std::string& contentInfo, Dali::Widget::Termination type)
53 {
54 }
55
56 void Widget::OnPause()
57 {
58 }
59
60 void Widget::OnResume()
61 {
62 }
63
64 void Widget::OnResize(Dali::Window window)
65 {
66 }
67
68 void Widget::OnUpdate(const std::string& contentInfo, int force)
69 {
70 }
71
72 void Widget::SignalConnected(SlotObserver* slotObserver, CallbackBase* callback)
73 {
74   mImpl->SignalConnected(slotObserver, callback);
75 }
76
77 void Widget::SignalDisconnected(SlotObserver* slotObserver, CallbackBase* callback)
78 {
79   mImpl->SignalDisconnected(slotObserver, callback);
80 }
81
82 void Widget::SetContentInfo(const std::string& contentInfo)
83 {
84   if(mImpl != nullptr)
85   {
86     mImpl->SetContentInfo(contentInfo);
87   }
88 }
89
90 void Widget::SetImpl(Impl* impl)
91 {
92   mImpl = impl;
93 }
94
95 Internal::Adaptor::Widget& GetImplementation(Dali::Widget& widget)
96 {
97   DALI_ASSERT_ALWAYS(widget && "widget handle is empty");
98
99   BaseObject& handle = widget.GetBaseObject();
100
101   return static_cast<Internal::Adaptor::Widget&>(handle);
102 }
103
104 const Internal::Adaptor::Widget& GetImplementation(const Dali::Widget& widget)
105 {
106   const BaseObject& handle = widget.GetBaseObject();
107
108   return static_cast<const Internal::Adaptor::Widget&>(handle);
109 }
110
111 } // namespace Adaptor
112
113 } // namespace Internal
114
115 } // namespace Dali