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>
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/window-devel.h>
31 #include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
32 #include <dali/internal/adaptor/common/adaptor-impl.h>
33 #include <dali/internal/window-system/common/event-handler.h>
39 class RenderSurfaceInterface;
46 class WindowRenderSurface;
50 using WindowPtr = IntrusivePtr< Window >;
51 using OrientationPtr = IntrusivePtr< Orientation >;
52 using EventHandlerPtr = IntrusivePtr< EventHandler >;
55 * Window provides a surface to render onto with orientation & indicator properties.
57 class Window : public Dali::Internal::Adaptor::SceneHolder, public EventHandler::Observer, public ConnectionTracker
60 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
61 typedef Dali::Window::FocusSignalType FocusSignalType;
62 typedef Dali::Window::ResizedSignalType ResizedSignalType;
63 typedef Dali::Window::FocusChangeSignalType FocusChangeSignalType;
64 typedef Dali::Window::ResizeSignalType ResizeSignalType;
65 typedef Dali::DevelWindow::VisibilityChangedSignalType VisibilityChangedSignalType;
66 typedef Dali::DevelWindow::TransitionEffectEventSignalType TransitionEffectEventSignalType;
67 typedef Signal< void () > SignalType;
70 * Create a new Window. This should only be called once by the Application class
71 * @param[in] positionSize The position and size of the window
72 * @param[in] name The window title
73 * @param[in] className The window class name
74 * @param[in] isTransparent Whether window is transparent
75 * @return A newly allocated Window
77 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
80 * @copydoc Dali::Window::ShowIndicator()
82 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
85 * @copydoc Dali::Window::SetIndicatorBgOpacity()
87 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
90 * @copydoc Dali::Window::RotateIndicator()
92 void RotateIndicator( Dali::Window::WindowOrientation orientation );
95 * @copydoc Dali::Window::SetClass()
97 void SetClass( std::string name, std::string className );
100 * @brief Gets the window class name.
101 * @return The class of the window
103 std::string GetClassName() const;
106 * @copydoc Dali::Window::Raise()
111 * @copydoc Dali::Window::Lower()
116 * @copydoc Dali::Window::Activate()
121 * @copydoc Dali::Window::GetLayerCount()
123 uint32_t GetLayerCount() const;
126 * @copydoc Dali::Window::GetLayer()
128 Dali::Layer GetLayer( uint32_t depth ) const;
131 * @copydoc Dali::DevelWindow::GetRenderTaskList()
133 Dali::RenderTaskList GetRenderTaskList() const;
136 * @copydoc Dali::Window::AddAvailableOrientation()
138 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
141 * @copydoc Dali::Window::RemoveAvailableOrientation()
143 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
146 * @copydoc Dali::Window::SetPreferredOrientation()
148 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
151 * @copydoc Dali::Window::GetPreferredOrientation()
153 Dali::Window::WindowOrientation GetPreferredOrientation();
156 * @copydoc Dali::Window::SetAcceptFocus()
158 void SetAcceptFocus( bool accept );
161 * @copydoc Dali::Window::IsFocusAcceptable()
163 bool IsFocusAcceptable() const;
166 * @copydoc Dali::Window::Show()
171 * @copydoc Dali::Window::Hide()
176 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
178 unsigned int GetSupportedAuxiliaryHintCount() const;
181 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
183 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
186 * @copydoc Dali::Window::AddAuxiliaryHint()
188 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
191 * @copydoc Dali::Window::RemoveAuxiliaryHint()
193 bool RemoveAuxiliaryHint( unsigned int id );
196 * @copydoc Dali::Window::SetAuxiliaryHintValue()
198 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
201 * @copydoc Dali::Window::GetAuxiliaryHintValue()
203 std::string GetAuxiliaryHintValue( unsigned int id ) const;
206 * @copydoc Dali::Window::GetAuxiliaryHintId()
208 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
211 * @copydoc Dali::Window::SetInputRegion()
213 void SetInputRegion( const Rect< int >& inputRegion );
216 * @copydoc Dali::Window::SetType()
218 void SetType( Dali::Window::Type type );
221 * @copydoc Dali::Window::GetType() const
223 Dali::Window::Type GetType() const;
226 * @copydoc Dali::Window::SetNotificationLevel()
228 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
231 * @copydoc Dali::Window::GetNotificationLevel()
233 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
236 * @copydoc Dali::Window::SetOpaqueState()
238 void SetOpaqueState( bool opaque );
241 * @copydoc Dali::Window::IsOpaqueState()
243 bool IsOpaqueState() const;
246 * @copydoc Dali::Window::SetScreenOffMode()
248 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
251 * @copydoc Dali::Window::GetScreenOffMode()
253 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
256 * @copydoc Dali::Window::SetBrightness()
258 bool SetBrightness( int brightness );
261 * @copydoc Dali::Window::GetBrightness()
263 int GetBrightness() const;
266 * @copydoc Dali::Window::SetSize()
268 void SetSize( Dali::Window::WindowSize size );
271 * @copydoc Dali::Window::GetSize()
273 Dali::Window::WindowSize GetSize() const;
276 * @copydoc Dali::Window::SetPosition()
278 void SetPosition( Dali::Window::WindowPosition position );
281 * @copydoc Dali::Window::GetPosition()
283 Dali::Window::WindowPosition GetPosition() const;
286 * @copydoc Dali::DevelWindow::SetPositionSize()
288 void SetPositionSize( PositionSize positionSize );
291 * @copydoc Dali::Window::GetRootLayer()
293 Dali::Layer GetRootLayer() const;
296 * @copydoc Dali::Window::SetTransparency()
298 void SetTransparency( bool transparent );
301 * @copydoc Dali::KeyGrab::GrabKey()
303 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
306 * @copydoc Dali::KeyGrab::UngrabKey()
308 bool UngrabKey( Dali::KEY key );
311 * @copydoc Dali::KeyGrab::GrabKeyList()
313 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
316 * @copydoc Dali::KeyGrab::UngrabKeyList()
318 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
321 * @copydoc Dali::DevelWindow::Get()
323 static Dali::Window Get( Dali::Actor actor );
326 * @copydoc Dali::DevelWindow::SetParent()
328 void SetParent( Dali::Window& parent );
331 * @copydoc Dali::DevelWindow::Unparent()
336 * @copydoc Dali::DevelWindow::GetParent()
338 Dali::Window GetParent();
341 * @copydoc Dali::DevelWindow::GetCurrentOrientation()
343 Dali::Window::WindowOrientation GetCurrentOrientation() const;
345 public: // Dali::Internal::Adaptor::SceneHolder
348 * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
350 Dali::Any GetNativeHandle() const override;
353 * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible
355 bool IsVisible() const override;
360 * @brief Enumeration for orietation mode.
361 * The Orientation Mode is related to screen size.
362 * If screen width is longer than height, the Orientation Mode will have LANDSCAPE.
363 * Otherwise screen width is shorter than height or same, the Orientation Mode will have PORTRAIT.
365 enum class OrientationMode
372 * Private constructor.
383 * Second stage initialization
385 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
388 * Called when the window becomes iconified or deiconified.
390 void OnIconifyChanged( bool iconified );
393 * Called when the window focus is changed.
395 void OnFocusChanged( bool focusIn );
398 * Called when the output is transformed.
400 void OnOutputTransformed();
403 * Called when the window receives a delete request.
405 void OnDeleteRequest();
408 * Called when the window receives a Transition effect-start/end event.
410 void OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type );
413 * @brief Set available orientation to window base.
415 void SetAvailableAnlges( const std::vector< int >& angles );
418 * @brief Convert from window orientation to angle using OrientationMode.
420 int ConvertToAngle( Dali::Window::WindowOrientation orientation );
423 * @brief Convert from angle to window orientation using OrientationMode.
425 Dali::Window::WindowOrientation ConvertToOrientation( int angle ) const;
428 * @brief Check available window orientation for Available orientation.
430 bool IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const;
432 private: // Dali::Internal::Adaptor::SceneHolder
435 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
437 void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
440 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
442 void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
445 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
447 void OnPause() override;
450 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
452 void OnResume() override;
455 * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
457 void RecalculateTouchPosition( Integration::Point& point ) override;
459 private: // Dali::Internal::Adaptor::EventHandler::Observer
462 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
464 void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
467 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
469 void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
472 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
474 void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
477 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
479 void OnRotation( const RotationEvent& rotation ) override;
484 * The user should connect to this signal to get a timing when indicator was shown / hidden.
486 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
489 * @copydoc Dali::Window::FocusChangedSignal()
491 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
494 * @copydoc Dali::Window::WindowFocusChangedSignal()
496 FocusChangeSignalType& FocusChangeSignal() { return mFocusChangeSignal; }
498 * @copydoc Dali::Window::ResizedSignal()
500 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
503 * @copydoc Dali::Window::ResizedSignal()
505 ResizeSignalType& ResizeSignal() { return mResizeSignal; }
508 * This signal is emitted when the window is requesting to be deleted
510 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
513 * @copydoc Dali::DevelWindow::VisibilityChangedSignal()
515 VisibilityChangedSignalType& VisibilityChangedSignal() { return mVisibilityChangedSignal; }
518 * @copydoc Dali::Window::SignalEventProcessingFinished()
520 Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); }
523 * @copydoc Dali::DevelWindow::TransitionEffectEventSignal()
525 TransitionEffectEventSignalType& TransitionEffectEventSignal() { return mTransitionEffectEventSignal; }
529 WindowRenderSurface* mWindowSurface; ///< The window rendering surface
530 WindowBase* mWindowBase;
532 std::string mClassName;
533 bool mIsTransparent:1;
534 bool mIsFocusAcceptable:1;
537 bool mResizeEnabled:1;
538 Dali::Window::Type mType;
539 Dali::Window mParentWindow;
541 OrientationPtr mOrientation;
542 std::vector< int > mAvailableAngles;
545 int mRotationAngle; ///< The angle of the rotation
546 int mWindowWidth; ///< The width of the window
547 int mWindowHeight; ///< The height of the window
549 EventHandlerPtr mEventHandler; ///< The window events handler
551 OrientationMode mOrientationMode;
553 int mNativeWindowId; ///< The Native Window Id
556 IndicatorSignalType mIndicatorVisibilityChangedSignal;
557 FocusSignalType mFocusChangedSignal;
558 ResizedSignalType mResizedSignal;
559 SignalType mDeleteRequestSignal;
560 FocusChangeSignalType mFocusChangeSignal;
561 ResizeSignalType mResizeSignal;
562 VisibilityChangedSignalType mVisibilityChangedSignal;
563 TransitionEffectEventSignalType mTransitionEffectEventSignal;
566 } // namespace Adaptor
567 } // namepsace Internal
569 // Helpers for public-api forwarding methods
571 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
573 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
574 BaseObject& object = window.GetBaseObject();
575 return static_cast<Internal::Adaptor::Window&>(object);
578 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
580 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
581 const BaseObject& object = window.GetBaseObject();
582 return static_cast<const Internal::Adaptor::Window&>(object);
587 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H