1 #ifndef __DALI_WIDGET_H__
2 #define __DALI_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-handle.h>
23 #include <dali/public-api/signals/dali-signal.h>
29 * @addtogroup dali_adaptor_framework
33 namespace Internal DALI_INTERNAL
46 * @brief Widget object should be created by WidgetApplication.
48 * The WidgetApplication class emits several widget instance lifecycle signals
49 * which the user can connect to.
50 * The user should connect to the CreateSignal of the Widget and
51 * create the Dali Widget object in the connected callback.
53 * Widget should follow the example below:
56 * class ExampleController: public ConnectionTracker
59 * ExampleController( WidgetApplication& widgetApplication )
60 * : mWidgetApplication( widgetApplication )
62 * mWidgetApplication.InitSignal().Connect( this, &ExampleController::Create );
65 * void Create( WidgetApplication& widgetApplication )
67 * Widget widget = Widget::New( WIDGET_ID );
68 * widget.CreateSignal( this, &ExampleController::WidgetCreate );
71 * void WidgetCreate( const std::string& id, bundle* content, Window window )
73 * // Do Dali components...
77 * WidgetApplication& mWidgetApplication;
80 * int main (int argc, char **argv)
82 * WidgetApplication app = WidgetApplication::New(&argc, &argv);
83 * ExampleController example( app );
89 class DALI_IMPORT_API Widget : public BaseHandle
94 * @brief Enumeration for terminate type of widget instance.
99 PERMANENT, //< User deleted this widget from the viewer @SINCE_1_2.62
100 TEMPORARY, //< Widget is deleted because of other reasons (e.g. widget process is terminated temporarily by the system) @SINCE_1_2.62
101 } WidgetTerminateType;
103 typedef Signal< void (const std::string&, bundle*, Window) > WidgetCreateSignalType; ///< Widget lifecycle signal type @SINCE_1_2.62
104 typedef Signal< void (const std::string&, bundle*, WidgetTerminateType) > WidgetTerminateSignalType; ///< Widget lifecycle signal type @SINCE_1_2.62
105 typedef Signal< void (const std::string&) > WidgetPauseSignalType; ///< Widget lifecycle signal type @SINCE_1_2.62
106 typedef Signal< void (const std::string&) > WidgetResumeSignalType; ///< Widget lifecycle signal type @SINCE_1_2.62
107 typedef Signal< void (const std::string&, Window) > WidgetResizeSignalType; ///< Widget lifecycle signal type @SINCE_1_2.62
108 typedef Signal< void (const std::string&, bundle*, int) > WidgetUpdateSignalType; ///< Widget lifecycle signal type @SINCE_1_2.62
113 * @brief This is the constructor for Widget.
115 * @param[in] id Id for widget class
116 * @return A handle to the Widget
118 static Widget New( const std::string& id );
121 * @brief The default constructor.
127 * @brief Copy Constructor.
129 * @param[in] Widget Handle to an object
131 Widget( const Widget& widget );
134 * @brief Assignment operator.
136 * @param[in] Widget Handle to an object
137 * @return A reference to this
139 Widget& operator=( const Widget& widget );
150 * @brief The user should connect to this signal to determine when they create widget.
152 * @return The signal to connect to
154 WidgetCreateSignalType& CreateSignal();
157 * @brief The user should connect to this signal to determine when they terminate widget.
159 * @return The signal to connect to
161 WidgetTerminateSignalType& TerminateSignal();
164 * @brief The user should connect to this signal to determine when they pause widget.
166 * @return The signal to connect to
168 WidgetPauseSignalType& PauseSignal();
171 * @brief The user should connect to this signal to determine when they resume widget.
173 * @return The signal to connect to
175 WidgetResumeSignalType& ResumeSignal();
178 * @brief The user should connect to this signal to determine when they resize widget.
180 * @return The signal to connect to
182 WidgetResizeSignalType& ResizeSignal();
185 * @brief The user should connect to this signal to determine when they update widget.
187 * @return The signal to connect to
189 WidgetUpdateSignalType& UpdateSignal();
191 public: // Not intended for application developers
194 * @brief Internal constructor.
196 explicit DALI_INTERNAL Widget(Internal::Adaptor::Widget* widget);
205 #endif // ___DALI_WIDGET_H__