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/public-api/object/property-array.h>
29 #include <dali/public-api/adaptor-framework/window.h>
30 #include <dali/public-api/adaptor-framework/key-grab.h>
31 #include <dali/devel-api/adaptor-framework/window-devel.h>
32 #include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
33 #include <dali/internal/adaptor/common/adaptor-impl.h>
34 #include <dali/internal/window-system/common/event-handler.h>
40 class RenderSurfaceInterface;
47 class WindowRenderSurface;
51 using WindowPtr = IntrusivePtr< Window >;
52 using OrientationPtr = IntrusivePtr< Orientation >;
53 using EventHandlerPtr = IntrusivePtr< EventHandler >;
56 * Window provides a surface to render onto with orientation & indicator properties.
58 class Window : public Dali::Internal::Adaptor::SceneHolder, public EventHandler::Observer, public ConnectionTracker
61 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
62 typedef Dali::Window::FocusSignalType FocusSignalType;
63 typedef Dali::Window::ResizedSignalType ResizedSignalType;
64 typedef Dali::Window::FocusChangeSignalType FocusChangeSignalType;
65 typedef Dali::Window::ResizeSignalType ResizeSignalType;
66 typedef Dali::DevelWindow::VisibilityChangedSignalType VisibilityChangedSignalType;
67 typedef Dali::DevelWindow::TransitionEffectEventSignalType TransitionEffectEventSignalType;
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::SetPreferredOrientation()
149 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
152 * @copydoc Dali::Window::GetPreferredOrientation()
154 Dali::Window::WindowOrientation GetPreferredOrientation();
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::GetSupportedAuxiliaryHintCount()
179 unsigned int GetSupportedAuxiliaryHintCount() const;
182 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
184 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
187 * @copydoc Dali::Window::AddAuxiliaryHint()
189 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
192 * @copydoc Dali::Window::RemoveAuxiliaryHint()
194 bool RemoveAuxiliaryHint( unsigned int id );
197 * @copydoc Dali::Window::SetAuxiliaryHintValue()
199 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
202 * @copydoc Dali::Window::GetAuxiliaryHintValue()
204 std::string GetAuxiliaryHintValue( unsigned int id ) const;
207 * @copydoc Dali::Window::GetAuxiliaryHintId()
209 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
212 * @copydoc Dali::Window::SetInputRegion()
214 void SetInputRegion( const Rect< int >& inputRegion );
217 * @copydoc Dali::Window::SetType()
219 void SetType( Dali::Window::Type type );
222 * @copydoc Dali::Window::GetType() const
224 Dali::Window::Type GetType() const;
227 * @copydoc Dali::Window::SetNotificationLevel()
229 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
232 * @copydoc Dali::Window::GetNotificationLevel()
234 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
237 * @copydoc Dali::Window::SetOpaqueState()
239 void SetOpaqueState( bool opaque );
242 * @copydoc Dali::Window::IsOpaqueState()
244 bool IsOpaqueState() const;
247 * @copydoc Dali::Window::SetScreenOffMode()
249 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
252 * @copydoc Dali::Window::GetScreenOffMode()
254 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
257 * @copydoc Dali::Window::SetBrightness()
259 bool SetBrightness( int brightness );
262 * @copydoc Dali::Window::GetBrightness()
264 int GetBrightness() const;
267 * @copydoc Dali::Window::SetSize()
269 void SetSize( Dali::Window::WindowSize size );
272 * @copydoc Dali::Window::GetSize()
274 Dali::Window::WindowSize GetSize() const;
277 * @copydoc Dali::Window::SetPosition()
279 void SetPosition( Dali::Window::WindowPosition position );
282 * @copydoc Dali::Window::GetPosition()
284 Dali::Window::WindowPosition GetPosition() const;
287 * @copydoc Dali::DevelWindow::SetPositionSize()
289 void SetPositionSize( PositionSize positionSize );
292 * @copydoc Dali::Window::GetRootLayer()
294 Dali::Layer GetRootLayer() const;
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 * @copydoc Dali::DevelWindow::Get()
324 static Dali::Window Get( Dali::Actor actor );
327 * @copydoc Dali::DevelWindow::SetParent()
329 void SetParent( Dali::Window& parent );
332 * @copydoc Dali::DevelWindow::Unparent()
337 * @copydoc Dali::DevelWindow::GetParent()
339 Dali::Window GetParent();
342 * @copydoc Dali::DevelWindow::GetCurrentOrientation()
344 Dali::Window::WindowOrientation GetCurrentOrientation() const;
347 * @copydoc Dali::DevelWindow::SetAvailableOrientations()
349 void SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations );
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 * @brief Enumeration for orietation mode.
367 * The Orientation Mode is related to screen size.
368 * If screen width is longer than height, the Orientation Mode will have LANDSCAPE.
369 * Otherwise screen width is shorter than height or same, the Orientation Mode will have PORTRAIT.
371 enum class OrientationMode
378 * Private constructor.
389 * Second stage initialization
391 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
394 * Called when the window becomes iconified or deiconified.
396 void OnIconifyChanged( bool iconified );
399 * Called when the window focus is changed.
401 void OnFocusChanged( bool focusIn );
404 * Called when the output is transformed.
406 void OnOutputTransformed();
409 * Called when the window receives a delete request.
411 void OnDeleteRequest();
414 * Called when the window receives a Transition effect-start/end event.
416 void OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type );
419 * @brief Set available orientation to window base.
421 void SetAvailableAnlges( const std::vector< int >& angles );
424 * @brief Convert from window orientation to angle using OrientationMode.
426 int ConvertToAngle( Dali::Window::WindowOrientation orientation );
429 * @brief Convert from angle to window orientation using OrientationMode.
431 Dali::Window::WindowOrientation ConvertToOrientation( int angle ) const;
434 * @brief Check available window orientation for Available orientation.
436 bool IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const;
438 private: // Dali::Internal::Adaptor::SceneHolder
441 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
443 void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
446 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
448 void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
451 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
453 void OnPause() override;
456 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
458 void OnResume() override;
461 * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
463 void RecalculateTouchPosition( Integration::Point& point ) override;
465 private: // Dali::Internal::Adaptor::EventHandler::Observer
468 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
470 void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
473 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
475 void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
478 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
480 void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
483 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
485 void OnRotation( const RotationEvent& rotation ) override;
490 * The user should connect to this signal to get a timing when indicator was shown / hidden.
492 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
495 * @copydoc Dali::Window::FocusChangedSignal()
497 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
500 * @copydoc Dali::Window::WindowFocusChangedSignal()
502 FocusChangeSignalType& FocusChangeSignal() { return mFocusChangeSignal; }
504 * @copydoc Dali::Window::ResizedSignal()
506 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
509 * @copydoc Dali::Window::ResizedSignal()
511 ResizeSignalType& ResizeSignal() { return mResizeSignal; }
514 * This signal is emitted when the window is requesting to be deleted
516 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
519 * @copydoc Dali::DevelWindow::VisibilityChangedSignal()
521 VisibilityChangedSignalType& VisibilityChangedSignal() { return mVisibilityChangedSignal; }
524 * @copydoc Dali::Window::SignalEventProcessingFinished()
526 Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); }
529 * @copydoc Dali::DevelWindow::TransitionEffectEventSignal()
531 TransitionEffectEventSignalType& TransitionEffectEventSignal() { return mTransitionEffectEventSignal; }
535 WindowRenderSurface* mWindowSurface; ///< The window rendering surface
536 WindowBase* mWindowBase;
538 std::string mClassName;
539 bool mIsTransparent:1;
540 bool mIsFocusAcceptable:1;
543 bool mResizeEnabled:1;
544 Dali::Window::Type mType;
545 Dali::Window mParentWindow;
547 OrientationPtr mOrientation;
548 std::vector< int > mAvailableAngles;
551 int mRotationAngle; ///< The angle of the rotation
552 int mWindowWidth; ///< The width of the window
553 int mWindowHeight; ///< The height of the window
555 EventHandlerPtr mEventHandler; ///< The window events handler
557 OrientationMode mOrientationMode;
559 int mNativeWindowId; ///< The Native Window Id
562 IndicatorSignalType mIndicatorVisibilityChangedSignal;
563 FocusSignalType mFocusChangedSignal;
564 ResizedSignalType mResizedSignal;
565 SignalType mDeleteRequestSignal;
566 FocusChangeSignalType mFocusChangeSignal;
567 ResizeSignalType mResizeSignal;
568 VisibilityChangedSignalType mVisibilityChangedSignal;
569 TransitionEffectEventSignalType mTransitionEffectEventSignal;
572 } // namespace Adaptor
573 } // namepsace Internal
575 // Helpers for public-api forwarding methods
577 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
579 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
580 BaseObject& object = window.GetBaseObject();
581 return static_cast<Internal::Adaptor::Window&>(object);
584 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
586 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
587 const BaseObject& object = window.GetBaseObject();
588 return static_cast<const Internal::Adaptor::Window&>(object);
593 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H