1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/devel-api/adaptor-framework/input-method-context.h>
23 #include <dali/public-api/events/gesture.h>
26 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
27 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
28 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
29 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
30 #include <dali-toolkit/internal/text/hidden-text.h>
31 #include <dali-toolkit/internal/text/input-filter.h>
32 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
33 #include <dali-toolkit/internal/text/text-anchor-control-interface.h>
34 #include <dali-toolkit/internal/text/text-model-interface.h>
35 #include <dali-toolkit/internal/text/text-selectable-control-interface.h>
36 #include <dali-toolkit/public-api/text/text-enumerations.h>
45 class ControlInterface;
46 class EditableControlInterface;
48 class RenderingController;
51 * @brief Text selection operations .
60 typedef IntrusivePtr<Controller> ControllerPtr;
63 * @brief A Text Controller is used by UI Controls which display text.
65 * It manipulates the Logical & Visual text models on behalf of the UI Controls.
66 * It provides a view of the text that can be used by rendering back-ends.
68 * For selectable/editable UI controls, the controller handles input events from the UI control
69 * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
71 * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
73 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
75 public: // Enumerated types.
77 * @brief Text related operations to be done in the relayout process.
81 NO_OPERATION = 0x0000,
82 CONVERT_TO_UTF32 = 0x0001,
84 VALIDATE_FONTS = 0x0004,
85 GET_LINE_BREAKS = 0x0008,
88 GET_GLYPH_METRICS = 0x0040,
90 UPDATE_LAYOUT_SIZE = 0x0100,
94 UPDATE_DIRECTION = 0x1000,
95 ALL_OPERATIONS = 0xFFFF
99 * @brief Used to distinguish between regular key events and InputMethodContext events
108 * @brief Used to specify whether to update the input style.
110 enum UpdateInputStyleType
113 DONT_UPDATE_INPUT_STYLE
117 * @brief Used to specify what has been updated after the Relayout() method has been called.
121 NONE_UPDATED = 0x0, ///< Nothing has been updated.
122 MODEL_UPDATED = 0x1, ///< The text's model has been updated.
123 DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
127 * @brief Different placeholder-text can be shown when the control is active/inactive.
131 PLACEHOLDER_TYPE_ACTIVE,
132 PLACEHOLDER_TYPE_INACTIVE,
136 * @brief Enumeration for Font Size Type.
140 POINT_SIZE, // The size of font in points.
141 PIXEL_SIZE // The size of font in pixels.
148 NO_ACTION, ///< Does no action if there is a tap on top of an area with no text.
149 HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
150 SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
162 TEXT_FIT_FONT_SIZE_TYPE
166 public: // Constructor.
168 * @brief Create a new instance of a Controller.
170 * @return A pointer to a new Controller.
172 static ControllerPtr New();
175 * @brief Create a new instance of a Controller.
177 * @param[in] controlInterface The control's interface.
179 * @return A pointer to a new Controller.
181 static ControllerPtr New(ControlInterface* controlInterface);
184 * @brief Create a new instance of a Controller.
186 * @param[in] controlInterface The control's interface.
187 * @param[in] editableControlInterface The editable control's interface.
188 * @param[in] selectableControlInterface The selectable control's interface.
189 * @param[in] anchorControlInterface The anchor control's interface.
191 * @return A pointer to a new Controller.
193 static ControllerPtr New(ControlInterface* controlInterface,
194 EditableControlInterface* editableControlInterface,
195 SelectableControlInterface* selectableControlInterface,
196 AnchorControlInterface* anchorControlInterface);
198 public: // Configure the text controller.
200 * @brief Called to enable text input.
202 * @note Selectable or editable controls should call this once after Controller::New().
203 * @param[in] decorator Used to create cursor, selection handle decorations etc.
204 * @param[in] inputMethodContext Used to manager ime.
206 void EnableTextInput(DecoratorPtr decorator, InputMethodContext& inputMethodContext);
209 * @brief Used to switch between bitmap & vector based glyphs
211 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
213 void SetGlyphType(TextAbstraction::GlyphType glyphType);
216 * @brief Enables/disables the mark-up processor.
218 * By default is disabled.
220 * @param[in] enable Whether to enable the mark-up processor.
222 void SetMarkupProcessorEnabled(bool enable);
225 * @brief Retrieves whether the mark-up processor is enabled.
227 * By default is disabled.
229 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
231 bool IsMarkupProcessorEnabled() const;
234 * @brief Enables/disables the auto text scrolling
236 * By default is disabled.
238 * @param[in] enable Whether to enable the auto scrolling
240 void SetAutoScrollEnabled(bool enable);
243 * @brief Retrieves whether auto text scrolling is enabled.
245 * By default is disabled.
247 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
249 bool IsAutoScrollEnabled() const;
252 * @brief Get direction of the text from the first line of text,
253 * @return bool rtl (right to left) is true
255 CharacterDirection GetAutoScrollDirection() const;
258 * @brief Get the alignment offset of the first line of text.
260 * @return The alignment offset.
262 float GetAutoScrollLineAlignment() const;
265 * @brief Enables the horizontal scrolling.
267 * @param[in] enable Whether to enable the horizontal scrolling.
269 void SetHorizontalScrollEnabled(bool enable);
272 * @brief Retrieves whether the horizontal scrolling is enabled.
274 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
276 bool IsHorizontalScrollEnabled() const;
279 * @brief Enables the vertical scrolling.
281 * @param[in] enable Whether to enable the vertical scrolling.
283 void SetVerticalScrollEnabled(bool enable);
286 * @brief Retrieves whether the verticall scrolling is enabled.
288 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
290 bool IsVerticalScrollEnabled() const;
293 * @brief Enables the smooth handle panning.
295 * @param[in] enable Whether to enable the smooth handle panning.
297 void SetSmoothHandlePanEnabled(bool enable);
300 * @brief Retrieves whether the smooth handle panning is enabled.
302 * @return @e true if the smooth handle panning is enabled.
304 bool IsSmoothHandlePanEnabled() const;
307 * @brief Sets the maximum number of characters that can be inserted into the TextModel
309 * @param[in] maxCharacters maximum number of characters to be accepted
311 void SetMaximumNumberOfCharacters(Length maxCharacters);
314 * @brief Sets the maximum number of characters that can be inserted into the TextModel
316 * @param[in] maxCharacters maximum number of characters to be accepted
318 int GetMaximumNumberOfCharacters();
321 * @brief Called to enable/disable cursor blink.
323 * @note Only editable controls should calls this.
324 * @param[in] enabled Whether the cursor should blink or not.
326 void SetEnableCursorBlink(bool enable);
329 * @brief Query whether cursor blink is enabled.
331 * @return Whether the cursor should blink or not.
333 bool GetEnableCursorBlink() const;
336 * @brief Whether to enable the multi-line layout.
338 * @param[in] enable \e true enables the multi-line (by default)
340 void SetMultiLineEnabled(bool enable);
343 * @return Whether the multi-line layout is enabled.
345 bool IsMultiLineEnabled() const;
348 * @brief Sets the text's horizontal alignment.
350 * @param[in] alignment The horizontal alignment.
352 void SetHorizontalAlignment(HorizontalAlignment::Type alignment);
355 * @copydoc ModelInterface::GetHorizontalAlignment()
357 HorizontalAlignment::Type GetHorizontalAlignment() const;
360 * @brief Sets the text's vertical alignment.
362 * @param[in] alignment The vertical alignment.
364 void SetVerticalAlignment(VerticalAlignment::Type alignment);
367 * @copydoc ModelInterface::GetVerticalAlignment()
369 VerticalAlignment::Type GetVerticalAlignment() const;
372 * @brief Sets the text's wrap mode
373 * @param[in] text wrap mode The unit of wrapping
375 void SetLineWrapMode(Text::LineWrap::Mode textWarpMode);
378 * @brief Retrieve text wrap mode previously set.
379 * @return text wrap mode
381 Text::LineWrap::Mode GetLineWrapMode() const;
384 * @brief Enable or disable the text elide.
386 * @param[in] enabled Whether to enable the text elide.
388 void SetTextElideEnabled(bool enabled);
391 * @copydoc ModelInterface::IsTextElideEnabled()
393 bool IsTextElideEnabled() const;
396 * @brief Enable or disable the text fit.
398 * @param[in] enabled Whether to enable the text fit.
400 void SetTextFitEnabled(bool enabled);
403 * @brief Whether the text fit is enabled or not.
405 * @return True if the text fit is enabled
407 bool IsTextFitEnabled() const;
410 * @brief Sets minimum size valid for text fit.
412 * @param[in] minimum size value.
413 * @param[in] type The font size type is point size or pixel size
415 void SetTextFitMinSize(float pointSize, FontSizeType type);
418 * @brief Retrieves the minimum point size valid for text fit.
420 * @return The minimum point size valid for text fit
422 float GetTextFitMinSize() const;
425 * @brief Sets maximum size valid for text fit.
427 * @param[in] maximum size value.
428 * @param[in] type The font size type is point size or pixel size
430 void SetTextFitMaxSize(float pointSize, FontSizeType type);
433 * @brief Retrieves the maximum point size valid for text fit.
435 * @return The maximum point size valid for text fit
437 float GetTextFitMaxSize() const;
440 * @brief Sets step size for font increase valid for text fit.
442 * @param[in] step size value.
443 * @param[in] type The font size type is point size or pixel size
445 void SetTextFitStepSize(float step, FontSizeType type);
448 * @brief Retrieves the step point size valid for text fit.
450 * @return The step point size valid for text fit
452 float GetTextFitStepSize() const;
455 * @brief Sets content size valid for text fit.
457 * @param[in] Content size value.
459 void SetTextFitContentSize(Vector2 size);
462 * @brief Retrieves the content size valid for text fit.
464 * @return The content size valid for text fit
466 Vector2 GetTextFitContentSize() const;
469 * @brief Enable or disable the placeholder text elide.
470 * @param enabled Whether to enable the placeholder text elide.
472 void SetPlaceholderTextElideEnabled(bool enabled);
475 * @brief Whether the placeholder text elide property is enabled.
476 * @return True if the placeholder text elide property is enabled, false otherwise.
478 bool IsPlaceholderTextElideEnabled() const;
481 * @brief Enable or disable the text selection.
482 * @param[in] enabled Whether to enable the text selection.
484 void SetSelectionEnabled(bool enabled);
487 * @brief Whether the text selection is enabled or not.
488 * @return True if the text selection is enabled
490 bool IsSelectionEnabled() const;
493 * @brief Enable or disable the text selection using Shift key.
494 * @param enabled Whether to enable the text selection using Shift key
496 void SetShiftSelectionEnabled(bool enabled);
499 * @brief Whether the text selection using Shift key is enabled or not.
500 * @return True if the text selection using Shift key is enabled
502 bool IsShiftSelectionEnabled() const;
505 * @brief Enable or disable the grab handles for text selection.
507 * @param[in] enabled Whether to enable the grab handles
509 void SetGrabHandleEnabled(bool enabled);
512 * @brief Returns whether the grab handles are enabled.
514 * @return True if the grab handles are enabled
516 bool IsGrabHandleEnabled() const;
519 * @brief Enable or disable the grab handles for text selection.
521 * @param[in] enabled Whether to enable the grab handles
523 void SetGrabHandlePopupEnabled(bool enabled);
526 * @brief Returns whether the grab handles are enabled.
528 * @return True if the grab handles are enabled
530 bool IsGrabHandlePopupEnabled() const;
533 * @brief Sets input type to password
535 * @note The string is displayed hidden character
537 * @param[in] passwordInput True if password input is enabled.
539 void SetInputModePassword(bool passwordInput);
542 * @brief Returns whether the input mode type is set as password.
544 * @return True if input mode type is password
546 bool IsInputModePassword();
549 * @brief Sets the action when there is a double tap event on top of a text area with no text.
551 * @param[in] action The action to do.
553 void SetNoTextDoubleTapAction(NoTextTap::Action action);
556 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
558 * @return The action to do.
560 NoTextTap::Action GetNoTextDoubleTapAction() const;
563 * @briefSets the action when there is a long press event on top of a text area with no text.
565 * @param[in] action The action to do.
567 void SetNoTextLongPressAction(NoTextTap::Action action);
570 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
572 * @return The action to do.
574 NoTextTap::Action GetNoTextLongPressAction() const;
577 * @brief Query if Underline settings were provided by string or map
578 * @return bool true if set by string
580 bool IsUnderlineSetByString();
583 * Set method underline setting were set by
584 * @param[in] bool, true if set by string
586 void UnderlineSetByString(bool setByString);
589 * @brief Query if shadow settings were provided by string or map
590 * @return bool true if set by string
592 bool IsShadowSetByString();
595 * Set method shadow setting were set by
596 * @param[in] bool, true if set by string
598 void ShadowSetByString(bool setByString);
601 * @brief Query if outline settings were provided by string or map
602 * @return bool true if set by string
604 bool IsOutlineSetByString();
607 * Set method outline setting were set by
608 * @param[in] bool, true if set by string
610 void OutlineSetByString(bool setByString);
613 * @brief Query if font style settings were provided by string or map
614 * @return bool true if set by string
616 bool IsFontStyleSetByString();
619 * Set method font style setting were set by
620 * @param[in] bool, true if set by string
622 void FontStyleSetByString(bool setByString);
626 * @brief Replaces any text previously set.
628 * @note This will be converted into UTF-32 when stored in the text model.
629 * @param[in] text A string of UTF-8 characters.
631 void SetText(const std::string& text);
634 * @brief Retrieve any text previously set.
636 * @param[out] text A string of UTF-8 characters.
638 void GetText(std::string& text) const;
641 * @brief Replaces any placeholder text previously set.
643 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
644 * @param[in] text A string of UTF-8 characters.
646 void SetPlaceholderText(PlaceholderType type, const std::string& text);
649 * @brief Retrieve any placeholder text previously set.
651 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
652 * @param[out] A string of UTF-8 characters.
654 void GetPlaceholderText(PlaceholderType type, std::string& text) const;
657 * @ brief Update the text after a font change
658 * @param[in] newDefaultFont The new font to change to
660 void UpdateAfterFontChange(const std::string& newDefaultFont);
663 * @brief The method acquires currently selected text
664 * @param selectedText variable to place selected text in
666 void RetrieveSelection(std::string& selectedText) const;
669 * @brief The method sets selection in given range
670 * @param start index of first character
671 * @param end index of first character after selection
673 void SetSelection(int start, int end);
676 * @brief This method retrieve indexes of current selection
678 * @return a pair, where first element is left index of selection and second is the right one
680 std::pair<int, int> GetSelectionIndexes() const;
683 * Place string in system clipboard
684 * @param source std::string
686 void CopyStringToClipboard(const std::string& source);
689 * Place currently selected text in system clipboard
690 * @param deleteAfterSending flag pointing if text should be deleted after sending to clipboard
692 void SendSelectionToClipboard(bool deleteAfterSending);
694 public: // Default style & Input style
696 * @brief Set the default font family.
698 * @param[in] defaultFontFamily The default font family.
700 void SetDefaultFontFamily(const std::string& defaultFontFamily);
703 * @brief Retrieve the default font family.
705 * @return The default font family.
707 const std::string& GetDefaultFontFamily() const;
710 * @brief Sets the placeholder text font family.
711 * @param[in] placeholderTextFontFamily The placeholder text font family.
713 void SetPlaceholderFontFamily(const std::string& placeholderTextFontFamily);
716 * @brief Retrieves the placeholder text font family.
718 * @return The placeholder text font family
720 const std::string& GetPlaceholderFontFamily() const;
723 * @brief Sets the default font weight.
725 * @param[in] weight The font weight.
727 void SetDefaultFontWeight(FontWeight weight);
730 * @brief Whether the font's weight has been defined.
732 bool IsDefaultFontWeightDefined() const;
735 * @brief Retrieves the default font weight.
737 * @return The default font weight.
739 FontWeight GetDefaultFontWeight() const;
742 * @brief Sets the placeholder text font weight.
744 * @param[in] weight The font weight
746 void SetPlaceholderTextFontWeight(FontWeight weight);
749 * @brief Whether the font's weight has been defined.
751 * @return True if the placeholder text font weight is defined
753 bool IsPlaceholderTextFontWeightDefined() const;
756 * @brief Retrieves the placeholder text font weight.
758 * @return The placeholder text font weight
760 FontWeight GetPlaceholderTextFontWeight() const;
763 * @brief Sets the default font width.
765 * @param[in] width The font width.
767 void SetDefaultFontWidth(FontWidth width);
770 * @brief Whether the font's width has been defined.
772 bool IsDefaultFontWidthDefined() const;
775 * @brief Retrieves the default font width.
777 * @return The default font width.
779 FontWidth GetDefaultFontWidth() const;
782 * @brief Sets the placeholder text font width.
784 * @param[in] width The font width
786 void SetPlaceholderTextFontWidth(FontWidth width);
789 * @brief Whether the font's width has been defined.
791 * @return True if the placeholder text font width is defined
793 bool IsPlaceholderTextFontWidthDefined() const;
796 * @brief Retrieves the placeholder text font width.
798 * @return The placeholder text font width
800 FontWidth GetPlaceholderTextFontWidth() const;
803 * @brief Sets the default font slant.
805 * @param[in] slant The font slant.
807 void SetDefaultFontSlant(FontSlant slant);
810 * @brief Whether the font's slant has been defined.
812 bool IsDefaultFontSlantDefined() const;
815 * @brief Retrieves the default font slant.
817 * @return The default font slant.
819 FontSlant GetDefaultFontSlant() const;
822 * @brief Sets the placeholder text font slant.
824 * @param[in] slant The font slant
826 void SetPlaceholderTextFontSlant(FontSlant slant);
829 * @brief Whether the font's slant has been defined.
831 * @return True if the placeholder text font slant is defined
833 bool IsPlaceholderTextFontSlantDefined() const;
836 * @brief Retrieves the placeholder text font slant.
838 * @return The placeholder text font slant
840 FontSlant GetPlaceholderTextFontSlant() const;
843 * @brief Set the default font size.
845 * @param[in] fontSize The default font size
846 * @param[in] type The font size type is point size or pixel size
848 void SetDefaultFontSize(float fontSize, FontSizeType type);
851 * @brief Retrieve the default point size.
853 * @param[in] type The font size type
854 * @return The default point size.
856 float GetDefaultFontSize(FontSizeType type) const;
859 * @brief Set the font size scale.
861 * @param[in] scale The font size scale
863 void SetFontSizeScale(float scale);
866 * @brief Get the font size scale.
868 * @return The font size scale.
870 float GetFontSizeScale() const;
873 * @brief Sets the Placeholder text font size.
874 * @param[in] fontSize The placeholder text font size
875 * @param[in] type The font size type is point size or pixel size
877 void SetPlaceholderTextFontSize(float fontSize, FontSizeType type);
880 * @brief Retrieves the Placeholder text font size.
881 * @param[in] type The font size type
882 * @return The placeholder font size
884 float GetPlaceholderTextFontSize(FontSizeType type) const;
887 * @brief Sets the text's default color.
889 * @param color The default color.
891 void SetDefaultColor(const Vector4& color);
894 * @brief Retrieves the text's default color.
896 * @return The default color.
898 const Vector4& GetDefaultColor() const;
901 * @brief Set the text color
903 * @param textColor The text color
905 void SetPlaceholderTextColor(const Vector4& textColor);
908 * @brief Retrieve the text color
910 * @return The text color
912 const Vector4& GetPlaceholderTextColor() const;
915 * @brief Set the shadow offset.
917 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
919 void SetShadowOffset(const Vector2& shadowOffset);
922 * @brief Retrieve the shadow offset.
924 * @return The shadow offset.
926 const Vector2& GetShadowOffset() const;
929 * @brief Set the shadow color.
931 * @param[in] shadowColor The shadow color.
933 void SetShadowColor(const Vector4& shadowColor);
936 * @brief Retrieve the shadow color.
938 * @return The shadow color.
940 const Vector4& GetShadowColor() const;
943 * @brief Set the shadow blur radius.
945 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
947 void SetShadowBlurRadius(const float& shadowBlurRadius);
950 * @brief Retrieve the shadow blur radius.
952 * @return The shadow blur radius.
954 const float& GetShadowBlurRadius() const;
957 * @brief Set the underline color.
959 * @param[in] color color of underline.
961 void SetUnderlineColor(const Vector4& color);
964 * @brief Retrieve the underline color.
966 * @return The underline color.
968 const Vector4& GetUnderlineColor() const;
971 * @brief Set the underline enabled flag.
973 * @param[in] enabled The underline enabled flag.
975 void SetUnderlineEnabled(bool enabled);
978 * @brief Returns whether the text is underlined or not.
980 * @return The underline state.
982 bool IsUnderlineEnabled() const;
985 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
987 * @param[in] height The height in pixels of the underline
989 void SetUnderlineHeight(float height);
992 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
994 * @return The height of the underline, or 0 if height is not overrided.
996 float GetUnderlineHeight() const;
999 * @brief Set the outline color.
1001 * @param[in] color color of outline.
1003 void SetOutlineColor(const Vector4& color);
1006 * @brief Retrieve the outline color.
1008 * @return The outline color.
1010 const Vector4& GetOutlineColor() const;
1013 * @brief Set the outline width
1015 * @param[in] width The width in pixels of the outline, 0 indicates no outline
1017 void SetOutlineWidth(uint16_t width);
1020 * @brief Retrieves the width of an outline
1022 * @return The width of the outline.
1024 uint16_t GetOutlineWidth() const;
1027 * @brief Set the background color.
1029 * @param[in] color color of background.
1031 void SetBackgroundColor(const Vector4& color);
1034 * @brief Retrieve the background color.
1036 * @return The background color.
1038 const Vector4& GetBackgroundColor() const;
1041 * @brief Set the background enabled flag.
1043 * @param[in] enabled The background enabled flag.
1045 void SetBackgroundEnabled(bool enabled);
1048 * @brief Returns whether to enable text background or not.
1050 * @return Whether text background is enabled.
1052 bool IsBackgroundEnabled() const;
1055 * @brief Sets the emboss's properties string.
1057 * @note The string is stored to be recovered.
1059 * @param[in] embossProperties The emboss's properties string.
1061 void SetDefaultEmbossProperties(const std::string& embossProperties);
1064 * @brief Retrieves the emboss's properties string.
1066 * @return The emboss's properties string.
1068 const std::string& GetDefaultEmbossProperties() const;
1071 * @brief Sets the outline's properties string.
1073 * @note The string is stored to be recovered.
1075 * @param[in] outlineProperties The outline's properties string.
1077 void SetDefaultOutlineProperties(const std::string& outlineProperties);
1080 * @brief Retrieves the outline's properties string.
1082 * @return The outline's properties string.
1084 const std::string& GetDefaultOutlineProperties() const;
1087 * @brief Sets the default line spacing.
1089 * @param[in] lineSpacing The line spacing.
1091 * @return True if lineSpacing has been updated, false otherwise
1093 bool SetDefaultLineSpacing(float lineSpacing);
1096 * @brief Retrieves the default line spacing.
1098 * @return The line spacing.
1100 float GetDefaultLineSpacing() const;
1103 * @brief Sets the default line size.
1105 * @param[in] lineSize The line size.
1107 * @return True if lineSize has been updated, false otherwise
1109 bool SetDefaultLineSize(float lineSize);
1112 * @brief Retrieves the default line size.
1114 * @return The line size.
1116 float GetDefaultLineSize() const;
1119 * @brief Sets the input text's color.
1121 * @param[in] color The input text's color.
1123 void SetInputColor(const Vector4& color);
1126 * @brief Retrieves the input text's color.
1128 * @return The input text's color.
1130 const Vector4& GetInputColor() const;
1133 * @brief Sets the input text's font family name.
1135 * @param[in] fontFamily The text's font family name.
1137 void SetInputFontFamily(const std::string& fontFamily);
1140 * @brief Retrieves the input text's font family name.
1142 * @return The input text's font family name.
1144 const std::string& GetInputFontFamily() const;
1147 * @brief Sets the input font's weight.
1149 * @param[in] weight The input font's weight.
1151 void SetInputFontWeight(FontWeight weight);
1154 * @return Whether the font's weight has been defined.
1156 bool IsInputFontWeightDefined() const;
1159 * @brief Retrieves the input font's weight.
1161 * @return The input font's weight.
1163 FontWeight GetInputFontWeight() const;
1166 * @brief Sets the input font's width.
1168 * @param[in] width The input font's width.
1170 void SetInputFontWidth(FontWidth width);
1173 * @return Whether the font's width has been defined.
1175 bool IsInputFontWidthDefined() const;
1178 * @brief Retrieves the input font's width.
1180 * @return The input font's width.
1182 FontWidth GetInputFontWidth() const;
1185 * @brief Sets the input font's slant.
1187 * @param[in] slant The input font's slant.
1189 void SetInputFontSlant(FontSlant slant);
1192 * @return Whether the font's slant has been defined.
1194 bool IsInputFontSlantDefined() const;
1197 * @brief Retrieves the input font's slant.
1199 * @return The input font's slant.
1201 FontSlant GetInputFontSlant() const;
1204 * @brief Sets the input font's point size.
1206 * @param[in] size The input font's point size.
1208 void SetInputFontPointSize(float size);
1211 * @brief Retrieves the input font's point size.
1213 * @return The input font's point size.
1215 float GetInputFontPointSize() const;
1218 * @brief Sets the input line spacing.
1220 * @param[in] lineSpacing The line spacing.
1222 void SetInputLineSpacing(float lineSpacing);
1225 * @brief Retrieves the input line spacing.
1227 * @return The line spacing.
1229 float GetInputLineSpacing() const;
1232 * @brief Sets the input shadow's properties string.
1234 * @note The string is stored to be recovered.
1236 * @param[in] shadowProperties The shadow's properties string.
1238 void SetInputShadowProperties(const std::string& shadowProperties);
1241 * @brief Retrieves the input shadow's properties string.
1243 * @return The shadow's properties string.
1245 const std::string& GetInputShadowProperties() const;
1248 * @brief Sets the input underline's properties string.
1250 * @note The string is stored to be recovered.
1252 * @param[in] underlineProperties The underline's properties string.
1254 void SetInputUnderlineProperties(const std::string& underlineProperties);
1257 * @brief Retrieves the input underline's properties string.
1259 * @return The underline's properties string.
1261 const std::string& GetInputUnderlineProperties() const;
1264 * @brief Sets the input emboss's properties string.
1266 * @note The string is stored to be recovered.
1268 * @param[in] embossProperties The emboss's properties string.
1270 void SetInputEmbossProperties(const std::string& embossProperties);
1273 * @brief Retrieves the input emboss's properties string.
1275 * @return The emboss's properties string.
1277 const std::string& GetInputEmbossProperties() const;
1280 * @brief Sets input the outline's properties string.
1282 * @note The string is stored to be recovered.
1284 * @param[in] outlineProperties The outline's properties string.
1286 void SetInputOutlineProperties(const std::string& outlineProperties);
1289 * @brief Retrieves the input outline's properties string.
1291 * @return The outline's properties string.
1293 const std::string& GetInputOutlineProperties() const;
1296 * @brief Set the control's interface.
1298 * @param[in] controlInterface The control's interface.
1300 void SetControlInterface(ControlInterface* controlInterface);
1303 * @brief Set the anchor control's interface.
1305 * @param[in] anchorControlInterface The control's interface.
1307 void SetAnchorControlInterface(AnchorControlInterface* anchorControlInterface);
1309 public: // Queries & retrieves.
1311 * @brief Return the layout engine.
1313 * @return A reference to the layout engine.
1315 Layout::Engine& GetLayoutEngine();
1318 * @brief Return a view of the text.
1320 * @return A reference to the view.
1325 * @copydoc Control::GetNaturalSize()
1327 Vector3 GetNaturalSize();
1330 * @copydoc Control::GetHeightForWidth()
1332 float GetHeightForWidth(float width);
1335 * @brief Calculates the point size for text for given layout()
1337 void FitPointSizeforLayout(Size layoutSize);
1340 * @brief Checks if the point size fits within the layout size.
1342 * @return Whether the point size fits within the layout size.
1344 bool CheckForTextFit(float pointSize, Size& layoutSize);
1347 * @brief Retrieves the text's number of lines for a given width.
1348 * @param[in] width The width of the text's area.
1349 * @ return The number of lines.
1351 int GetLineCount(float width);
1354 * @brief Retrieves the text's model.
1356 * @return A pointer to the text's model.
1358 const ModelInterface* const GetTextModel() const;
1361 * @brief Used to get scrolled distance by user input
1363 * @return Distance from last scroll offset to new scroll offset
1365 float GetScrollAmountByUserInput();
1368 * @brief Get latest scroll amount, control size and layout size
1370 * This method is used to get information of control's scroll
1371 * @param[out] scrollPosition The current scrolled position
1372 * @param[out] controlHeight The size of a UI control
1373 * @param[out] layoutHeight The size of a bounding box to layout text within.
1375 * @return Whether the text scroll position is changed or not after last update.
1377 bool GetTextScrollInfo(float& scrollPosition, float& controlHeight, float& layoutHeight);
1380 * @brief Used to set the hidden input option
1382 void SetHiddenInputOption(const Property::Map& options);
1385 * @brief Used to get the hidden input option
1387 void GetHiddenInputOption(Property::Map& options);
1390 * @brief Used to set the input filter option
1392 void SetInputFilterOption(const Property::Map& options);
1395 * @brief Used to get the input filter option
1397 void GetInputFilterOption(Property::Map& options);
1400 * @brief Sets the Placeholder Properties.
1402 * @param[in] map The placeholder property map
1404 void SetPlaceholderProperty(const Property::Map& map);
1407 * @brief Retrieves the Placeholder Property map.
1409 * @param[out] map The property map
1411 void GetPlaceholderProperty(Property::Map& map);
1414 * @brief Checks text direction.
1415 * @return The text direction.
1417 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1420 * @brief Retrieves vertical line alignment
1421 * @return The vertical line alignment
1423 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1426 * @brief Sets vertical line alignment
1427 * @param[in] alignment The vertical line alignment for the text
1429 void SetVerticalLineAlignment(Toolkit::DevelText::VerticalLineAlignment::Type alignment);
1432 * @brief Retrieves ellipsis position
1433 * @return The ellipsis position
1435 Toolkit::DevelText::EllipsisPosition::Type GetEllipsisPosition() const;
1438 * @brief Sets ellipsis position
1439 * @param[in] ellipsisPosition The ellipsis position for the text
1441 void SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type ellipsisPosition);
1444 * @brief Retrieves ignoreSpaceAfterText value from model
1445 * @return The value of ignoreSpaceAfterText
1447 bool IsIgnoreSpacesAfterText() const;
1450 * @brief Sets ignoreSpaceAfterText value to model
1451 * @param[in] ignore The value of ignoreSpacesAfterText for the text
1453 void SetIgnoreSpacesAfterText(bool ignore);
1456 * @brief Sets SetMatchLayoutDirection value to model
1457 * @param[in] match The value of matchLayoutDirection for the text
1459 void SetMatchLayoutDirection(DevelText::MatchLayoutDirection type);
1462 * @brief Retrieves matchLayoutDirection value from model
1463 * @return The value of matchLayoutDirection
1465 DevelText::MatchLayoutDirection GetMatchLayoutDirection() const;
1468 * @brief Sets layoutDirection type value.
1469 * @param[in] layoutDirection The value of the layout direction type.
1471 void SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection);
1474 * @brief Gets layoutDirection type value.
1475 * @param[in] actor The actor which will get the layout direction type.
1476 * @return The value of the layout direction type.
1478 Dali::LayoutDirection::Type GetLayoutDirection(Dali::Actor& actor) const;
1481 * @brief Sets the layout direction changed.
1483 void ChangedLayoutDirection();
1486 * @brief Retrieves if showing real text or not.
1487 * @return The value of showing real text.
1489 bool IsShowingRealText() const;
1491 public: // Relayout.
1493 * @brief Triggers a relayout which updates View (if necessary).
1495 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1496 * @param[in] size A the size of a bounding box to layout text within.
1497 * @param[in] layoutDirection The direction of the system language.
1499 * @return Whether the text model or decorations were updated.
1501 UpdateTextType Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT);
1504 * @brief Request a relayout using the ControlInterface.
1506 void RequestRelayout();
1508 public: // Input style change signals.
1510 * @return Whether the queue of input style changed signals is empty.
1512 bool IsInputStyleChangedSignalsQueueEmpty();
1515 * @brief Process all pending input style changed signals.
1517 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1518 * text controls. Text controls may send signals to state the input style has changed.
1520 void ProcessInputStyleChangedSignals();
1522 public: // Text-input Event Queuing.
1524 * @brief Called by editable UI controls when keyboard focus is gained.
1526 void KeyboardFocusGainEvent();
1529 * @brief Called by editable UI controls when focus is lost.
1531 void KeyboardFocusLostEvent();
1534 * @brief Called by editable UI controls when key events are received.
1536 * @param[in] event The key event.
1537 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1539 bool KeyEvent(const Dali::KeyEvent& event);
1542 * @brief Called by anchor when a tap gesture occurs.
1543 * @param[in] x The x position relative to the top-left of the parent control.
1544 * @param[in] y The y position relative to the top-left of the parent control.
1546 void AnchorEvent(float x, float y);
1549 * @brief Called by editable UI controls when a tap gesture occurs.
1550 * @param[in] tapCount The number of taps.
1551 * @param[in] x The x position relative to the top-left of the parent control.
1552 * @param[in] y The y position relative to the top-left of the parent control.
1554 void TapEvent(unsigned int tapCount, float x, float y);
1557 * @brief Called by editable UI controls when a pan gesture occurs.
1559 * @param[in] state The state of the gesture.
1560 * @param[in] displacement This distance panned since the last pan gesture.
1562 void PanEvent(GestureState state, const Vector2& displacement);
1565 * @brief Called by editable UI controls when a long press gesture occurs.
1567 * @param[in] state The state of the gesture.
1568 * @param[in] x The x position relative to the top-left of the parent control.
1569 * @param[in] y The y position relative to the top-left of the parent control.
1571 void LongPressEvent(GestureState state, float x, float y);
1574 * @brief Used to get the Primary cursor position.
1576 * @return Primary cursor position.
1578 CharacterIndex GetPrimaryCursorPosition() const;
1581 * @brief Used to set the Primary cursor position.
1583 * @param[in] index for the Primary cursor position.
1584 * @return[in] true if cursor position changed, false otherwise.
1586 bool SetPrimaryCursorPosition(CharacterIndex index);
1589 * @brief Creates a selection event.
1591 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1593 * @param[in] x The x position relative to the top-left of the parent control.
1594 * @param[in] y The y position relative to the top-left of the parent control.
1595 * @param[in] selection type like the whole text is selected or unselected.
1597 void SelectEvent(float x, float y, SelectionType selection);
1600 * @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
1602 void SetTextSelectionRange(const uint32_t* start, const uint32_t* end);
1605 * @copydoc Text::SelectableControlInterface::GetTextSelectionRange()
1607 Uint32Pair GetTextSelectionRange() const;
1610 * @copydoc Text::SelectableControlInterface::SelectWholeText()
1612 void SelectWholeText();
1615 * @copydoc Text::SelectableControlInterface::SelectNone()
1620 * @copydoc Text::SelectableControlInterface::GetSelectedText()
1622 string GetSelectedText() const;
1625 * @copydoc Text::EditableControlInterface::IsEditable()
1627 virtual bool IsEditable() const;
1630 * @copydoc Text::EditableControlInterface::SetEditable()
1632 virtual void SetEditable(bool editable);
1635 * @copydoc Dali::Toolkit::Internal::TextEditor::ScrollBy()
1637 virtual void ScrollBy(Vector2 scroll);
1640 * @copydoc Dali::Toolkit::Internal::TextEditor::GetHorizontalScrollPosition()
1642 float GetHorizontalScrollPosition();
1645 * @copydoc Dali::Toolkit::Internal::TextEditor::GetVerticalScrollPosition()
1647 float GetVerticalScrollPosition();
1650 * @brief Event received from input method context
1652 * @param[in] inputMethodContext The input method context.
1653 * @param[in] inputMethodContextEvent The event received.
1654 * @return A data struture indicating if update is needed, cursor position and current text.
1656 InputMethodContext::CallbackData OnInputMethodContextEvent(InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent);
1659 * @brief Event from Clipboard notifying an Item has been selected for pasting
1661 void PasteClipboardItemEvent();
1664 * @brief Return true when text control should clear key input focus when escape key is pressed.
1666 * @return Whether text control should clear key input focus or not when escape key is pressed.
1668 bool ShouldClearFocusOnEscape() const;
1671 * @brief Create an actor that renders the text background color
1673 * @return the created actor or an empty handle if no background color needs to be rendered.
1675 Actor CreateBackgroundActor();
1678 * @brief Used to reset the cursor position after setting a new text.
1680 * @param[in] cursorIndex Where to place the cursor.
1682 void ResetCursorPosition(CharacterIndex cursorIndex);
1685 * @brief The method acquires current position of cursor
1686 * @return unsigned value with cursor position
1688 CharacterIndex GetCursorPosition();
1690 protected: // Inherit from Text::Decorator::ControllerInterface.
1692 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1694 void GetTargetSize(Vector2& targetSize) override;
1697 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1699 void AddDecoration(Actor& actor, bool needsClipping) override;
1702 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1704 void DecorationEvent(HandleType handle, HandleState state, float x, float y) override;
1706 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1708 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1710 void TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::Buttons button) override;
1712 protected: // Inherit from HiddenText.
1714 * @brief Invoked from HiddenText when showing time of the last character was expired
1716 void DisplayTimeExpired() override;
1720 * @brief Called by editable UI controls when key events are received.
1722 * @param[in] text The text to insert.
1723 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1725 void InsertText(const std::string& text, InsertType type);
1728 * @brief Paste given string into Text model
1729 * @param[in] stringToPaste this string will be inserted into the text model
1731 void PasteText(const std::string& stringToPaste);
1734 * @brief Remove a given number of characters
1736 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1737 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1738 * style when pre-edit text is removed.
1740 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1741 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1742 * @param[in] type Whether to update the input style.
1743 * @return True if the remove was successful.
1745 bool RemoveText(int cursorOffset,
1746 int numberOfCharacters,
1747 UpdateInputStyleType type);
1750 * @brief Checks if text is selected and if so removes it.
1751 * @return true if text was removed
1753 bool RemoveSelectedText();
1756 * @brief Update anchor position from given number of inserted characters.
1758 * @param[in] numberOfCharacters The number of inserted characters.
1759 * @param[in] previousCursorIndex A cursor position before event occurs.
1761 void InsertTextAnchor(int numberOfCharacters,
1762 CharacterIndex previousCursorIndex);
1765 * @brief Update anchor position from given number of removed characters.
1767 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1768 * @param[in] numberOfCharacters The number of removed characters.
1769 * @param[in] previousCursorIndex A cursor position before event occurs.
1771 void RemoveTextAnchor(int cursorOffset,
1772 int numberOfCharacters,
1773 CharacterIndex previousCursorIndex);
1775 private: // Relayout.
1777 * @brief Lays-out the text.
1779 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1781 * @param[in] size A the size of a bounding box to layout text within.
1782 * @param[in] operations The layout operations which need to be done.
1783 * @param[out] layoutSize The size of the laid-out text.
1785 bool DoRelayout(const Size& size,
1786 OperationsMask operations,
1790 * @brief Calulates the vertical offset to align the text inside the bounding box.
1792 * @param[in] size The size of the bounding box.
1794 void CalculateVerticalOffset(const Size& size);
1798 * @brief Process queued events which modify the model.
1800 void ProcessModifyEvents();
1803 * @brief Used to process an event queued from SetText()
1805 void TextReplacedEvent();
1808 * @brief Used to process an event queued from key events etc.
1810 void TextInsertedEvent();
1813 * @brief Used to process an event queued from backspace key etc.
1815 void TextDeletedEvent();
1818 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1820 * @param[in] keyCode The keycode for the key pressed
1821 * @return True if a character was deleted.
1823 bool DeleteEvent(int keyCode);
1825 private: // Helpers.
1827 * @brief Used to remove the text included the placeholder text.
1832 * @brief Helper to show the place holder text..
1834 void ShowPlaceholderText();
1837 * @brief Helper to clear font-specific data (only).
1839 void ClearFontData();
1842 * @brief Helper to clear text's style data.
1844 void ClearStyleData();
1847 * @brief Used to reset the scroll position after setting a new text.
1849 void ResetScrollPosition();
1851 private: // Private contructors & copy operator.
1853 * @brief Private constructor.
1858 * @brief Private constructor.
1860 Controller(ControlInterface* controlInterface);
1863 * @brief Private constructor.
1865 Controller(ControlInterface* controlInterface,
1866 EditableControlInterface* editableControlInterface,
1867 SelectableControlInterface* selectableControlInterface,
1868 AnchorControlInterface* anchorControlInterface);
1871 Controller(const Controller& handle);
1874 Controller& operator=(const Controller& handle);
1876 protected: // Destructor.
1878 * @brief A reference counted object may only be deleted by calling Unreference().
1880 virtual ~Controller();
1883 struct Impl; ///< Made public for testing purposes
1886 struct EventHandler;
1887 struct InputFontHandler;
1888 struct PlaceholderHandler;
1897 } // namespace Toolkit
1901 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H