1 #ifndef __DALI_INTERNAL_WINDOW_H__
2 #define __DALI_INTERNAL_WINDOW_H__
5 * Copyright (c) 2014 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 <adaptor-impl.h>
28 #include <indicator-impl.h>
30 #include <orientation.h>
31 #include <render-surface.h>
32 #include <drag-and-drop-detector.h>
52 typedef IntrusivePtr<Window> WindowPtr;
53 typedef IntrusivePtr<Orientation> OrientationPtr;
56 * Window provides a surface to render onto with orientation & indicator properties.
58 class Window : public Dali::BaseObject, public Indicator::Observer, public LifeCycleObserver
61 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
64 * Create a new Window. This should only be called once by the Application class
65 * @param[in] windowPosition The position and size of the window
66 * @param[in] name The window title
67 * @param[in] isTransparent Whether window is transparent
68 * @return A newly allocated Window
70 static Window* New(const PositionSize& posSize, const std::string& name, bool isTransparent = false);
73 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
74 * @param[in] adaptor An initialized adaptor
76 void SetAdaptor(Dali::Adaptor& adaptor);
79 * Get the window surface
80 * @return The render surface
82 RenderSurface* GetSurface();
85 * @copydoc Dali::Window::ShowIndicator()
87 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
90 * @copydoc Dali::Window::SetIndicatorBgOpacity()
92 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
95 * @copydoc Dali::Window::RotateIndicator()
97 void RotateIndicator( Dali::Window::WindowOrientation orientation );
100 * @copydoc Dali::Window::SetClass()
102 void SetClass( std::string name, std::string klass );
105 * @copydoc Dali::Window::Raise()
110 * @copydoc Dali::Window::Lower()
115 * @copydoc Dali::Window::Activate()
120 * @copydoc Dali::Window::GetOrientation()
122 OrientationPtr GetOrientation();
125 * @copydoc Dali::Window::AddAvailableOrientation()
127 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
130 * @copydoc Dali::Window::RemoveAvailableOrientation()
132 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
135 * @copydoc Dali::Window::SetAvailableOrientations()
137 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
140 * @copydoc Dali::Window::GetAvailableOrientations()
142 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
145 * @copydoc Dali::Window::SetPreferredOrientation()
147 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
150 * @copydoc Dali::Window::GetPreferredOrientation()
152 Dali::Window::WindowOrientation GetPreferredOrientation();
155 * @copydoc Dali::Window::GetDragAndDropDetector() const
157 Dali::DragAndDropDetector GetDragAndDropDetector() const;
160 * @copydoc Dali::Window::GetNativeHandle() const
162 Dali::Any GetNativeHandle() const;
165 * Called from Orientation after the Change signal has been sent
167 void RotationDone( int orientation, int width, int height );
171 * Private constructor.
182 * Second stage initialization
184 void Initialize(const PositionSize& posSize, const std::string& name);
187 * Shows / hides the indicator bar.
188 * Handles close/open if rotation changes whilst hidden
190 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
193 * Close current indicator and open a connection onto the new indicator service.
194 * Effect may not be synchronous if waiting for an indicator update on existing connection.
196 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
199 * Change the indicator actor's rotation to match the current orientation
201 void SetIndicatorActorRotation();
204 * Set the indicator properties on the window
206 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
208 private: // Indicator::Observer interface
211 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorTypeChanged()
213 virtual void IndicatorTypeChanged( Indicator::Type type );
216 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorClosed()
218 virtual void IndicatorClosed(Indicator* indicator);
221 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorVisibilityChanged()
223 virtual void IndicatorVisibilityChanged( bool isVisible );
225 private: // Adaptor::Observer interface
228 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
230 virtual void OnStart();
233 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
235 virtual void OnPause();
238 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
240 virtual void OnResume();
243 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
245 virtual void OnStop();
248 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
250 virtual void OnDestroy();
254 * The user should connect to this signal to get a timing when indicator was shown / hidden.
256 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
260 typedef std::vector<Indicator*> DiscardedIndicators;
262 RenderSurface* mSurface;
263 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
264 bool mIndicatorIsShown:1; ///< private state
265 bool mShowRotatedIndicatorOnClose:1;
267 bool mIsTransparent:1;
268 bool mWMRotationAppSet:1;
269 Indicator* mIndicator;
270 Dali::Window::WindowOrientation mIndicatorOrientation;
271 Dali::Window::WindowOrientation mNextIndicatorOrientation;
272 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
273 Integration::SystemOverlay* mOverlay;
275 Dali::DragAndDropDetector mDragAndDropDetector;
278 EventHandler* mEventHandler;
280 OrientationPtr mOrientation;
281 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
282 Dali::Window::WindowOrientation mPreferredOrientation;
285 IndicatorSignalType mIndicatorVisibilityChangedSignal;
288 } // namespace Adaptor
289 } // namepsace Internal
291 // Helpers for public-api forwarding methods
293 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
295 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
296 BaseObject& object = window.GetBaseObject();
297 return static_cast<Internal::Adaptor::Window&>(object);
300 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
302 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
303 const BaseObject& object = window.GetBaseObject();
304 return static_cast<const Internal::Adaptor::Window&>(object);
310 #endif // __DALI_INTERNAL_WINDOW_H__