Partial update implementation, first phase.
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / window-devel.cpp
1 /*
2  * Copyright (c) 2019 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 // EXTERNAL INCLUDES
19 #include <dali/public-api/events/key-event.h>
20 #include <dali/public-api/events/touch-event.h>
21 #include <dali/public-api/events/wheel-event.h>
22
23 // INTERNAL INCLUDES
24 #include <dali/devel-api/adaptor-framework/window-devel.h>
25 #include <dali/internal/window-system/common/window-impl.h>
26
27 namespace Dali
28 {
29
30 namespace DevelWindow
31 {
32
33 Window New(Any surface, PositionSize windowPosition, const std::string& name, bool isTransparent)
34 {
35   return DevelWindow::New(surface, windowPosition, name, "", isTransparent);
36 }
37
38 Window New(Any surface, PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent)
39 {
40   Window newWindow;
41
42   const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
43   bool isNewWindowAllowed = true;
44
45   if (isAdaptorAvailable)
46   {
47     Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
48     isNewWindowAllowed = Internal::Adaptor::Adaptor::GetImplementation(adaptor).IsMultipleWindowSupported();
49   }
50
51   if (isNewWindowAllowed)
52   {
53     Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(surface, windowPosition, name, className, isTransparent);
54
55     Integration::SceneHolder sceneHolder = Integration::SceneHolder(window);
56     if (isAdaptorAvailable)
57     {
58       Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
59       Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder, name, className, isTransparent);
60     }
61     newWindow = Window(window);
62   }
63   else
64   {
65     DALI_LOG_ERROR("This device can't support multiple windows.\n");
66   }
67
68   return newWindow;
69 }
70
71 void SetPositionSize( Window window, PositionSize positionSize )
72 {
73   GetImplementation( window ).SetPositionSize( positionSize );
74 }
75
76 Dali::RenderTaskList GetRenderTaskList( Window window )
77 {
78   return GetImplementation( window ).GetRenderTaskList();
79 }
80
81 Window Get( Actor actor )
82 {
83   return Internal::Adaptor::Window::Get( actor );
84 }
85
86 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
87 {
88   return GetImplementation( window ).EventProcessingFinishedSignal();
89 }
90
91 KeyEventSignalType& KeyEventSignal( Window window )
92 {
93   return GetImplementation( window ).KeyEventSignal();
94 }
95
96 TouchSignalType& TouchSignal( Window window )
97 {
98   return GetImplementation( window ).TouchSignal();
99 }
100
101 WheelEventSignalType& WheelEventSignal( Window window )
102 {
103   return GetImplementation( window ).WheelEventSignal();
104 }
105
106 VisibilityChangedSignalType& VisibilityChangedSignal( Window window )
107 {
108   return GetImplementation( window ).VisibilityChangedSignal();
109 }
110
111 TransitionEffectEventSignalType& TransitionEffectEventSignal( Window window )
112 {
113   return GetImplementation( window ).TransitionEffectEventSignal();
114 }
115
116 void SetParent( Window window, Window parent )
117 {
118   GetImplementation( window ).SetParent( parent );
119 }
120
121 void Unparent( Window window )
122 {
123   GetImplementation( window ).Unparent();
124 }
125
126 Window GetParent( Window window )
127 {
128   return GetImplementation( window ).GetParent();
129 }
130
131 Window DownCast( BaseHandle handle )
132 {
133   return Window( dynamic_cast<Dali::Internal::Adaptor::Window*>( handle.GetObjectPtr()) );
134 }
135
136 Dali::Window::WindowOrientation GetCurrentOrientation( Window window )
137 {
138   return GetImplementation( window ).GetCurrentOrientation();
139 }
140
141 void SetAvailableOrientations( Window window, const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
142 {
143   GetImplementation( window ).SetAvailableOrientations( orientations );
144 }
145
146 int32_t GetNativeId( Window window )
147 {
148   return GetImplementation( window ).GetNativeId();
149 }
150
151 void SetDamagedAreas(Window window, std::vector<Dali::Rect<int>>& areas)
152 {
153   GetImplementation(window).SetDamagedAreas(areas);
154 }
155
156 } // namespace DevelWindow
157
158 } // namespace Dali