1 #ifndef DALI_INTERNAL_WIDGET_H
2 #define DALI_INTERNAL_WIDGET_H
5 * Copyright (c) 2017 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>
33 * @addtogroup dali_adaptor_framework
44 typedef IntrusivePtr<Widget> WidgetPtr;
47 * @brief This is the internal base class of custom widget.
49 * It will provides several widget instance lifecycle virtual functions
50 * which the user can override.
52 * User should override OnCreate function and create scene for custom widget.
54 * Plus, Implements ConnectionTrackerInterface so that signals (typically connected to member functions) will
55 * be disconnected automatically when the control is destroyed.
59 class DALI_IMPORT_API Widget : public BaseObject, public ConnectionTrackerInterface
64 * @brief Creates a new WidgetImpl instance.
67 * @return A handle to the WidgetImpl instance
69 static WidgetPtr New();
72 * @brief The user should override this function to determine when they create widget.
75 * @param[in] contentInfo Information from WidgetView for creating. It contains previous status of widget which is sent by SetContentInfo before.
76 * @param[in] window Window handle for widget
78 virtual void OnCreate( const std::string& contentInfo, Dali::Window window );
81 * @brief The user should override this function to determine when they terminate widget.
84 * @param[in] contentInfo Data from WidgetView for deleting
85 * @param[in] type Termination type. When user delete widget view, termination type is PERMANENT.
87 virtual void OnTerminate( const std::string& contentInfo, Dali::Widget::Termination type );
90 * @brief The user should override this function to determine when they pause widget.
93 virtual void OnPause();
96 * @brief The user should override this function to determine when they resume widget.
99 virtual void OnResume();
102 * @brief The user should override this function to determine when they resize widget.
105 * @param[in] window Window handle for widget
107 virtual void OnResize( Dali::Window window );
110 * @brief The user should override this function to determine when they update widget.
113 * @param[in] contentInfo Data from WidgetView for updating
114 * @param[in] force Although the widget is paused, if it is true, the widget can be updated
116 virtual void OnUpdate( const std::string& contentInfo, int force );
118 // From ConnectionTrackerInterface
121 * @copydoc ConnectionTrackerInterface::SignalConnected
123 virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback );
126 * @copydoc ConnectionTrackerInterface::SignalDisconnected
128 virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback );
131 * @brief Set content info to WidgetView.
134 * @param[in] contentInfo Content info is kind of context information which contains current status of widget.
136 void SetContentInfo( const std::string& contentInfo );
141 * @brief WidgetImpl constructor
146 * @brief Virtual destructor
152 class Impl; // Class declaration is public so we can internally add devel API's to the WidgetImpl
155 * Set pointer of WidgetImpl Internal.
158 void SetImpl( Widget::Impl* impl );
164 DALI_INTERNAL Widget(const Widget&);
165 DALI_INTERNAL Widget& operator=(Widget&);
171 * @brief Gets implementation from the handle.
175 * @return Implementation
176 * @pre handle is initialized and points to a widget
178 DALI_IMPORT_API Internal::Adaptor::Widget& GetImplementation( Dali::Widget& widget );
181 * @brief Gets implementation from the handle.
185 * @return Implementation
186 * @pre Handle is initialized and points to a widget.
188 DALI_IMPORT_API const Internal::Adaptor::Widget& GetImplementation( const Dali::Widget& widget );
190 } // namespace Adaptor
192 } // namespace Internal
199 #endif // DALI_INTERNAL_WIDGET_H