Add ecore_wl2_window_commit() when setting minumum size and maximum size.
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / widget-impl.h
1 #ifndef DALI_INTERNAL_WIDGET_H
2 #define DALI_INTERNAL_WIDGET_H
3
4 /*
5  * Copyright (c) 2020 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 <dali/public-api/object/base-object.h>
23 #include <dali/public-api/signals/connection-tracker-interface.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/adaptor-framework/widget.h>
27 #include <dali/public-api/adaptor-framework/window.h>
28
29 namespace Dali
30 {
31 /**
32  * @addtogroup dali_adaptor_framework
33  * @{
34  */
35
36 namespace Internal
37 {
38 namespace Adaptor
39 {
40 class Widget;
41 typedef IntrusivePtr<Widget> WidgetPtr;
42
43 /**
44  * @brief This is the internal base class of custom widget.
45  *
46  * It will provides several widget instance lifecycle virtual functions
47  * which the user can override.
48  *
49  * User should override OnCreate function and create scene for custom widget.
50  *
51  * Plus, Implements ConnectionTrackerInterface so that signals (typically connected to member functions) will
52  * be disconnected automatically when the control is destroyed.
53  *
54  * @SINCE_1_3_5
55  */
56 class DALI_ADAPTOR_API Widget : public BaseObject, public ConnectionTrackerInterface
57 {
58 public:
59   /**
60    * @brief Creates a new WidgetImpl instance.
61    *
62    * @SINCE_1_3_5
63    * @return A handle to the WidgetImpl instance
64    */
65   static WidgetPtr New();
66
67   /**
68    * @brief The user should override this function to determine when they create widget.
69    *
70    * @SINCE_1_3_5
71    * @param[in] contentInfo Information from WidgetView for creating. It contains previous status of widget which is sent by SetContentInfo before.
72    * @param[in] window Window handle for widget
73    */
74   virtual void OnCreate(const std::string& contentInfo, Dali::Window window);
75
76   /**
77    * @brief The user should override this function to determine when they terminate widget.
78    *
79    * @SINCE_1_3_5
80    * @param[in] contentInfo Data from WidgetView for deleting
81    * @param[in] type Termination type. When user delete widget view, termination type is PERMANENT.
82    */
83   virtual void OnTerminate(const std::string& contentInfo, Dali::Widget::Termination type);
84
85   /**
86    * @brief The user should override this function to determine when they pause widget.
87    * @SINCE_1_3_5
88    */
89   virtual void OnPause();
90
91   /**
92    * @brief The user should override this function to determine when they resume widget.
93    * @SINCE_1_3_5
94    */
95   virtual void OnResume();
96
97   /**
98    * @brief The user should override this function to determine when they resize widget.
99    *
100    * @SINCE_1_3_5
101    * @param[in] window Window handle for widget
102    */
103   virtual void OnResize(Dali::Window window);
104
105   /**
106    * @brief The user should override this function to determine when they update widget.
107    *
108    * @SINCE_1_3_5
109    * @param[in] contentInfo Data from WidgetView for updating
110    * @param[in] force Although the widget is paused, if it is true, the widget can be updated
111    */
112   virtual void OnUpdate(const std::string& contentInfo, int force);
113
114   // From ConnectionTrackerInterface
115
116   /**
117    * @copydoc ConnectionTrackerInterface::SignalConnected
118    */
119   void SignalConnected(SlotObserver* slotObserver, CallbackBase* callback) override;
120
121   /**
122    * @copydoc ConnectionTrackerInterface::SignalDisconnected
123    */
124   void SignalDisconnected(SlotObserver* slotObserver, CallbackBase* callback) override;
125
126   /**
127    * @brief Set content info to WidgetView.
128    *
129    * @SINCE_1_3_5
130    * @param[in] contentInfo Content info is kind of context information which contains current status of widget.
131    */
132   void SetContentInfo(const std::string& contentInfo);
133
134   /**
135    * @brief Check Widget is using key
136    *
137    * widget can set flag to SetUsingKeyEvent
138    *
139    * @return True if Widget is using key
140    */
141   bool IsKeyEventUsing() const;
142
143   /**
144    * @brief Set the flag that widget is using keyEvent
145    *
146    * @param[in] flag The flag to set.
147    */
148   void SetUsingKeyEvent(bool flag);
149
150 protected:
151   /**
152    * @brief WidgetImpl constructor
153    */
154   Widget();
155
156   /**
157    * @brief Virtual destructor
158    */
159   ~Widget() override;
160
161   /// @cond internal
162 public:
163   class Impl; // Class declaration is public so we can internally add devel API's to the WidgetImpl
164
165   /**
166    * Set pointer of WidgetImpl Internal.
167    * @SINCE_1_3_5
168    */
169   void SetImpl(Impl* impl);
170
171   /**
172    * @brief Set the Information of widget
173    *
174    * @param window The window to set the information of widget
175    * @param widgetId The Id of widget
176    */
177   void SetInformation(Dali::Window window, const std::string& widgetId);
178
179   /**
180    * @brief Get the Window of widget
181    *
182    * @return the window of widget
183    */
184   Dali::Window GetWindow() const;
185
186   /**
187    * @brief Get the id of widget
188    *
189    * @return the id of widget
190    */
191   std::string GetWidgetId() const;
192
193 private:
194   Impl* mImpl;
195
196   // Undefined
197   DALI_INTERNAL Widget(const Widget&);
198   DALI_INTERNAL Widget& operator=(Widget&);
199   /// @endcond
200 };
201
202 /**
203  * @brief Gets implementation from the handle.
204  *
205  * @SINCE_1_3_5
206  * @param handle
207  * @return Implementation
208  * @pre handle is initialized and points to a widget
209  */
210 DALI_ADAPTOR_API Internal::Adaptor::Widget& GetImplementation(Dali::Widget& widget);
211
212 /**
213  * @brief Gets implementation from the handle.
214  *
215  * @SINCE_1_3_5
216  * @param handle
217  * @return Implementation
218  * @pre Handle is initialized and points to a widget.
219  */
220 DALI_ADAPTOR_API const Internal::Adaptor::Widget& GetImplementation(const Dali::Widget& widget);
221
222 } // namespace Adaptor
223
224 } // namespace Internal
225
226 /**
227  * @}
228  */
229
230 } // namespace Dali
231 #endif // DALI_INTERNAL_WIDGET_H