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