[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / text-controls / text-selection-popup.h
1 #ifndef DALI_TOOLKIT_TEXT_SELECTION_POPUP_H
2 #define DALI_TOOLKIT_TEXT_SELECTION_POPUP_H
3
4 /*
5  * Copyright (c) 2022 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 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23 #include <dali/public-api/object/property-map.h>
24
25 namespace Dali
26 {
27 namespace Toolkit
28 {
29 class TextSelectionPopupCallbackInterface;
30
31 namespace Internal DALI_INTERNAL
32 {
33 class TextSelectionPopup;
34 }
35
36 /**
37  * @brief A control which provides a Popup with a number of buttons
38  *
39  * The style of the pop can be set through style sheets, this includes the images for the buttons
40  * A Show and Hide API is provided.
41  *
42  * If the buttons exceed the size constraints of the popup then it will offer scrolling.
43  *
44  *
45  */
46 class DALI_TOOLKIT_API TextSelectionPopup : public Control
47 {
48 public:
49   enum Buttons
50   {
51     CUT        = 1u << 0,
52     COPY       = 1u << 1,
53     PASTE      = 1u << 2,
54     SELECT     = 1u << 3,
55     SELECT_ALL = 1u << 4,
56     CLIPBOARD  = 1u << 5,
57     NONE       = 1u << 6,
58   };
59
60   /**
61    * @brief The start and end property ranges for this control.
62    */
63   enum PropertyRange
64   {
65     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
66     PROPERTY_END_INDEX   = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
67   };
68
69   /**
70    * @brief An enumeration of properties belonging to the TextSelectionPopup class.
71    */
72   struct Property
73   {
74     enum
75     {
76       /**
77        * @brief The maximum size the Popup can be.
78        * @details Name "popupMaxSize", type Vector2.
79        */
80       POPUP_MAX_SIZE = PROPERTY_START_INDEX,
81
82       /**
83        * @brief The minimum size the Popup can be.
84        * @details Name "popupMinSize", type Vector2.
85        */
86       POPUP_MIN_SIZE,
87
88       /**
89        * @brief The maximum size an option can be.
90        * @details Name "optionMaxSize", type Vector2.
91        */
92       OPTION_MAX_SIZE,
93
94       /**
95        * @brief The minimum size an option can be.
96        * @details Name "optionMinSize", type Vector2.
97        */
98       OPTION_MIN_SIZE,
99
100       /**
101        * @brief The size of the divider between options.
102        * @details Name "optionDividerSize", type Vector2.
103        */
104       OPTION_DIVIDER_SIZE,
105
106       /**
107        * @brief The padding of the divider between options.
108        * @details Name "optionDividerPadding", type Vector4.
109        */
110       OPTION_DIVIDER_PADDING,
111
112       /**
113        * @brief The image to use as the popup clipboard icon.
114        * @details Name "popupClipboardButtonImage", type string.
115        */
116       POPUP_CLIPBOARD_BUTTON_ICON_IMAGE,
117
118       /**
119        * @brief The image to use as the popup cut icon.
120        * @details Name "popupCutButtonImage", type string.
121        */
122       POPUP_CUT_BUTTON_ICON_IMAGE,
123
124       /**
125        * @brief The image to use as the popup copy icon.
126        * @details Name "popupCopyButtonImage", type string.
127        */
128       POPUP_COPY_BUTTON_ICON_IMAGE,
129
130       /**
131        * @brief The image to use as the popup paste icon.
132        * @details Name "popupPasteButtonImage", type string.
133        */
134       POPUP_PASTE_BUTTON_ICON_IMAGE,
135
136       /**
137        * @brief The image to use as the popup select icon.
138        * @details Name "popupSelectButtonImage", type string.
139        */
140       POPUP_SELECT_BUTTON_ICON_IMAGE,
141
142       /**
143        * @brief The image to use as the popup select all icon.
144        * @details Name "popupSelectAllButtonImage", type string.
145        */
146       POPUP_SELECT_ALL_BUTTON_ICON_IMAGE,
147
148       /**
149        * @brief The color of the divider between options.
150        * @details Name "popupDividerColor", type Vector4.
151        */
152       POPUP_DIVIDER_COLOR,
153
154       /**
155        * @brief The color of the icons (if supplied).
156        * @details Name "popupIconColor", type Vector4.
157        */
158       POPUP_ICON_COLOR,
159
160       /**
161        * @brief The color of the option when pressed.
162        * @details Name "popupPressedColor", type Vector4.
163        */
164       POPUP_PRESSED_COLOR,
165
166       /**
167        * @brief The corner radius of the option when pressed.
168        * @details Name "popupPressedCornerRadius", type float.
169        */
170       POPUP_PRESSED_CORNER_RADIUS,
171
172       /**
173        * @brief The image to use for the option when pressed.
174        * @details Name "popupPressedImage", type string.
175        */
176       POPUP_PRESSED_IMAGE,
177
178       /**
179        * @brief The duration of the fade-in animation.
180        * @details Name "popupFadeInDuration", type float.
181        */
182       POPUP_FADE_IN_DURATION,
183
184       /**
185        * @brief The duration of the fade-out animation.
186        * @details Name "popupFadeOutDuration", type float.
187        */
188       POPUP_FADE_OUT_DURATION,
189
190       /**
191        * @brief The popup background can have a separate border with a different color.
192        * @details Name "backgroundBorder", type Property::Map.
193        * @note Optional.
194        */
195       BACKGROUND_BORDER,
196
197       /**
198        * @brief The popup background.
199        * @details Name "background", type Property::Map.
200        * @note Optional.
201        */
202       BACKGROUND,
203
204       /**
205        * @brief The minimum size of popup label.
206        * @details Name "labelMinimumSize", type Vector2.
207        * @note Optional.
208        */
209       LABEL_MINIMUM_SIZE,
210
211       /**
212        * @brief The padding of popup label.
213        * @details Name "labelPadding", type Vector4.
214        * @note Optional.
215        */
216       LABEL_PADDING,
217
218       /**
219        * @brief The text visual map of popup label.
220        * @details Name "labelTextVisual", type Property::Map.
221        * @note Optional.
222        */
223       LABEL_TEXT_VISUAL,
224
225       /**
226        * @brief Whether the scroll-bar is enabled.
227        * @details Name "enableScrollBar", type Property::BOOLEAN.
228        * @note Optional.
229        */
230       ENABLE_SCROLL_BAR
231     };
232   };
233
234   /**
235    * Create the TextSelectionPopup control.
236    * @param[in] callbackInterface The text popup callback interface which receives the button click callbacks.
237    * @return A handle to the TextSelectionPopup control.
238    */
239   static TextSelectionPopup New(TextSelectionPopupCallbackInterface* callbackInterface);
240
241   /**
242    * @brief Creates an empty handle.
243    */
244   TextSelectionPopup();
245
246   /**
247    * @brief Copy constructor.
248    *
249    * @param[in] handle The handle to copy from.
250    */
251   TextSelectionPopup(const TextSelectionPopup& handle);
252
253   /**
254    * @brief Assignment operator.
255    *
256    * @param[in] handle The handle to copy from.
257    * @return A reference to this.
258    */
259   TextSelectionPopup& operator=(const TextSelectionPopup& handle);
260
261   /**
262    * @brief Move constructor.
263    *
264    * @param[in] handle The handle to move from.
265    */
266   TextSelectionPopup(TextSelectionPopup&& handle);
267
268   /**
269    * @brief Move assignment operator.
270    *
271    * @param[in] handle The handle to move from.
272    * @return A reference to this.
273    */
274   TextSelectionPopup& operator=(TextSelectionPopup&& handle);
275
276   /**
277    * @brief Destructor
278    *
279    * This is non-virtual since derived Handle types must not contain data or virtual methods.
280    */
281   ~TextSelectionPopup();
282
283   /**
284    * @brief Downcast a handle to TextSelectionPopup.
285    *
286    * If the BaseHandle points is a TextSelectionPopup the downcast returns a valid handle.
287    * If not the returned handle is left empty.
288    *
289    * @param[in] handle Handle to an object
290    * @return handle to a TextSelectionPopup or an empty handle
291    */
292   static TextSelectionPopup DownCast(BaseHandle handle);
293
294   /**
295    * @brief Specify which buttons to show in Popup
296    * @param[in] buttonsToEnable Buttons to enable
297    */
298   void EnableButtons(Toolkit::TextSelectionPopup::Buttons buttonsToEnable);
299
300   /**
301    * @brief Raises the toolbar's actor above the given @e target actor.
302    *
303    * @param[in] target The actor to get above of.
304    */
305   void RaiseAbove(Actor target);
306
307   /**
308    * @brief Show the Popup if not being shown
309    */
310   void ShowPopup();
311
312   /**
313    * @brief Hide the Popup if shown
314    */
315   void HidePopup();
316
317   /**
318    * @brief Used to set options of text selection popup
319    *
320    * @param[in] properties The text selection popup options
321    */
322   void SetProperties(const Dali::Property::Map& properties);
323
324   /**
325    * @brief Retrieve property map of text selection popup options
326    *
327    * @param[out] properties The text selection popup options
328    */
329   void GetProperties(Dali::Property::Map& properties);
330
331 public: // Not intended for application developers
332   /**
333    * @brief Creates a handle using the Toolkit::Internal implementation.
334    *
335    * @param[in] implementation The Control implementation.
336    */
337   DALI_INTERNAL TextSelectionPopup(Internal::TextSelectionPopup& implementation);
338
339   /**
340    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
341    *
342    * @param[in]  internal  A pointer to the internal CustomActor.
343    */
344   explicit DALI_INTERNAL TextSelectionPopup(Dali::Internal::CustomActor* internal);
345
346 }; // Class TextSelectionPopup
347
348 } // namespace Toolkit
349
350 } // namespace Dali
351
352 #endif // DALI_TOOLKIT_TEXT_SELECTION_POPUP_H