Change default permanent delete flag and add CloseRemoteSurface
[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 <wayland-extension/tizen-remote-surface-client-protocol.h>
30 #include <tbm_surface.h>
31
32 namespace Dali
33 {
34
35 namespace WidgetView
36 {
37
38 namespace Internal
39 {
40
41 class WidgetView : public Toolkit::Internal::Control
42 {
43 public:
44
45   /**
46    * @copydoc Dali::WidgetView::WidgetView::New
47    */
48   static Dali::WidgetView::WidgetView New( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
49
50   /**
51    * @copydoc Dali::WidgetView::WidgetView::PauseWidget
52    */
53   bool PauseWidget();
54
55   /**
56    * @copydoc Dali::WidgetView::WidgetView::ResumeWidget
57    */
58   bool ResumeWidget();
59
60   /**
61    * @copydoc Dali::WidgetView::WidgetView::CancelTouchEvent
62    */
63   bool CancelTouchEvent();
64
65   /**
66    * @copydoc Dali::WidgetView::WidgetView::ActivateFaultedWidget
67    */
68   void ActivateFaultedWidget();
69
70   void SendWidgetEvent( int event );
71
72 public: // Internal API
73
74   /**
75    * @brief Called when a property of an object of this type is set.
76    * @SINCE_1_1.38
77    * @param[in] object The object whose property is set.
78    * @param[in] index The property index.
79    * @param[in] value The new property value.
80    */
81   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
82
83   /**
84    * @brief Called to retrieve a property of an object of this type.
85    * @SINCE_1_1.38
86    * @param[in] object The object whose property is to be retrieved.
87    * @param[in] index The property index.
88    * @return The current value of the property.
89    */
90   static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
91
92   /**
93    * @brief Performs actions as requested using the action name.
94    * @SINCE_1_1.38
95    * @param[in] object The object on which to perform the action.
96    * @param[in] actionName The action to perform.
97    * @param[in] attributes The attributes with which to perfrom this action.
98    * @return True if action has been accepted by this control
99    */
100   static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
101
102   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
103
104   const std::string& GetWidgetId() const;
105
106   const std::string& GetInstanceId() const;
107
108   const std::string& GetContentInfo();
109
110   const std::string& GetTitle();
111
112   float GetUpdatePeriod() const;
113
114   void ShowPreview( bool show );
115
116   bool IsPreviewVisible();
117
118   void ShowStateText( bool show );
119
120   bool IsStateTextVisible();
121
122   bool IsWidgetFaulted();
123
124   void SetPermanentDelete( bool permanentDelete );
125
126 // ToDo: This funstion will be used for widgetDeletedSignal
127   void RemoveObjectView();
128
129   bool IsPermanentDelete();
130
131   bool IsWidgetImageView();
132
133   void UpdateImageSource( tbm_surface_h source );
134
135   void CreateWidgetImageView();
136
137   void ConnectSignal( tizen_remote_surface* surface );
138
139   bool OnTouch( Dali::Actor actor, const Dali::TouchData& event );
140
141   bool OnWheelEvent( Dali::Actor actor, const Dali::WheelEvent& event );
142
143   void CloseRemoteSurface();
144
145 public: //Signals
146
147   /**
148    * @copydoc Dali::WidgetView::WidgetView::WidgetAddedSignal
149    */
150   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetAddedSignal();
151
152   /**
153    * @copydoc Dali::WidgetView::WidgetView::WidgetDeletedSignal
154    */
155   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetDeletedSignal();
156
157   /**
158    * @copydoc Dali::WidgetView::WidgetView::WidgetCreationAbortedSignal
159    */
160   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetCreationAbortedSignal();
161
162   /**
163    * @copydoc Dali::WidgetView::WidgetView::WidgetContentUpdatedSignal
164    */
165   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetContentUpdatedSignal();
166
167   /**
168    * @copydoc Dali::WidgetView::WidgetView::WidgetUpdatePeriodChangedSignal
169    */
170   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetUpdatePeriodChangedSignal();
171
172   /**
173    * @copydoc Dali::WidgetView::WidgetView::WidgetFaultedSignal
174    */
175   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetFaultedSignal();
176
177 protected:
178
179   /**
180    * Construct a new WidgetView.
181    */
182   WidgetView();
183
184   /**
185    * Construct a new WidgetView.
186    */
187   WidgetView( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
188
189   /**
190    * A reference counted object may only be deleted by calling Unreference()
191    */
192   virtual ~WidgetView();
193
194 private: // From Control
195
196   /**
197    * @copydoc Toolkit::Control::OnInitialize()
198    */
199   virtual void OnInitialize();
200
201   /**
202    * @copydoc Toolkit::Control::OnStageConnect()
203    */
204   virtual void OnStageConnection( int depth );
205
206   /**
207    * @copydoc Toolkit::Control::OnStageDisconnection()
208    */
209   virtual void OnStageDisconnection();
210
211   /**
212    * @copydoc Toolkit::Control::OnSizeSet()
213    */
214   virtual void OnSizeSet( const Vector3& targetSize );
215
216   /**
217    * @copydoc Toolkit::Control::GetNaturalSize
218    */
219   virtual Vector3 GetNaturalSize();
220
221   /**
222    * @copydoc Toolkit::Control::GetHeightForWidth()
223    */
224   virtual float GetHeightForWidth( float width );
225
226   /**
227    * @copydoc Toolkit::Control::GetWidthForHeight()
228    */
229   virtual float GetWidthForHeight( float height );
230
231 private:
232
233   // Undefined
234   WidgetView( const WidgetView& );
235
236   // Undefined
237   WidgetView& operator= ( const WidgetView& );
238
239 private:
240
241   Toolkit::ImageView mWidgetImageView;     ///< Widget content
242   Toolkit::ImageView mPreviewImage;   ///< Preview image
243   Toolkit::TextLabel mStateText;      ///< State text
244   Dali::NativeImageSourcePtr mImageSource;
245
246   std::string mWidgetId;
247   std::string mInstanceId;
248   std::string mContentInfo;
249   std::string mTitle;
250
251   int mWidth;
252   int mHeight;
253   int mPid;
254   float mUpdatePeriod;
255
256   bool mPreviewVisible;
257   bool mStateTextVisible;
258   bool mPermanentDelete;
259
260   tizen_remote_surface* mRemoteSurface;
261
262   // Signals
263   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetAddedSignal;
264   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetDeletedSignal;
265   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetCreationAbortedSignal;
266   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetContentUpdatedSignal;
267   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetUpdatePeriodChangedSignal;
268   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetFaultedSignal;
269 };
270
271 } // namespace Internal
272
273 // Helpers for public-api forwarding methods
274
275 inline Internal::WidgetView& GetImplementation( WidgetView& widgetView )
276 {
277   DALI_ASSERT_ALWAYS( widgetView );
278
279   Dali::RefObject& handle = widgetView.GetImplementation();
280
281   return static_cast<Internal::WidgetView&>( handle );
282 }
283
284 inline const Internal::WidgetView& GetImplementation( const WidgetView& widgetView )
285 {
286   DALI_ASSERT_ALWAYS( widgetView );
287
288   const Dali::RefObject& handle = widgetView.GetImplementation();
289
290   return static_cast<const Internal::WidgetView&>( handle );
291 }
292
293 } // namespace WidgetView
294
295 } // namespace Dali
296
297 #endif // __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__