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>
25 #include <orientation.h>
26 #include <render-surface.h>
27 #include <drag-and-drop-detector.h>
30 #include <base/lifecycle-observer.h>
31 #include <adaptor-impl.h>
32 #include <indicator-impl.h>
53 typedef IntrusivePtr<Window> WindowPtr;
54 typedef IntrusivePtr<Orientation> OrientationPtr;
57 * Window provides a surface to render onto with orientation & indicator properties.
59 class Window : public Dali::BaseObject, public Indicator::Observer, public LifeCycleObserver
62 typedef Dali::Window::IndicatorSignalV2 IndicatorSignalV2;
65 * Create a new Window. This should only be called once by the Application class
66 * @param[in] windowPosition The position and size of the window
67 * @param[in] name The window title
68 * @param[in] isTransparent Whether window is transparent
69 * @return A newly allocated Window
71 static Window* New(const PositionSize& posSize, const std::string& name, bool isTransparent = false);
74 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
75 * @param[in] adaptor An initialized adaptor
77 void SetAdaptor(Dali::Adaptor& adaptor);
80 * Get the window surface
81 * @return The render surface
83 RenderSurface* GetSurface();
86 * @copydoc Dali::Window::SetIndicatorStyle()
88 void SetIndicatorStyle( Dali::Window::IndicatorStyle style );
91 * @copydoc Dali::Window::ShowIndicator()
93 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
96 * @copydoc Dali::Window::SetIndicatorBgOpacity()
98 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
101 * @copydoc Dali::Window::RotateIndicator()
103 void RotateIndicator( Dali::Window::WindowOrientation orientation );
106 * @copydoc Dali::Window::SetClass()
108 void SetClass( std::string name, std::string klass );
111 * @copydoc Dali::Window::Raise()
116 * @copydoc Dali::Window::Lower()
121 * @copydoc Dali::Window::Activate()
126 * @copydoc Dali::Window::GetOrientation()
128 OrientationPtr GetOrientation();
131 * @copydoc Dali::Window::AddAvailableOrientation()
133 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
136 * @copydoc Dali::Window::RemoveAvailableOrientation()
138 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
141 * @copydoc Dali::Window::SetAvailableOrientations()
143 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
146 * @copydoc Dali::Window::GetAvailableOrientations()
148 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
151 * @copydoc Dali::Window::SetPreferredOrientation()
153 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
156 * @copydoc Dali::Window::GetPreferredOrientation()
158 Dali::Window::WindowOrientation GetPreferredOrientation();
161 * @copydoc Dali::Window::GetDragAndDropDetector() const
163 Dali::DragAndDropDetector GetDragAndDropDetector() const;
166 * @copydoc Dali::Window::GetNativeHandle() const
168 Dali::Any GetNativeHandle() const;
171 * Called from Orientation after the Change signal has been sent
173 void RotationDone( int orientation, int width, int height );
178 * Private constructor.
189 * Second stage initialization
191 void Initialize(const PositionSize& posSize, const std::string& name);
194 * Shows / hides the indicator bar.
195 * Handles close/open if rotation changes whilst hidden
197 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
200 * Close current indicator and open a connection onto the new indicator service.
201 * Effect may not be synchronous if waiting for an indicator update on existing connection.
203 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
206 * Change the indicator actor's rotation to match the current orientation
208 void SetIndicatorActorRotation();
211 * Set the indicator properties on the window
213 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
215 private: // Indicator::Observer interface
218 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorTypeChanged()
220 virtual void IndicatorTypeChanged( Indicator::Type type );
223 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorClosed()
225 virtual void IndicatorClosed(Indicator* indicator);
228 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorVisibilityChanged()
230 virtual void IndicatorVisibilityChanged( bool isVisible );
232 private: // Adaptor::Observer interface
235 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
237 virtual void OnStart();
240 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
242 virtual void OnPause();
245 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
247 virtual void OnResume();
250 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
252 virtual void OnStop();
255 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
257 virtual void OnDestroy();
261 * The user should connect to this signal to get a timing when indicator was shown / hidden.
263 IndicatorSignalV2& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignalV2; }
267 typedef std::vector<Indicator*> DiscardedIndicators;
269 RenderSurface* mSurface;
270 Dali::Window::IndicatorStyle mIndicatorStyle; ///< indicator style
271 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
272 bool mIndicatorIsShown:1; ///< private state
273 bool mShowRotatedIndicatorOnClose:1;
275 bool mIsTransparent:1;
276 bool mWMRotationAppSet:1;
277 Indicator* mIndicator;
278 Dali::Window::WindowOrientation mIndicatorOrientation;
279 Dali::Window::WindowOrientation mNextIndicatorOrientation;
280 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
281 Integration::SystemOverlay* mOverlay;
283 Dali::DragAndDropDetector mDragAndDropDetector;
286 EventHandler* mEventHandler;
288 OrientationPtr mOrientation;
289 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
290 Dali::Window::WindowOrientation mPreferredOrientation;
293 IndicatorSignalV2 mIndicatorVisibilityChangedSignalV2;
296 } // namespace Adaptor
297 } // namepsace Internal
299 // Helpers for public-api forwarding methods
301 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
303 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
304 BaseObject& object = window.GetBaseObject();
305 return static_cast<Internal::Adaptor::Window&>(object);
308 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
310 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
311 const BaseObject& object = window.GetBaseObject();
312 return static_cast<const Internal::Adaptor::Window&>(object);
318 #endif // __DALI_INTERNAL_WINDOW_H__