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>
27 #ifdef DALI_ADAPTOR_COMPILATION
28 #include <dali/integration-api/scene-holder-impl.h>
30 #include <dali/integration-api/adaptors/scene-holder-impl.h>
34 #include <dali/internal/adaptor/common/adaptor-impl.h>
35 #include <dali/public-api/adaptor-framework/window.h>
36 #include <dali/public-api/adaptor-framework/key-grab.h>
37 #include <dali/devel-api/adaptor-framework/window-devel.h>
38 #include <dali/internal/window-system/common/event-handler.h>
44 class RenderSurfaceInterface;
51 class WindowRenderSurface;
55 using WindowPtr = IntrusivePtr< Window >;
56 using OrientationPtr = IntrusivePtr< Orientation >;
57 using EventHandlerPtr = IntrusivePtr< EventHandler >;
60 * Window provides a surface to render onto with orientation & indicator properties.
62 class Window : public Dali::Internal::Adaptor::SceneHolder, public EventHandler::Observer, public ConnectionTracker
65 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
66 typedef Dali::Window::FocusSignalType FocusSignalType;
67 typedef Dali::Window::ResizedSignalType ResizedSignalType;
68 typedef Signal< void () > SignalType;
71 * Create a new Window. This should only be called once by the Application class
72 * @param[in] positionSize The position and size of the window
73 * @param[in] name The window title
74 * @param[in] className The window class name
75 * @param[in] isTransparent Whether window is transparent
76 * @return A newly allocated Window
78 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
81 * @copydoc Dali::Window::ShowIndicator()
83 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
86 * @copydoc Dali::Window::SetIndicatorBgOpacity()
88 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
91 * @copydoc Dali::Window::RotateIndicator()
93 void RotateIndicator( Dali::Window::WindowOrientation orientation );
96 * @copydoc Dali::Window::SetClass()
98 void SetClass( std::string name, std::string className );
101 * @brief Gets the window class name.
102 * @return The class of the window
104 std::string GetClassName() const;
107 * @copydoc Dali::Window::Raise()
112 * @copydoc Dali::Window::Lower()
117 * @copydoc Dali::Window::Activate()
122 * @copydoc Dali::Window::GetLayerCount()
124 uint32_t GetLayerCount() const;
127 * @copydoc Dali::Window::GetLayer()
129 Dali::Layer GetLayer( uint32_t depth ) const;
132 * @copydoc Dali::DevelWindow::GetRenderTaskList()
134 Dali::RenderTaskList GetRenderTaskList() const;
137 * @copydoc Dali::Window::AddAvailableOrientation()
139 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
142 * @copydoc Dali::Window::RemoveAvailableOrientation()
144 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
147 * @copydoc Dali::Window::SetAvailableOrientations()
149 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
152 * @copydoc Dali::Window::GetAvailableOrientations()
154 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
157 * @copydoc Dali::Window::SetPreferredOrientation()
159 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
162 * @copydoc Dali::Window::GetPreferredOrientation()
164 Dali::Window::WindowOrientation GetPreferredOrientation();
167 * @copydoc Dali::Window::SetAcceptFocus()
169 void SetAcceptFocus( bool accept );
172 * @copydoc Dali::Window::IsFocusAcceptable()
174 bool IsFocusAcceptable() const;
177 * @copydoc Dali::Window::Show()
182 * @copydoc Dali::Window::Hide()
187 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
189 unsigned int GetSupportedAuxiliaryHintCount() const;
192 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
194 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
197 * @copydoc Dali::Window::AddAuxiliaryHint()
199 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
202 * @copydoc Dali::Window::RemoveAuxiliaryHint()
204 bool RemoveAuxiliaryHint( unsigned int id );
207 * @copydoc Dali::Window::SetAuxiliaryHintValue()
209 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
212 * @copydoc Dali::Window::GetAuxiliaryHintValue()
214 std::string GetAuxiliaryHintValue( unsigned int id ) const;
217 * @copydoc Dali::Window::GetAuxiliaryHintId()
219 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
222 * @copydoc Dali::Window::SetInputRegion()
224 void SetInputRegion( const Rect< int >& inputRegion );
227 * @copydoc Dali::Window::SetType()
229 void SetType( Dali::Window::Type type );
232 * @copydoc Dali::Window::GetType() const
234 Dali::Window::Type GetType() const;
237 * @copydoc Dali::Window::SetNotificationLevel()
239 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
242 * @copydoc Dali::Window::GetNotificationLevel()
244 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
247 * @copydoc Dali::Window::SetOpaqueState()
249 void SetOpaqueState( bool opaque );
252 * @copydoc Dali::Window::IsOpaqueState()
254 bool IsOpaqueState() const;
257 * @copydoc Dali::Window::SetScreenOffMode()
259 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
262 * @copydoc Dali::Window::GetScreenOffMode()
264 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
267 * @copydoc Dali::Window::SetBrightness()
269 bool SetBrightness( int brightness );
272 * @copydoc Dali::Window::GetBrightness()
274 int GetBrightness() const;
277 * @copydoc Dali::Window::SetSize()
279 void SetSize( Dali::Window::WindowSize size );
282 * @copydoc Dali::Window::GetSize()
284 Dali::Window::WindowSize GetSize() const;
287 * @copydoc Dali::Window::SetPosition()
289 void SetPosition( Dali::Window::WindowPosition position );
292 * @copydoc Dali::Window::GetPosition()
294 Dali::Window::WindowPosition GetPosition() const;
297 * @copydoc Dali::DevelWindow::SetPositionSize()
299 void SetPositionSize( PositionSize positionSize );
302 * @copydoc Dali::Window::GetRootLayer()
304 Dali::Layer GetRootLayer() const;
307 * @copydoc Dali::Window::SetTransparency()
309 void SetTransparency( bool transparent );
312 * @copydoc Dali::KeyGrab::GrabKey()
314 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
317 * @copydoc Dali::KeyGrab::UngrabKey()
319 bool UngrabKey( Dali::KEY key );
322 * @copydoc Dali::KeyGrab::GrabKeyList()
324 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
327 * @copydoc Dali::KeyGrab::UngrabKeyList()
329 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
332 * @copydoc Dali::DevelWindow::Get()
334 static Dali::Window Get( Dali::Actor actor );
337 * @copydoc Dali::DevelWindow::SetParent()
339 void SetParent( Dali::Window& parent );
342 * @copydoc Dali::DevelWindow::Unparent()
347 * @copydoc Dali::DevelWindow::GetParent()
349 Dali::Window GetParent();
351 public: // Dali::Internal::Adaptor::SceneHolder
354 * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
356 Dali::Any GetNativeHandle() const override;
359 * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible
361 bool IsVisible() const override;
366 * Private constructor.
377 * Second stage initialization
379 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
382 * Called when the window becomes iconified or deiconified.
384 void OnIconifyChanged( bool iconified );
387 * Called when the window focus is changed.
389 void OnFocusChanged( bool focusIn );
392 * Called when the output is transformed.
394 void OnOutputTransformed();
397 * Called when the window receives a delete request.
399 void OnDeleteRequest();
401 private: // Dali::Internal::Adaptor::SceneHolder
404 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
406 void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
409 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
411 void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
414 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
416 void OnPause() override;
419 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
421 void OnResume() override;
424 * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
426 void RecalculateTouchPosition( Integration::Point& point ) override;
428 private: // Dali::Internal::Adaptor::EventHandler::Observer
431 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
433 void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
436 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
438 void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
441 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
443 void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
446 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
448 void OnRotation( const RotationEvent& rotation ) override;
453 * The user should connect to this signal to get a timing when indicator was shown / hidden.
455 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
458 * @copydoc Dali::Window::FocusChangedSignal()
460 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
463 * @copydoc Dali::Window::ResizedSignal()
465 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
468 * This signal is emitted when the window is requesting to be deleted
470 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
473 * @copydoc Dali::Window::SignalEventProcessingFinished()
475 Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); }
479 WindowRenderSurface* mWindowSurface; ///< The window rendering surface
480 WindowBase* mWindowBase;
482 std::string mClassName;
483 bool mIsTransparent:1;
484 bool mIsFocusAcceptable:1;
487 bool mResizeEnabled:1;
488 Dali::Window::Type mType;
489 Dali::Window mParentWindow;
491 OrientationPtr mOrientation;
492 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
493 Dali::Window::WindowOrientation mPreferredOrientation;
495 int mRotationAngle; ///< The angle of the rotation
496 int mWindowWidth; ///< The width of the window
497 int mWindowHeight; ///< The height of the window
499 EventHandlerPtr mEventHandler; ///< The window events handler
502 IndicatorSignalType mIndicatorVisibilityChangedSignal;
503 FocusSignalType mFocusChangedSignal;
504 ResizedSignalType mResizedSignal;
505 SignalType mDeleteRequestSignal;
510 } // namespace Adaptor
511 } // namepsace Internal
513 // Helpers for public-api forwarding methods
515 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
517 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
518 BaseObject& object = window.GetBaseObject();
519 return static_cast<Internal::Adaptor::Window&>(object);
522 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
524 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
525 const BaseObject& object = window.GetBaseObject();
526 return static_cast<const Internal::Adaptor::Window&>(object);
531 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H