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::SetIndicatorStyle()
87 void SetIndicatorStyle( Dali::Window::IndicatorStyle style );
90 * @copydoc Dali::Window::ShowIndicator()
92 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
95 * @copydoc Dali::Window::SetIndicatorBgOpacity()
97 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
100 * @copydoc Dali::Window::RotateIndicator()
102 void RotateIndicator( Dali::Window::WindowOrientation orientation );
105 * @copydoc Dali::Window::SetClass()
107 void SetClass( std::string name, std::string klass );
110 * @copydoc Dali::Window::Raise()
115 * @copydoc Dali::Window::Lower()
120 * @copydoc Dali::Window::Activate()
125 * @copydoc Dali::Window::GetOrientation()
127 OrientationPtr GetOrientation();
130 * @copydoc Dali::Window::AddAvailableOrientation()
132 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
135 * @copydoc Dali::Window::RemoveAvailableOrientation()
137 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
140 * @copydoc Dali::Window::SetAvailableOrientations()
142 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
145 * @copydoc Dali::Window::GetAvailableOrientations()
147 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
150 * @copydoc Dali::Window::SetPreferredOrientation()
152 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
155 * @copydoc Dali::Window::GetPreferredOrientation()
157 Dali::Window::WindowOrientation GetPreferredOrientation();
160 * @copydoc Dali::Window::GetDragAndDropDetector() const
162 Dali::DragAndDropDetector GetDragAndDropDetector() const;
165 * @copydoc Dali::Window::GetNativeHandle() const
167 Dali::Any GetNativeHandle() const;
170 * Called from Orientation after the Change signal has been sent
172 void RotationDone( int orientation, int width, int height );
176 * Private constructor.
187 * Second stage initialization
189 void Initialize(const PositionSize& posSize, const std::string& name);
192 * Shows / hides the indicator bar.
193 * Handles close/open if rotation changes whilst hidden
195 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
198 * Close current indicator and open a connection onto the new indicator service.
199 * Effect may not be synchronous if waiting for an indicator update on existing connection.
201 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
204 * Change the indicator actor's rotation to match the current orientation
206 void SetIndicatorActorRotation();
209 * Set the indicator properties on the window
211 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
213 private: // Indicator::Observer interface
216 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorTypeChanged()
218 virtual void IndicatorTypeChanged( Indicator::Type type );
221 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorClosed()
223 virtual void IndicatorClosed(Indicator* indicator);
226 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorVisibilityChanged()
228 virtual void IndicatorVisibilityChanged( bool isVisible );
230 private: // Adaptor::Observer interface
233 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
235 virtual void OnStart();
238 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
240 virtual void OnPause();
243 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
245 virtual void OnResume();
248 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
250 virtual void OnStop();
253 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
255 virtual void OnDestroy();
259 * The user should connect to this signal to get a timing when indicator was shown / hidden.
261 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
265 typedef std::vector<Indicator*> DiscardedIndicators;
267 RenderSurface* mSurface;
268 Dali::Window::IndicatorStyle mIndicatorStyle; ///< indicator style
269 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
270 bool mIndicatorIsShown:1; ///< private state
271 bool mShowRotatedIndicatorOnClose:1;
273 bool mIsTransparent:1;
274 bool mWMRotationAppSet:1;
275 Indicator* mIndicator;
276 Dali::Window::WindowOrientation mIndicatorOrientation;
277 Dali::Window::WindowOrientation mNextIndicatorOrientation;
278 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
279 Integration::SystemOverlay* mOverlay;
281 Dali::DragAndDropDetector mDragAndDropDetector;
284 EventHandler* mEventHandler;
286 OrientationPtr mOrientation;
287 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
288 Dali::Window::WindowOrientation mPreferredOrientation;
291 IndicatorSignalType mIndicatorVisibilityChangedSignal;
294 } // namespace Adaptor
295 } // namepsace Internal
297 // Helpers for public-api forwarding methods
299 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
301 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
302 BaseObject& object = window.GetBaseObject();
303 return static_cast<Internal::Adaptor::Window&>(object);
306 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
308 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
309 const BaseObject& object = window.GetBaseObject();
310 return static_cast<const Internal::Adaptor::Window&>(object);
316 #endif // __DALI_INTERNAL_WINDOW_H__