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/public-api/adaptor-framework/window.h>
35 #include <dali/public-api/adaptor-framework/key-grab.h>
36 #include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
37 #include <dali/devel-api/adaptor-framework/window-devel.h>
43 class RenderSurfaceInterface;
51 class RotationObserver;
52 class WindowRenderSurface;
56 using WindowPtr = IntrusivePtr< Window >;
57 using OrientationPtr = IntrusivePtr< Orientation >;
58 using EventHandlerPtr = IntrusivePtr< EventHandler >;
61 * Window provides a surface to render onto with orientation & indicator properties.
63 class Window : public Dali::Internal::Adaptor::SceneHolder, public ConnectionTracker
66 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
67 typedef Dali::Window::FocusSignalType FocusSignalType;
68 typedef Dali::Window::ResizedSignalType ResizedSignalType;
69 typedef Signal< void () > SignalType;
72 * Create a new Window. This should only be called once by the Application class
73 * @param[in] positionSize The position and size of the window
74 * @param[in] name The window title
75 * @param[in] className The window class name
76 * @param[in] isTransparent Whether window is transparent
77 * @return A newly allocated Window
79 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
82 * @copydoc Dali::Window::ShowIndicator()
84 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
87 * @copydoc Dali::Window::SetIndicatorBgOpacity()
89 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
92 * @copydoc Dali::Window::RotateIndicator()
94 void RotateIndicator( Dali::Window::WindowOrientation orientation );
97 * @copydoc Dali::Window::SetClass()
99 void SetClass( std::string name, std::string className );
102 * @brief Gets the window class name.
103 * @return The class of the window
105 std::string GetClassName() const;
108 * @copydoc Dali::Window::Raise()
113 * @copydoc Dali::Window::Lower()
118 * @copydoc Dali::Window::Activate()
123 * @copydoc Dali::Window::GetLayerCount()
125 uint32_t GetLayerCount() const;
128 * @copydoc Dali::Window::GetLayer()
130 Dali::Layer GetLayer( uint32_t depth ) const;
133 * @copydoc Dali::Window::AddAvailableOrientation()
135 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
138 * @copydoc Dali::Window::RemoveAvailableOrientation()
140 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
143 * @copydoc Dali::Window::SetAvailableOrientations()
145 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
148 * @copydoc Dali::Window::GetAvailableOrientations()
150 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
153 * @copydoc Dali::Window::SetPreferredOrientation()
155 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
158 * @copydoc Dali::Window::GetPreferredOrientation()
160 Dali::Window::WindowOrientation GetPreferredOrientation();
163 * @copydoc Dali::Window::GetDragAndDropDetector() const
165 Dali::DragAndDropDetector GetDragAndDropDetector() const;
168 * @copydoc Dali::Window::SetAcceptFocus()
170 void SetAcceptFocus( bool accept );
173 * @copydoc Dali::Window::IsFocusAcceptable()
175 bool IsFocusAcceptable() const;
178 * @copydoc Dali::Window::Show()
183 * @copydoc Dali::Window::Hide()
188 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
190 unsigned int GetSupportedAuxiliaryHintCount() const;
193 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
195 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
198 * @copydoc Dali::Window::AddAuxiliaryHint()
200 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
203 * @copydoc Dali::Window::RemoveAuxiliaryHint()
205 bool RemoveAuxiliaryHint( unsigned int id );
208 * @copydoc Dali::Window::SetAuxiliaryHintValue()
210 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
213 * @copydoc Dali::Window::GetAuxiliaryHintValue()
215 std::string GetAuxiliaryHintValue( unsigned int id ) const;
218 * @copydoc Dali::Window::GetAuxiliaryHintId()
220 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
223 * @copydoc Dali::Window::SetInputRegion()
225 void SetInputRegion( const Rect< int >& inputRegion );
228 * @copydoc Dali::Window::SetType()
230 void SetType( Dali::Window::Type type );
233 * @copydoc Dali::Window::GetType() const
235 Dali::Window::Type GetType() const;
238 * @copydoc Dali::Window::SetNotificationLevel()
240 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
243 * @copydoc Dali::Window::GetNotificationLevel()
245 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
248 * @copydoc Dali::Window::SetOpaqueState()
250 void SetOpaqueState( bool opaque );
253 * @copydoc Dali::Window::IsOpaqueState()
255 bool IsOpaqueState() const;
258 * @copydoc Dali::Window::SetScreenOffMode()
260 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
263 * @copydoc Dali::Window::GetScreenOffMode()
265 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
268 * @copydoc Dali::Window::SetBrightness()
270 bool SetBrightness( int brightness );
273 * @copydoc Dali::Window::GetBrightness()
275 int GetBrightness() const;
278 * @copydoc Dali::Window::SetSize()
280 void SetSize( Dali::Window::WindowSize size );
283 * @copydoc Dali::Window::GetSize()
285 Dali::Window::WindowSize GetSize() const;
288 * @copydoc Dali::Window::SetPosition()
290 void SetPosition( Dali::Window::WindowPosition position );
293 * @copydoc Dali::Window::GetPosition()
295 Dali::Window::WindowPosition GetPosition() const;
298 * @copydoc Dali::DevelWindow::SetPositionSize()
300 void SetPositionSize( PositionSize positionSize );
303 * @copydoc Dali::Window::GetRootLayer()
305 Dali::Layer GetRootLayer() const;
308 * @copydoc Dali::Window::SetTransparency()
310 void SetTransparency( bool transparent );
313 * @copydoc Dali::KeyGrab::GrabKey()
315 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
318 * @copydoc Dali::KeyGrab::UngrabKey()
320 bool UngrabKey( Dali::KEY key );
323 * @copydoc Dali::KeyGrab::GrabKeyList()
325 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
328 * @copydoc Dali::KeyGrab::UngrabKeyList()
330 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
333 * Called from Orientation after the Change signal has been sent
335 void RotationDone( int orientation, int width, int height );
338 * Set the rotation observer (note, some adaptors may not have a rotation observer)
339 * @param[in] observer The rotation observer
340 * @return If the rotation observer is set
342 bool SetRotationObserver( RotationObserver* observer );
345 * @copydoc Dali::DevelWindow::Get()
347 static Dali::Window Get( Dali::Actor actor );
349 public: // Dali::Internal::Adaptor::SceneHolder
352 * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
354 Dali::Any GetNativeHandle() const override;
357 * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible
359 bool IsVisible() const override;
364 * Private constructor.
375 * Second stage initialization
377 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
380 * Called when the window becomes iconified or deiconified.
382 void OnIconifyChanged( bool iconified );
385 * Called when the window focus is changed.
387 void OnFocusChanged( bool focusIn );
390 * Called when the output is transformed.
392 void OnOutputTransformed();
395 * Called when the window receives a delete request.
397 void OnDeleteRequest();
399 private: // Dali::Internal::Adaptor::SceneHolder
402 * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedTouchPoint
404 void FeedTouchPoint( TouchPoint& point, int timeStamp ) override;
407 * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedWheelEvent
409 void FeedWheelEvent( WheelEvent& wheelEvent ) override;
412 * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedKeyEvent
414 void FeedKeyEvent( KeyEvent& keyEvent ) override;
417 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
419 void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
422 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
424 void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
427 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
429 void OnPause() override;
432 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
434 void OnResume() override;
439 * The user should connect to this signal to get a timing when indicator was shown / hidden.
441 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
444 * @copydoc Dali::Window::FocusChangedSignal()
446 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
449 * @copydoc Dali::Window::ResizedSignal()
451 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
454 * This signal is emitted when the window is requesting to be deleted
456 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
459 * @copydoc Dali::Window::SignalEventProcessingFinished()
461 Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); };
464 * @copydoc Dali::Window::KeyEventSignal()
466 Dali::DevelWindow::KeyEventSignalType& KeyEventSignal() { return mScene.KeyEventSignal(); };
469 * @copydoc Dali::Window::TouchSignal()
471 Dali::DevelWindow::TouchSignalType& TouchSignal() { return mScene.TouchSignal(); };
474 * @copydoc Dali::Window::WheelEventSignal()
476 Dali::DevelWindow::WheelEventSignalType& WheelEventSignal() { return mScene.WheelEventSignal(); };
480 WindowRenderSurface* mWindowSurface; ///< The window rendering surface
481 WindowBase* mWindowBase;
483 std::string mClassName;
484 bool mIsTransparent:1;
485 bool mIsFocusAcceptable:1;
488 bool mResizeEnabled:1;
489 Dali::DragAndDropDetector mDragAndDropDetector;
490 Dali::Window::Type mType;
492 OrientationPtr mOrientation;
493 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
494 Dali::Window::WindowOrientation mPreferredOrientation;
496 EventHandlerPtr mEventHandler; ///< The window events handler
499 IndicatorSignalType mIndicatorVisibilityChangedSignal;
500 FocusSignalType mFocusChangedSignal;
501 ResizedSignalType mResizedSignal;
502 SignalType mDeleteRequestSignal;
507 } // namespace Adaptor
508 } // namepsace Internal
510 // Helpers for public-api forwarding methods
512 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
514 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
515 BaseObject& object = window.GetBaseObject();
516 return static_cast<Internal::Adaptor::Window&>(object);
519 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
521 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
522 const BaseObject& object = window.GetBaseObject();
523 return static_cast<const Internal::Adaptor::Window&>(object);
528 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H