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 <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>
43 class WidgetView : public Toolkit::Internal::Control
48 * @copydoc Dali::WidgetView::WidgetView::New
50 static Dali::WidgetView::WidgetView New( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
53 * @copydoc Dali::WidgetView::WidgetView::PauseWidget
58 * @copydoc Dali::WidgetView::WidgetView::ResumeWidget
63 * @copydoc Dali::WidgetView::WidgetView::CancelTouchEvent
65 bool CancelTouchEvent();
68 * @copydoc Dali::WidgetView::WidgetView::ActivateFaultedWidget
70 void ActivateFaultedWidget();
72 void SendWidgetEvent( int event );
74 public: // Internal API
77 * @brief Called when a property of an object of this type is set.
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.
83 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
86 * @brief Called to retrieve a property of an object of this type.
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.
92 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
95 * @brief Performs actions as requested using the action name.
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
102 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
104 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
106 const std::string& GetWidgetId() const;
108 const std::string& GetInstanceId() const;
110 const std::string& GetContentInfo();
112 const std::string& GetTitle();
114 float GetUpdatePeriod() const;
116 void SetPreviewVisible( bool visible );
118 bool IsPreviewVisible();
120 void SetLoadingTextVisible( bool visible );
122 void SetRetryTextVisible( bool visible );
124 bool IsLoadingTextVisible();
126 bool IsRetryTextVisible();
128 bool IsWidgetFaulted();
130 void SetPermanentDelete( bool permanentDelete );
132 void RemoveWidgetImage();
134 bool IsPermanentDelete();
136 bool IsWidgetImageView();
138 void UpdateImageSource( tbm_surface_h source );
140 void CreateWidgetImageView();
142 void ConnectSignal( tizen_remote_surface* surface );
144 bool OnTouch( Dali::Actor actor, const Dali::TouchData& event );
146 bool OnWheelEvent( Dali::Actor actor, const Dali::WheelEvent& event );
148 void CloseRemoteSurface();
150 void SetLoadingTextPropertyMap( Dali::Property::Map map );
152 void SetRetryTextPropertyMap( Dali::Property::Map map );
154 void SetWidgetImagePropertyMap( Dali::Property::Map map );
156 void ShowLoadingState( bool show );
158 void ShowRetryState( bool show );
160 void TerminateWidget();
165 * @copydoc Dali::WidgetView::WidgetView::WidgetAddedSignal
167 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetAddedSignal();
170 * @copydoc Dali::WidgetView::WidgetView::WidgetDeletedSignal
172 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetDeletedSignal();
175 * @copydoc Dali::WidgetView::WidgetView::WidgetCreationAbortedSignal
177 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetCreationAbortedSignal();
180 * @copydoc Dali::WidgetView::WidgetView::WidgetContentUpdatedSignal
182 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetContentUpdatedSignal();
185 * @copydoc Dali::WidgetView::WidgetView::WidgetUpdatePeriodChangedSignal
187 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetUpdatePeriodChangedSignal();
190 * @copydoc Dali::WidgetView::WidgetView::WidgetFaultedSignal
192 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetFaultedSignal();
194 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetTerminatedSignal();
199 * Construct a new WidgetView.
204 * Construct a new WidgetView.
206 WidgetView( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
209 * A reference counted object may only be deleted by calling Unreference()
211 virtual ~WidgetView();
213 float TextPixelToPointSize( int pixelSize );
215 private: // From Control
218 * @copydoc Toolkit::Control::OnInitialize()
220 virtual void OnInitialize();
223 * @copydoc Toolkit::Control::OnStageConnect()
225 virtual void OnStageConnection( int depth );
228 * @copydoc Toolkit::Control::OnStageDisconnection()
230 virtual void OnStageDisconnection();
233 * @copydoc Toolkit::Control::OnSizeSet()
235 virtual void OnSizeSet( const Vector3& targetSize );
238 * @copydoc Toolkit::Control::GetNaturalSize
240 virtual Vector3 GetNaturalSize();
243 * @copydoc Toolkit::Control::GetHeightForWidth()
245 virtual float GetHeightForWidth( float width );
248 * @copydoc Toolkit::Control::GetWidthForHeight()
250 virtual float GetWidthForHeight( float height );
255 WidgetView( const WidgetView& );
258 WidgetView& operator= ( const WidgetView& );
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;
270 std::string mWidgetId;
271 std::string mInstanceId;
272 std::string mContentInfo;
280 bool mPreviewVisible;
282 bool mLoadingTextVisible;
283 std::string mLoadingTextString;
285 bool mRetryTextVisible;
286 std::string mRetryTextString;
289 bool mPermanentDelete;
290 screen_connector_toolkit_h mWatcherHandle;
291 tizen_remote_surface* mRemoteSurface;
293 Dali::Property::Map mWidgetImagePropertyMap;
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;
304 Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetTerminatedSignal;
307 } // namespace Internal
309 // Helpers for public-api forwarding methods
311 inline Internal::WidgetView& GetImplementation( WidgetView& widgetView )
313 DALI_ASSERT_ALWAYS( widgetView );
315 Dali::RefObject& handle = widgetView.GetImplementation();
317 return static_cast<Internal::WidgetView&>( handle );
320 inline const Internal::WidgetView& GetImplementation( const WidgetView& widgetView )
322 DALI_ASSERT_ALWAYS( widgetView );
324 const Dali::RefObject& handle = widgetView.GetImplementation();
326 return static_cast<const Internal::WidgetView&>( handle );
329 } // namespace WidgetView
333 #endif // __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__