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>
41 class WidgetView : public Toolkit::Internal::Control
46 * @copydoc Dali::WidgetView::WidgetView::New
48 static Dali::WidgetView::WidgetView New( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
51 * @copydoc Dali::WidgetView::WidgetView::PauseWidget
56 * @copydoc Dali::WidgetView::WidgetView::ResumeWidget
61 * @copydoc Dali::WidgetView::WidgetView::CancelTouchEvent
63 bool CancelTouchEvent();
66 * @copydoc Dali::WidgetView::WidgetView::ActivateFaultedWidget
68 void ActivateFaultedWidget();
70 void SendWidgetEvent( int event );
72 public: // Internal API
75 * @brief Called when a property of an object of this type is set.
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.
81 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
84 * @brief Called to retrieve a property of an object of this type.
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.
90 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
93 * @brief Performs actions as requested using the action name.
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
100 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
102 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
104 const std::string& GetWidgetId() const;
106 const std::string& GetInstanceId() const;
108 const std::string& GetContentInfo();
110 const std::string& GetTitle();
112 float GetUpdatePeriod() const;
114 void ShowPreview( bool show );
116 bool IsPreviewVisible();
118 void ShowStateText( bool show );
120 bool IsStateTextVisible();
122 bool IsWidgetFaulted();
124 void SetPermanentDelete( bool permanentDelete );
126 // ToDo: This funstion will be used for widgetDeletedSignal
127 void RemoveObjectView();
129 bool IsPermanentDelete();
131 bool IsWidgetImageView();
133 void UpdateImageSource( tbm_surface_h source );
135 void CreateWidgetImageView();
137 void ConnectSignal( tizen_remote_surface* surface );
139 bool OnTouch( Dali::Actor actor, const Dali::TouchData& event );
141 bool OnWheelEvent( Dali::Actor actor, const Dali::WheelEvent& event );
143 void CloseRemoteSurface();
148 * @copydoc Dali::WidgetView::WidgetView::WidgetAddedSignal
150 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetAddedSignal();
153 * @copydoc Dali::WidgetView::WidgetView::WidgetDeletedSignal
155 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetDeletedSignal();
158 * @copydoc Dali::WidgetView::WidgetView::WidgetCreationAbortedSignal
160 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetCreationAbortedSignal();
163 * @copydoc Dali::WidgetView::WidgetView::WidgetContentUpdatedSignal
165 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetContentUpdatedSignal();
168 * @copydoc Dali::WidgetView::WidgetView::WidgetUpdatePeriodChangedSignal
170 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetUpdatePeriodChangedSignal();
173 * @copydoc Dali::WidgetView::WidgetView::WidgetFaultedSignal
175 Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetFaultedSignal();
180 * Construct a new WidgetView.
185 * Construct a new WidgetView.
187 WidgetView( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
190 * A reference counted object may only be deleted by calling Unreference()
192 virtual ~WidgetView();
194 private: // From Control
197 * @copydoc Toolkit::Control::OnInitialize()
199 virtual void OnInitialize();
202 * @copydoc Toolkit::Control::OnStageConnect()
204 virtual void OnStageConnection( int depth );
207 * @copydoc Toolkit::Control::OnStageDisconnection()
209 virtual void OnStageDisconnection();
212 * @copydoc Toolkit::Control::OnSizeSet()
214 virtual void OnSizeSet( const Vector3& targetSize );
217 * @copydoc Toolkit::Control::GetNaturalSize
219 virtual Vector3 GetNaturalSize();
222 * @copydoc Toolkit::Control::GetHeightForWidth()
224 virtual float GetHeightForWidth( float width );
227 * @copydoc Toolkit::Control::GetWidthForHeight()
229 virtual float GetWidthForHeight( float height );
234 WidgetView( const WidgetView& );
237 WidgetView& operator= ( const WidgetView& );
241 Toolkit::ImageView mWidgetImageView; ///< Widget content
242 Toolkit::ImageView mPreviewImage; ///< Preview image
243 Toolkit::TextLabel mStateText; ///< State text
244 Dali::NativeImageSourcePtr mImageSource;
246 std::string mWidgetId;
247 std::string mInstanceId;
248 std::string mContentInfo;
256 bool mPreviewVisible;
257 bool mStateTextVisible;
258 bool mPermanentDelete;
260 tizen_remote_surface* mRemoteSurface;
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;
271 } // namespace Internal
273 // Helpers for public-api forwarding methods
275 inline Internal::WidgetView& GetImplementation( WidgetView& widgetView )
277 DALI_ASSERT_ALWAYS( widgetView );
279 Dali::RefObject& handle = widgetView.GetImplementation();
281 return static_cast<Internal::WidgetView&>( handle );
284 inline const Internal::WidgetView& GetImplementation( const WidgetView& widgetView )
286 DALI_ASSERT_ALWAYS( widgetView );
288 const Dali::RefObject& handle = widgetView.GetImplementation();
290 return static_cast<const Internal::WidgetView&>( handle );
293 } // namespace WidgetView
297 #endif // __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__