1 #ifndef __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__
2 #define __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__
6 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
12 * http://floralicense.org/license/
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.
22 #include <public_api/widget_view/widget_view.h>
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 #include <screen_connector_toolkit.h>
42 class WidgetView : public Toolkit::Internal::Control
47 * @copydoc Dali::WidgetView::WidgetView::New
49 static Dali::WidgetView::WidgetView New( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
52 * @copydoc Dali::WidgetView::WidgetView::PauseWidget
57 * @copydoc Dali::WidgetView::WidgetView::ResumeWidget
62 * @copydoc Dali::WidgetView::WidgetView::CancelTouchEvent
64 bool CancelTouchEvent();
67 * @copydoc Dali::WidgetView::WidgetView::ActivateFaultedWidget
69 void ActivateFaultedWidget();
71 void SendWidgetEvent( int event );
73 public: // Internal API
76 * @brief Called when a property of an object of this type is set.
78 * @param[in] object The object whose property is set.
79 * @param[in] index The property index.
80 * @param[in] value The new property value.
82 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
85 * @brief Called to retrieve a property of an object of this type.
87 * @param[in] object The object whose property is to be retrieved.
88 * @param[in] index The property index.
89 * @return The current value of the property.
91 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
94 * @brief Performs actions as requested using the action name.
96 * @param[in] object The object on which to perform the action.
97 * @param[in] actionName The action to perform.
98 * @param[in] attributes The attributes with which to perfrom this action.
99 * @return True if action has been accepted by this control
101 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
103 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
105 const std::string& GetWidgetId() const;
107 const std::string& GetInstanceId() const;
109 const std::string& GetContentInfo();
111 const std::string& GetTitle();
113 float GetUpdatePeriod() const;
115 void SetPreviewVisible( bool visible );
117 bool IsPreviewVisible();
119 void SetLoadingTextVisible( bool visible );
121 void SetRetryTextVisible( bool visible );
123 bool IsLoadingTextVisible();
125 bool IsRetryTextVisible();
127 bool IsWidgetFaulted();
129 void SetPermanentDelete( bool permanentDelete );
131 void RemoveWidgetImage();
133 bool IsPermanentDelete();
135 bool IsWidgetImageView();
137 void UpdateImageSource( tbm_surface_h source );
139 void CreateWidgetImageView();
141 void ConnectSignal( tizen_remote_surface* surface );
143 bool OnTouch( Dali::Actor actor, const Dali::TouchData& event );
145 bool OnWheelEvent( Dali::Actor actor, const Dali::WheelEvent& event );
147 void CloseRemoteSurface();
149 void SetLoadingTextPropertyMap( Dali::Property::Map map );
151 void SetRetryTextPropertyMap( Dali::Property::Map map );
153 void ShowLoadingState( bool show );
155 void ShowRetryState( bool show );
157 void TerminateWidget();
162 * @copydoc Dali::WidgetView::WidgetView::WidgetAddedSignal
164 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetAddedSignal();
167 * @copydoc Dali::WidgetView::WidgetView::WidgetDeletedSignal
169 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetDeletedSignal();
172 * @copydoc Dali::WidgetView::WidgetView::WidgetCreationAbortedSignal
174 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetCreationAbortedSignal();
177 * @copydoc Dali::WidgetView::WidgetView::WidgetContentUpdatedSignal
179 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetContentUpdatedSignal();
182 * @copydoc Dali::WidgetView::WidgetView::WidgetUpdatePeriodChangedSignal
184 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetUpdatePeriodChangedSignal();
187 * @copydoc Dali::WidgetView::WidgetView::WidgetFaultedSignal
189 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetFaultedSignal();
191 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetTerminatedSignal();
196 * Construct a new WidgetView.
201 * Construct a new WidgetView.
203 WidgetView( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
206 * A reference counted object may only be deleted by calling Unreference()
208 virtual ~WidgetView();
210 float TextPixelToPointSize( int pixelSize );
212 private: // From Control
215 * @copydoc Toolkit::Control::OnInitialize()
217 virtual void OnInitialize();
220 * @copydoc Toolkit::Control::OnStageConnect()
222 virtual void OnStageConnection( int depth );
225 * @copydoc Toolkit::Control::OnStageDisconnection()
227 virtual void OnStageDisconnection();
230 * @copydoc Toolkit::Control::OnSizeSet()
232 virtual void OnSizeSet( const Vector3& targetSize );
235 * @copydoc Toolkit::Control::GetNaturalSize
237 virtual Vector3 GetNaturalSize();
240 * @copydoc Toolkit::Control::GetHeightForWidth()
242 virtual float GetHeightForWidth( float width );
245 * @copydoc Toolkit::Control::GetWidthForHeight()
247 virtual float GetWidthForHeight( float height );
252 WidgetView( const WidgetView& );
255 WidgetView& operator= ( const WidgetView& );
259 Toolkit::ImageView mWidgetImageView; ///< Widget content
260 Toolkit::ImageView mPreviewImage; ///< Preview image
261 Toolkit::TextLabel mLoadingText; ///< Loading text
262 Toolkit::TextLabel mRetryText; ///< Retry text
263 Dali::Actor mPreviewActor;
264 Dali::Actor mStateTextActor;
265 Dali::NativeImageSourcePtr mImageSource;
267 std::string mWidgetId;
268 std::string mInstanceId;
269 std::string mContentInfo;
277 bool mPreviewVisible;
279 bool mLoadingTextVisible;
280 std::string mLoadingTextString;
282 bool mRetryTextVisible;
283 std::string mRetryTextString;
286 bool mPermanentDelete;
287 screen_connector_toolkit_h mWatcherHandle;
288 tizen_remote_surface* mRemoteSurface;
291 Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetAddedSignal;
292 Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetDeletedSignal;
293 Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetCreationAbortedSignal;
294 Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetContentUpdatedSignal;
295 Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetUpdatePeriodChangedSignal;
296 Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetFaultedSignal;
299 Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetTerminatedSignal;
302 } // namespace Internal
304 // Helpers for public-api forwarding methods
306 inline Internal::WidgetView& GetImplementation( WidgetView& widgetView )
308 DALI_ASSERT_ALWAYS( widgetView );
310 Dali::RefObject& handle = widgetView.GetImplementation();
312 return static_cast<Internal::WidgetView&>( handle );
315 inline const Internal::WidgetView& GetImplementation( const WidgetView& widgetView )
317 DALI_ASSERT_ALWAYS( widgetView );
319 const Dali::RefObject& handle = widgetView.GetImplementation();
321 return static_cast<const Internal::WidgetView&>( handle );
324 } // namespace WidgetView
328 #endif // __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__