1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
5 * Copyright (c) 2018 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>
26 #include <dali/internal/adaptor/common/lifecycle-observer.h>
27 #include <dali/internal/adaptor/common/adaptor-impl.h>
28 #include <dali/internal/window-system/common/indicator-interface.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/drag-and-drop-detector.h>
47 class WindowRenderSurface;
51 typedef IntrusivePtr<Window> WindowPtr;
52 typedef IntrusivePtr<Orientation> OrientationPtr;
55 * Window provides a surface to render onto with orientation & indicator properties.
57 class Window : public Dali::BaseObject, public IndicatorInterface::Observer, public LifeCycleObserver, public ConnectionTracker
60 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
61 typedef Dali::Window::FocusSignalType FocusSignalType;
62 typedef Dali::Window::ResizedSignalType ResizedSignalType;
63 typedef Signal< void () > SignalType;
66 * Create a new Window. This should only be called once by the Application class
67 * @param[in] positionSize The position and size of the window
68 * @param[in] name The window title
69 * @param[in] className The window class name
70 * @param[in] isTransparent Whether window is transparent
71 * @return A newly allocated Window
73 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
76 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
77 * @param[in] adaptor An initialized adaptor
79 void SetAdaptor(Dali::Adaptor& adaptor);
82 * Get the window surface
83 * @return The render surface
85 WindowRenderSurface* GetSurface();
88 * @copydoc Dali::Window::ShowIndicator()
90 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
93 * @copydoc Dali::Window::SetIndicatorBgOpacity()
95 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
98 * Set the indicator visible mode
100 void SetIndicatorVisibleMode( Dali::Window::IndicatorVisibleMode mode );
103 * @copydoc Dali::Window::RotateIndicator()
105 void RotateIndicator( Dali::Window::WindowOrientation orientation );
108 * @copydoc Dali::Window::SetClass()
110 void SetClass( std::string name, std::string className );
113 * @copydoc Dali::Window::Raise()
118 * @copydoc Dali::Window::Lower()
123 * @copydoc Dali::Window::Activate()
128 * @copydoc Dali::Window::AddAvailableOrientation()
130 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
133 * @copydoc Dali::Window::RemoveAvailableOrientation()
135 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
138 * @copydoc Dali::Window::SetAvailableOrientations()
140 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
143 * @copydoc Dali::Window::GetAvailableOrientations()
145 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
148 * @copydoc Dali::Window::SetPreferredOrientation()
150 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
153 * @copydoc Dali::Window::GetPreferredOrientation()
155 Dali::Window::WindowOrientation GetPreferredOrientation();
158 * @copydoc Dali::Window::GetDragAndDropDetector() const
160 Dali::DragAndDropDetector GetDragAndDropDetector() const;
163 * @copydoc Dali::Window::GetNativeHandle() const
165 Dali::Any GetNativeHandle() 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::IsVisible() const
190 bool IsVisible() const;
193 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
195 unsigned int GetSupportedAuxiliaryHintCount() const;
198 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
200 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
203 * @copydoc Dali::Window::AddAuxiliaryHint()
205 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
208 * @copydoc Dali::Window::RemoveAuxiliaryHint()
210 bool RemoveAuxiliaryHint( unsigned int id );
213 * @copydoc Dali::Window::SetAuxiliaryHintValue()
215 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
218 * @copydoc Dali::Window::GetAuxiliaryHintValue()
220 std::string GetAuxiliaryHintValue( unsigned int id ) const;
223 * @copydoc Dali::Window::GetAuxiliaryHintId()
225 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
228 * @copydoc Dali::Window::SetInputRegion()
230 void SetInputRegion( const Rect< int >& inputRegion );
233 * @copydoc Dali::Window::SetType()
235 void SetType( Dali::Window::Type type );
238 * @copydoc Dali::Window::GetType() const
240 Dali::Window::Type GetType() const;
243 * @copydoc Dali::Window::SetNotificationLevel()
245 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
248 * @copydoc Dali::Window::GetNotificationLevel()
250 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
253 * @copydoc Dali::Window::SetOpaqueState()
255 void SetOpaqueState( bool opaque );
258 * @copydoc Dali::Window::IsOpaqueState()
260 bool IsOpaqueState() const;
263 * @copydoc Dali::Window::SetScreenOffMode()
265 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
268 * @copydoc Dali::Window::GetScreenOffMode()
270 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
273 * @copydoc Dali::Window::SetBrightness()
275 bool SetBrightness( int brightness );
278 * @copydoc Dali::Window::GetBrightness()
280 int GetBrightness() const;
283 * @copydoc Dali::Window::SetSize()
285 void SetSize( Dali::Window::WindowSize size );
288 * @copydoc Dali::Window::GetSize()
290 Dali::Window::WindowSize GetSize() const;
293 * @copydoc Dali::Window::SetPosition()
295 void SetPosition( Dali::Window::WindowPosition position );
298 * @copydoc Dali::Window::GetPosition()
300 Dali::Window::WindowPosition GetPosition() const;
303 * @copydoc Dali::DevelWindow::SetPositionSize()
305 void SetPositionSize( PositionSize positionSize );
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 );
340 * Private constructor.
351 * Second stage initialization
353 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
356 * Shows / hides the indicator bar.
357 * Handles close/open if rotation changes whilst hidden
359 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
362 * Close current indicator and open a connection onto the new indicator service.
363 * Effect may not be synchronous if waiting for an indicator update on existing connection.
365 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
368 * Change the indicator actor's rotation to match the current orientation
370 void SetIndicatorActorRotation();
373 * Set the indicator properties on the window
375 void SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation );
378 * Called when the window becomes iconified or deiconified.
380 void OnIconifyChanged( bool iconified );
383 * Called when the window focus is changed.
385 void OnFocusChanged( bool focusIn );
388 * Called when the output is transformed.
390 void OnOutputTransformed();
393 * Called when the window receives a delete request.
395 void OnDeleteRequest();
398 * Called when the Ecore indicator event is received.
400 void OnIndicatorFlicked();
402 private: // IndicatorInterface::Observer interface
405 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorTypeChanged()
407 virtual void IndicatorTypeChanged( IndicatorInterface::Type type );
410 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorClosed()
412 virtual void IndicatorClosed( IndicatorInterface* indicator);
415 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorVisibilityChanged()
417 virtual void IndicatorVisibilityChanged( bool isVisible );
419 private: // Adaptor::Observer interface
422 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
424 virtual void OnStart();
427 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
429 virtual void OnPause();
432 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
434 virtual void OnResume();
437 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
439 virtual void OnStop();
442 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
444 virtual void OnDestroy();
449 * The user should connect to this signal to get a timing when indicator was shown / hidden.
451 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
454 * @copydoc Dali::Window::FocusChangedSignal()
456 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
459 * @copydoc Dali::Window::ResizedSignal()
461 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
464 * This signal is emitted when the window is requesting to be deleted
466 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
470 WindowRenderSurface* mSurface;
471 WindowBase* mWindowBase;
472 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
473 bool mIndicatorIsShown:1; ///< private state
474 bool mShowRotatedIndicatorOnClose:1;
476 bool mIsTransparent:1;
477 bool mIsFocusAcceptable:1;
481 bool mResizeEnabled:1;
482 std::unique_ptr< IndicatorInterface > mIndicator;
483 Dali::Window::WindowOrientation mIndicatorOrientation;
484 Dali::Window::WindowOrientation mNextIndicatorOrientation;
485 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
486 Integration::SystemOverlay* mOverlay;
488 Dali::DragAndDropDetector mDragAndDropDetector;
489 Dali::Window::Type mType;
491 OrientationPtr mOrientation;
492 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
493 Dali::Window::WindowOrientation mPreferredOrientation;
496 IndicatorSignalType mIndicatorVisibilityChangedSignal;
497 FocusSignalType mFocusChangedSignal;
498 ResizedSignalType mResizedSignal;
499 SignalType mDeleteRequestSignal;
502 } // namespace Adaptor
503 } // namepsace Internal
505 // Helpers for public-api forwarding methods
507 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
509 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
510 BaseObject& object = window.GetBaseObject();
511 return static_cast<Internal::Adaptor::Window&>(object);
514 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
516 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
517 const BaseObject& object = window.GetBaseObject();
518 return static_cast<const Internal::Adaptor::Window&>(object);
523 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H