1 #ifndef __DALI_INTERNAL_WINDOW_H__
2 #define __DALI_INTERNAL_WINDOW_H__
5 * Copyright (c) 2017 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 <base/lifecycle-observer.h>
27 #include <base/interfaces/indicator-interface.h>
28 #include <adaptor-impl.h>
30 #include <orientation.h>
31 #include <render-surface.h>
32 #include <drag-and-drop-detector.h>
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
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 RenderSurface* 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 * @copydoc Dali::Window::RotateIndicator()
100 void RotateIndicator( Dali::Window::WindowOrientation orientation );
103 * @copydoc Dali::Window::SetClass()
105 void SetClass( std::string name, std::string klass );
108 * @copydoc Dali::Window::Raise()
113 * @copydoc Dali::Window::Lower()
118 * @copydoc Dali::Window::Activate()
123 * @copydoc Dali::Window::AddAvailableOrientation()
125 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
128 * @copydoc Dali::Window::RemoveAvailableOrientation()
130 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
133 * @copydoc Dali::Window::SetAvailableOrientations()
135 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
138 * @copydoc Dali::Window::GetAvailableOrientations()
140 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
143 * @copydoc Dali::Window::SetPreferredOrientation()
145 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
148 * @copydoc Dali::Window::GetPreferredOrientation()
150 Dali::Window::WindowOrientation GetPreferredOrientation();
153 * @copydoc Dali::Window::GetDragAndDropDetector() const
155 Dali::DragAndDropDetector GetDragAndDropDetector() const;
158 * @copydoc Dali::Window::GetNativeHandle() const
160 Dali::Any GetNativeHandle() const;
163 * @copydoc Dali::Window::SetAcceptFocus()
165 void SetAcceptFocus( bool accept );
168 * @copydoc Dali::Window::IsFocusAcceptable()
170 bool IsFocusAcceptable() const;
173 * @copydoc Dali::Window::Show()
178 * @copydoc Dali::Window::Hide()
183 * @copydoc Dali::Window::IsVisible() const
185 bool IsVisible() const;
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::Window::SetTransparency()
300 void SetTransparency( bool transparent );
303 * Called from Orientation after the Change signal has been sent
305 void RotationDone( int orientation, int width, int height );
308 * Set the indicator visible mode
310 void SetIndicatorVisibleMode( Dali::Window::IndicatorVisibleMode mode );
314 * Private constructor.
325 * Second stage initialization
327 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
330 * Shows / hides the indicator bar.
331 * Handles close/open if rotation changes whilst hidden
333 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
336 * Close current indicator and open a connection onto the new indicator service.
337 * Effect may not be synchronous if waiting for an indicator update on existing connection.
339 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
342 * Change the indicator actor's rotation to match the current orientation
344 void SetIndicatorActorRotation();
347 * Set the indicator properties on the window
349 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
351 private: // IndicatorInterface::Observer interface
354 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorTypeChanged()
356 virtual void IndicatorTypeChanged( IndicatorInterface::Type type );
359 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorClosed()
361 virtual void IndicatorClosed( IndicatorInterface* indicator);
364 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorVisibilityChanged()
366 virtual void IndicatorVisibilityChanged( bool isVisible );
368 private: // Adaptor::Observer interface
371 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
373 virtual void OnStart();
376 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
378 virtual void OnPause();
381 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
383 virtual void OnResume();
386 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
388 virtual void OnStop();
391 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
393 virtual void OnDestroy();
398 * The user should connect to this signal to get a timing when indicator was shown / hidden.
400 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
403 * @copydoc Dali::Window::FocusChangedSignal()
405 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
408 * @copydoc Dali::Window::ResizedSignal()
410 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
413 * This signal is emitted when the window is requesting to be deleted
415 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
419 typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
421 RenderSurface* mSurface;
422 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
423 bool mIndicatorIsShown:1; ///< private state
424 bool mShowRotatedIndicatorOnClose:1;
426 bool mIsTransparent:1;
427 bool mWMRotationAppSet:1;
428 bool mEcoreEventHander:1;
429 bool mIsFocusAcceptable:1;
433 bool mResizeEnabled:1;
434 IndicatorInterface* mIndicator;
435 Dali::Window::WindowOrientation mIndicatorOrientation;
436 Dali::Window::WindowOrientation mNextIndicatorOrientation;
437 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
438 Integration::SystemOverlay* mOverlay;
440 Dali::DragAndDropDetector mDragAndDropDetector;
441 Dali::Window::Type mType;
444 EventHandler* mEventHandler;
446 OrientationPtr mOrientation;
447 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
448 Dali::Window::WindowOrientation mPreferredOrientation;
450 std::vector< std::string > mSupportedAuxiliaryHints;
451 AuxiliaryHints mAuxiliaryHints;
454 IndicatorSignalType mIndicatorVisibilityChangedSignal;
455 FocusSignalType mFocusChangedSignal;
456 ResizedSignalType mResizedSignal;
457 SignalType mDeleteRequestSignal;
460 } // namespace Adaptor
461 } // namepsace Internal
463 // Helpers for public-api forwarding methods
465 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
467 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
468 BaseObject& object = window.GetBaseObject();
469 return static_cast<Internal::Adaptor::Window&>(object);
472 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
474 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
475 const BaseObject& object = window.GetBaseObject();
476 return static_cast<const Internal::Adaptor::Window&>(object);
482 #endif // __DALI_INTERNAL_WINDOW_H__