1 #ifndef DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H
2 #define DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H
5 * Copyright (c) 2023 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 <screen_connector_provider.h>
23 #include <widget_base.h>
26 #include <dali/devel-api/adaptor-framework/window-devel.h>
27 #include <dali/internal/adaptor/common/application-impl.h>
28 #include <dali/internal/system/common/widget-application-impl.h>
38 class WidgetApplication;
39 typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
42 * Implementation of the WidgetApplication class.
44 class WidgetApplicationTizen : public WidgetApplication, public ConnectionTracker
47 typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction> CreateWidgetFunctionPair;
48 typedef std::vector<CreateWidgetFunctionPair> CreateWidgetFunctionContainer;
51 * Create a new widget application
52 * @param[in] argc A pointer to the number of arguments
53 * @param[in] argv A pointer to the argument list
54 * @param[in] stylesheet The path to user defined theme file
55 * @param[in] windowData The window data
57 static WidgetApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet, const WindowData& windowData);
61 * @copydoc Dali::Internal::Adaptor::Application::OnInit()
63 void OnInit() override;
66 * @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
68 void RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction) override;
71 * Add widget name - CreateWidgetFunction pair to container.
73 void AddWidgetCreatingFunctionPair(CreateWidgetFunctionPair pair);
76 * Find and get CreateWidgetFunctionPair in container by widget name.
78 CreateWidgetFunctionPair GetWidgetCreatingFunctionPair(const std::string& widgetName);
81 * Add widget_base_instance_h - Widget instance pair to container.
83 void AddWidget(widget_base_instance_h widgetBaseInstance, Dali::Widget widget, Dali::Window window, const std::string& widgetId);
86 * Find and get Widget instance in container by widget_base_instance_h.
88 Dali::Widget GetWidget(widget_base_instance_h widgetBaseInstance) const;
91 * Delete widget_base_instance_h - Widget instance pair in container.
93 void DeleteWidget(widget_base_instance_h widgetBaseInstance);
96 * Find and get Window instance in container by widget_base_instance_h.
98 Dali::Window GetWindowFromWidget(Dali::Widget widget) const;
101 * Find and get widget_base_instance in container by widget id.
103 widget_base_instance_h GetWidgetInstanceFromWidgetId(std::string& widgetId) const;
105 * Get the number of created widget.
107 int32_t GetWidgetCount();
110 * @brief connect the keyEvent for window
112 * @param[in] window window for connecting keyEvent
114 void ConnectKeyEvent(Dali::Window window);
117 * @brief Callback for widget window
119 * If Widget Application consume key event, this api is not called.
121 * @param[in] event The key event.
123 void OnWindowKeyEvent(const Dali::KeyEvent& event);
126 * @brief Feed keyEvent to Widget.
128 * @param[in] instanceHandle the handle of widget instance
129 * @param[in] keyEvent The key event for widget
130 * @return True if widget consume keyEvent, false otherwise.
132 bool FeedKeyEvent(widget_base_instance_h instanceHandle, const Dali::KeyEvent& keyEvent);
136 * Private Constructor
137 * @param[in] argc A pointer to the number of arguments
138 * @param[in] argv A pointer to the argument list
139 * @param[in] stylesheet The path to user defined theme file
140 * @param[in] windowData The window data
142 WidgetApplicationTizen(int* argc, char** argv[], const std::string& stylesheet, const WindowData& windowData);
147 virtual ~WidgetApplicationTizen();
149 WidgetApplicationTizen(const Application&) = delete;
150 WidgetApplicationTizen& operator=(Application&) = delete;
153 typedef std::pair<widget_base_instance_h, Dali::Widget> WidgetInstancePair;
154 typedef std::vector<WidgetInstancePair> WidgetInstanceContainer;
156 CreateWidgetFunctionContainer mCreateWidgetFunctionContainer;
157 WidgetInstanceContainer mWidgetInstanceContainer;
159 bool mConnectedKeyEvent; // Check if keyEvent is connected
160 bool mReceivedKeyEvent; // Check if application receive keyEvent
163 } // namespace Adaptor
165 } // namespace Internal
169 #endif // DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H