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 Retrieves whether the current text contains anchors.
236 * @return @e true if the current text contains anchors. @e false.
238 bool HasAnchors() const;
241 * @brief Enables/disables the auto text scrolling
243 * By default is disabled.
245 * @param[in] enable Whether to enable the auto scrolling
247 void SetAutoScrollEnabled(bool enable);
250 * @brief Retrieves whether auto text scrolling is enabled.
252 * By default is disabled.
254 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
256 bool IsAutoScrollEnabled() const;
259 * @brief Get direction of the text from the first line of text,
260 * @return bool rtl (right to left) is true
262 CharacterDirection GetAutoScrollDirection() const;
265 * @brief Get the alignment offset of the first line of text.
267 * @return The alignment offset.
269 float GetAutoScrollLineAlignment() const;
272 * @brief Enables the horizontal scrolling.
274 * @param[in] enable Whether to enable the horizontal scrolling.
276 void SetHorizontalScrollEnabled(bool enable);
279 * @brief Retrieves whether the horizontal scrolling is enabled.
281 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
283 bool IsHorizontalScrollEnabled() const;
286 * @brief Enables the vertical scrolling.
288 * @param[in] enable Whether to enable the vertical scrolling.
290 void SetVerticalScrollEnabled(bool enable);
293 * @brief Retrieves whether the verticall scrolling is enabled.
295 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
297 bool IsVerticalScrollEnabled() const;
300 * @brief Enables the smooth handle panning.
302 * @param[in] enable Whether to enable the smooth handle panning.
304 void SetSmoothHandlePanEnabled(bool enable);
307 * @brief Retrieves whether the smooth handle panning is enabled.
309 * @return @e true if the smooth handle panning is enabled.
311 bool IsSmoothHandlePanEnabled() const;
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 void SetMaximumNumberOfCharacters(Length maxCharacters);
321 * @brief Sets the maximum number of characters that can be inserted into the TextModel
323 * @param[in] maxCharacters maximum number of characters to be accepted
325 int GetMaximumNumberOfCharacters();
328 * @brief Called to enable/disable cursor blink.
330 * @note Only editable controls should calls this.
331 * @param[in] enabled Whether the cursor should blink or not.
333 void SetEnableCursorBlink(bool enable);
336 * @brief Query whether cursor blink is enabled.
338 * @return Whether the cursor should blink or not.
340 bool GetEnableCursorBlink() const;
343 * @brief Whether to enable the multi-line layout.
345 * @param[in] enable \e true enables the multi-line (by default)
347 void SetMultiLineEnabled(bool enable);
350 * @return Whether the multi-line layout is enabled.
352 bool IsMultiLineEnabled() const;
355 * @brief Sets the text's horizontal alignment.
357 * @param[in] alignment The horizontal alignment.
359 void SetHorizontalAlignment(HorizontalAlignment::Type alignment);
362 * @copydoc ModelInterface::GetHorizontalAlignment()
364 HorizontalAlignment::Type GetHorizontalAlignment() const;
367 * @brief Sets the text's vertical alignment.
369 * @param[in] alignment The vertical alignment.
371 void SetVerticalAlignment(VerticalAlignment::Type alignment);
374 * @copydoc ModelInterface::GetVerticalAlignment()
376 VerticalAlignment::Type GetVerticalAlignment() const;
379 * @brief Sets the text's wrap mode
380 * @param[in] text wrap mode The unit of wrapping
382 void SetLineWrapMode(Text::LineWrap::Mode textWarpMode);
385 * @brief Retrieve text wrap mode previously set.
386 * @return text wrap mode
388 Text::LineWrap::Mode GetLineWrapMode() const;
391 * @brief Enable or disable the text elide.
393 * @param[in] enabled Whether to enable the text elide.
395 void SetTextElideEnabled(bool enabled);
398 * @copydoc ModelInterface::IsTextElideEnabled()
400 bool IsTextElideEnabled() const;
403 * @brief Enable or disable the text fit.
405 * @param[in] enabled Whether to enable the text fit.
407 void SetTextFitEnabled(bool enabled);
410 * @brief Whether the text fit is enabled or not.
412 * @return True if the text fit is enabled
414 bool IsTextFitEnabled() const;
417 * @brief Sets minimum size valid for text fit.
419 * @param[in] minimum size value.
420 * @param[in] type The font size type is point size or pixel size
422 void SetTextFitMinSize(float pointSize, FontSizeType type);
425 * @brief Retrieves the minimum point size valid for text fit.
427 * @return The minimum point size valid for text fit
429 float GetTextFitMinSize() const;
432 * @brief Sets maximum size valid for text fit.
434 * @param[in] maximum size value.
435 * @param[in] type The font size type is point size or pixel size
437 void SetTextFitMaxSize(float pointSize, FontSizeType type);
440 * @brief Retrieves the maximum point size valid for text fit.
442 * @return The maximum point size valid for text fit
444 float GetTextFitMaxSize() const;
447 * @brief Sets step size for font increase valid for text fit.
449 * @param[in] step size value.
450 * @param[in] type The font size type is point size or pixel size
452 void SetTextFitStepSize(float step, FontSizeType type);
455 * @brief Retrieves the step point size valid for text fit.
457 * @return The step point size valid for text fit
459 float GetTextFitStepSize() const;
462 * @brief Sets content size valid for text fit.
464 * @param[in] Content size value.
466 void SetTextFitContentSize(Vector2 size);
469 * @brief Retrieves the content size valid for text fit.
471 * @return The content size valid for text fit
473 Vector2 GetTextFitContentSize() const;
476 * @brief Enable or disable the placeholder text elide.
477 * @param enabled Whether to enable the placeholder text elide.
479 void SetPlaceholderTextElideEnabled(bool enabled);
482 * @brief Whether the placeholder text elide property is enabled.
483 * @return True if the placeholder text elide property is enabled, false otherwise.
485 bool IsPlaceholderTextElideEnabled() const;
488 * @brief Enable or disable the text selection.
489 * @param[in] enabled Whether to enable the text selection.
491 void SetSelectionEnabled(bool enabled);
494 * @brief Whether the text selection is enabled or not.
495 * @return True if the text selection is enabled
497 bool IsSelectionEnabled() const;
500 * @brief Enable or disable the text selection using Shift key.
501 * @param enabled Whether to enable the text selection using Shift key
503 void SetShiftSelectionEnabled(bool enabled);
506 * @brief Whether the text selection using Shift key is enabled or not.
507 * @return True if the text selection using Shift key is enabled
509 bool IsShiftSelectionEnabled() const;
512 * @brief Enable or disable the grab handles for text selection.
514 * @param[in] enabled Whether to enable the grab handles
516 void SetGrabHandleEnabled(bool enabled);
519 * @brief Returns whether the grab handles are enabled.
521 * @return True if the grab handles are enabled
523 bool IsGrabHandleEnabled() const;
526 * @brief Enable or disable the grab handles for text selection.
528 * @param[in] enabled Whether to enable the grab handles
530 void SetGrabHandlePopupEnabled(bool enabled);
533 * @brief Returns whether the grab handles are enabled.
535 * @return True if the grab handles are enabled
537 bool IsGrabHandlePopupEnabled() const;
540 * @brief Sets input type to password
542 * @note The string is displayed hidden character
544 * @param[in] passwordInput True if password input is enabled.
546 void SetInputModePassword(bool passwordInput);
549 * @brief Returns whether the input mode type is set as password.
551 * @return True if input mode type is password
553 bool IsInputModePassword();
556 * @brief Sets the action when there is a double tap event on top of a text area with no text.
558 * @param[in] action The action to do.
560 void SetNoTextDoubleTapAction(NoTextTap::Action action);
563 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
565 * @return The action to do.
567 NoTextTap::Action GetNoTextDoubleTapAction() const;
570 * @briefSets the action when there is a long press event on top of a text area with no text.
572 * @param[in] action The action to do.
574 void SetNoTextLongPressAction(NoTextTap::Action action);
577 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
579 * @return The action to do.
581 NoTextTap::Action GetNoTextLongPressAction() const;
584 * @brief Query if Underline settings were provided by string or map
585 * @return bool true if set by string
587 bool IsUnderlineSetByString();
590 * Set method underline setting were set by
591 * @param[in] bool, true if set by string
593 void UnderlineSetByString(bool setByString);
596 * @brief Query if shadow settings were provided by string or map
597 * @return bool true if set by string
599 bool IsShadowSetByString();
602 * Set method shadow setting were set by
603 * @param[in] bool, true if set by string
605 void ShadowSetByString(bool setByString);
608 * @brief Query if outline settings were provided by string or map
609 * @return bool true if set by string
611 bool IsOutlineSetByString();
614 * Set method outline setting were set by
615 * @param[in] bool, true if set by string
617 void OutlineSetByString(bool setByString);
620 * @brief Query if font style settings were provided by string or map
621 * @return bool true if set by string
623 bool IsFontStyleSetByString();
626 * Set method font style setting were set by
627 * @param[in] bool, true if set by string
629 void FontStyleSetByString(bool setByString);
633 * @brief Replaces any text previously set.
635 * @note This will be converted into UTF-32 when stored in the text model.
636 * @param[in] text A string of UTF-8 characters.
638 void SetText(const std::string& text);
641 * @brief Retrieve any text previously set.
643 * @param[out] text A string of UTF-8 characters.
645 void GetText(std::string& text) const;
648 * @brief Replaces any placeholder text previously set.
650 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
651 * @param[in] text A string of UTF-8 characters.
653 void SetPlaceholderText(PlaceholderType type, const std::string& text);
656 * @brief Retrieve any placeholder text previously set.
658 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
659 * @param[out] A string of UTF-8 characters.
661 void GetPlaceholderText(PlaceholderType type, std::string& text) const;
664 * @ brief Update the text after a font change
665 * @param[in] newDefaultFont The new font to change to
667 void UpdateAfterFontChange(const std::string& newDefaultFont);
670 * @brief The method acquires currently selected text
671 * @param selectedText variable to place selected text in
673 void RetrieveSelection(std::string& selectedText) const;
676 * @brief The method sets selection in given range
677 * @param start index of first character
678 * @param end index of first character after selection
680 void SetSelection(int start, int end);
683 * @brief This method retrieve indexes of current selection
685 * @return a pair, where first element is left index of selection and second is the right one
687 std::pair<int, int> GetSelectionIndexes() const;
690 * Place string in system clipboard
691 * @param source std::string
693 void CopyStringToClipboard(const std::string& source);
696 * Place currently selected text in system clipboard
697 * @param deleteAfterSending flag pointing if text should be deleted after sending to clipboard
699 void SendSelectionToClipboard(bool deleteAfterSending);
701 public: // Default style & Input style
703 * @brief Set the default font family.
705 * @param[in] defaultFontFamily The default font family.
707 void SetDefaultFontFamily(const std::string& defaultFontFamily);
710 * @brief Retrieve the default font family.
712 * @return The default font family.
714 const std::string& GetDefaultFontFamily() const;
717 * @brief Sets the placeholder text font family.
718 * @param[in] placeholderTextFontFamily The placeholder text font family.
720 void SetPlaceholderFontFamily(const std::string& placeholderTextFontFamily);
723 * @brief Retrieves the placeholder text font family.
725 * @return The placeholder text font family
727 const std::string& GetPlaceholderFontFamily() const;
730 * @brief Sets the default font weight.
732 * @param[in] weight The font weight.
734 void SetDefaultFontWeight(FontWeight weight);
737 * @brief Whether the font's weight has been defined.
739 bool IsDefaultFontWeightDefined() const;
742 * @brief Retrieves the default font weight.
744 * @return The default font weight.
746 FontWeight GetDefaultFontWeight() const;
749 * @brief Sets the placeholder text font weight.
751 * @param[in] weight The font weight
753 void SetPlaceholderTextFontWeight(FontWeight weight);
756 * @brief Whether the font's weight has been defined.
758 * @return True if the placeholder text font weight is defined
760 bool IsPlaceholderTextFontWeightDefined() const;
763 * @brief Retrieves the placeholder text font weight.
765 * @return The placeholder text font weight
767 FontWeight GetPlaceholderTextFontWeight() const;
770 * @brief Sets the default font width.
772 * @param[in] width The font width.
774 void SetDefaultFontWidth(FontWidth width);
777 * @brief Whether the font's width has been defined.
779 bool IsDefaultFontWidthDefined() const;
782 * @brief Retrieves the default font width.
784 * @return The default font width.
786 FontWidth GetDefaultFontWidth() const;
789 * @brief Sets the placeholder text font width.
791 * @param[in] width The font width
793 void SetPlaceholderTextFontWidth(FontWidth width);
796 * @brief Whether the font's width has been defined.
798 * @return True if the placeholder text font width is defined
800 bool IsPlaceholderTextFontWidthDefined() const;
803 * @brief Retrieves the placeholder text font width.
805 * @return The placeholder text font width
807 FontWidth GetPlaceholderTextFontWidth() const;
810 * @brief Sets the default font slant.
812 * @param[in] slant The font slant.
814 void SetDefaultFontSlant(FontSlant slant);
817 * @brief Whether the font's slant has been defined.
819 bool IsDefaultFontSlantDefined() const;
822 * @brief Retrieves the default font slant.
824 * @return The default font slant.
826 FontSlant GetDefaultFontSlant() const;
829 * @brief Sets the placeholder text font slant.
831 * @param[in] slant The font slant
833 void SetPlaceholderTextFontSlant(FontSlant slant);
836 * @brief Whether the font's slant has been defined.
838 * @return True if the placeholder text font slant is defined
840 bool IsPlaceholderTextFontSlantDefined() const;
843 * @brief Retrieves the placeholder text font slant.
845 * @return The placeholder text font slant
847 FontSlant GetPlaceholderTextFontSlant() const;
850 * @brief Set the default font size.
852 * @param[in] fontSize The default font size
853 * @param[in] type The font size type is point size or pixel size
855 void SetDefaultFontSize(float fontSize, FontSizeType type);
858 * @brief Retrieve the default point size.
860 * @param[in] type The font size type
861 * @return The default point size.
863 float GetDefaultFontSize(FontSizeType type) const;
866 * @brief Set the font size scale.
868 * @param[in] scale The font size scale
870 void SetFontSizeScale(float scale);
873 * @brief Get the font size scale.
875 * @return The font size scale.
877 float GetFontSizeScale() const;
880 * @brief Sets the Placeholder text font size.
881 * @param[in] fontSize The placeholder text font size
882 * @param[in] type The font size type is point size or pixel size
884 void SetPlaceholderTextFontSize(float fontSize, FontSizeType type);
887 * @brief Retrieves the Placeholder text font size.
888 * @param[in] type The font size type
889 * @return The placeholder font size
891 float GetPlaceholderTextFontSize(FontSizeType type) const;
894 * @brief Sets the text's default color.
896 * @param color The default color.
898 void SetDefaultColor(const Vector4& color);
901 * @brief Retrieves the text's default color.
903 * @return The default color.
905 const Vector4& GetDefaultColor() const;
908 * @brief Set the text color
910 * @param textColor The text color
912 void SetPlaceholderTextColor(const Vector4& textColor);
915 * @brief Retrieve the text color
917 * @return The text color
919 const Vector4& GetPlaceholderTextColor() const;
922 * @brief Set the shadow offset.
924 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
926 void SetShadowOffset(const Vector2& shadowOffset);
929 * @brief Retrieve the shadow offset.
931 * @return The shadow offset.
933 const Vector2& GetShadowOffset() const;
936 * @brief Set the shadow color.
938 * @param[in] shadowColor The shadow color.
940 void SetShadowColor(const Vector4& shadowColor);
943 * @brief Retrieve the shadow color.
945 * @return The shadow color.
947 const Vector4& GetShadowColor() const;
950 * @brief Set the shadow blur radius.
952 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
954 void SetShadowBlurRadius(const float& shadowBlurRadius);
957 * @brief Retrieve the shadow blur radius.
959 * @return The shadow blur radius.
961 const float& GetShadowBlurRadius() const;
964 * @brief Set the underline color.
966 * @param[in] color color of underline.
968 void SetUnderlineColor(const Vector4& color);
971 * @brief Retrieve the underline color.
973 * @return The underline color.
975 const Vector4& GetUnderlineColor() const;
978 * @brief Set the underline enabled flag.
980 * @param[in] enabled The underline enabled flag.
982 void SetUnderlineEnabled(bool enabled);
985 * @brief Returns whether the text is underlined or not.
987 * @return The underline state.
989 bool IsUnderlineEnabled() const;
992 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
994 * @param[in] height The height in pixels of the underline
996 void SetUnderlineHeight(float height);
999 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
1001 * @return The height of the underline, or 0 if height is not overrided.
1003 float GetUnderlineHeight() const;
1006 * @brief Set the outline color.
1008 * @param[in] color color of outline.
1010 void SetOutlineColor(const Vector4& color);
1013 * @brief Retrieve the outline color.
1015 * @return The outline color.
1017 const Vector4& GetOutlineColor() const;
1020 * @brief Set the outline width
1022 * @param[in] width The width in pixels of the outline, 0 indicates no outline
1024 void SetOutlineWidth(uint16_t width);
1027 * @brief Retrieves the width of an outline
1029 * @return The width of the outline.
1031 uint16_t GetOutlineWidth() const;
1034 * @brief Set the background color.
1036 * @param[in] color color of background.
1038 void SetBackgroundColor(const Vector4& color);
1041 * @brief Retrieve the background color.
1043 * @return The background color.
1045 const Vector4& GetBackgroundColor() const;
1048 * @brief Set the background enabled flag.
1050 * @param[in] enabled The background enabled flag.
1052 void SetBackgroundEnabled(bool enabled);
1055 * @brief Returns whether to enable text background or not.
1057 * @return Whether text background is enabled.
1059 bool IsBackgroundEnabled() const;
1062 * @brief Sets the emboss's properties string.
1064 * @note The string is stored to be recovered.
1066 * @param[in] embossProperties The emboss's properties string.
1068 void SetDefaultEmbossProperties(const std::string& embossProperties);
1071 * @brief Retrieves the emboss's properties string.
1073 * @return The emboss's properties string.
1075 const std::string& GetDefaultEmbossProperties() const;
1078 * @brief Sets the outline's properties string.
1080 * @note The string is stored to be recovered.
1082 * @param[in] outlineProperties The outline's properties string.
1084 void SetDefaultOutlineProperties(const std::string& outlineProperties);
1087 * @brief Retrieves the outline's properties string.
1089 * @return The outline's properties string.
1091 const std::string& GetDefaultOutlineProperties() const;
1094 * @brief Sets the default line spacing.
1096 * @param[in] lineSpacing The line spacing.
1098 * @return True if lineSpacing has been updated, false otherwise
1100 bool SetDefaultLineSpacing(float lineSpacing);
1103 * @brief Retrieves the default line spacing.
1105 * @return The line spacing.
1107 float GetDefaultLineSpacing() const;
1110 * @brief Sets the default line size.
1112 * @param[in] lineSize The line size.
1114 * @return True if lineSize has been updated, false otherwise
1116 bool SetDefaultLineSize(float lineSize);
1119 * @brief Retrieves the default line size.
1121 * @return The line size.
1123 float GetDefaultLineSize() const;
1126 * @brief Sets the input text's color.
1128 * @param[in] color The input text's color.
1130 void SetInputColor(const Vector4& color);
1133 * @brief Retrieves the input text's color.
1135 * @return The input text's color.
1137 const Vector4& GetInputColor() const;
1140 * @brief Sets the input text's font family name.
1142 * @param[in] fontFamily The text's font family name.
1144 void SetInputFontFamily(const std::string& fontFamily);
1147 * @brief Retrieves the input text's font family name.
1149 * @return The input text's font family name.
1151 const std::string& GetInputFontFamily() const;
1154 * @brief Sets the input font's weight.
1156 * @param[in] weight The input font's weight.
1158 void SetInputFontWeight(FontWeight weight);
1161 * @return Whether the font's weight has been defined.
1163 bool IsInputFontWeightDefined() const;
1166 * @brief Retrieves the input font's weight.
1168 * @return The input font's weight.
1170 FontWeight GetInputFontWeight() const;
1173 * @brief Sets the input font's width.
1175 * @param[in] width The input font's width.
1177 void SetInputFontWidth(FontWidth width);
1180 * @return Whether the font's width has been defined.
1182 bool IsInputFontWidthDefined() const;
1185 * @brief Retrieves the input font's width.
1187 * @return The input font's width.
1189 FontWidth GetInputFontWidth() const;
1192 * @brief Sets the input font's slant.
1194 * @param[in] slant The input font's slant.
1196 void SetInputFontSlant(FontSlant slant);
1199 * @return Whether the font's slant has been defined.
1201 bool IsInputFontSlantDefined() const;
1204 * @brief Retrieves the input font's slant.
1206 * @return The input font's slant.
1208 FontSlant GetInputFontSlant() const;
1211 * @brief Sets the input font's point size.
1213 * @param[in] size The input font's point size.
1215 void SetInputFontPointSize(float size);
1218 * @brief Retrieves the input font's point size.
1220 * @return The input font's point size.
1222 float GetInputFontPointSize() const;
1225 * @brief Sets the input line spacing.
1227 * @param[in] lineSpacing The line spacing.
1229 void SetInputLineSpacing(float lineSpacing);
1232 * @brief Retrieves the input line spacing.
1234 * @return The line spacing.
1236 float GetInputLineSpacing() const;
1239 * @brief Sets the input shadow's properties string.
1241 * @note The string is stored to be recovered.
1243 * @param[in] shadowProperties The shadow's properties string.
1245 void SetInputShadowProperties(const std::string& shadowProperties);
1248 * @brief Retrieves the input shadow's properties string.
1250 * @return The shadow's properties string.
1252 const std::string& GetInputShadowProperties() const;
1255 * @brief Sets the input underline's properties string.
1257 * @note The string is stored to be recovered.
1259 * @param[in] underlineProperties The underline's properties string.
1261 void SetInputUnderlineProperties(const std::string& underlineProperties);
1264 * @brief Retrieves the input underline's properties string.
1266 * @return The underline's properties string.
1268 const std::string& GetInputUnderlineProperties() const;
1271 * @brief Sets the input emboss's properties string.
1273 * @note The string is stored to be recovered.
1275 * @param[in] embossProperties The emboss's properties string.
1277 void SetInputEmbossProperties(const std::string& embossProperties);
1280 * @brief Retrieves the input emboss's properties string.
1282 * @return The emboss's properties string.
1284 const std::string& GetInputEmbossProperties() const;
1287 * @brief Sets input the outline's properties string.
1289 * @note The string is stored to be recovered.
1291 * @param[in] outlineProperties The outline's properties string.
1293 void SetInputOutlineProperties(const std::string& outlineProperties);
1296 * @brief Retrieves the input outline's properties string.
1298 * @return The outline's properties string.
1300 const std::string& GetInputOutlineProperties() const;
1303 * @brief Set the control's interface.
1305 * @param[in] controlInterface The control's interface.
1307 void SetControlInterface(ControlInterface* controlInterface);
1310 * @brief Set the anchor control's interface.
1312 * @param[in] anchorControlInterface The control's interface.
1314 void SetAnchorControlInterface(AnchorControlInterface* anchorControlInterface);
1316 public: // Queries & retrieves.
1318 * @brief Return the layout engine.
1320 * @return A reference to the layout engine.
1322 Layout::Engine& GetLayoutEngine();
1325 * @brief Return a view of the text.
1327 * @return A reference to the view.
1332 * @copydoc Control::GetNaturalSize()
1334 Vector3 GetNaturalSize();
1337 * @copydoc Control::GetHeightForWidth()
1339 float GetHeightForWidth(float width);
1342 * @brief Calculates the point size for text for given layout()
1344 void FitPointSizeforLayout(Size layoutSize);
1347 * @brief Checks if the point size fits within the layout size.
1349 * @return Whether the point size fits within the layout size.
1351 bool CheckForTextFit(float pointSize, Size& layoutSize);
1354 * @brief Retrieves the text's number of lines for a given width.
1355 * @param[in] width The width of the text's area.
1356 * @ return The number of lines.
1358 int GetLineCount(float width);
1361 * @brief Retrieves the text's model.
1363 * @return A pointer to the text's model.
1365 const ModelInterface* const GetTextModel() const;
1368 * @brief Used to get scrolled distance by user input
1370 * @return Distance from last scroll offset to new scroll offset
1372 float GetScrollAmountByUserInput();
1375 * @brief Get latest scroll amount, control size and layout size
1377 * This method is used to get information of control's scroll
1378 * @param[out] scrollPosition The current scrolled position
1379 * @param[out] controlHeight The size of a UI control
1380 * @param[out] layoutHeight The size of a bounding box to layout text within.
1382 * @return Whether the text scroll position is changed or not after last update.
1384 bool GetTextScrollInfo(float& scrollPosition, float& controlHeight, float& layoutHeight);
1387 * @brief Used to set the hidden input option
1389 void SetHiddenInputOption(const Property::Map& options);
1392 * @brief Used to get the hidden input option
1394 void GetHiddenInputOption(Property::Map& options);
1397 * @brief Used to set the input filter option
1399 void SetInputFilterOption(const Property::Map& options);
1402 * @brief Used to get the input filter option
1404 void GetInputFilterOption(Property::Map& options);
1407 * @brief Sets the Placeholder Properties.
1409 * @param[in] map The placeholder property map
1411 void SetPlaceholderProperty(const Property::Map& map);
1414 * @brief Retrieves the Placeholder Property map.
1416 * @param[out] map The property map
1418 void GetPlaceholderProperty(Property::Map& map);
1421 * @brief Checks text direction.
1422 * @return The text direction.
1424 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1427 * @brief Retrieves vertical line alignment
1428 * @return The vertical line alignment
1430 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1433 * @brief Sets vertical line alignment
1434 * @param[in] alignment The vertical line alignment for the text
1436 void SetVerticalLineAlignment(Toolkit::DevelText::VerticalLineAlignment::Type alignment);
1439 * @brief Retrieves ellipsis position
1440 * @return The ellipsis position
1442 Toolkit::DevelText::EllipsisPosition::Type GetEllipsisPosition() const;
1445 * @brief Sets ellipsis position
1446 * @param[in] ellipsisPosition The ellipsis position for the text
1448 void SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type ellipsisPosition);
1451 * @brief Retrieves ignoreSpaceAfterText value from model
1452 * @return The value of ignoreSpaceAfterText
1454 bool IsIgnoreSpacesAfterText() const;
1457 * @brief Sets ignoreSpaceAfterText value to model
1458 * @param[in] ignore The value of ignoreSpacesAfterText for the text
1460 void SetIgnoreSpacesAfterText(bool ignore);
1463 * @brief Sets SetMatchLayoutDirection value to model
1464 * @param[in] match The value of matchLayoutDirection for the text
1466 void SetMatchLayoutDirection(DevelText::MatchLayoutDirection type);
1469 * @brief Retrieves matchLayoutDirection value from model
1470 * @return The value of matchLayoutDirection
1472 DevelText::MatchLayoutDirection GetMatchLayoutDirection() const;
1475 * @brief Sets layoutDirection type value.
1476 * @param[in] layoutDirection The value of the layout direction type.
1478 void SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection);
1481 * @brief Gets layoutDirection type value.
1482 * @param[in] actor The actor which will get the layout direction type.
1483 * @return The value of the layout direction type.
1485 Dali::LayoutDirection::Type GetLayoutDirection(Dali::Actor& actor) const;
1488 * @brief Sets the layout direction changed.
1490 void ChangedLayoutDirection();
1493 * @brief Retrieves if showing real text or not.
1494 * @return The value of showing real text.
1496 bool IsShowingRealText() const;
1498 public: // Relayout.
1500 * @brief Triggers a relayout which updates View (if necessary).
1502 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1503 * @param[in] size A the size of a bounding box to layout text within.
1504 * @param[in] layoutDirection The direction of the system language.
1506 * @return Whether the text model or decorations were updated.
1508 UpdateTextType Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT);
1511 * @brief Request a relayout using the ControlInterface.
1513 void RequestRelayout();
1515 public: // Input style change signals.
1517 * @return Whether the queue of input style changed signals is empty.
1519 bool IsInputStyleChangedSignalsQueueEmpty();
1522 * @brief Process all pending input style changed signals.
1524 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1525 * text controls. Text controls may send signals to state the input style has changed.
1527 void ProcessInputStyleChangedSignals();
1529 public: // Text-input Event Queuing.
1531 * @brief Called by editable UI controls when keyboard focus is gained.
1533 void KeyboardFocusGainEvent();
1536 * @brief Called by editable UI controls when focus is lost.
1538 void KeyboardFocusLostEvent();
1541 * @brief Called by editable UI controls when key events are received.
1543 * @param[in] event The key event.
1544 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1546 bool KeyEvent(const Dali::KeyEvent& event);
1549 * @brief Called by anchor when a tap gesture occurs.
1550 * @param[in] x The x position relative to the top-left of the parent control.
1551 * @param[in] y The y position relative to the top-left of the parent control.
1553 void AnchorEvent(float x, float y);
1556 * @brief Called by editable UI controls when a tap gesture occurs.
1557 * @param[in] tapCount The number of taps.
1558 * @param[in] x The x position relative to the top-left of the parent control.
1559 * @param[in] y The y position relative to the top-left of the parent control.
1561 void TapEvent(unsigned int tapCount, float x, float y);
1564 * @brief Called by editable UI controls when a pan gesture occurs.
1566 * @param[in] state The state of the gesture.
1567 * @param[in] displacement This distance panned since the last pan gesture.
1569 void PanEvent(GestureState state, const Vector2& displacement);
1572 * @brief Called by editable UI controls when a long press gesture occurs.
1574 * @param[in] state The state of the gesture.
1575 * @param[in] x The x position relative to the top-left of the parent control.
1576 * @param[in] y The y position relative to the top-left of the parent control.
1578 void LongPressEvent(GestureState state, float x, float y);
1581 * @brief Used to get the Primary cursor position.
1583 * @return Primary cursor position.
1585 CharacterIndex GetPrimaryCursorPosition() const;
1588 * @brief Used to set the Primary cursor position.
1590 * @param[in] index for the Primary cursor position.
1591 * @param[in] focused true if UI control has gained focus to receive key event, false otherwise.
1592 * @return[in] true if cursor position changed, false otherwise.
1594 bool SetPrimaryCursorPosition(CharacterIndex index, bool focused);
1597 * @brief Creates a selection event.
1599 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1601 * @param[in] x The x position relative to the top-left of the parent control.
1602 * @param[in] y The y position relative to the top-left of the parent control.
1603 * @param[in] selection type like the whole text is selected or unselected.
1605 void SelectEvent(float x, float y, SelectionType selection);
1608 * @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
1610 void SetTextSelectionRange(const uint32_t* start, const uint32_t* end);
1613 * @copydoc Text::SelectableControlInterface::GetTextSelectionRange()
1615 Uint32Pair GetTextSelectionRange() const;
1618 * @copydoc Text::SelectableControlInterface::SelectWholeText()
1620 void SelectWholeText();
1623 * @copydoc Text::SelectableControlInterface::SelectNone()
1628 * @copydoc Text::SelectableControlInterface::GetSelectedText()
1630 string GetSelectedText() const;
1633 * @copydoc Text::EditableControlInterface::IsEditable()
1635 virtual bool IsEditable() const;
1638 * @copydoc Text::EditableControlInterface::SetEditable()
1640 virtual void SetEditable(bool editable);
1643 * @copydoc Dali::Toolkit::Internal::TextEditor::ScrollBy()
1645 virtual void ScrollBy(Vector2 scroll);
1648 * @copydoc Dali::Toolkit::Internal::TextEditor::GetHorizontalScrollPosition()
1650 float GetHorizontalScrollPosition();
1653 * @copydoc Dali::Toolkit::Internal::TextEditor::GetVerticalScrollPosition()
1655 float GetVerticalScrollPosition();
1658 * @brief Event received from input method context
1660 * @param[in] inputMethodContext The input method context.
1661 * @param[in] inputMethodContextEvent The event received.
1662 * @return A data struture indicating if update is needed, cursor position and current text.
1664 InputMethodContext::CallbackData OnInputMethodContextEvent(InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent);
1667 * @brief Event from Clipboard notifying an Item has been selected for pasting
1669 void PasteClipboardItemEvent();
1672 * @brief Return true when text control should clear key input focus when escape key is pressed.
1674 * @return Whether text control should clear key input focus or not when escape key is pressed.
1676 bool ShouldClearFocusOnEscape() const;
1679 * @brief Create an actor that renders the text background color
1681 * @return the created actor or an empty handle if no background color needs to be rendered.
1683 Actor CreateBackgroundActor();
1686 * @brief Used to reset the cursor position after setting a new text.
1688 * @param[in] cursorIndex Where to place the cursor.
1690 void ResetCursorPosition(CharacterIndex cursorIndex);
1693 * @brief The method acquires current position of cursor
1694 * @return unsigned value with cursor position
1696 CharacterIndex GetCursorPosition();
1698 protected: // Inherit from Text::Decorator::ControllerInterface.
1700 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1702 void GetTargetSize(Vector2& targetSize) override;
1705 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1707 void AddDecoration(Actor& actor, bool needsClipping) override;
1710 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1712 void DecorationEvent(HandleType handle, HandleState state, float x, float y) override;
1714 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1716 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1718 void TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::Buttons button) override;
1720 protected: // Inherit from HiddenText.
1722 * @brief Invoked from HiddenText when showing time of the last character was expired
1724 void DisplayTimeExpired() override;
1728 * @brief Called by editable UI controls when key events are received.
1730 * @param[in] text The text to insert.
1731 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1733 void InsertText(const std::string& text, InsertType type);
1736 * @brief Paste given string into Text model
1737 * @param[in] stringToPaste this string will be inserted into the text model
1739 void PasteText(const std::string& stringToPaste);
1742 * @brief Remove a given number of characters
1744 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1745 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1746 * style when pre-edit text is removed.
1748 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1749 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1750 * @param[in] type Whether to update the input style.
1751 * @return True if the remove was successful.
1753 bool RemoveText(int cursorOffset,
1754 int numberOfCharacters,
1755 UpdateInputStyleType type);
1758 * @brief Checks if text is selected and if so removes it.
1759 * @return true if text was removed
1761 bool RemoveSelectedText();
1764 * @brief Update anchor position from given number of inserted characters.
1766 * @param[in] numberOfCharacters The number of inserted characters.
1767 * @param[in] previousCursorIndex A cursor position before event occurs.
1769 void InsertTextAnchor(int numberOfCharacters,
1770 CharacterIndex previousCursorIndex);
1773 * @brief Update anchor position from given number of removed characters.
1775 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1776 * @param[in] numberOfCharacters The number of removed characters.
1777 * @param[in] previousCursorIndex A cursor position before event occurs.
1779 void RemoveTextAnchor(int cursorOffset,
1780 int numberOfCharacters,
1781 CharacterIndex previousCursorIndex);
1783 private: // Relayout.
1785 * @brief Lays-out the text.
1787 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1789 * @param[in] size A the size of a bounding box to layout text within.
1790 * @param[in] operations The layout operations which need to be done.
1791 * @param[out] layoutSize The size of the laid-out text.
1793 bool DoRelayout(const Size& size,
1794 OperationsMask operations,
1798 * @brief Calulates the vertical offset to align the text inside the bounding box.
1800 * @param[in] size The size of the bounding box.
1802 void CalculateVerticalOffset(const Size& size);
1806 * @brief Process queued events which modify the model.
1808 void ProcessModifyEvents();
1811 * @brief Used to process an event queued from SetText()
1813 void TextReplacedEvent();
1816 * @brief Used to process an event queued from key events etc.
1818 void TextInsertedEvent();
1821 * @brief Used to process an event queued from backspace key etc.
1823 void TextDeletedEvent();
1826 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1828 * @param[in] keyCode The keycode for the key pressed
1829 * @return True if a character was deleted.
1831 bool DeleteEvent(int keyCode);
1833 private: // Helpers.
1835 * @brief Used to remove the text included the placeholder text.
1840 * @brief Helper to show the place holder text..
1842 void ShowPlaceholderText();
1845 * @brief Helper to clear font-specific data (only).
1847 void ClearFontData();
1850 * @brief Helper to clear text's style data.
1852 void ClearStyleData();
1855 * @brief Used to reset the scroll position after setting a new text.
1857 void ResetScrollPosition();
1859 private: // Private contructors & copy operator.
1861 * @brief Private constructor.
1866 * @brief Private constructor.
1868 Controller(ControlInterface* controlInterface);
1871 * @brief Private constructor.
1873 Controller(ControlInterface* controlInterface,
1874 EditableControlInterface* editableControlInterface,
1875 SelectableControlInterface* selectableControlInterface,
1876 AnchorControlInterface* anchorControlInterface);
1879 Controller(const Controller& handle);
1882 Controller& operator=(const Controller& handle);
1884 protected: // Destructor.
1886 * @brief A reference counted object may only be deleted by calling Unreference().
1888 virtual ~Controller();
1891 struct Impl; ///< Made public for testing purposes
1894 struct EventHandler;
1895 struct InputFontHandler;
1896 struct PlaceholderHandler;
1905 } // namespace Toolkit
1909 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H