Modified internal api for fault widget case
[platform/core/uifw/widget-viewer-dali.git] / internal / widget_view / widget_view_impl.h
1 #ifndef __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__
2 #define __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__
3
4 /*
5  * Samsung API
6  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7  *
8  * Licensed under the Flora License, Version 1.1 (the License);
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://floralicense.org/license/
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an AS IS BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 // INTERNAL INCLUDES
22 #include <public_api/widget_view/widget_view.h>
23
24 // EXTERNAL INCLUDES
25 #include <dali/public-api/adaptor-framework/native-image-source.h>
26 #include <dali-toolkit/public-api/controls/control-impl.h>
27 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
28 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
29 #include <dali/public-api/object/property-map.h>
30 #include <wayland-extension/tizen-remote-surface-client-protocol.h>
31 #include <tbm_surface.h>
32 #include <screen_connector_toolkit.h>
33
34 namespace Dali
35 {
36
37 namespace WidgetView
38 {
39
40 namespace Internal
41 {
42
43 class WidgetView : public Toolkit::Internal::Control
44 {
45 public:
46
47   /**
48    * @copydoc Dali::WidgetView::WidgetView::New
49    */
50   static Dali::WidgetView::WidgetView New( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
51
52   /**
53    * @copydoc Dali::WidgetView::WidgetView::PauseWidget
54    */
55   bool PauseWidget();
56
57   /**
58    * @copydoc Dali::WidgetView::WidgetView::ResumeWidget
59    */
60   bool ResumeWidget();
61
62   /**
63    * @copydoc Dali::WidgetView::WidgetView::CancelTouchEvent
64    */
65   bool CancelTouchEvent();
66
67   /**
68    * @copydoc Dali::WidgetView::WidgetView::ActivateFaultedWidget
69    */
70   void ActivateFaultedWidget();
71
72   void SendWidgetEvent( int event );
73
74 public: // Internal API
75
76   /**
77    * @brief Called when a property of an object of this type is set.
78    * @SINCE_1_1.38
79    * @param[in] object The object whose property is set.
80    * @param[in] index The property index.
81    * @param[in] value The new property value.
82    */
83   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
84
85   /**
86    * @brief Called to retrieve a property of an object of this type.
87    * @SINCE_1_1.38
88    * @param[in] object The object whose property is to be retrieved.
89    * @param[in] index The property index.
90    * @return The current value of the property.
91    */
92   static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
93
94   /**
95    * @brief Performs actions as requested using the action name.
96    * @SINCE_1_1.38
97    * @param[in] object The object on which to perform the action.
98    * @param[in] actionName The action to perform.
99    * @param[in] attributes The attributes with which to perfrom this action.
100    * @return True if action has been accepted by this control
101    */
102   static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
103
104   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
105
106   const std::string& GetWidgetId() const;
107
108   const std::string& GetInstanceId() const;
109
110   const std::string& GetContentInfo();
111
112   const std::string& GetTitle();
113
114   float GetUpdatePeriod() const;
115
116   void SetPreviewVisible( bool visible );
117
118   bool IsPreviewVisible();
119
120   void SetLoadingTextVisible( bool visible );
121
122   void SetRetryTextVisible( bool visible );
123
124   bool IsLoadingTextVisible();
125
126   bool IsRetryTextVisible();
127
128   bool IsWidgetFaulted();
129
130   void SetPermanentDelete( bool permanentDelete );
131
132   void RemoveWidgetImage();
133
134   bool IsPermanentDelete();
135
136   bool IsWidgetImageView();
137
138   void UpdateImageSource( tbm_surface_h source );
139
140   void CreateWidgetImageView();
141
142   void ConnectSignal( tizen_remote_surface* surface );
143
144   bool OnTouch( Dali::Actor actor, const Dali::TouchData& event );
145
146   bool OnWheelEvent( Dali::Actor actor, const Dali::WheelEvent& event );
147
148   void CloseRemoteSurface();
149
150   void SetLoadingTextPropertyMap( Dali::Property::Map map );
151
152   void SetRetryTextPropertyMap( Dali::Property::Map map );
153
154   void SetWidgetImagePropertyMap( Dali::Property::Map map );
155
156   void ShowLoadingState( bool show );
157
158   void ShowRetryState( bool show );
159
160   void TerminateWidget();
161
162 public: //Signals
163
164   /**
165    * @copydoc Dali::WidgetView::WidgetView::WidgetAddedSignal
166    */
167   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetAddedSignal();
168
169   /**
170    * @copydoc Dali::WidgetView::WidgetView::WidgetDeletedSignal
171    */
172   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetDeletedSignal();
173
174   /**
175    * @copydoc Dali::WidgetView::WidgetView::WidgetCreationAbortedSignal
176    */
177   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetCreationAbortedSignal();
178
179   /**
180    * @copydoc Dali::WidgetView::WidgetView::WidgetContentUpdatedSignal
181    */
182   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetContentUpdatedSignal();
183
184   /**
185    * @copydoc Dali::WidgetView::WidgetView::WidgetUpdatePeriodChangedSignal
186    */
187   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetUpdatePeriodChangedSignal();
188
189   /**
190    * @copydoc Dali::WidgetView::WidgetView::WidgetFaultedSignal
191    */
192   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetFaultedSignal();
193
194   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetTerminatedSignal();
195
196 protected:
197
198   /**
199    * Construct a new WidgetView.
200    */
201   WidgetView();
202
203   /**
204    * Construct a new WidgetView.
205    */
206   WidgetView( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
207
208   /**
209    * A reference counted object may only be deleted by calling Unreference()
210    */
211   virtual ~WidgetView();
212
213   float TextPixelToPointSize( int pixelSize );
214
215 private: // From Control
216
217   /**
218    * @copydoc Toolkit::Control::OnInitialize()
219    */
220   virtual void OnInitialize();
221
222   /**
223    * @copydoc Toolkit::Control::OnStageConnect()
224    */
225   virtual void OnStageConnection( int depth );
226
227   /**
228    * @copydoc Toolkit::Control::OnStageDisconnection()
229    */
230   virtual void OnStageDisconnection();
231
232   /**
233    * @copydoc Toolkit::Control::OnSizeSet()
234    */
235   virtual void OnSizeSet( const Vector3& targetSize );
236
237   /**
238    * @copydoc Toolkit::Control::GetNaturalSize
239    */
240   virtual Vector3 GetNaturalSize();
241
242   /**
243    * @copydoc Toolkit::Control::GetHeightForWidth()
244    */
245   virtual float GetHeightForWidth( float width );
246
247   /**
248    * @copydoc Toolkit::Control::GetWidthForHeight()
249    */
250   virtual float GetWidthForHeight( float height );
251
252 private:
253
254   // Undefined
255   WidgetView( const WidgetView& );
256
257   // Undefined
258   WidgetView& operator= ( const WidgetView& );
259
260 private:
261
262   Toolkit::ImageView mWidgetImageView;     ///< Widget content
263   Toolkit::ImageView mPreviewImage;   ///< Preview image
264   Toolkit::TextLabel mLoadingText;      ///< Loading text
265   Toolkit::TextLabel mRetryText;      ///< Retry text
266   Dali::Actor mPreviewActor;
267   Dali::Actor mStateTextActor;
268   Dali::NativeImageSourcePtr mImageSource;
269
270   std::string mWidgetId;
271   std::string mInstanceId;
272   std::string mContentInfo;
273   std::string mTitle;
274
275   int mWidth;
276   int mHeight;
277   int mPid;
278   float mUpdatePeriod;
279
280   bool mPreviewVisible;
281
282   bool mLoadingTextVisible;
283   std::string mLoadingTextString;
284
285   bool mRetryTextVisible;
286   std::string mRetryTextString;
287   bool mRetryState;
288
289   bool mPermanentDelete;
290   screen_connector_toolkit_h mWatcherHandle;
291   tizen_remote_surface* mRemoteSurface;
292
293   Dali::Property::Map mWidgetImagePropertyMap;
294
295   // Signals
296   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetAddedSignal;
297   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetDeletedSignal;
298   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetCreationAbortedSignal;
299   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetContentUpdatedSignal;
300   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetUpdatePeriodChangedSignal;
301   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetFaultedSignal;
302
303   // Internal signal
304   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetTerminatedSignal;
305 };
306
307 } // namespace Internal
308
309 // Helpers for public-api forwarding methods
310
311 inline Internal::WidgetView& GetImplementation( WidgetView& widgetView )
312 {
313   DALI_ASSERT_ALWAYS( widgetView );
314
315   Dali::RefObject& handle = widgetView.GetImplementation();
316
317   return static_cast<Internal::WidgetView&>( handle );
318 }
319
320 inline const Internal::WidgetView& GetImplementation( const WidgetView& widgetView )
321 {
322   DALI_ASSERT_ALWAYS( widgetView );
323
324   const Dali::RefObject& handle = widgetView.GetImplementation();
325
326   return static_cast<const Internal::WidgetView&>( handle );
327 }
328
329 } // namespace WidgetView
330
331 } // namespace Dali
332
333 #endif // __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__