Use WindowData in the constructors of Application and Window
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / tizen-wayland / widget-application-impl-tizen.h
1 #ifndef DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H
2 #define DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <screen_connector_provider.h>
23 #include <widget_base.h>
24
25 // INTERNAL INCLUDES
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>
29
30 namespace Dali
31 {
32 class Widget;
33
34 namespace Internal
35 {
36 namespace Adaptor
37 {
38 class WidgetApplication;
39 typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
40
41 /**
42  * Implementation of the WidgetApplication class.
43  */
44 class WidgetApplicationTizen : public WidgetApplication, public ConnectionTracker
45 {
46 public:
47   typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction> CreateWidgetFunctionPair;
48   typedef std::vector<CreateWidgetFunctionPair>                                       CreateWidgetFunctionContainer;
49
50   /**
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
56    */
57   static WidgetApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet, const WindowData& windowData);
58
59 public:
60   /**
61    * @copydoc Dali::Internal::Adaptor::Application::OnInit()
62    */
63   void OnInit() override;
64
65   /**
66    * @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
67    */
68   void RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction) override;
69
70   /**
71    * Add widget name - CreateWidgetFunction pair to container.
72    */
73   void AddWidgetCreatingFunctionPair(CreateWidgetFunctionPair pair);
74
75   /**
76    * Find and get CreateWidgetFunctionPair in container by widget name.
77    */
78   CreateWidgetFunctionPair GetWidgetCreatingFunctionPair(const std::string& widgetName);
79
80   /**
81    * Add widget_base_instance_h - Widget instance pair to container.
82    */
83   void AddWidget(widget_base_instance_h widgetBaseInstance, Dali::Widget widget, Dali::Window window, const std::string& widgetId);
84
85   /**
86    * Find and get Widget instance in container by widget_base_instance_h.
87    */
88   Dali::Widget GetWidget(widget_base_instance_h widgetBaseInstance) const;
89
90   /**
91    * Delete widget_base_instance_h - Widget instance pair in container.
92    */
93   void DeleteWidget(widget_base_instance_h widgetBaseInstance);
94
95   /**
96    * Find and get Window instance in container by widget_base_instance_h.
97    */
98   Dali::Window GetWindowFromWidget(Dali::Widget widget) const;
99
100   /**
101    * Find and get widget_base_instance in container by widget id.
102    */
103   widget_base_instance_h GetWidgetInstanceFromWidgetId(std::string& widgetId) const;
104   /**
105    * Get the number of created widget.
106    */
107   int32_t GetWidgetCount();
108
109   /**
110    * @brief connect the keyEvent for window
111    *
112    * @param[in] window window for connecting keyEvent
113    */
114   void ConnectKeyEvent(Dali::Window window);
115
116   /**
117    * @brief Callback for widget window
118    *
119    * If Widget Application consume key event, this api is not called.
120    *
121    * @param[in] event The key event.
122    */
123   void OnWindowKeyEvent(const Dali::KeyEvent& event);
124
125   /**
126    * @brief Feed keyEvent to Widget.
127    *
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.
131    */
132   bool FeedKeyEvent(widget_base_instance_h instanceHandle, const Dali::KeyEvent& keyEvent);
133
134 protected:
135   /**
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
141    */
142   WidgetApplicationTizen(int* argc, char** argv[], const std::string& stylesheet, const WindowData& windowData);
143
144   /**
145    * Destructor
146    */
147   virtual ~WidgetApplicationTizen();
148
149   WidgetApplicationTizen(const Application&) = delete;
150   WidgetApplicationTizen& operator=(Application&) = delete;
151
152 private:
153   typedef std::pair<widget_base_instance_h, Dali::Widget> WidgetInstancePair;
154   typedef std::vector<WidgetInstancePair>                 WidgetInstanceContainer;
155
156   CreateWidgetFunctionContainer mCreateWidgetFunctionContainer;
157   WidgetInstanceContainer       mWidgetInstanceContainer;
158
159   bool mConnectedKeyEvent; // Check if keyEvent is connected
160   bool mReceivedKeyEvent;  // Check if application receive keyEvent
161 };
162
163 } // namespace Adaptor
164
165 } // namespace Internal
166
167 } // namespace Dali
168
169 #endif // DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H