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();
340 public: // Dali::Internal::Adaptor::SceneHolder
343 * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
345 Dali::Any GetNativeHandle() const override;
348 * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible
350 bool IsVisible() const override;
355 * @brief Enumeration for orietation mode.
356 * The Orientation Mode is related to screen size.
357 * If screen width is longer than height, the Orientation Mode will have LANDSCAPE.
358 * Otherwise screen width is shorter than height or same, the Orientation Mode will have PORTRAIT.
360 enum class OrientationMode
367 * Private constructor.
378 * Second stage initialization
380 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
383 * Called when the window becomes iconified or deiconified.
385 void OnIconifyChanged( bool iconified );
388 * Called when the window focus is changed.
390 void OnFocusChanged( bool focusIn );
393 * Called when the output is transformed.
395 void OnOutputTransformed();
398 * Called when the window receives a delete request.
400 void OnDeleteRequest();
403 * Called when the window receives a Transition effect-start/end event.
405 void OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type );
408 * @brief Set available orientation to window base.
410 void SetAvailableAnlges( const std::vector< int >& angles );
413 * @brief Convert from window orientation to angle using OrientationMode.
415 int ConvertToAngle( Dali::Window::WindowOrientation orientation );
418 * @brief Convert from angle to window orientation using OrientationMode.
420 Dali::Window::WindowOrientation ConvertToOrientation( int angle );
422 private: // Dali::Internal::Adaptor::SceneHolder
425 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
427 void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
430 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
432 void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
435 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
437 void OnPause() override;
440 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
442 void OnResume() override;
445 * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
447 void RecalculateTouchPosition( Integration::Point& point ) override;
449 private: // Dali::Internal::Adaptor::EventHandler::Observer
452 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
454 void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
457 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
459 void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
462 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
464 void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
467 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
469 void OnRotation( const RotationEvent& rotation ) override;
474 * The user should connect to this signal to get a timing when indicator was shown / hidden.
476 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
479 * @copydoc Dali::Window::FocusChangedSignal()
481 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
484 * @copydoc Dali::Window::WindowFocusChangedSignal()
486 FocusChangeSignalType& FocusChangeSignal() { return mFocusChangeSignal; }
488 * @copydoc Dali::Window::ResizedSignal()
490 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
493 * @copydoc Dali::Window::ResizedSignal()
495 ResizeSignalType& ResizeSignal() { return mResizeSignal; }
498 * This signal is emitted when the window is requesting to be deleted
500 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
503 * @copydoc Dali::DevelWindow::VisibilityChangedSignal()
505 VisibilityChangedSignalType& VisibilityChangedSignal() { return mVisibilityChangedSignal; }
508 * @copydoc Dali::Window::SignalEventProcessingFinished()
510 Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); }
513 * @copydoc Dali::DevelWindow::TransitionEffectEventSignal()
515 TransitionEffectEventSignalType& TransitionEffectEventSignal() { return mTransitionEffectEventSignal; }
519 WindowRenderSurface* mWindowSurface; ///< The window rendering surface
520 WindowBase* mWindowBase;
522 std::string mClassName;
523 bool mIsTransparent:1;
524 bool mIsFocusAcceptable:1;
527 bool mResizeEnabled:1;
528 Dali::Window::Type mType;
529 Dali::Window mParentWindow;
531 OrientationPtr mOrientation;
532 std::vector< int > mAvailableAngles;
535 int mRotationAngle; ///< The angle of the rotation
536 int mWindowWidth; ///< The width of the window
537 int mWindowHeight; ///< The height of the window
539 EventHandlerPtr mEventHandler; ///< The window events handler
541 OrientationMode mOrientationMode;
544 IndicatorSignalType mIndicatorVisibilityChangedSignal;
545 FocusSignalType mFocusChangedSignal;
546 ResizedSignalType mResizedSignal;
547 SignalType mDeleteRequestSignal;
548 FocusChangeSignalType mFocusChangeSignal;
549 ResizeSignalType mResizeSignal;
550 VisibilityChangedSignalType mVisibilityChangedSignal;
551 TransitionEffectEventSignalType mTransitionEffectEventSignal;
554 } // namespace Adaptor
555 } // namepsace Internal
557 // Helpers for public-api forwarding methods
559 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
561 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
562 BaseObject& object = window.GetBaseObject();
563 return static_cast<Internal::Adaptor::Window&>(object);
566 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
568 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
569 const BaseObject& object = window.GetBaseObject();
570 return static_cast<const Internal::Adaptor::Window&>(object);
575 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H