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