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 Dali::Window::FocusChangeSignalType FocusChangeSignalType;
69 typedef Dali::Window::ResizeSignalType ResizeSignalType;
70 typedef Dali::DevelWindow::TransitionEffectEventSignalType TransitionEffectEventSignalType;
71 typedef Signal< void () > SignalType;
74 * Create a new Window. This should only be called once by the Application class
75 * @param[in] positionSize The position and size of the window
76 * @param[in] name The window title
77 * @param[in] className The window class name
78 * @param[in] isTransparent Whether window is transparent
79 * @return A newly allocated Window
81 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
84 * @copydoc Dali::Window::ShowIndicator()
86 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
89 * @copydoc Dali::Window::SetIndicatorBgOpacity()
91 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
94 * @copydoc Dali::Window::RotateIndicator()
96 void RotateIndicator( Dali::Window::WindowOrientation orientation );
99 * @copydoc Dali::Window::SetClass()
101 void SetClass( std::string name, std::string className );
104 * @brief Gets the window class name.
105 * @return The class of the window
107 std::string GetClassName() const;
110 * @copydoc Dali::Window::Raise()
115 * @copydoc Dali::Window::Lower()
120 * @copydoc Dali::Window::Activate()
125 * @copydoc Dali::Window::GetLayerCount()
127 uint32_t GetLayerCount() const;
130 * @copydoc Dali::Window::GetLayer()
132 Dali::Layer GetLayer( uint32_t depth ) const;
135 * @copydoc Dali::DevelWindow::GetRenderTaskList()
137 Dali::RenderTaskList GetRenderTaskList() const;
140 * @copydoc Dali::Window::AddAvailableOrientation()
142 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
145 * @copydoc Dali::Window::RemoveAvailableOrientation()
147 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
150 * @copydoc Dali::Window::SetAvailableOrientations()
152 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
155 * @copydoc Dali::Window::GetAvailableOrientations()
157 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
160 * @copydoc Dali::Window::SetPreferredOrientation()
162 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
165 * @copydoc Dali::Window::GetPreferredOrientation()
167 Dali::Window::WindowOrientation GetPreferredOrientation();
170 * @copydoc Dali::Window::SetAcceptFocus()
172 void SetAcceptFocus( bool accept );
175 * @copydoc Dali::Window::IsFocusAcceptable()
177 bool IsFocusAcceptable() const;
180 * @copydoc Dali::Window::Show()
185 * @copydoc Dali::Window::Hide()
190 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
192 unsigned int GetSupportedAuxiliaryHintCount() const;
195 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
197 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
200 * @copydoc Dali::Window::AddAuxiliaryHint()
202 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
205 * @copydoc Dali::Window::RemoveAuxiliaryHint()
207 bool RemoveAuxiliaryHint( unsigned int id );
210 * @copydoc Dali::Window::SetAuxiliaryHintValue()
212 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
215 * @copydoc Dali::Window::GetAuxiliaryHintValue()
217 std::string GetAuxiliaryHintValue( unsigned int id ) const;
220 * @copydoc Dali::Window::GetAuxiliaryHintId()
222 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
225 * @copydoc Dali::Window::SetInputRegion()
227 void SetInputRegion( const Rect< int >& inputRegion );
230 * @copydoc Dali::Window::SetType()
232 void SetType( Dali::Window::Type type );
235 * @copydoc Dali::Window::GetType() const
237 Dali::Window::Type GetType() const;
240 * @copydoc Dali::Window::SetNotificationLevel()
242 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
245 * @copydoc Dali::Window::GetNotificationLevel()
247 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
250 * @copydoc Dali::Window::SetOpaqueState()
252 void SetOpaqueState( bool opaque );
255 * @copydoc Dali::Window::IsOpaqueState()
257 bool IsOpaqueState() const;
260 * @copydoc Dali::Window::SetScreenOffMode()
262 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
265 * @copydoc Dali::Window::GetScreenOffMode()
267 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
270 * @copydoc Dali::Window::SetBrightness()
272 bool SetBrightness( int brightness );
275 * @copydoc Dali::Window::GetBrightness()
277 int GetBrightness() const;
280 * @copydoc Dali::Window::SetSize()
282 void SetSize( Dali::Window::WindowSize size );
285 * @copydoc Dali::Window::GetSize()
287 Dali::Window::WindowSize GetSize() const;
290 * @copydoc Dali::Window::SetPosition()
292 void SetPosition( Dali::Window::WindowPosition position );
295 * @copydoc Dali::Window::GetPosition()
297 Dali::Window::WindowPosition GetPosition() const;
300 * @copydoc Dali::DevelWindow::SetPositionSize()
302 void SetPositionSize( PositionSize positionSize );
305 * @copydoc Dali::Window::GetRootLayer()
307 Dali::Layer GetRootLayer() const;
310 * @copydoc Dali::Window::SetTransparency()
312 void SetTransparency( bool transparent );
315 * @copydoc Dali::KeyGrab::GrabKey()
317 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
320 * @copydoc Dali::KeyGrab::UngrabKey()
322 bool UngrabKey( Dali::KEY key );
325 * @copydoc Dali::KeyGrab::GrabKeyList()
327 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
330 * @copydoc Dali::KeyGrab::UngrabKeyList()
332 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
335 * @copydoc Dali::DevelWindow::Get()
337 static Dali::Window Get( Dali::Actor actor );
340 * @copydoc Dali::DevelWindow::SetParent()
342 void SetParent( Dali::Window& parent );
345 * @copydoc Dali::DevelWindow::Unparent()
350 * @copydoc Dali::DevelWindow::GetParent()
352 Dali::Window GetParent();
354 public: // Dali::Internal::Adaptor::SceneHolder
357 * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
359 Dali::Any GetNativeHandle() const override;
362 * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible
364 bool IsVisible() const override;
369 * Private constructor.
380 * Second stage initialization
382 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
385 * Called when the window becomes iconified or deiconified.
387 void OnIconifyChanged( bool iconified );
390 * Called when the window focus is changed.
392 void OnFocusChanged( bool focusIn );
395 * Called when the output is transformed.
397 void OnOutputTransformed();
400 * Called when the window receives a delete request.
402 void OnDeleteRequest();
405 * Called when the window receives a Transition effect-start/end event.
407 void OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type );
409 private: // Dali::Internal::Adaptor::SceneHolder
412 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
414 void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
417 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
419 void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
422 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
424 void OnPause() override;
427 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
429 void OnResume() override;
432 * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
434 void RecalculateTouchPosition( Integration::Point& point ) override;
436 private: // Dali::Internal::Adaptor::EventHandler::Observer
439 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
441 void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
444 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
446 void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
449 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
451 void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
454 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
456 void OnRotation( const RotationEvent& rotation ) override;
461 * The user should connect to this signal to get a timing when indicator was shown / hidden.
463 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
466 * @copydoc Dali::Window::FocusChangedSignal()
468 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
471 * @copydoc Dali::Window::WindowFocusChangedSignal()
473 FocusChangeSignalType& FocusChangeSignal() { return mFocusChangeSignal; }
475 * @copydoc Dali::Window::ResizedSignal()
477 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
479 * @copydoc Dali::Window::ResizedSignal()
481 ResizeSignalType& ResizeSignal() { return mResizeSignal; }
484 * This signal is emitted when the window is requesting to be deleted
486 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
489 * @copydoc Dali::Window::SignalEventProcessingFinished()
491 Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); }
494 * @copydoc Dali::DevelWindow::TransitionEffectEventSignal()
496 TransitionEffectEventSignalType& TransitionEffectEventSignal() { return mTransitionEffectEventSignal; }
500 WindowRenderSurface* mWindowSurface; ///< The window rendering surface
501 WindowBase* mWindowBase;
503 std::string mClassName;
504 bool mIsTransparent:1;
505 bool mIsFocusAcceptable:1;
508 bool mResizeEnabled:1;
509 Dali::Window::Type mType;
510 Dali::Window mParentWindow;
512 OrientationPtr mOrientation;
513 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
514 Dali::Window::WindowOrientation mPreferredOrientation;
516 int mRotationAngle; ///< The angle of the rotation
517 int mWindowWidth; ///< The width of the window
518 int mWindowHeight; ///< The height of the window
520 EventHandlerPtr mEventHandler; ///< The window events handler
523 IndicatorSignalType mIndicatorVisibilityChangedSignal;
524 FocusSignalType mFocusChangedSignal;
525 ResizedSignalType mResizedSignal;
526 SignalType mDeleteRequestSignal;
527 FocusChangeSignalType mFocusChangeSignal;
528 ResizeSignalType mResizeSignal;
529 TransitionEffectEventSignalType mTransitionEffectEventSignal;
532 } // namespace Adaptor
533 } // namepsace Internal
535 // Helpers for public-api forwarding methods
537 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
539 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
540 BaseObject& object = window.GetBaseObject();
541 return static_cast<Internal::Adaptor::Window&>(object);
544 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
546 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
547 const BaseObject& object = window.GetBaseObject();
548 return static_cast<const Internal::Adaptor::Window&>(object);
553 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H