[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / controller / text-controller.h
1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_H
3
4 /*
5  * Copyright (c) 2024 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-toolkit/devel-api/text/spanned.h>
23 #include <dali/devel-api/adaptor-framework/clipboard.h>
24 #include <dali/devel-api/adaptor-framework/input-method-context.h>
25 #include <dali/integration-api/processor-interface.h>
26 #include <dali/public-api/events/gesture.h>
27
28 // INTERNAL INCLUDES
29 #include <dali-toolkit/devel-api/controls/text-controls/text-anchor-devel.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
32 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
33 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
34 #include <dali-toolkit/internal/text/hidden-text.h>
35 #include <dali-toolkit/internal/text/input-filter.h>
36 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
37 #include <dali-toolkit/internal/text/text-anchor-control-interface.h>
38 #include <dali-toolkit/internal/text/text-model-interface.h>
39 #include <dali-toolkit/internal/text/text-selectable-control-interface.h>
40 #include <dali-toolkit/public-api/text/text-enumerations.h>
41
42 namespace Dali::Toolkit::Text
43 {
44 class Controller;
45 class ControlInterface;
46 class EditableControlInterface;
47 class View;
48 class RenderingController;
49
50 /**
51    * @brief Text selection operations .
52    */
53 enum SelectionType
54 {
55   INTERACTIVE = 0x0000, ///< Select the word where the cursor is located.
56   ALL         = 0x0001, ///< Select the whole text.
57   NONE        = 0x0002, ///< Unselect the whole text.
58   RANGE       = 0x0003  ///< Select the range text.
59 };
60
61 typedef IntrusivePtr<Controller> ControllerPtr;
62
63 /**
64  * @brief A Text Controller is used by UI Controls which display text.
65  *
66  * It manipulates the Logical & Visual text models on behalf of the UI Controls.
67  * It provides a view of the text that can be used by rendering back-ends.
68  *
69  * For selectable/editable UI controls, the controller handles input events from the UI control
70  * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
71  *
72  * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
73  */
74 class Controller : public RefObject,
75                    public Decorator::ControllerInterface,
76                    public TextSelectionPopupCallbackInterface,
77                    public HiddenText::Observer,
78                    public ConnectionTracker,
79                    public Integration::Processor
80 {
81 public: // Enumerated types.
82   /**
83    * @brief Text related operations to be done in the relayout process.
84    */
85   enum OperationsMask
86   {
87     NO_OPERATION       = 0x0000,
88     CONVERT_TO_UTF32   = 0x0001,
89     GET_SCRIPTS        = 0x0002,
90     VALIDATE_FONTS     = 0x0004,
91     GET_LINE_BREAKS    = 0x0008,
92     BIDI_INFO          = 0x0010,
93     SHAPE_TEXT         = 0x0020,
94     GET_GLYPH_METRICS  = 0x0040,
95     LAYOUT             = 0x0080,
96     UPDATE_LAYOUT_SIZE = 0x0100,
97     REORDER            = 0x0200,
98     ALIGN              = 0x0400,
99     COLOR              = 0x0800,
100     UPDATE_DIRECTION   = 0x1000,
101     ALL_OPERATIONS     = 0xFFFF
102   };
103
104   /**
105    * @brief Used to distinguish between regular key events and InputMethodContext events
106    */
107   enum InsertType
108   {
109     COMMIT,
110     PRE_EDIT
111   };
112
113   /**
114    * @brief Used to specify whether to update the input style.
115    */
116   enum UpdateInputStyleType
117   {
118     UPDATE_INPUT_STYLE,
119     DONT_UPDATE_INPUT_STYLE
120   };
121
122   /**
123    * @brief Used to specify what has been updated after the Relayout() method has been called.
124    */
125   enum UpdateTextType
126   {
127     NONE_UPDATED      = 0x0, ///< Nothing has been updated.
128     MODEL_UPDATED     = 0x1, ///< The text's model has been updated.
129     DECORATOR_UPDATED = 0x2  ///< The decoration has been updated.
130   };
131
132   /**
133    * @brief Different placeholder-text can be shown when the control is active/inactive.
134    */
135   enum PlaceholderType
136   {
137     PLACEHOLDER_TYPE_ACTIVE,
138     PLACEHOLDER_TYPE_INACTIVE,
139   };
140
141   /**
142    * @brief Enumeration for Font Size Type.
143    */
144   enum FontSizeType
145   {
146     POINT_SIZE, // The size of font in points.
147     PIXEL_SIZE  // The size of font in pixels.
148   };
149
150   struct NoTextTap
151   {
152     enum Action
153     {
154       NO_ACTION,           ///< Does no action if there is a tap on top of an area with no text.
155       HIGHLIGHT,           ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
156       SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
157     };
158   };
159
160   struct TextFitInfo
161   {
162     enum Property
163     {
164       TEXT_FIT_ENABLE,
165       TEXT_FIT_MIN_SIZE,
166       TEXT_FIT_MAX_SIZE,
167       TEXT_FIT_STEP_SIZE,
168       TEXT_FIT_FONT_SIZE_TYPE
169     };
170   };
171
172 public: // Constructor.
173   /**
174    * @brief Create a new instance of a Controller.
175    *
176    * @return A pointer to a new Controller.
177    */
178   static ControllerPtr New()
179   {
180     return ControllerPtr(new Controller());
181   }
182
183   /**
184    * @brief Create a new instance of a Controller.
185    *
186    * @param[in] controlInterface The control's interface.
187    *
188    * @return A pointer to a new Controller.
189    */
190   static ControllerPtr New(ControlInterface* controlInterface)
191   {
192     return ControllerPtr(new Controller(controlInterface));
193   }
194
195   /**
196    * @brief Create a new instance of a Controller.
197    *
198    * @param[in] controlInterface The control's interface.
199    * @param[in] editableControlInterface The editable control's interface.
200    * @param[in] selectableControlInterface The selectable control's interface.
201    * @param[in] anchorControlInterface The anchor control's interface.
202    *
203    * @return A pointer to a new Controller.
204    */
205   static ControllerPtr New(ControlInterface*           controlInterface,
206                            EditableControlInterface*   editableControlInterface,
207                            SelectableControlInterface* selectableControlInterface,
208                            AnchorControlInterface*     anchorControlInterface)
209   {
210     return ControllerPtr(new Controller(controlInterface,
211                                         editableControlInterface,
212                                         selectableControlInterface,
213                                         anchorControlInterface));
214   }
215
216 public: // Configure the text controller.
217   /**
218    * @brief Called to enable text input.
219    *
220    * @note Selectable or editable controls should call this once after Controller::New().
221    * @param[in] decorator Used to create cursor, selection handle decorations etc.
222    * @param[in] inputMethodContext Used to manager ime.
223    */
224   void EnableTextInput(DecoratorPtr decorator, InputMethodContext& inputMethodContext);
225
226   /**
227    * @brief Used to switch between bitmap & vector based glyphs
228    *
229    * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
230    */
231   void SetGlyphType(TextAbstraction::GlyphType glyphType);
232
233   /**
234    * @brief Enables/disables the mark-up processor.
235    *
236    * By default is disabled.
237    *
238    * @param[in] enable Whether to enable the mark-up processor.
239    */
240   void SetMarkupProcessorEnabled(bool enable);
241
242   /**
243    * @brief Retrieves whether the mark-up processor is enabled.
244    *
245    * By default is disabled.
246    *
247    * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
248    */
249   bool IsMarkupProcessorEnabled() const;
250
251   /**
252    * @brief Retrieves whether the current text contains anchors.
253    *
254    * @return @e true if the current text contains anchors. @e false.
255    */
256   bool HasAnchors() const;
257
258   /**
259    * @brief Enables/disables the auto text scrolling
260    *
261    * By default is disabled.
262    *
263    * @param[in] enable Whether to enable the auto scrolling
264    */
265   void SetAutoScrollEnabled(bool enable);
266
267   /**
268    * @brief Whether the auto scrolling texture exceed max texture.
269    *
270    * By default is false.
271    *
272    * @param[in] exceed Whether the auto scrolling texture exceed max texture.
273    */
274   void SetAutoScrollMaxTextureExceeded(bool exceed);
275
276   /**
277    * @brief Retrieves whether auto text scrolling is enabled.
278    *
279    * By default is disabled.
280    *
281    * @return @e true if auto scrolling is enabled, otherwise returns @e false.
282    */
283   bool IsAutoScrollEnabled() const;
284
285   /**
286    * @brief Get direction of the text from the first line of text,
287    * @return bool rtl (right to left) is true
288    */
289   CharacterDirection GetAutoScrollDirection() const;
290
291   /**
292    * @brief Get the alignment offset of the first line of text.
293    *
294    * @return The alignment offset.
295    */
296   float GetAutoScrollLineAlignment() const;
297
298   /**
299    * @brief Enables the horizontal scrolling.
300    *
301    * @param[in] enable Whether to enable the horizontal scrolling.
302    */
303   void SetHorizontalScrollEnabled(bool enable);
304
305   /**
306    * @brief Retrieves whether the horizontal scrolling is enabled.
307    *
308    * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
309    */
310   bool IsHorizontalScrollEnabled() const;
311
312   /**
313    * @brief Enables the vertical scrolling.
314    *
315    * @param[in] enable Whether to enable the vertical scrolling.
316    */
317   void SetVerticalScrollEnabled(bool enable);
318
319   /**
320    * @brief Retrieves whether the verticall scrolling is enabled.
321    *
322    * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
323    */
324   bool IsVerticalScrollEnabled() const;
325
326   /**
327    * @brief Enables the smooth handle panning.
328    *
329    * @param[in] enable Whether to enable the smooth handle panning.
330    */
331   void SetSmoothHandlePanEnabled(bool enable);
332
333   /**
334    * @brief Retrieves whether the smooth handle panning is enabled.
335    *
336    * @return @e true if the smooth handle panning is enabled.
337    */
338   bool IsSmoothHandlePanEnabled() const;
339
340   /**
341    * @brief Sets the maximum number of characters that can be inserted into the TextModel
342    *
343    * @param[in] maxCharacters maximum number of characters to be accepted
344    */
345   void SetMaximumNumberOfCharacters(Length maxCharacters);
346
347   /**
348    * @brief Sets the maximum number of characters that can be inserted into the TextModel
349    *
350    * @param[in] maxCharacters maximum number of characters to be accepted
351    */
352   int GetMaximumNumberOfCharacters();
353
354   /**
355    * @brief Called to enable/disable cursor blink.
356    *
357    * @note Only editable controls should calls this.
358    * @param[in] enabled Whether the cursor should blink or not.
359    */
360   void SetEnableCursorBlink(bool enable);
361
362   /**
363    * @brief Query whether cursor blink is enabled.
364    *
365    * @return Whether the cursor should blink or not.
366    */
367   bool GetEnableCursorBlink() const;
368
369   /**
370    * @brief Whether to enable the multi-line layout.
371    *
372    * @param[in] enable \e true enables the multi-line (by default)
373    */
374   void SetMultiLineEnabled(bool enable);
375
376   /**
377    * @return Whether the multi-line layout is enabled.
378    */
379   bool IsMultiLineEnabled() const;
380
381   /**
382    * @brief Sets the text's horizontal alignment.
383    *
384    * @param[in] alignment The horizontal alignment.
385    */
386   void SetHorizontalAlignment(HorizontalAlignment::Type alignment);
387
388   /**
389    * @copydoc ModelInterface::GetHorizontalAlignment()
390    */
391   HorizontalAlignment::Type GetHorizontalAlignment() const;
392
393   /**
394    * @brief Sets the text's vertical alignment.
395    *
396    * @param[in] alignment The vertical alignment.
397    */
398   void SetVerticalAlignment(VerticalAlignment::Type alignment);
399
400   /**
401    * @copydoc ModelInterface::GetVerticalAlignment()
402    */
403   VerticalAlignment::Type GetVerticalAlignment() const;
404
405   /**
406    * @brief Sets the text's wrap mode
407    * @param[in] text wrap mode The unit of wrapping
408    */
409   void SetLineWrapMode(Text::LineWrap::Mode textWarpMode);
410
411   /**
412    * @brief Retrieve text wrap mode previously set.
413    * @return text wrap mode
414    */
415   Text::LineWrap::Mode GetLineWrapMode() const;
416
417   /**
418    * @brief Enable or disable the text elide.
419    *
420    * @param[in] enabled Whether to enable the text elide.
421    */
422   void SetTextElideEnabled(bool enabled);
423
424   /**
425    * @copydoc ModelInterface::IsTextElideEnabled()
426    */
427   bool IsTextElideEnabled() const;
428
429   /**
430    * @brief Enable or disable the text fit.
431    *
432    * @param[in] enabled Whether to enable the text fit.
433    */
434   void SetTextFitEnabled(bool enabled);
435
436   /**
437    * @brief Whether the text fit is enabled or not.
438    *
439    * @return True if the text fit is enabled
440    */
441   bool IsTextFitEnabled() const;
442
443   /**
444    * @brief Sets current line size.
445    *
446    * @param[in] lineSize line size value to store the MinLineSize set by user when TextFitArray is enabled.
447    */
448   void SetCurrentLineSize(float lineSize);
449
450   /**
451    * @brief Retrieves the current line size.
452    *
453    * @return The current line size
454    */
455   float GetCurrentLineSize() const;
456
457   /**
458    * @brief Sets minimum size valid for text fit.
459    *
460    * @param[in] minimum size value.
461    * @param[in] type The font size type is point size or pixel size
462    */
463   void SetTextFitMinSize(float pointSize, FontSizeType type);
464
465   /**
466    * @brief Retrieves the minimum point size valid for text fit.
467    *
468    * @return The minimum point size valid for text fit
469    */
470   float GetTextFitMinSize() const;
471
472   /**
473    * @brief Sets maximum size valid for text fit.
474    *
475    * @param[in] maximum size value.
476    * @param[in] type The font size type is point size or pixel size
477    */
478   void SetTextFitMaxSize(float pointSize, FontSizeType type);
479
480   /**
481    * @brief Retrieves the maximum point size valid for text fit.
482    *
483    * @return The maximum point size valid for text fit
484    */
485   float GetTextFitMaxSize() const;
486
487   /**
488    * @brief Sets step size for font increase valid for text fit.
489    *
490    * @param[in] step size value.
491    * @param[in] type The font size type is point size or pixel size
492    */
493   void SetTextFitStepSize(float step, FontSizeType type);
494
495   /**
496    * @brief Retrieves the step point size valid for text fit.
497    *
498    * @return The step point size valid for text fit
499    */
500   float GetTextFitStepSize() const;
501
502   /**
503    * @brief Sets content size valid for text fit.
504    *
505    * @param[in] Content size value.
506    */
507   void SetTextFitContentSize(Vector2 size);
508
509   /**
510    * @brief Retrieves the content size valid for text fit.
511    *
512    * @return The content size valid for text fit
513    */
514   Vector2 GetTextFitContentSize() const;
515
516   /**
517    * @brief Retrieve the fited point size.
518    *
519    * @return The fited point size.
520    */
521   float GetTextFitPointSize() const;
522
523   /**
524    * @brief Sets whether the text fit properties have changed.
525    *
526    * @param[in] changed Whether to changed the text fit.
527    */
528   void SetTextFitChanged(bool changed);
529
530   /**
531    * @brief Whether the text fit properties are changed or not.
532    *
533    * @return True if the text fit properties are changed
534    */
535   bool IsTextFitChanged() const;
536
537   /**
538    * @brief Sets line size valid for text fit.
539    *
540    * @param[in] lineSize line size value
541    */
542   void SetTextFitLineSize(float lineSize);
543
544   /**
545    * @brief Enable or disable the text fit array.
546    *
547    * @param[in] enabled Whether to enable the text fit array.
548    */
549   void SetTextFitArrayEnabled(bool enabled);
550
551   /**
552    * @brief Whether the text fit array is enabled or not.
553    *
554    * @return True if the text fit array is enabled.
555    */
556   bool IsTextFitArrayEnabled() const;
557
558   /**
559    * @brief Sets the text fit array.
560    *
561    * @param[in] fitOptions The list of text fit options.
562    */
563   void SetTextFitArray(std::vector<Toolkit::DevelTextLabel::FitOption>& fitOptions);
564
565   /**
566    * @brief Retrieve the text fit array.
567    *
568    * @return The list of text fit options.
569    */
570   std::vector<Toolkit::DevelTextLabel::FitOption>& GetTextFitArray();
571
572   /**
573    * @brief Sets disabled color opacity.
574    *
575    * @param[in] opacity The color opacity value in disabled state.
576    */
577   void SetDisabledColorOpacity(float opacity);
578
579   /**
580    * @brief Retrieves the disabled color opacity.
581    *
582    * @return The disabled color opacity value for disabled state.
583    */
584   float GetDisabledColorOpacity() const;
585
586   /**
587    * @brief Enable or disable the placeholder text elide.
588    * @param enabled Whether to enable the placeholder text elide.
589    */
590   void SetPlaceholderTextElideEnabled(bool enabled);
591
592   /**
593    * @brief Whether the placeholder text elide property is enabled.
594    * @return True if the placeholder text elide property is enabled, false otherwise.
595    */
596   bool IsPlaceholderTextElideEnabled() const;
597
598   /**
599    * @brief Enable or disable the text selection.
600    * @param[in] enabled Whether to enable the text selection.
601    */
602   void SetSelectionEnabled(bool enabled);
603
604   /**
605    * @brief Whether the text selection is enabled or not.
606    * @return True if the text selection is enabled
607    */
608   bool IsSelectionEnabled() const;
609
610   /**
611    * @brief Enable or disable the text selection using Shift key.
612    * @param enabled Whether to enable the text selection using Shift key
613    */
614   void SetShiftSelectionEnabled(bool enabled);
615
616   /**
617    * @brief Whether the text selection using Shift key is enabled or not.
618    * @return True if the text selection using Shift key is enabled
619    */
620   bool IsShiftSelectionEnabled() const;
621
622   /**
623    * @brief Enable or disable the grab handles for text selection.
624    *
625    * @param[in] enabled Whether to enable the grab handles
626    */
627   void SetGrabHandleEnabled(bool enabled);
628
629   /**
630    * @brief Returns whether the grab handles are enabled.
631    *
632    * @return True if the grab handles are enabled
633    */
634   bool IsGrabHandleEnabled() const;
635
636   /**
637    * @brief Enable or disable the grab handles for text selection.
638    *
639    * @param[in] enabled Whether to enable the grab handles
640    */
641   void SetGrabHandlePopupEnabled(bool enabled);
642
643   /**
644    * @brief Returns whether the grab handles are enabled.
645    *
646    * @return True if the grab handles are enabled
647    */
648   bool IsGrabHandlePopupEnabled() const;
649
650   /**
651    * @brief Sets input type to password
652    *
653    * @note The string is displayed hidden character
654    *
655    * @param[in] passwordInput True if password input is enabled.
656    */
657   void SetInputModePassword(bool passwordInput);
658
659   /**
660    * @brief Returns whether the input mode type is set as password.
661    *
662    * @return True if input mode type is password
663    */
664   bool IsInputModePassword();
665
666   /**
667    * @brief Sets the action when there is a double tap event on top of a text area with no text.
668    *
669    * @param[in] action The action to do.
670    */
671   void SetNoTextDoubleTapAction(NoTextTap::Action action);
672
673   /**
674    * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
675    *
676    * @return The action to do.
677    */
678   NoTextTap::Action GetNoTextDoubleTapAction() const;
679
680   /**
681    * @briefSets the action when there is a long press event on top of a text area with no text.
682    *
683    * @param[in] action The action to do.
684    */
685   void SetNoTextLongPressAction(NoTextTap::Action action);
686
687   /**
688    * @brief Retrieves the action when there is a long press event on top of a text area with no text.
689    *
690    * @return The action to do.
691    */
692   NoTextTap::Action GetNoTextLongPressAction() const;
693
694   /**
695    * @brief Query if Underline settings were provided by string or map
696    * @return bool true if set by string
697    */
698   bool IsUnderlineSetByString();
699
700   /**
701    * Set method underline setting were set by
702    * @param[in] bool, true if set by string
703    */
704   void UnderlineSetByString(bool setByString);
705
706   /**
707    * @brief Query if shadow settings were provided by string or map
708    * @return bool true if set by string
709    */
710   bool IsShadowSetByString();
711
712   /**
713    * Set method shadow setting were set by
714    * @param[in] bool, true if set by string
715    */
716   void ShadowSetByString(bool setByString);
717
718   /**
719    * @brief Query if outline settings were provided by string or map
720    * @return bool true if set by string
721    */
722   bool IsOutlineSetByString();
723
724   /**
725    * Set method outline setting were set by
726    * @param[in] bool, true if set by string
727    */
728   void OutlineSetByString(bool setByString);
729
730   /**
731    * @brief Query if font style settings were provided by string or map
732    * @return bool true if set by string
733    */
734   bool IsFontStyleSetByString();
735
736   /**
737    * Set method font style setting were set by
738    * @param[in] bool, true if set by string
739    */
740   void FontStyleSetByString(bool setByString);
741
742   /**
743    * @brief Query if Strikethrough settings were provided by string or map
744    * @return bool true if set by string
745    */
746   bool IsStrikethroughSetByString();
747
748   /**
749    * Set method Strikethrough setting were set by
750    * @param[in] bool, true if set by string
751    */
752   void StrikethroughSetByString(bool setByString);
753
754   /**
755    * @brief Set the override used for strikethrough height, 0 indicates height will be supplied by font metrics
756    *
757    * @param[in] height The height in pixels of the strikethrough
758    */
759   void SetStrikethroughHeight(float height);
760
761   /**
762    * @brief Retrieves the override height of an strikethrough, 0 indicates height is supplied by font metrics
763    *
764    * @return The height of the strikethrough, or 0 if height is not overrided.
765    */
766   float GetStrikethroughHeight() const;
767
768   /**
769    * @brief Set the strikethrough color.
770    *
771    * @param[in] color color of strikethrough.
772    */
773   void SetStrikethroughColor(const Vector4& color);
774
775   /**
776    * @brief Retrieve the strikethrough color.
777    *
778    * @return The strikethrough color.
779    */
780   const Vector4& GetStrikethroughColor() const;
781
782   /**
783    * @brief Set the strikethrough enabled flag.
784    *
785    * @param[in] enabled The strikethrough enabled flag.
786    */
787   void SetStrikethroughEnabled(bool enabled);
788
789   /**
790    * @brief Returns whether the text has a strikethrough or not.
791    *
792    * @return The strikethrough state.
793    */
794   bool IsStrikethroughEnabled() const;
795
796 public: // Update.
797   /**
798    * @brief Replaces any text previously set.
799    *
800    * @note This will be converted into UTF-32 when stored in the text model.
801    * @param[in] text A string of UTF-8 characters.
802    */
803   void SetText(const std::string& text);
804
805   /**
806    * @brief Retrieve any text previously set.
807    *
808    * @param[out] text A string of UTF-8 characters.
809    */
810   void GetText(std::string& text) const;
811
812   /**
813    * @brief Retrieves number of characters previously set.
814    *
815    * @return A length of string of UTF-32 characters.
816    */
817   Length GetNumberOfCharacters() const;
818
819   /**
820  * @brief Set the @p spannedText
821  * the spanned text contains content (text) and  format (spans with ranges)
822  * the text is copied into text-controller and the spans are applied on ranges
823  *
824  * @param[in] spannedText the text with spans.
825  */
826   void SetSpannedText(const Text::Spanned& spannedText);
827
828   /**
829    * @brief Replaces any placeholder text previously set.
830    *
831    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
832    * @param[in] text A string of UTF-8 characters.
833    */
834   void SetPlaceholderText(PlaceholderType type, const std::string& text);
835
836   /**
837    * @brief Retrieve any placeholder text previously set.
838    *
839    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
840    * @param[out] A string of UTF-8 characters.
841    */
842   void GetPlaceholderText(PlaceholderType type, std::string& text) const;
843
844   /**
845    * @ brief Update the text after a font change
846    * @param[in] newDefaultFont The new font to change to
847    */
848   void UpdateAfterFontChange(const std::string& newDefaultFont);
849
850   /**
851    * @brief The method acquires currently selected text
852    * @param selectedText variable to place selected text in
853    */
854   void RetrieveSelection(std::string& selectedText) const;
855
856   /**
857    * @brief The method sets selection in given range
858    * @param start index of first character
859    * @param end   index of first character after selection
860    */
861   void SetSelection(int start, int end);
862
863   /**
864    * @brief This method retrieve indexes of current selection
865    *
866    * @return a pair, where first element is left index of selection and second is the right one
867    */
868   std::pair<int, int> GetSelectionIndexes() const;
869
870   /**
871    * Place string in system clipboard
872    * @param source std::string
873    */
874   void CopyStringToClipboard(const std::string& source);
875
876   /**
877    * Place currently selected text in system clipboard
878    * @param deleteAfterSending flag pointing if text should be deleted after sending to clipboard
879    */
880   void SendSelectionToClipboard(bool deleteAfterSending);
881
882 public: // Default style & Input style
883   /**
884    * @brief Set the default font family.
885    *
886    * @param[in] defaultFontFamily The default font family.
887    */
888   void SetDefaultFontFamily(const std::string& defaultFontFamily);
889
890   /**
891    * @brief Retrieve the default font family.
892    *
893    * @return The default font family.
894    */
895   std::string GetDefaultFontFamily() const;
896
897   /**
898    * @brief Sets the placeholder text font family.
899    * @param[in] placeholderTextFontFamily The placeholder text font family.
900    */
901   void SetPlaceholderFontFamily(const std::string& placeholderTextFontFamily);
902
903   /**
904    * @brief Retrieves the placeholder text font family.
905    *
906    * @return The placeholder text font family
907    */
908   std::string GetPlaceholderFontFamily() const;
909
910   /**
911    * @brief Sets the default font weight.
912    *
913    * @param[in] weight The font weight.
914    */
915   void SetDefaultFontWeight(FontWeight weight);
916
917   /**
918    * @brief Whether the font's weight has been defined.
919    */
920   bool IsDefaultFontWeightDefined() const;
921
922   /**
923    * @brief Retrieves the default font weight.
924    *
925    * @return The default font weight.
926    */
927   FontWeight GetDefaultFontWeight() const;
928
929   /**
930    * @brief Sets the placeholder text font weight.
931    *
932    * @param[in] weight The font weight
933    */
934   void SetPlaceholderTextFontWeight(FontWeight weight);
935
936   /**
937    * @brief Whether the font's weight has been defined.
938    *
939    * @return True if the placeholder text font weight is defined
940    */
941   bool IsPlaceholderTextFontWeightDefined() const;
942
943   /**
944    * @brief Retrieves the placeholder text font weight.
945    *
946    * @return The placeholder text font weight
947    */
948   FontWeight GetPlaceholderTextFontWeight() const;
949
950   /**
951    * @brief Sets the default font width.
952    *
953    * @param[in] width The font width.
954    */
955   void SetDefaultFontWidth(FontWidth width);
956
957   /**
958    * @brief Whether the font's width has been defined.
959    */
960   bool IsDefaultFontWidthDefined() const;
961
962   /**
963    * @brief Retrieves the default font width.
964    *
965    * @return The default font width.
966    */
967   FontWidth GetDefaultFontWidth() const;
968
969   /**
970    * @brief Sets the placeholder text font width.
971    *
972    * @param[in] width The font width
973    */
974   void SetPlaceholderTextFontWidth(FontWidth width);
975
976   /**
977    * @brief Whether the font's width has been defined.
978    *
979    * @return True if the placeholder text font width is defined
980    */
981   bool IsPlaceholderTextFontWidthDefined() const;
982
983   /**
984    * @brief Retrieves the placeholder text font width.
985    *
986    * @return The placeholder text font width
987    */
988   FontWidth GetPlaceholderTextFontWidth() const;
989
990   /**
991    * @brief Sets the default font slant.
992    *
993    * @param[in] slant The font slant.
994    */
995   void SetDefaultFontSlant(FontSlant slant);
996
997   /**
998    * @brief Whether the font's slant has been defined.
999    */
1000   bool IsDefaultFontSlantDefined() const;
1001
1002   /**
1003    * @brief Retrieves the default font slant.
1004    *
1005    * @return The default font slant.
1006    */
1007   FontSlant GetDefaultFontSlant() const;
1008
1009   /**
1010    * @brief Sets the placeholder text font slant.
1011    *
1012    * @param[in] slant The font slant
1013    */
1014   void SetPlaceholderTextFontSlant(FontSlant slant);
1015
1016   /**
1017    * @brief Whether the font's slant has been defined.
1018    *
1019    * @return True if the placeholder text font slant is defined
1020    */
1021   bool IsPlaceholderTextFontSlantDefined() const;
1022
1023   /**
1024    * @brief Retrieves the placeholder text font slant.
1025    *
1026    * @return The placeholder text font slant
1027    */
1028   FontSlant GetPlaceholderTextFontSlant() const;
1029
1030   /**
1031    * @brief Set the default font size.
1032    *
1033    * @param[in] fontSize The default font size
1034    * @param[in] type The font size type is point size or pixel size
1035    */
1036   void SetDefaultFontSize(float fontSize, FontSizeType type);
1037
1038   /**
1039    * @brief Retrieve the default point size.
1040    *
1041    * @param[in] type The font size type
1042    * @return The default point size.
1043    */
1044   float GetDefaultFontSize(FontSizeType type) const;
1045
1046   /**
1047    * @brief Set the font size scale.
1048    *
1049    * @param[in] scale The font size scale
1050    */
1051   void SetFontSizeScale(float scale);
1052
1053   /**
1054    * @brief Get the font size scale.
1055    *
1056    * @return The font size scale.
1057    */
1058   float GetFontSizeScale() const;
1059
1060   /**
1061    * @brief Set the font size scale enabled flag.
1062    *
1063    * @param[in] enabled whether to enable the font size scale.
1064    */
1065   void SetFontSizeScaleEnabled(bool enabled);
1066
1067   /**
1068    * @brief Returns whether the font size scale is enabled or not.
1069    *
1070    * @return @e true if the font size scale is enabled, otherwise returns @e false.
1071    */
1072   bool IsFontSizeScaleEnabled() const;
1073
1074   /**
1075    * @brief Sets the Placeholder text font size.
1076    * @param[in] fontSize The placeholder text font size
1077    * @param[in] type The font size type is point size or pixel size
1078    */
1079   void SetPlaceholderTextFontSize(float fontSize, FontSizeType type);
1080
1081   /**
1082    * @brief Retrieves the Placeholder text font size.
1083    * @param[in] type The font size type
1084    * @return The placeholder font size
1085    */
1086   float GetPlaceholderTextFontSize(FontSizeType type) const;
1087
1088   /**
1089    * @brief Sets the text's default color.
1090    *
1091    * @param color The default color.
1092    */
1093   void SetDefaultColor(const Vector4& color);
1094
1095   /**
1096    * @brief Retrieves the text's default color.
1097    *
1098    * @return The default color.
1099    */
1100   const Vector4& GetDefaultColor() const;
1101
1102   /**
1103    * @brief Sets the anchor's default color.
1104    *
1105    * @param color The anchor color.
1106    */
1107   void SetAnchorColor(const Vector4& color);
1108
1109   /**
1110    * @brief Retrieves the anchor's default color.
1111    *
1112    * @return The anchor color.
1113    */
1114   const Vector4& GetAnchorColor() const;
1115
1116   /**
1117    * @brief Sets the anchor's clicked color.
1118    *
1119    * @param color The anchor color.
1120    */
1121   void SetAnchorClickedColor(const Vector4& color);
1122
1123   /**
1124    * @brief Retrieves the anchor's clicked color.
1125    *
1126    * @return The anchor color.
1127    */
1128   const Vector4& GetAnchorClickedColor() const;
1129
1130   /**
1131    * @brief Sets the user interaction enabled.
1132    *
1133    * @param enabled whether to enable the user interaction.
1134    */
1135   void SetUserInteractionEnabled(bool enabled);
1136
1137   /**
1138    * @brief Whether the user interaction is enabled.
1139    *
1140    * @return true if the user interaction is enabled, false otherwise.
1141    */
1142   bool IsUserInteractionEnabled() const;
1143
1144   /**
1145    * @brief Set the text color
1146    *
1147    * @param textColor The text color
1148    */
1149   void SetPlaceholderTextColor(const Vector4& textColor);
1150
1151   /**
1152    * @brief Retrieve the text color
1153    *
1154    * @return The text color
1155    */
1156   const Vector4& GetPlaceholderTextColor() const;
1157
1158   /**
1159    * @brief Set the shadow offset.
1160    *
1161    * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
1162    */
1163   void SetShadowOffset(const Vector2& shadowOffset);
1164
1165   /**
1166    * @brief Retrieve the shadow offset.
1167    *
1168    * @return The shadow offset.
1169    */
1170   const Vector2& GetShadowOffset() const;
1171
1172   /**
1173    * @brief Set the shadow color.
1174    *
1175    * @param[in] shadowColor The shadow color.
1176    */
1177   void SetShadowColor(const Vector4& shadowColor);
1178
1179   /**
1180    * @brief Retrieve the shadow color.
1181    *
1182    * @return The shadow color.
1183    */
1184   const Vector4& GetShadowColor() const;
1185
1186   /**
1187    * @brief Set the shadow blur radius.
1188    *
1189    * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
1190    */
1191   void SetShadowBlurRadius(const float& shadowBlurRadius);
1192
1193   /**
1194    * @brief Retrieve the shadow blur radius.
1195    *
1196    * @return The shadow blur radius.
1197    */
1198   const float& GetShadowBlurRadius() const;
1199
1200   /**
1201    * @brief Set the underline color.
1202    *
1203    * @param[in] color color of underline.
1204    */
1205   void SetUnderlineColor(const Vector4& color);
1206
1207   /**
1208    * @brief Retrieve the underline color.
1209    *
1210    * @return The underline color.
1211    */
1212   const Vector4& GetUnderlineColor() const;
1213
1214   /**
1215    * @brief Set the underline enabled flag.
1216    *
1217    * @param[in] enabled The underline enabled flag.
1218    */
1219   void SetUnderlineEnabled(bool enabled);
1220
1221   /**
1222    * @brief Returns whether the text is underlined or not.
1223    *
1224    * @return The underline state.
1225    */
1226   bool IsUnderlineEnabled() const;
1227
1228   /**
1229    * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
1230    *
1231    * @param[in] height The height in pixels of the underline
1232    */
1233   void SetUnderlineHeight(float height);
1234
1235   /**
1236    * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
1237    *
1238    * @return The height of the underline, or 0 if height is not overrided.
1239    */
1240   float GetUnderlineHeight() const;
1241
1242   /**
1243    * @brief Sets the underline type.
1244    * @param[in] type The underline type.
1245    */
1246   void SetUnderlineType(Text::Underline::Type type);
1247
1248   /**
1249    * @brief Retrieve underline type.
1250    * @return The underline type.
1251    */
1252   Text::Underline::Type GetUnderlineType() const;
1253
1254   /**
1255    * @brief Set the width of the dashes of the dashed underline.
1256    *
1257    * @param[in] width The width in pixels of the dashes of the dashed underline.
1258    */
1259   void SetDashedUnderlineWidth(float width);
1260
1261   /**
1262    * @brief Retrieves the width of the dashes of the dashed underline.
1263    *
1264    * @return The width of the dashes of the dashed underline.
1265    */
1266   float GetDashedUnderlineWidth() const;
1267
1268   /**
1269    * @brief Set the gap between the dashes of the dashed underline.
1270    *
1271    * @param[in] gap The gap between the dashes of the dashed underline.
1272    */
1273   void SetDashedUnderlineGap(float gap);
1274
1275   /**
1276    * @brief Retrieves the gap between the dashes of the dashed underline.
1277    *
1278    * @return The The gap between the dashes of the dashed underline.
1279    */
1280   float GetDashedUnderlineGap() const;
1281
1282   /**
1283    * @brief Set the outline color.
1284    *
1285    * @param[in] color color of outline.
1286    */
1287   void SetOutlineColor(const Vector4& color);
1288
1289   /**
1290    * @brief Retrieve the outline color.
1291    *
1292    * @return The outline color.
1293    */
1294   const Vector4& GetOutlineColor() const;
1295
1296   /**
1297    * @brief Set the outline width
1298    *
1299    * @param[in] width The width in pixels of the outline, 0 indicates no outline
1300    */
1301   void SetOutlineWidth(uint16_t width);
1302
1303   /**
1304    * @brief Retrieves the width of an outline
1305    *
1306    * @return The width of the outline.
1307    */
1308   uint16_t GetOutlineWidth() const;
1309
1310   /**
1311    * @brief Set the background color.
1312    *
1313    * @param[in] color color of background.
1314    */
1315   void SetBackgroundColor(const Vector4& color);
1316
1317   /**
1318    * @brief Retrieve the background color.
1319    *
1320    * @return The background color.
1321    */
1322   const Vector4& GetBackgroundColor() const;
1323
1324   /**
1325    * @brief Set the background enabled flag.
1326    *
1327    * @param[in] enabled The background enabled flag.
1328    */
1329   void SetBackgroundEnabled(bool enabled);
1330
1331   /**
1332    * @brief Returns whether to enable text background or not.
1333    *
1334    * @return Whether text background is enabled.
1335    */
1336   bool IsBackgroundEnabled() const;
1337
1338   /**
1339    * @brief Sets the emboss's properties string.
1340    *
1341    * @note The string is stored to be recovered.
1342    *
1343    * @param[in] embossProperties The emboss's properties string.
1344    */
1345   void SetDefaultEmbossProperties(const std::string& embossProperties);
1346
1347   /**
1348    * @brief Retrieves the emboss's properties string.
1349    *
1350    * @return The emboss's properties string.
1351    */
1352   std::string GetDefaultEmbossProperties() const;
1353
1354   /**
1355    * @brief Sets the outline's properties string.
1356    *
1357    * @note The string is stored to be recovered.
1358    *
1359    * @param[in] outlineProperties The outline's properties string.
1360    */
1361   void SetDefaultOutlineProperties(const std::string& outlineProperties);
1362
1363   /**
1364    * @brief Retrieves the outline's properties string.
1365    *
1366    * @return The outline's properties string.
1367    */
1368   std::string GetDefaultOutlineProperties() const;
1369
1370   /**
1371    * @brief Sets the default line spacing.
1372    *
1373    * @param[in] lineSpacing The line spacing.
1374    *
1375    * @return True if lineSpacing has been updated, false otherwise
1376    */
1377   bool SetDefaultLineSpacing(float lineSpacing);
1378
1379   /**
1380    * @brief Retrieves the default line spacing.
1381    *
1382    * @return The line spacing.
1383    */
1384   float GetDefaultLineSpacing() const;
1385
1386   /**
1387    * @brief Sets the default line size.
1388    *
1389    * @param[in] lineSize The line size.
1390    *
1391    * @return True if lineSize has been updated, false otherwise
1392    */
1393   bool SetDefaultLineSize(float lineSize);
1394
1395   /**
1396    * @brief Retrieves the default line size.
1397    *
1398    * @return The line size.
1399    */
1400   float GetDefaultLineSize() const;
1401
1402   /**
1403    * @brief Sets the relative line size to the original line size.
1404    *
1405    * @param[in] relativeLineSize The relativeline size.
1406    *
1407    * @return True if relativeLineSize has been updated, false otherwise
1408    */
1409   bool SetRelativeLineSize(float lineSize);
1410
1411   /**
1412    * @brief Retrieves the relative line size.
1413    *
1414    * @return The relative line size.
1415    */
1416   float GetRelativeLineSize() const;
1417
1418   /**
1419    * @brief Sets the input text's color.
1420    *
1421    * @param[in] color The input text's color.
1422    */
1423   void SetInputColor(const Vector4& color);
1424
1425   /**
1426    * @brief Retrieves the input text's color.
1427    *
1428    * @return The input text's color.
1429    */
1430   const Vector4& GetInputColor() const;
1431
1432   /**
1433    * @brief Sets the input text's font family name.
1434    *
1435    * @param[in] fontFamily The text's font family name.
1436    */
1437   void SetInputFontFamily(const std::string& fontFamily);
1438
1439   /**
1440    * @brief Retrieves the input text's font family name.
1441    *
1442    * @return The input text's font family name.
1443    */
1444   std::string GetInputFontFamily() const;
1445
1446   /**
1447    * @brief Sets the input font's weight.
1448    *
1449    * @param[in] weight The input font's weight.
1450    */
1451   void SetInputFontWeight(FontWeight weight);
1452
1453   /**
1454    * @return Whether the font's weight has been defined.
1455    */
1456   bool IsInputFontWeightDefined() const;
1457
1458   /**
1459    * @brief Retrieves the input font's weight.
1460    *
1461    * @return The input font's weight.
1462    */
1463   FontWeight GetInputFontWeight() const;
1464
1465   /**
1466    * @brief Sets the input font's width.
1467    *
1468    * @param[in] width The input font's width.
1469    */
1470   void SetInputFontWidth(FontWidth width);
1471
1472   /**
1473    * @return Whether the font's width has been defined.
1474    */
1475   bool IsInputFontWidthDefined() const;
1476
1477   /**
1478    * @brief Retrieves the input font's width.
1479    *
1480    * @return The input font's width.
1481    */
1482   FontWidth GetInputFontWidth() const;
1483
1484   /**
1485    * @brief Sets the input font's slant.
1486    *
1487    * @param[in] slant The input font's slant.
1488    */
1489   void SetInputFontSlant(FontSlant slant);
1490
1491   /**
1492    * @return Whether the font's slant has been defined.
1493    */
1494   bool IsInputFontSlantDefined() const;
1495
1496   /**
1497    * @brief Retrieves the input font's slant.
1498    *
1499    * @return The input font's slant.
1500    */
1501   FontSlant GetInputFontSlant() const;
1502
1503   /**
1504    * @brief Sets the input font's point size.
1505    *
1506    * @param[in] size The input font's point size.
1507    * @param[in] defaultFontSizeUpdated True If the default font size is updated and sets the input point size, false otherwise.
1508    */
1509   void SetInputFontPointSize(float size, bool defaultFontSizeUpdated = false);
1510
1511   /**
1512    * @brief Retrieves the input font's point size.
1513    *
1514    * @return The input font's point size.
1515    */
1516   float GetInputFontPointSize() const;
1517
1518   /**
1519    * @brief Sets the input line spacing.
1520    *
1521    * @param[in] lineSpacing The line spacing.
1522    */
1523   void SetInputLineSpacing(float lineSpacing);
1524
1525   /**
1526    * @brief Retrieves the input line spacing.
1527    *
1528    * @return The line spacing.
1529    */
1530   float GetInputLineSpacing() const;
1531
1532   /**
1533    * @brief Sets the input shadow's properties string.
1534    *
1535    * @note The string is stored to be recovered.
1536    *
1537    * @param[in] shadowProperties The shadow's properties string.
1538    */
1539   void SetInputShadowProperties(const std::string& shadowProperties);
1540
1541   /**
1542    * @brief Retrieves the input shadow's properties string.
1543    *
1544    * @return The shadow's properties string.
1545    */
1546   std::string GetInputShadowProperties() const;
1547
1548   /**
1549    * @brief Sets the input underline's properties string.
1550    *
1551    * @note The string is stored to be recovered.
1552    *
1553    * @param[in] underlineProperties The underline's properties string.
1554    */
1555   void SetInputUnderlineProperties(const std::string& underlineProperties);
1556
1557   /**
1558    * @brief Retrieves the input underline's properties string.
1559    *
1560    * @return The underline's properties string.
1561    */
1562   std::string GetInputUnderlineProperties() const;
1563
1564   /**
1565    * @brief Sets the input emboss's properties string.
1566    *
1567    * @note The string is stored to be recovered.
1568    *
1569    * @param[in] embossProperties The emboss's properties string.
1570    */
1571   void SetInputEmbossProperties(const std::string& embossProperties);
1572
1573   /**
1574    * @brief Retrieves the input emboss's properties string.
1575    *
1576    * @return The emboss's properties string.
1577    */
1578   std::string GetInputEmbossProperties() const;
1579
1580   /**
1581    * @brief Sets input the outline's properties string.
1582    *
1583    * @note The string is stored to be recovered.
1584    *
1585    * @param[in] outlineProperties The outline's properties string.
1586    */
1587   void SetInputOutlineProperties(const std::string& outlineProperties);
1588
1589   /**
1590    * @brief Retrieves the input outline's properties string.
1591    *
1592    * @return The outline's properties string.
1593    */
1594   std::string GetInputOutlineProperties() const;
1595
1596   /**
1597    * @brief Sets the input strikethrough's properties string.
1598    *
1599    * @note The string is stored to be recovered.
1600    *
1601    * @param[in] strikethroughProperties The strikethrough's properties string.
1602    */
1603   void SetInputStrikethroughProperties(const std::string& strikethroughProperties);
1604
1605   /**
1606    * @brief Retrieves the input strikethrough's properties string.
1607    *
1608    * @return The strikethrough's properties string.
1609    */
1610   std::string GetInputStrikethroughProperties() const;
1611
1612   /**
1613    * @brief Set the control's interface.
1614    *
1615    * @param[in] controlInterface The control's interface.
1616    */
1617   void SetControlInterface(ControlInterface* controlInterface);
1618
1619   /**
1620    * @brief Set the anchor control's interface.
1621    *
1622    * @param[in] anchorControlInterface The control's interface.
1623    */
1624   void SetAnchorControlInterface(AnchorControlInterface* anchorControlInterface);
1625
1626   /**
1627    * @brief Sets the character spacing.
1628    *
1629    * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
1630    *
1631    * @param[in] characterSpacing The character spacing.
1632    */
1633   void SetCharacterSpacing(float characterSpacing);
1634
1635   /**
1636    * @brief Retrieves the character spacing.
1637    *
1638    * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
1639    *
1640    * @return The character spacing.
1641    */
1642   const float GetCharacterSpacing() const;
1643
1644   /**
1645    * @brief Sets the visual transform offset.
1646    *
1647    * @param[in] offset The offset.
1648    */
1649   void SetVisualTransformOffset(Vector2 offset);
1650
1651 public: // Queries & retrieves.
1652   /**
1653    * @brief Return the layout engine.
1654    *
1655    * @return A reference to the layout engine.
1656    */
1657   Layout::Engine& GetLayoutEngine();
1658
1659   /**
1660    * @brief Return a view of the text.
1661    *
1662    * @return A reference to the view.
1663    */
1664   View& GetView();
1665
1666   /**
1667    * @copydoc Control::GetNaturalSize()
1668    */
1669   Vector3 GetNaturalSize();
1670
1671   /**
1672    * @copydoc Control::GetHeightForWidth()
1673    */
1674   float GetHeightForWidth(float width);
1675
1676   /**
1677    * @brief Calculates the point size for text for given layout()
1678    */
1679   void FitPointSizeforLayout(Size layoutSize);
1680
1681   /**
1682    * @brief Calculates the point size for text for given layout() using fit array.
1683    */
1684   void FitArrayPointSizeforLayout(Size layoutSize);
1685
1686   /**
1687    * @brief Checks if the point size fits within the layout size.
1688    *
1689    * @return Whether the point size fits within the layout size.
1690    */
1691   bool CheckForTextFit(float pointSize, Size& layoutSize);
1692
1693   /**
1694    * @brief Retrieves the text's number of lines for a given width.
1695    * @param[in] width The width of the text's area.
1696    * @ return The number of lines.
1697    */
1698   int GetLineCount(float width);
1699
1700   /**
1701    * @brief Retrieves the text's model.
1702    *
1703    * @return A pointer to the text's model.
1704    */
1705   const ModelInterface* GetTextModel() const;
1706
1707   /**
1708    * @brief Used to get scrolled distance by user input
1709    *
1710    * @return Distance from last scroll offset to new scroll offset
1711    */
1712   float GetScrollAmountByUserInput();
1713
1714   /**
1715    * @brief Get latest scroll amount, control size and layout size
1716    *
1717    * This method is used to get information of control's scroll
1718    * @param[out] scrollPosition The current scrolled position
1719    * @param[out] controlHeight The size of a UI control
1720    * @param[out] layoutHeight The size of a bounding box to layout text within.
1721    *
1722    * @return Whether the text scroll position is changed or not after last update.
1723    */
1724   bool GetTextScrollInfo(float& scrollPosition, float& controlHeight, float& layoutHeight);
1725
1726   /**
1727    * @brief Used to set the hidden input option
1728    */
1729   void SetHiddenInputOption(const Property::Map& options);
1730
1731   /**
1732    * @brief Used to get the hidden input option
1733    */
1734   void GetHiddenInputOption(Property::Map& options);
1735
1736   /**
1737    * @brief Used to set the input filter option
1738    */
1739   void SetInputFilterOption(const Property::Map& options);
1740
1741   /**
1742    * @brief Used to get the input filter option
1743    */
1744   void GetInputFilterOption(Property::Map& options);
1745
1746   /**
1747    * @brief Sets the Placeholder Properties.
1748    *
1749    * @param[in] map The placeholder property map
1750    */
1751   void SetPlaceholderProperty(const Property::Map& map);
1752
1753   /**
1754    * @brief Retrieves the Placeholder Property map.
1755    *
1756    * @param[out] map The property map
1757    */
1758   void GetPlaceholderProperty(Property::Map& map);
1759
1760   /**
1761    * @brief Checks text direction.
1762    * @return The text direction.
1763    */
1764   Toolkit::DevelText::TextDirection::Type GetTextDirection();
1765
1766   /**
1767    * @brief Retrieves vertical line alignment
1768    * @return The vertical line alignment
1769    */
1770   Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1771
1772   /**
1773    * @brief Sets vertical line alignment
1774    * @param[in] alignment The vertical line alignment for the text
1775    */
1776   void SetVerticalLineAlignment(Toolkit::DevelText::VerticalLineAlignment::Type alignment);
1777
1778   /**
1779    * @brief Retrieves ellipsis position
1780    * @return The ellipsis position
1781    */
1782   Toolkit::DevelText::EllipsisPosition::Type GetEllipsisPosition() const;
1783
1784   /**
1785    * @brief Sets ellipsis position
1786    * @param[in] ellipsisPosition The ellipsis position for the text
1787    */
1788   void SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type ellipsisPosition);
1789
1790   /**
1791    * @brief Retrieves ignoreSpaceAfterText value from model
1792    * @return The value of ignoreSpaceAfterText
1793    */
1794   bool IsIgnoreSpacesAfterText() const;
1795
1796   /**
1797    * @brief Sets ignoreSpaceAfterText value to model
1798    * @param[in] ignore The value of ignoreSpacesAfterText for the text
1799    */
1800   void SetIgnoreSpacesAfterText(bool ignore);
1801
1802   /**
1803    * @brief Retrieves removeFrontInset value from model
1804    * @return The value of removeFrontInset
1805    */
1806   bool IsRemoveFrontInset() const;
1807
1808   /**
1809    * @brief Sets removeFrontInset value to model
1810    * @param[in] remove The value of removeFrontInset for the text
1811    */
1812   void SetRemoveFrontInset(bool remove);
1813
1814   /**
1815    * @brief Retrieves removeBackInset value from model
1816    * @return The value of removeBackInset
1817    */
1818   bool IsRemoveBackInset() const;
1819
1820   /**
1821    * @brief Sets removeBackInset value to model
1822    * @param[in] remove The value of removeBackInset for the text
1823    */
1824   void SetRemoveBackInset(bool remove);
1825
1826   /**
1827    * @brief Sets SetMatchLayoutDirection value to model
1828    * @param[in] match The value of matchLayoutDirection for the text
1829    */
1830   void SetMatchLayoutDirection(DevelText::MatchLayoutDirection type);
1831
1832   /**
1833    * @brief Retrieves matchLayoutDirection value from model
1834    * @return The value of matchLayoutDirection
1835    */
1836   DevelText::MatchLayoutDirection GetMatchLayoutDirection() const;
1837
1838   /**
1839    * @brief Sets layoutDirection type value.
1840    * @param[in] layoutDirection The value of the layout direction type.
1841    */
1842   void SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection);
1843
1844   /**
1845    * @brief Gets layoutDirection type value.
1846    * @param[in] actor The actor which will get the layout direction type.
1847    * @return The value of the layout direction type.
1848    */
1849   Dali::LayoutDirection::Type GetLayoutDirection(Dali::Actor& actor) const;
1850
1851   /**
1852    * @brief Get the rendered size of a specific text range.
1853    * if the requested text is at multilines, multiple sizes will be returned for each text located in a separate line.
1854    * if a line contains characters with different directions, multiple sizes will be returned for each block of contiguous characters with the same direction.
1855    *
1856    * @param[in] startIndex start index of the text requested to calculate size for.
1857    * @param[in] endIndex end index(included) of the text requested to calculate size for.
1858    * @return list of sizes of the reuested text.
1859    */
1860   Vector<Vector2> GetTextSize(CharacterIndex startIndex, CharacterIndex endIndex);
1861
1862   /**
1863    * @brief Get the top/left rendered position of a specific text range.
1864    * if the requested text is at multilines, multiple positions will be returned for each text located in a separate line.
1865    * if a line contains characters with different directions, multiple positions will be returned for each block of contiguous characters with the same direction.
1866    *
1867    * @param[in] startIndex start index of the text requested to get position to.
1868    * @param[in] endIndex end index(included) of the text requested to get position to.
1869    * @return list of positions of the requested text.
1870    */
1871   Vector<Vector2> GetTextPosition(CharacterIndex startIndex, CharacterIndex endIndex);
1872
1873   /**
1874    * @brief Get the line bounding rectangle.
1875    * if the requested index is out of range or the line is not yet rendered, a rect of {0, 0, 0, 0} is returned.
1876    *
1877    * @param[in] lineIndex line index to which we want to calculate the geometry for.
1878    * @return bounding rectangle.
1879    */
1880   Rect<float> GetLineBoundingRectangle(const uint32_t lineIndex);
1881
1882   /**
1883    * @brief Get the char bounding rectangle.
1884    * If the text is not yet rendered or the index > text.Count(); a rect of {0, 0, 0, 0} is returned.
1885    *
1886    * @param[in] charIndex character index to which we want to calculate the geometry for.
1887    * @return bounding rectangle.
1888    */
1889   Rect<float> GetCharacterBoundingRectangle(const uint32_t charIndex);
1890
1891   /**
1892    * @brief Get the character index.
1893    * If the text is not yet rendered or the text is empty, -1 is returned.
1894    *
1895    * @param[in] visualX visual x position.
1896    * @param[in] visualY visual y position.
1897    * @return character index.
1898    */
1899   int GetCharacterIndexAtPosition(float visualX, float visualY);
1900
1901   /**
1902    * @brief Gets the bounding box of a specific text range.
1903    *
1904    * @param[in] startIndex start index of the text requested to get bounding box to.
1905    * @param[in] endIndex end index(included) of the text requested to get bounding box to.
1906    * @return bounding box of the requested text.
1907    */
1908   Rect<> GetTextBoundingRectangle(CharacterIndex startIndex, CharacterIndex endIndex);
1909
1910   /**
1911    * @brief Sets the layout direction changed.
1912    */
1913   void ChangedLayoutDirection();
1914
1915   /**
1916    * @brief Clear font and style data.
1917    */
1918   void ResetFontAndStyleData();
1919
1920   /**
1921    * @brief Retrieves if showing real text or not.
1922    * @return The value of showing real text.
1923    */
1924   bool IsShowingRealText() const;
1925
1926 public: // Relayout.
1927   /**
1928    * @brief Triggers a relayout which updates View (if necessary).
1929    *
1930    * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1931    * @param[in] size A the size of a bounding box to layout text within.
1932    * @param[in] layoutDirection The direction of the system language.
1933    *
1934    * @return Whether the text model or decorations were updated.
1935    */
1936   UpdateTextType Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT);
1937
1938   /**
1939    * @brief Request a relayout using the ControlInterface.
1940    */
1941   void RequestRelayout();
1942
1943 public: // Input style change signals.
1944   /**
1945    * @return Whether the queue of input style changed signals is empty.
1946    */
1947   bool IsInputStyleChangedSignalsQueueEmpty();
1948
1949   /**
1950    * @brief Request process all pending input style changed signals.
1951    *
1952    * Request to calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1953    * text controls. Text controls may send signals to state the input style has changed.
1954    *
1955    * The signal will be execute next idle time, or skip if we fail to add idler.
1956    */
1957   void RequestProcessInputStyleChangedSignals();
1958
1959 private:
1960   /**
1961    * @brief Callbacks called on idle.
1962    *
1963    * If there are notifications of change of input style on the queue, Toolkit::TextField::InputStyleChangedSignal() are emitted.
1964    */
1965   void OnIdleSignal();
1966
1967 public: // Text-input Event Queuing.
1968   /**
1969    * @brief Called by editable UI controls when keyboard focus is gained.
1970    */
1971   void KeyboardFocusGainEvent();
1972
1973   /**
1974    * @brief Called by editable UI controls when focus is lost.
1975    */
1976   void KeyboardFocusLostEvent();
1977
1978   /**
1979    * @brief Called by editable UI controls when key events are received.
1980    *
1981    * @param[in] event The key event.
1982    * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1983    */
1984   bool KeyEvent(const Dali::KeyEvent& event);
1985
1986   /**
1987    * @brief Called by anchor when a tap gesture occurs.
1988    * @param[in] x The x position relative to the top-left of the parent control.
1989    * @param[in] y The y position relative to the top-left of the parent control.
1990    */
1991   void AnchorEvent(float x, float y);
1992
1993   /**
1994    * @brief Called by editable UI controls when a tap gesture occurs.
1995    * @param[in] tapCount The number of taps.
1996    * @param[in] x The x position relative to the top-left of the parent control.
1997    * @param[in] y The y position relative to the top-left of the parent control.
1998    */
1999   void TapEvent(unsigned int tapCount, float x, float y);
2000
2001   /**
2002    * @brief Called by editable UI controls when a pan gesture occurs.
2003    *
2004    * @param[in] state The state of the gesture.
2005    * @param[in] displacement This distance panned since the last pan gesture.
2006    */
2007   void PanEvent(GestureState state, const Vector2& displacement);
2008
2009   /**
2010    * @brief Called by editable UI controls when a long press gesture occurs.
2011    *
2012    * @param[in] state The state of the gesture.
2013    * @param[in] x The x position relative to the top-left of the parent control.
2014    * @param[in] y The y position relative to the top-left of the parent control.
2015    */
2016   void LongPressEvent(GestureState state, float x, float y);
2017
2018   /**
2019    * @brief Used to get the Primary cursor position.
2020    *
2021    * @return Primary cursor position.
2022    */
2023   CharacterIndex GetPrimaryCursorPosition() const;
2024
2025   /**
2026    * @brief Used to set the Primary cursor position.
2027    *
2028    * @param[in] index for the Primary cursor position.
2029    * @param[in] focused true if UI control has gained focus to receive key event, false otherwise.
2030    * @return[in] true if cursor position changed, false otherwise.
2031    */
2032   bool SetPrimaryCursorPosition(CharacterIndex index, bool focused);
2033
2034   /**
2035    * @brief Creates a selection event.
2036    *
2037    * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
2038    *
2039    * @param[in] x The x position relative to the top-left of the parent control.
2040    * @param[in] y The y position relative to the top-left of the parent control.
2041    * @param[in] selection type like the whole text is selected or unselected.
2042    */
2043   void SelectEvent(float x, float y, SelectionType selection);
2044
2045   /**
2046    * @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
2047    */
2048   void SetTextSelectionRange(const uint32_t* start, const uint32_t* end);
2049
2050   /**
2051    * @copydoc Text::SelectableControlInterface::GetTextSelectionRange()
2052    */
2053   Uint32Pair GetTextSelectionRange() const;
2054
2055   /**
2056    * @copydoc Text::SelectableControlInterface::SelectWholeText()
2057    */
2058   void SelectWholeText();
2059
2060   /**
2061    * @copydoc Text::EditableControlInterface::CopyText()
2062    */
2063   string CopyText();
2064
2065   /**
2066    * @copydoc Text::EditableControlInterface::CutText()
2067    */
2068   string CutText();
2069
2070   /**
2071    * @copydoc Text::EditableControlInterface::PasteText()
2072    */
2073   void PasteText();
2074
2075   /**
2076    * @copydoc Text::SelectableControlInterface::SelectNone()
2077    */
2078   void SelectNone();
2079
2080   /**
2081    * @copydoc Text::SelectableControlInterface::SelectText()
2082    */
2083   void SelectText(const uint32_t start, const uint32_t end);
2084
2085   /**
2086    * @copydoc Text::SelectableControlInterface::GetSelectedText()
2087    */
2088   string GetSelectedText() const;
2089
2090   /**
2091    * @copydoc Text::EditableControlInterface::IsEditable()
2092    */
2093   virtual bool IsEditable() const;
2094
2095   /**
2096    * @copydoc Text::EditableControlInterface::SetEditable()
2097    */
2098   virtual void SetEditable(bool editable);
2099
2100   /**
2101    * @copydoc Dali::Toolkit::Internal::TextEditor::ScrollBy()
2102    */
2103   virtual void ScrollBy(Vector2 scroll);
2104
2105   /**
2106    * @brief Whether the text is scrollable.
2107    * @return Returns true if the text is scrollable.
2108    */
2109   bool IsScrollable(const Vector2& displacement);
2110
2111   /**
2112    * @copydoc Dali::Toolkit::Internal::TextEditor::GetHorizontalScrollPosition()
2113    */
2114   float GetHorizontalScrollPosition();
2115
2116   /**
2117    * @copydoc Dali::Toolkit::Internal::TextEditor::GetVerticalScrollPosition()
2118    */
2119   float GetVerticalScrollPosition();
2120
2121   /**
2122    * @brief Event received from input method context
2123    *
2124    * @param[in] inputMethodContext The input method context.
2125    * @param[in] inputMethodContextEvent The event received.
2126    * @return A data struture indicating if update is needed, cursor position and current text.
2127    */
2128   InputMethodContext::CallbackData OnInputMethodContextEvent(InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent);
2129
2130   /**
2131    * @brief Event from Clipboard notifying an Item has been selected for pasting
2132    *
2133    * @param[in] id The id of the data request.
2134    * @param[in] mimeType The mime type of data received.
2135    * @param[in] data The data received.
2136    * @note
2137    * This event is executed by receiving the Clipboard's DataReceivedSignal.
2138    */
2139   void PasteClipboardItemEvent(uint32_t id, const char* mimeType, const char* data);
2140
2141   /**
2142    * @brief Return true when text control should clear key input focus when escape key is pressed.
2143    *
2144    * @return Whether text control should clear key input focus or not when escape key is pressed.
2145    */
2146   bool ShouldClearFocusOnEscape() const;
2147
2148   /**
2149    * @brief Create an actor that renders the text background color
2150    *
2151    * @return the created actor or an empty handle if no background color needs to be rendered.
2152    */
2153   Actor CreateBackgroundActor();
2154
2155   /**
2156    * @brief Used to reset the cursor position after setting a new text.
2157    *
2158    * @param[in] cursorIndex Where to place the cursor.
2159    */
2160   void ResetCursorPosition(CharacterIndex cursorIndex);
2161
2162   /**
2163    * @brief The method acquires current position of cursor
2164    * @return unsigned value with cursor position
2165    */
2166   CharacterIndex GetCursorPosition();
2167
2168   /**
2169    * @brief Resets a provided vector with actors that marks the position of anchors in markup enabled text
2170    *
2171    * @param[out] anchorActors the vector of actor (empty collection if no anchors available).
2172    */
2173   void GetAnchorActors(std::vector<Toolkit::TextAnchor>& anchorActors);
2174
2175   /**
2176    * @brief Return an index of first anchor in the anchor vector whose boundaries includes given character offset
2177    *
2178    * @param[in] characterOffset A position in text coords.
2179    *
2180    * @return the index in anchor vector (-1 if an anchor not found)
2181    */
2182   int GetAnchorIndex(size_t characterOffset);
2183
2184 protected: // Inherit from Text::Decorator::ControllerInterface.
2185   /**
2186    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
2187    */
2188   void GetTargetSize(Vector2& targetSize) override;
2189
2190   /**
2191    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
2192    */
2193   void AddDecoration(Actor& actor, DecorationType type, bool needsClipping) override;
2194
2195   /**
2196    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
2197    */
2198   void DecorationEvent(HandleType handle, HandleState state, float x, float y) override;
2199
2200 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
2201   /**
2202    * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
2203    */
2204   void TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::Buttons button) override;
2205
2206 protected: // Inherit from HiddenText.
2207   /**
2208    * @brief Invoked from HiddenText when showing time of the last character was expired
2209    */
2210   void DisplayTimeExpired() override;
2211
2212 protected: // Inherit from Integration::Processor
2213   /**
2214    * @copydoc Dali::Integration::Processor::Process()
2215    */
2216   void Process(bool postProcess) override;
2217
2218   /**
2219    * @copydoc Dali::Integration::Processor::GetProcessorName()
2220    */
2221   std::string_view GetProcessorName() const override
2222   {
2223     return "Text::Controller";
2224   }
2225
2226 private: // Private contructors & copy operator.
2227   /**
2228    * @brief Private constructor.
2229    */
2230   Controller()
2231   : Controller(nullptr, nullptr, nullptr, nullptr)
2232   {
2233   }
2234
2235   /**
2236    * @brief Private constructor.
2237    */
2238   Controller(ControlInterface* controlInterface)
2239   : Controller(controlInterface, nullptr, nullptr, nullptr)
2240   {
2241   }
2242
2243   /**
2244    * @brief Private constructor.
2245    */
2246   Controller(ControlInterface*           controlInterface,
2247              EditableControlInterface*   editableControlInterface,
2248              SelectableControlInterface* selectableControlInterface,
2249              AnchorControlInterface*     anchorControlInterface);
2250
2251   Controller(const Controller& handle) = delete;
2252   Controller& operator=(const Controller& handle) = delete;
2253
2254 protected: // Destructor.
2255   /**
2256    * @brief A reference counted object may only be deleted by calling Unreference().
2257    */
2258   virtual ~Controller();
2259
2260 public:
2261   struct Impl; ///< Made public for testing purposes
2262
2263 private:
2264   struct EventHandler;
2265   struct InputFontHandler;
2266   struct InputProperties;
2267   struct PlaceholderHandler;
2268   struct Relayouter;
2269   struct TextUpdater;
2270   struct SpannableHandler;
2271
2272   std::unique_ptr<Impl> mImpl{nullptr};
2273 };
2274
2275 } // namespace Dali::Toolkit::Text
2276
2277 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H