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::AddAvailableOrientation()
122 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
125 * @copydoc Dali::Window::RemoveAvailableOrientation()
127 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
130 * @copydoc Dali::Window::SetAvailableOrientations()
132 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
135 * @copydoc Dali::Window::GetAvailableOrientations()
137 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
140 * @copydoc Dali::Window::SetPreferredOrientation()
142 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
145 * @copydoc Dali::Window::GetPreferredOrientation()
147 Dali::Window::WindowOrientation GetPreferredOrientation();
150 * @copydoc Dali::Window::GetDragAndDropDetector() const
152 Dali::DragAndDropDetector GetDragAndDropDetector() const;
155 * @copydoc Dali::Window::GetNativeHandle() const
157 Dali::Any GetNativeHandle() const;
160 * Called from Orientation after the Change signal has been sent
162 void RotationDone( int orientation, int width, int height );
166 * Private constructor.
177 * Second stage initialization
179 void Initialize(const PositionSize& posSize, const std::string& name);
182 * Shows / hides the indicator bar.
183 * Handles close/open if rotation changes whilst hidden
185 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
188 * Close current indicator and open a connection onto the new indicator service.
189 * Effect may not be synchronous if waiting for an indicator update on existing connection.
191 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
194 * Change the indicator actor's rotation to match the current orientation
196 void SetIndicatorActorRotation();
199 * Set the indicator properties on the window
201 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
203 private: // Indicator::Observer interface
206 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorTypeChanged()
208 virtual void IndicatorTypeChanged( Indicator::Type type );
211 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorClosed()
213 virtual void IndicatorClosed(Indicator* indicator);
216 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorVisibilityChanged()
218 virtual void IndicatorVisibilityChanged( bool isVisible );
220 private: // Adaptor::Observer interface
223 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
225 virtual void OnStart();
228 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
230 virtual void OnPause();
233 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
235 virtual void OnResume();
238 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
240 virtual void OnStop();
243 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
245 virtual void OnDestroy();
249 * The user should connect to this signal to get a timing when indicator was shown / hidden.
251 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
255 typedef std::vector<Indicator*> DiscardedIndicators;
257 RenderSurface* mSurface;
258 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
259 bool mIndicatorIsShown:1; ///< private state
260 bool mShowRotatedIndicatorOnClose:1;
262 bool mIsTransparent:1;
263 bool mWMRotationAppSet:1;
264 Indicator* mIndicator;
265 Dali::Window::WindowOrientation mIndicatorOrientation;
266 Dali::Window::WindowOrientation mNextIndicatorOrientation;
267 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
268 Integration::SystemOverlay* mOverlay;
270 Dali::DragAndDropDetector mDragAndDropDetector;
273 EventHandler* mEventHandler;
275 OrientationPtr mOrientation;
276 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
277 Dali::Window::WindowOrientation mPreferredOrientation;
280 IndicatorSignalType mIndicatorVisibilityChangedSignal;
283 } // namespace Adaptor
284 } // namepsace Internal
286 // Helpers for public-api forwarding methods
288 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
290 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
291 BaseObject& object = window.GetBaseObject();
292 return static_cast<Internal::Adaptor::Window&>(object);
295 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
297 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
298 const BaseObject& object = window.GetBaseObject();
299 return static_cast<const Internal::Adaptor::Window&>(object);
305 #endif // __DALI_INTERNAL_WINDOW_H__