1 #ifndef DALI_WIDGET_APPLICATION_H
2 #define DALI_WIDGET_APPLICATION_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/adaptor-framework/application.h>
27 * @addtogroup dali_adaptor_framework
31 namespace Internal DALI_INTERNAL
35 class WidgetApplication;
38 } // namespace DALI_INTERNAL
43 * @brief An WidgetApplication class object should be created by every widget application
44 * that wishes to use Dali.
46 * It provides a means for initializing the
47 * resources required by the Dali::Core.
49 * The WidgetApplication class emits several signals which the user can
50 * connect to. The user should not create any Dali objects in the main
51 * function and instead should connect to the Init signal of the
52 * WidgetApplication and create the Dali Widget object in the connected callback.
54 * WidgetApplications should follow the example below:
58 * //Widget header which
59 * #include <my-widget.h>
61 * class ExampleController: public ConnectionTracker
64 * ExampleController( Application& application )
65 * : mWidgetApplication( application )
67 * mApplication.InitSignal().Connect( this, &ExampleController::Create );
70 * static Widget CreateWidgetFunction(const std::string& widgetName)
72 * MyWidget widget = MyWidget::New();
76 * void Create( Application& application )
78 * mApplication.RegisterWidgetCreatingFunction( "myWidget", &ExampleController::CreateWidgetFunction );
82 * WidgetApplication& mWidgetApplication;
85 * int main (int argc, char **argv)
87 * WidgetApplication app = WidgetApplication::New(&argc, &argv);
88 * ExampleController example( app );
93 * If required, you can also connect class member functions to a signal:
96 * MyWidgetApplication app;
97 * app.ResumeSignal().Connect(&app, &MyWidgetApplication::Resume);
102 class DALI_ADAPTOR_API WidgetApplication : public Application
106 * @brief This is the typedef for Widget creator.
109 typedef Widget (*CreateWidgetFunction)(const std::string&);
113 * @brief This is the constructor for WidgetApplications with a name.
116 * @param[in,out] argc A pointer to the number of arguments
117 * @param[in,out] argv A pointer to the argument list
118 * @param[in] stylesheet The path to user defined theme file
119 * @return A handle to the WidgetApplication
120 * @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
122 static WidgetApplication New(int* argc, char** argv[], const std::string& stylesheet);
125 * @brief The default constructor.
131 * @brief Copy Constructor.
134 * @param[in] widgetApplication Handle to an object
136 WidgetApplication(const WidgetApplication& widgetApplication);
139 * @brief Assignment operator.
142 * @param[in] widgetApplication Handle to an object
143 * @return A reference to this
145 WidgetApplication& operator=(const WidgetApplication& widgetApplication);
148 * @brief Move constructor.
151 * @param[in] rhs A reference to the moved handle
153 WidgetApplication(WidgetApplication&& rhs);
156 * @brief Move assignment operator.
159 * @param[in] rhs A reference to the moved handle
160 * @return A reference to this handle
162 WidgetApplication& operator=(WidgetApplication&& rhs);
168 ~WidgetApplication();
171 * @brief Register create function for widget.
174 * @param[in] widgetName Name of widget
175 * @param[in] createFunction Function pointer for widget creation.
177 void RegisterWidgetCreatingFunction(const std::string& widgetName, CreateWidgetFunction createFunction);
179 public: // Not intended for application developers
182 * @brief Internal constructor.
184 explicit DALI_INTERNAL WidgetApplication(Internal::Adaptor::WidgetApplication* widgetApplication);
193 #endif // DALI_WIDGET_APPLICATION_H