1 #ifndef DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H
2 #define DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H
5 * Copyright (c) 2021 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 <widget_base.h>
23 #include <screen_connector_provider.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
56 static WidgetApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet);
60 * @copydoc Dali::Internal::Adaptor::Application::OnInit()
62 void OnInit() override;
65 * @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
67 void RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction) override;
70 * Add widget name - CreateWidgetFunction pair to container.
72 void AddWidgetCreatingFunctionPair(CreateWidgetFunctionPair pair);
75 * Find and get CreateWidgetFunctionPair in container by widget name.
77 CreateWidgetFunctionPair GetWidgetCreatingFunctionPair(const std::string& widgetName);
80 * Add widget_base_instance_h - Widget instance pair to container.
82 void AddWidget(widget_base_instance_h widgetBaseInstance, Dali::Widget widget, Dali::Window window, const std::string& widgetId);
85 * Find and get Widget instance in container by widget_base_instance_h.
87 Dali::Widget GetWidget(widget_base_instance_h widgetBaseInstance) const;
90 * Delete widget_base_instance_h - Widget instance pair in container.
92 void DeleteWidget(widget_base_instance_h widgetBaseInstance);
95 * Find and get Window instance in container by widget_base_instance_h.
97 Dali::Window GetWindowFromWidget(Dali::Widget widget) const;
100 * Find and get widget_base_instance in container by widget id.
102 widget_base_instance_h GetWidgetInstanceFromWidgetId(std::string& widgetId) const;
104 * Get the number of created widget.
106 int32_t GetWidgetCount();
109 * @brief connect the keyEvent for window
111 * @param[in] window window for connecting keyEvent
113 void ConnectKeyEvent(Dali::Window window);
116 * @brief Callback for widget window
118 * If Widget Application consume key event, this api is not called.
120 * @param[in] event The key event.
122 void OnWindowKeyEvent(const Dali::KeyEvent& event);
125 * @brief Feed keyEvent to Widget.
127 * @param[in] instanceHandle the handle of widget instance
128 * @param[in] keyEvent The key event for widget
129 * @return True if widget consume keyEvent, false otherwise.
131 bool FeedKeyEvent(widget_base_instance_h instanceHandle, const Dali::KeyEvent& keyEvent);
135 * Private Constructor
136 * @param[in] argc A pointer to the number of arguments
137 * @param[in] argv A pointer to the argument list
138 * @param[in] stylesheet The path to user defined theme file
140 WidgetApplicationTizen(int* argc, char** argv[], const std::string& stylesheet);
145 virtual ~WidgetApplicationTizen();
147 WidgetApplicationTizen(const Application&) = delete;
148 WidgetApplicationTizen& operator=(Application&) = delete;
151 typedef std::pair<widget_base_instance_h, Dali::Widget> WidgetInstancePair;
152 typedef std::vector<WidgetInstancePair> WidgetInstanceContainer;
154 CreateWidgetFunctionContainer mCreateWidgetFunctionContainer;
155 WidgetInstanceContainer mWidgetInstanceContainer;
157 bool mConnectedKeyEvent; // Check if keyEvent is connected
158 bool mReceivedKeyEvent; // Check if application receive keyEvent
161 } // namespace Adaptor
163 } // namespace Internal
167 #endif // DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H