1 #ifndef DALI_INTERNAL_WIDGET_H
2 #define DALI_INTERNAL_WIDGET_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/base-object.h>
23 #include <dali/public-api/signals/connection-tracker-interface.h>
26 #include <dali/public-api/adaptor-framework/widget.h>
27 #include <dali/public-api/adaptor-framework/window.h>
32 * @addtogroup dali_adaptor_framework
41 typedef IntrusivePtr<Widget> WidgetPtr;
44 * @brief This is the internal base class of custom widget.
46 * It will provides several widget instance lifecycle virtual functions
47 * which the user can override.
49 * User should override OnCreate function and create scene for custom widget.
51 * Plus, Implements ConnectionTrackerInterface so that signals (typically connected to member functions) will
52 * be disconnected automatically when the control is destroyed.
56 class DALI_ADAPTOR_API Widget : public BaseObject, public ConnectionTrackerInterface
60 * @brief Creates a new WidgetImpl instance.
63 * @return A handle to the WidgetImpl instance
65 static WidgetPtr New();
68 * @brief The user should override this function to determine when they create widget.
71 * @param[in] contentInfo Information from WidgetView for creating. It contains previous status of widget which is sent by SetContentInfo before.
72 * @param[in] window Window handle for widget
74 virtual void OnCreate(const std::string& contentInfo, Dali::Window window);
77 * @brief The user should override this function to determine when they terminate widget.
80 * @param[in] contentInfo Data from WidgetView for deleting
81 * @param[in] type Termination type. When user delete widget view, termination type is PERMANENT.
83 virtual void OnTerminate(const std::string& contentInfo, Dali::Widget::Termination type);
86 * @brief The user should override this function to determine when they pause widget.
89 virtual void OnPause();
92 * @brief The user should override this function to determine when they resume widget.
95 virtual void OnResume();
98 * @brief The user should override this function to determine when they resize widget.
101 * @param[in] window Window handle for widget
103 virtual void OnResize(Dali::Window window);
106 * @brief The user should override this function to determine when they update widget.
109 * @param[in] contentInfo Data from WidgetView for updating
110 * @param[in] force Although the widget is paused, if it is true, the widget can be updated
112 virtual void OnUpdate(const std::string& contentInfo, int force);
114 // From ConnectionTrackerInterface
117 * @copydoc ConnectionTrackerInterface::SignalConnected
119 void SignalConnected(SlotObserver* slotObserver, CallbackBase* callback) override;
122 * @copydoc ConnectionTrackerInterface::SignalDisconnected
124 void SignalDisconnected(SlotObserver* slotObserver, CallbackBase* callback) override;
127 * @brief Set content info to WidgetView.
130 * @param[in] contentInfo Content info is kind of context information which contains current status of widget.
132 void SetContentInfo(const std::string& contentInfo);
135 * @brief Check Widget is using key
137 * widget can set flag to SetUsingKeyEvent
139 * @return True if Widget is using key
141 bool IsKeyEventUsing() const;
144 * @brief Set the flag that widget is using keyEvent
146 * @param[in] flag The flag to set.
148 void SetUsingKeyEvent(bool flag);
152 * @brief WidgetImpl constructor
157 * @brief Virtual destructor
163 class Impl; // Class declaration is public so we can internally add devel API's to the WidgetImpl
166 * Set pointer of WidgetImpl Internal.
169 void SetImpl(Impl* impl);
172 * @brief Set the Information of widget
174 * @param window The window to set the information of widget
175 * @param widgetId The Id of widget
177 void SetInformation(Dali::Window window, const std::string& widgetId);
180 * @brief Get the Window of widget
182 * @return the window of widget
184 Dali::Window GetWindow() const;
187 * @brief Get the id of widget
189 * @return the id of widget
191 std::string GetWidgetId() const;
197 DALI_INTERNAL Widget(const Widget&);
198 DALI_INTERNAL Widget& operator=(Widget&);
203 * @brief Gets implementation from the handle.
207 * @return Implementation
208 * @pre handle is initialized and points to a widget
210 DALI_ADAPTOR_API Internal::Adaptor::Widget& GetImplementation(Dali::Widget& widget);
213 * @brief Gets implementation from the handle.
217 * @return Implementation
218 * @pre Handle is initialized and points to a widget.
220 DALI_ADAPTOR_API const Internal::Adaptor::Widget& GetImplementation(const Dali::Widget& widget);
222 } // namespace Adaptor
224 } // namespace Internal
231 #endif // DALI_INTERNAL_WIDGET_H