[Tizen] Add Keyboard repeat setting changed signal to Window
[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/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 Window Get( Actor actor )
77 {
78   return Internal::Adaptor::Window::Get( actor );
79 }
80
81 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
82 {
83   return GetImplementation( window ).EventProcessingFinishedSignal();
84 }
85
86 WheelEventSignalType& WheelEventSignal( Window window )
87 {
88   return GetImplementation( window ).WheelEventSignal();
89 }
90
91 VisibilityChangedSignalType& VisibilityChangedSignal( Window window )
92 {
93   return GetImplementation( window ).VisibilityChangedSignal();
94 }
95
96 TransitionEffectEventSignalType& TransitionEffectEventSignal( Window window )
97 {
98   return GetImplementation( window ).TransitionEffectEventSignal();
99 }
100
101 KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal( Window window )
102 {
103   return GetImplementation( window ).KeyboardRepeatSettingsChangedSignal();
104 }
105
106 void SetParent( Window window, Window parent )
107 {
108   GetImplementation( window ).SetParent( parent );
109 }
110
111 void Unparent( Window window )
112 {
113   GetImplementation( window ).Unparent();
114 }
115
116 Window GetParent( Window window )
117 {
118   return GetImplementation( window ).GetParent();
119 }
120
121 Window DownCast( BaseHandle handle )
122 {
123   return Window( dynamic_cast<Dali::Internal::Adaptor::Window*>( handle.GetObjectPtr()) );
124 }
125
126 Dali::Window::WindowOrientation GetCurrentOrientation( Window window )
127 {
128   return GetImplementation( window ).GetCurrentOrientation();
129 }
130
131 void SetAvailableOrientations( Window window, const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
132 {
133   GetImplementation( window ).SetAvailableOrientations( orientations );
134 }
135
136 int32_t GetNativeId( Window window )
137 {
138   return GetImplementation( window ).GetNativeId();
139 }
140
141 void SetDamagedAreas(Window window, std::vector<Dali::Rect<int>>& areas)
142 {
143   GetImplementation(window).SetDamagedAreas(areas);
144 }
145
146 void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
147 {
148   GetImplementation( window ).AddFrameRenderedCallback( std::move( callback ), frameId );
149 }
150
151 void AddFramePresentedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
152 {
153   GetImplementation( window ).AddFramePresentedCallback( std::move( callback ), frameId );
154 }
155
156 } // namespace DevelWindow
157
158 } // namespace Dali