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