1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/ref-object.h>
23 #include <dali/public-api/object/base-object.h>
26 #include <dali/internal/adaptor/common/lifecycle-observer.h>
27 #include <dali/internal/adaptor/common/adaptor-impl.h>
28 #include <dali/public-api/adaptor-framework/window.h>
29 #include <dali/public-api/adaptor-framework/key-grab.h>
30 #include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
41 class WindowRenderSurface;
45 typedef IntrusivePtr<Window> WindowPtr;
46 typedef IntrusivePtr<Orientation> OrientationPtr;
49 * Window provides a surface to render onto with orientation & indicator properties.
51 class Window : public Dali::BaseObject, public LifeCycleObserver, public ConnectionTracker
54 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
55 typedef Dali::Window::FocusSignalType FocusSignalType;
56 typedef Dali::Window::ResizedSignalType ResizedSignalType;
57 typedef Signal< void () > SignalType;
60 * Create a new Window. This should only be called once by the Application class
61 * @param[in] positionSize The position and size of the window
62 * @param[in] name The window title
63 * @param[in] className The window class name
64 * @param[in] isTransparent Whether window is transparent
65 * @return A newly allocated Window
67 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
70 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
71 * @param[in] adaptor An initialized adaptor
73 void SetAdaptor(Dali::Adaptor& adaptor);
76 * Get the window surface
77 * @return The render surface
79 WindowRenderSurface* GetSurface();
82 * @copydoc Dali::Window::ShowIndicator()
84 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
87 * @copydoc Dali::Window::SetIndicatorBgOpacity()
89 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
92 * @copydoc Dali::Window::RotateIndicator()
94 void RotateIndicator( Dali::Window::WindowOrientation orientation );
97 * @copydoc Dali::Window::SetClass()
99 void SetClass( std::string name, std::string className );
102 * @copydoc Dali::Window::Raise()
107 * @copydoc Dali::Window::Lower()
112 * @copydoc Dali::Window::Activate()
117 * @copydoc Dali::Window::AddAvailableOrientation()
119 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
122 * @copydoc Dali::Window::RemoveAvailableOrientation()
124 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
127 * @copydoc Dali::Window::SetAvailableOrientations()
129 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
132 * @copydoc Dali::Window::GetAvailableOrientations()
134 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
137 * @copydoc Dali::Window::SetPreferredOrientation()
139 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
142 * @copydoc Dali::Window::GetPreferredOrientation()
144 Dali::Window::WindowOrientation GetPreferredOrientation();
147 * @copydoc Dali::Window::GetDragAndDropDetector() const
149 Dali::DragAndDropDetector GetDragAndDropDetector() const;
152 * @copydoc Dali::Window::GetNativeHandle() const
154 Dali::Any GetNativeHandle() const;
157 * @copydoc Dali::Window::SetAcceptFocus()
159 void SetAcceptFocus( bool accept );
162 * @copydoc Dali::Window::IsFocusAcceptable()
164 bool IsFocusAcceptable() const;
167 * @copydoc Dali::Window::Show()
172 * @copydoc Dali::Window::Hide()
177 * @copydoc Dali::Window::IsVisible() const
179 bool IsVisible() const;
182 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
184 unsigned int GetSupportedAuxiliaryHintCount() const;
187 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
189 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
192 * @copydoc Dali::Window::AddAuxiliaryHint()
194 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
197 * @copydoc Dali::Window::RemoveAuxiliaryHint()
199 bool RemoveAuxiliaryHint( unsigned int id );
202 * @copydoc Dali::Window::SetAuxiliaryHintValue()
204 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
207 * @copydoc Dali::Window::GetAuxiliaryHintValue()
209 std::string GetAuxiliaryHintValue( unsigned int id ) const;
212 * @copydoc Dali::Window::GetAuxiliaryHintId()
214 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
217 * @copydoc Dali::Window::SetInputRegion()
219 void SetInputRegion( const Rect< int >& inputRegion );
222 * @copydoc Dali::Window::SetType()
224 void SetType( Dali::Window::Type type );
227 * @copydoc Dali::Window::GetType() const
229 Dali::Window::Type GetType() const;
232 * @copydoc Dali::Window::SetNotificationLevel()
234 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
237 * @copydoc Dali::Window::GetNotificationLevel()
239 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
242 * @copydoc Dali::Window::SetOpaqueState()
244 void SetOpaqueState( bool opaque );
247 * @copydoc Dali::Window::IsOpaqueState()
249 bool IsOpaqueState() const;
252 * @copydoc Dali::Window::SetScreenOffMode()
254 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
257 * @copydoc Dali::Window::GetScreenOffMode()
259 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
262 * @copydoc Dali::Window::SetBrightness()
264 bool SetBrightness( int brightness );
267 * @copydoc Dali::Window::GetBrightness()
269 int GetBrightness() const;
272 * @copydoc Dali::Window::SetSize()
274 void SetSize( Dali::Window::WindowSize size );
277 * @copydoc Dali::Window::GetSize()
279 Dali::Window::WindowSize GetSize() const;
282 * @copydoc Dali::Window::SetPosition()
284 void SetPosition( Dali::Window::WindowPosition position );
287 * @copydoc Dali::Window::GetPosition()
289 Dali::Window::WindowPosition GetPosition() const;
292 * @copydoc Dali::DevelWindow::SetPositionSize()
294 void SetPositionSize( PositionSize positionSize );
297 * @copydoc Dali::Window::SetTransparency()
299 void SetTransparency( bool transparent );
302 * @copydoc Dali::KeyGrab::GrabKey()
304 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
307 * @copydoc Dali::KeyGrab::UngrabKey()
309 bool UngrabKey( Dali::KEY key );
312 * @copydoc Dali::KeyGrab::GrabKeyList()
314 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
317 * @copydoc Dali::KeyGrab::UngrabKeyList()
319 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
322 * Called from Orientation after the Change signal has been sent
324 void RotationDone( int orientation, int width, int height );
329 * Private constructor.
340 * Second stage initialization
342 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
345 * Called when the window becomes iconified or deiconified.
347 void OnIconifyChanged( bool iconified );
350 * Called when the window focus is changed.
352 void OnFocusChanged( bool focusIn );
355 * Called when the output is transformed.
357 void OnOutputTransformed();
360 * Called when the window receives a delete request.
362 void OnDeleteRequest();
364 private: // Adaptor::Observer interface
367 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
369 virtual void OnStart();
372 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
374 virtual void OnPause();
377 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
379 virtual void OnResume();
382 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
384 virtual void OnStop();
387 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
389 virtual void OnDestroy();
394 * The user should connect to this signal to get a timing when indicator was shown / hidden.
396 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
399 * @copydoc Dali::Window::FocusChangedSignal()
401 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
404 * @copydoc Dali::Window::ResizedSignal()
406 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
409 * This signal is emitted when the window is requesting to be deleted
411 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
415 WindowRenderSurface* mSurface;
416 WindowBase* mWindowBase;
418 bool mIsTransparent:1;
419 bool mIsFocusAcceptable:1;
423 bool mResizeEnabled:1;
425 Dali::DragAndDropDetector mDragAndDropDetector;
426 Dali::Window::Type mType;
428 OrientationPtr mOrientation;
429 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
430 Dali::Window::WindowOrientation mPreferredOrientation;
433 IndicatorSignalType mIndicatorVisibilityChangedSignal;
434 FocusSignalType mFocusChangedSignal;
435 ResizedSignalType mResizedSignal;
436 SignalType mDeleteRequestSignal;
439 } // namespace Adaptor
440 } // namepsace Internal
442 // Helpers for public-api forwarding methods
444 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
446 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
447 BaseObject& object = window.GetBaseObject();
448 return static_cast<Internal::Adaptor::Window&>(object);
451 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
453 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
454 const BaseObject& object = window.GetBaseObject();
455 return static_cast<const Internal::Adaptor::Window&>(object);
460 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H