1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
5 * Copyright (c) 2019 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>
24 #include <dali/public-api/actors/layer.h>
25 #include <dali/public-api/render-tasks/render-task-list.h>
26 #include <dali/integration-api/scene.h>
29 #include <dali/internal/adaptor/common/lifecycle-observer.h>
30 #include <dali/internal/adaptor/common/adaptor-impl.h>
31 #include <dali/public-api/adaptor-framework/window.h>
32 #include <dali/public-api/adaptor-framework/key-grab.h>
33 #include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
45 class WindowRenderSurface;
49 typedef IntrusivePtr<Window> WindowPtr;
50 typedef IntrusivePtr<Orientation> OrientationPtr;
53 * Window provides a surface to render onto with orientation & indicator properties.
55 class Window : public Dali::BaseObject, public LifeCycleObserver, public ConnectionTracker
58 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
59 typedef Dali::Window::FocusSignalType FocusSignalType;
60 typedef Dali::Window::ResizedSignalType ResizedSignalType;
61 typedef Signal< void () > SignalType;
64 * Create a new Window. This should only be called once by the Application class
65 * @param[in] positionSize The position and size of the window
66 * @param[in] name The window title
67 * @param[in] className The window class name
68 * @param[in] isTransparent Whether window is transparent
69 * @return A newly allocated Window
71 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
74 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
75 * @param[in] adaptor An initialized adaptor
77 void SetAdaptor(Dali::Adaptor& adaptor);
80 * Get the window surface
81 * @return The render surface
83 WindowRenderSurface* GetSurface();
86 * @copydoc Dali::Window::ShowIndicator()
88 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
91 * @copydoc Dali::Window::SetIndicatorBgOpacity()
93 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
96 * @copydoc Dali::Window::RotateIndicator()
98 void RotateIndicator( Dali::Window::WindowOrientation orientation );
101 * @copydoc Dali::Window::SetClass()
103 void SetClass( std::string name, std::string className );
106 * @copydoc Dali::Window::Raise()
111 * @copydoc Dali::Window::Lower()
116 * @copydoc Dali::Window::Activate()
121 * @copydoc Dali::Window::Add()
123 void Add( Dali::Actor actor );
126 * @copydoc Dali::Window::Remove()
128 void Remove( Dali::Actor remove );
131 * @copydoc Dali::Window::SetBackgroundColor()
133 void SetBackgroundColor(Vector4 color);
136 * @copydoc Dali::Window::GetBackgroundColor()
138 Vector4 GetBackgroundColor() const;
141 * @copydoc Dali::Window::GetRootLayer()
143 Dali::Layer GetRootLayer() const;
146 * @copydoc Dali::Window::GetLayerCount()
148 uint32_t GetLayerCount() const;
151 * @copydoc Dali::Window::GetLayer()
153 Dali::Layer GetLayer( uint32_t depth ) const;
156 * @copydoc Dali::Window::AddAvailableOrientation()
158 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
161 * @copydoc Dali::Window::RemoveAvailableOrientation()
163 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
166 * @copydoc Dali::Window::SetAvailableOrientations()
168 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
171 * @copydoc Dali::Window::GetAvailableOrientations()
173 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
176 * @copydoc Dali::Window::SetPreferredOrientation()
178 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
181 * @copydoc Dali::Window::GetPreferredOrientation()
183 Dali::Window::WindowOrientation GetPreferredOrientation();
186 * @copydoc Dali::Window::GetDragAndDropDetector() const
188 Dali::DragAndDropDetector GetDragAndDropDetector() const;
191 * @copydoc Dali::Window::GetNativeHandle() const
193 Dali::Any GetNativeHandle() const;
196 * @copydoc Dali::Window::SetAcceptFocus()
198 void SetAcceptFocus( bool accept );
201 * @copydoc Dali::Window::IsFocusAcceptable()
203 bool IsFocusAcceptable() const;
206 * @copydoc Dali::Window::Show()
211 * @copydoc Dali::Window::Hide()
216 * @copydoc Dali::Window::IsVisible() const
218 bool IsVisible() const;
221 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
223 unsigned int GetSupportedAuxiliaryHintCount() const;
226 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
228 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
231 * @copydoc Dali::Window::AddAuxiliaryHint()
233 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
236 * @copydoc Dali::Window::RemoveAuxiliaryHint()
238 bool RemoveAuxiliaryHint( unsigned int id );
241 * @copydoc Dali::Window::SetAuxiliaryHintValue()
243 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
246 * @copydoc Dali::Window::GetAuxiliaryHintValue()
248 std::string GetAuxiliaryHintValue( unsigned int id ) const;
251 * @copydoc Dali::Window::GetAuxiliaryHintId()
253 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
256 * @copydoc Dali::Window::SetInputRegion()
258 void SetInputRegion( const Rect< int >& inputRegion );
261 * @copydoc Dali::Window::SetType()
263 void SetType( Dali::Window::Type type );
266 * @copydoc Dali::Window::GetType() const
268 Dali::Window::Type GetType() const;
271 * @copydoc Dali::Window::SetNotificationLevel()
273 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
276 * @copydoc Dali::Window::GetNotificationLevel()
278 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
281 * @copydoc Dali::Window::SetOpaqueState()
283 void SetOpaqueState( bool opaque );
286 * @copydoc Dali::Window::IsOpaqueState()
288 bool IsOpaqueState() const;
291 * @copydoc Dali::Window::SetScreenOffMode()
293 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
296 * @copydoc Dali::Window::GetScreenOffMode()
298 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
301 * @copydoc Dali::Window::SetBrightness()
303 bool SetBrightness( int brightness );
306 * @copydoc Dali::Window::GetBrightness()
308 int GetBrightness() const;
311 * @copydoc Dali::Window::SetSize()
313 void SetSize( Dali::Window::WindowSize size );
316 * @copydoc Dali::Window::GetSize()
318 Dali::Window::WindowSize GetSize() const;
321 * @copydoc Dali::Window::SetPosition()
323 void SetPosition( Dali::Window::WindowPosition position );
326 * @copydoc Dali::Window::GetPosition()
328 Dali::Window::WindowPosition GetPosition() const;
331 * @copydoc Dali::DevelWindow::SetPositionSize()
333 void SetPositionSize( PositionSize positionSize );
336 * @copydoc Dali::Window::SetTransparency()
338 void SetTransparency( bool transparent );
341 * @copydoc Dali::KeyGrab::GrabKey()
343 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
346 * @copydoc Dali::KeyGrab::UngrabKey()
348 bool UngrabKey( Dali::KEY key );
351 * @copydoc Dali::KeyGrab::GrabKeyList()
353 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
356 * @copydoc Dali::KeyGrab::UngrabKeyList()
358 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
361 * Called from Orientation after the Change signal has been sent
363 void RotationDone( int orientation, int width, int height );
366 * @brief Retrieves the unique ID of the window.
369 uint32_t GetId() const;
374 * Private constructor.
385 * Second stage initialization
387 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
390 * Called when the window becomes iconified or deiconified.
392 void OnIconifyChanged( bool iconified );
395 * Called when the window focus is changed.
397 void OnFocusChanged( bool focusIn );
400 * Called when the output is transformed.
402 void OnOutputTransformed();
405 * Called when the window receives a delete request.
407 void OnDeleteRequest();
409 private: // Adaptor::Observer interface
412 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
414 virtual void OnStart();
417 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
419 virtual void OnPause();
422 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
424 virtual void OnResume();
427 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
429 virtual void OnStop();
432 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
434 virtual void OnDestroy();
439 * The user should connect to this signal to get a timing when indicator was shown / hidden.
441 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
444 * @copydoc Dali::Window::FocusChangedSignal()
446 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
449 * @copydoc Dali::Window::ResizedSignal()
451 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
454 * This signal is emitted when the window is requesting to be deleted
456 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
460 static uint32_t mWindowCounter; ///< A counter to track the window creation
461 uint32_t mId; ///< A unique ID to identify the window starting from 0
462 std::unique_ptr< WindowRenderSurface > mSurface;
463 Dali::Integration::Scene mScene;
464 WindowBase* mWindowBase;
466 bool mIsTransparent:1;
467 bool mIsFocusAcceptable:1;
471 bool mResizeEnabled:1;
473 Dali::DragAndDropDetector mDragAndDropDetector;
474 Dali::Window::Type mType;
476 OrientationPtr mOrientation;
477 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
478 Dali::Window::WindowOrientation mPreferredOrientation;
480 Vector4 mBackgroundColor;
483 IndicatorSignalType mIndicatorVisibilityChangedSignal;
484 FocusSignalType mFocusChangedSignal;
485 ResizedSignalType mResizedSignal;
486 SignalType mDeleteRequestSignal;
489 } // namespace Adaptor
490 } // namepsace Internal
492 // Helpers for public-api forwarding methods
494 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
496 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
497 BaseObject& object = window.GetBaseObject();
498 return static_cast<Internal::Adaptor::Window&>(object);
501 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
503 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
504 const BaseObject& object = window.GetBaseObject();
505 return static_cast<const Internal::Adaptor::Window&>(object);
510 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H