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/layouts/layout-engine.h>
32 #include <dali-toolkit/internal/text/text-model-interface.h>
33 #include <dali-toolkit/internal/text/text-selectable-control-interface.h>
34 #include <dali-toolkit/public-api/text/text-enumerations.h>
43 class ControlInterface;
44 class EditableControlInterface;
46 class RenderingController;
49 * @brief Text selection operations .
58 typedef IntrusivePtr<Controller> ControllerPtr;
61 * @brief A Text Controller is used by UI Controls which display text.
63 * It manipulates the Logical & Visual text models on behalf of the UI Controls.
64 * It provides a view of the text that can be used by rendering back-ends.
66 * For selectable/editable UI controls, the controller handles input events from the UI control
67 * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
69 * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
71 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
73 public: // Enumerated types.
75 * @brief Text related operations to be done in the relayout process.
79 NO_OPERATION = 0x0000,
80 CONVERT_TO_UTF32 = 0x0001,
82 VALIDATE_FONTS = 0x0004,
83 GET_LINE_BREAKS = 0x0008,
86 GET_GLYPH_METRICS = 0x0040,
88 UPDATE_LAYOUT_SIZE = 0x0100,
92 UPDATE_DIRECTION = 0x1000,
93 ALL_OPERATIONS = 0xFFFF
97 * @brief Used to distinguish between regular key events and InputMethodContext events
106 * @brief Used to specify whether to update the input style.
108 enum UpdateInputStyleType
111 DONT_UPDATE_INPUT_STYLE
115 * @brief Used to specify what has been updated after the Relayout() method has been called.
119 NONE_UPDATED = 0x0, ///< Nothing has been updated.
120 MODEL_UPDATED = 0x1, ///< The text's model has been updated.
121 DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
125 * @brief Different placeholder-text can be shown when the control is active/inactive.
129 PLACEHOLDER_TYPE_ACTIVE,
130 PLACEHOLDER_TYPE_INACTIVE,
134 * @brief Enumeration for Font Size Type.
138 POINT_SIZE, // The size of font in points.
139 PIXEL_SIZE // The size of font in pixels.
146 NO_ACTION, ///< Does no action if there is a tap on top of an area with no text.
147 HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
148 SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
160 TEXT_FIT_FONT_SIZE_TYPE
164 public: // Constructor.
166 * @brief Create a new instance of a Controller.
168 * @return A pointer to a new Controller.
170 static ControllerPtr New();
173 * @brief Create a new instance of a Controller.
175 * @param[in] controlInterface The control's interface.
177 * @return A pointer to a new Controller.
179 static ControllerPtr New(ControlInterface* controlInterface);
182 * @brief Create a new instance of a Controller.
184 * @param[in] controlInterface The control's interface.
185 * @param[in] editableControlInterface The editable control's interface.
186 * @param[in] selectableControlInterface The selectable control's interface.
188 * @return A pointer to a new Controller.
190 static ControllerPtr New(ControlInterface* controlInterface,
191 EditableControlInterface* editableControlInterface,
192 SelectableControlInterface* selectableControlInterface);
194 public: // Configure the text controller.
196 * @brief Called to enable text input.
198 * @note Selectable or editable controls should call this once after Controller::New().
199 * @param[in] decorator Used to create cursor, selection handle decorations etc.
200 * @param[in] inputMethodContext Used to manager ime.
202 void EnableTextInput(DecoratorPtr decorator, InputMethodContext& inputMethodContext);
205 * @brief Used to switch between bitmap & vector based glyphs
207 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
209 void SetGlyphType(TextAbstraction::GlyphType glyphType);
212 * @brief Enables/disables the mark-up processor.
214 * By default is disabled.
216 * @param[in] enable Whether to enable the mark-up processor.
218 void SetMarkupProcessorEnabled(bool enable);
221 * @brief Retrieves whether the mark-up processor is enabled.
223 * By default is disabled.
225 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
227 bool IsMarkupProcessorEnabled() const;
230 * @brief Enables/disables the auto text scrolling
232 * By default is disabled.
234 * @param[in] enable Whether to enable the auto scrolling
236 void SetAutoScrollEnabled(bool enable);
239 * @brief Retrieves whether auto text scrolling is enabled.
241 * By default is disabled.
243 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
245 bool IsAutoScrollEnabled() const;
248 * @brief Get direction of the text from the first line of text,
249 * @return bool rtl (right to left) is true
251 CharacterDirection GetAutoScrollDirection() const;
254 * @brief Get the alignment offset of the first line of text.
256 * @return The alignment offset.
258 float GetAutoScrollLineAlignment() const;
261 * @brief Enables the horizontal scrolling.
263 * @param[in] enable Whether to enable the horizontal scrolling.
265 void SetHorizontalScrollEnabled(bool enable);
268 * @brief Retrieves whether the horizontal scrolling is enabled.
270 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
272 bool IsHorizontalScrollEnabled() const;
275 * @brief Enables the vertical scrolling.
277 * @param[in] enable Whether to enable the vertical scrolling.
279 void SetVerticalScrollEnabled(bool enable);
282 * @brief Retrieves whether the verticall scrolling is enabled.
284 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
286 bool IsVerticalScrollEnabled() const;
289 * @brief Enables the smooth handle panning.
291 * @param[in] enable Whether to enable the smooth handle panning.
293 void SetSmoothHandlePanEnabled(bool enable);
296 * @brief Retrieves whether the smooth handle panning is enabled.
298 * @return @e true if the smooth handle panning is enabled.
300 bool IsSmoothHandlePanEnabled() const;
303 * @brief Sets the maximum number of characters that can be inserted into the TextModel
305 * @param[in] maxCharacters maximum number of characters to be accepted
307 void SetMaximumNumberOfCharacters(Length maxCharacters);
310 * @brief Sets the maximum number of characters that can be inserted into the TextModel
312 * @param[in] maxCharacters maximum number of characters to be accepted
314 int GetMaximumNumberOfCharacters();
317 * @brief Called to enable/disable cursor blink.
319 * @note Only editable controls should calls this.
320 * @param[in] enabled Whether the cursor should blink or not.
322 void SetEnableCursorBlink(bool enable);
325 * @brief Query whether cursor blink is enabled.
327 * @return Whether the cursor should blink or not.
329 bool GetEnableCursorBlink() const;
332 * @brief Whether to enable the multi-line layout.
334 * @param[in] enable \e true enables the multi-line (by default)
336 void SetMultiLineEnabled(bool enable);
339 * @return Whether the multi-line layout is enabled.
341 bool IsMultiLineEnabled() const;
344 * @brief Sets the text's horizontal alignment.
346 * @param[in] alignment The horizontal alignment.
348 void SetHorizontalAlignment(HorizontalAlignment::Type alignment);
351 * @copydoc ModelInterface::GetHorizontalAlignment()
353 HorizontalAlignment::Type GetHorizontalAlignment() const;
356 * @brief Sets the text's vertical alignment.
358 * @param[in] alignment The vertical alignment.
360 void SetVerticalAlignment(VerticalAlignment::Type alignment);
363 * @copydoc ModelInterface::GetVerticalAlignment()
365 VerticalAlignment::Type GetVerticalAlignment() const;
368 * @brief Sets the text's wrap mode
369 * @param[in] text wrap mode The unit of wrapping
371 void SetLineWrapMode(Text::LineWrap::Mode textWarpMode);
374 * @brief Retrieve text wrap mode previously set.
375 * @return text wrap mode
377 Text::LineWrap::Mode GetLineWrapMode() const;
380 * @brief Enable or disable the text elide.
382 * @param[in] enabled Whether to enable the text elide.
384 void SetTextElideEnabled(bool enabled);
387 * @copydoc ModelInterface::IsTextElideEnabled()
389 bool IsTextElideEnabled() const;
392 * @brief Enable or disable the text fit.
394 * @param[in] enabled Whether to enable the text fit.
396 void SetTextFitEnabled(bool enabled);
399 * @brief Whether the text fit is enabled or not.
401 * @return True if the text fit is enabled
403 bool IsTextFitEnabled() const;
406 * @brief Sets minimum size valid for text fit.
408 * @param[in] minimum size value.
409 * @param[in] type The font size type is point size or pixel size
411 void SetTextFitMinSize(float pointSize, FontSizeType type);
414 * @brief Retrieves the minimum point size valid for text fit.
416 * @return The minimum point size valid for text fit
418 float GetTextFitMinSize() const;
421 * @brief Sets maximum size valid for text fit.
423 * @param[in] maximum size value.
424 * @param[in] type The font size type is point size or pixel size
426 void SetTextFitMaxSize(float pointSize, FontSizeType type);
429 * @brief Retrieves the maximum point size valid for text fit.
431 * @return The maximum point size valid for text fit
433 float GetTextFitMaxSize() const;
436 * @brief Sets step size for font increase valid for text fit.
438 * @param[in] step size value.
439 * @param[in] type The font size type is point size or pixel size
441 void SetTextFitStepSize(float step, FontSizeType type);
444 * @brief Retrieves the step point size valid for text fit.
446 * @return The step point size valid for text fit
448 float GetTextFitStepSize() const;
451 * @brief Sets content size valid for text fit.
453 * @param[in] Content size value.
455 void SetTextFitContentSize(Vector2 size);
458 * @brief Retrieves the content size valid for text fit.
460 * @return The content size valid for text fit
462 Vector2 GetTextFitContentSize() const;
465 * @brief Enable or disable the placeholder text elide.
466 * @param enabled Whether to enable the placeholder text elide.
468 void SetPlaceholderTextElideEnabled(bool enabled);
471 * @brief Whether the placeholder text elide property is enabled.
472 * @return True if the placeholder text elide property is enabled, false otherwise.
474 bool IsPlaceholderTextElideEnabled() const;
477 * @brief Enable or disable the text selection.
478 * @param[in] enabled Whether to enable the text selection.
480 void SetSelectionEnabled(bool enabled);
483 * @brief Whether the text selection is enabled or not.
484 * @return True if the text selection is enabled
486 bool IsSelectionEnabled() const;
489 * @brief Enable or disable the text selection using Shift key.
490 * @param enabled Whether to enable the text selection using Shift key
492 void SetShiftSelectionEnabled(bool enabled);
495 * @brief Whether the text selection using Shift key is enabled or not.
496 * @return True if the text selection using Shift key is enabled
498 bool IsShiftSelectionEnabled() const;
501 * @brief Enable or disable the grab handles for text selection.
503 * @param[in] enabled Whether to enable the grab handles
505 void SetGrabHandleEnabled(bool enabled);
508 * @brief Returns whether the grab handles are enabled.
510 * @return True if the grab handles are enabled
512 bool IsGrabHandleEnabled() const;
515 * @brief Enable or disable the grab handles for text selection.
517 * @param[in] enabled Whether to enable the grab handles
519 void SetGrabHandlePopupEnabled(bool enabled);
522 * @brief Returns whether the grab handles are enabled.
524 * @return True if the grab handles are enabled
526 bool IsGrabHandlePopupEnabled() const;
529 * @brief Sets input type to password
531 * @note The string is displayed hidden character
533 * @param[in] passwordInput True if password input is enabled.
535 void SetInputModePassword(bool passwordInput);
538 * @brief Returns whether the input mode type is set as password.
540 * @return True if input mode type is password
542 bool IsInputModePassword();
545 * @brief Sets the action when there is a double tap event on top of a text area with no text.
547 * @param[in] action The action to do.
549 void SetNoTextDoubleTapAction(NoTextTap::Action action);
552 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
554 * @return The action to do.
556 NoTextTap::Action GetNoTextDoubleTapAction() const;
559 * @briefSets the action when there is a long press event on top of a text area with no text.
561 * @param[in] action The action to do.
563 void SetNoTextLongPressAction(NoTextTap::Action action);
566 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
568 * @return The action to do.
570 NoTextTap::Action GetNoTextLongPressAction() const;
573 * @brief Query if Underline settings were provided by string or map
574 * @return bool true if set by string
576 bool IsUnderlineSetByString();
579 * Set method underline setting were set by
580 * @param[in] bool, true if set by string
582 void UnderlineSetByString(bool setByString);
585 * @brief Query if shadow settings were provided by string or map
586 * @return bool true if set by string
588 bool IsShadowSetByString();
591 * Set method shadow setting were set by
592 * @param[in] bool, true if set by string
594 void ShadowSetByString(bool setByString);
597 * @brief Query if outline settings were provided by string or map
598 * @return bool true if set by string
600 bool IsOutlineSetByString();
603 * Set method outline setting were set by
604 * @param[in] bool, true if set by string
606 void OutlineSetByString(bool setByString);
609 * @brief Query if font style settings were provided by string or map
610 * @return bool true if set by string
612 bool IsFontStyleSetByString();
615 * Set method font style setting were set by
616 * @param[in] bool, true if set by string
618 void FontStyleSetByString(bool setByString);
622 * @brief Replaces any text previously set.
624 * @note This will be converted into UTF-32 when stored in the text model.
625 * @param[in] text A string of UTF-8 characters.
627 void SetText(const std::string& text);
630 * @brief Retrieve any text previously set.
632 * @param[out] text A string of UTF-8 characters.
634 void GetText(std::string& text) const;
637 * @brief Replaces any placeholder text previously set.
639 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
640 * @param[in] text A string of UTF-8 characters.
642 void SetPlaceholderText(PlaceholderType type, const std::string& text);
645 * @brief Retrieve any placeholder text previously set.
647 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
648 * @param[out] A string of UTF-8 characters.
650 void GetPlaceholderText(PlaceholderType type, std::string& text) const;
653 * @ brief Update the text after a font change
654 * @param[in] newDefaultFont The new font to change to
656 void UpdateAfterFontChange(const std::string& newDefaultFont);
659 * @brief The method acquires currently selected text
660 * @param selectedText variable to place selected text in
662 void RetrieveSelection(std::string& selectedText) const;
665 * @brief The method sets selection in given range
666 * @param start index of first character
667 * @param end index of first character after selection
669 void SetSelection(int start, int end);
672 * @brief This method retrieve indexes of current selection
674 * @return a pair, where first element is left index of selection and second is the right one
676 std::pair<int, int> GetSelectionIndexes() const;
679 * Place string in system clipboard
680 * @param source std::string
682 void CopyStringToClipboard(const std::string& source);
685 * Place currently selected text in system clipboard
686 * @param deleteAfterSending flag pointing if text should be deleted after sending to clipboard
688 void SendSelectionToClipboard(bool deleteAfterSending);
690 public: // Default style & Input style
692 * @brief Set the default font family.
694 * @param[in] defaultFontFamily The default font family.
696 void SetDefaultFontFamily(const std::string& defaultFontFamily);
699 * @brief Retrieve the default font family.
701 * @return The default font family.
703 const std::string& GetDefaultFontFamily() const;
706 * @brief Sets the placeholder text font family.
707 * @param[in] placeholderTextFontFamily The placeholder text font family.
709 void SetPlaceholderFontFamily(const std::string& placeholderTextFontFamily);
712 * @brief Retrieves the placeholder text font family.
714 * @return The placeholder text font family
716 const std::string& GetPlaceholderFontFamily() const;
719 * @brief Sets the default font weight.
721 * @param[in] weight The font weight.
723 void SetDefaultFontWeight(FontWeight weight);
726 * @brief Whether the font's weight has been defined.
728 bool IsDefaultFontWeightDefined() const;
731 * @brief Retrieves the default font weight.
733 * @return The default font weight.
735 FontWeight GetDefaultFontWeight() const;
738 * @brief Sets the placeholder text font weight.
740 * @param[in] weight The font weight
742 void SetPlaceholderTextFontWeight(FontWeight weight);
745 * @brief Whether the font's weight has been defined.
747 * @return True if the placeholder text font weight is defined
749 bool IsPlaceholderTextFontWeightDefined() const;
752 * @brief Retrieves the placeholder text font weight.
754 * @return The placeholder text font weight
756 FontWeight GetPlaceholderTextFontWeight() const;
759 * @brief Sets the default font width.
761 * @param[in] width The font width.
763 void SetDefaultFontWidth(FontWidth width);
766 * @brief Whether the font's width has been defined.
768 bool IsDefaultFontWidthDefined() const;
771 * @brief Retrieves the default font width.
773 * @return The default font width.
775 FontWidth GetDefaultFontWidth() const;
778 * @brief Sets the placeholder text font width.
780 * @param[in] width The font width
782 void SetPlaceholderTextFontWidth(FontWidth width);
785 * @brief Whether the font's width has been defined.
787 * @return True if the placeholder text font width is defined
789 bool IsPlaceholderTextFontWidthDefined() const;
792 * @brief Retrieves the placeholder text font width.
794 * @return The placeholder text font width
796 FontWidth GetPlaceholderTextFontWidth() const;
799 * @brief Sets the default font slant.
801 * @param[in] slant The font slant.
803 void SetDefaultFontSlant(FontSlant slant);
806 * @brief Whether the font's slant has been defined.
808 bool IsDefaultFontSlantDefined() const;
811 * @brief Retrieves the default font slant.
813 * @return The default font slant.
815 FontSlant GetDefaultFontSlant() const;
818 * @brief Sets the placeholder text font slant.
820 * @param[in] slant The font slant
822 void SetPlaceholderTextFontSlant(FontSlant slant);
825 * @brief Whether the font's slant has been defined.
827 * @return True if the placeholder text font slant is defined
829 bool IsPlaceholderTextFontSlantDefined() const;
832 * @brief Retrieves the placeholder text font slant.
834 * @return The placeholder text font slant
836 FontSlant GetPlaceholderTextFontSlant() const;
839 * @brief Set the default font size.
841 * @param[in] fontSize The default font size
842 * @param[in] type The font size type is point size or pixel size
844 void SetDefaultFontSize(float fontSize, FontSizeType type);
847 * @brief Retrieve the default point size.
849 * @param[in] type The font size type
850 * @return The default point size.
852 float GetDefaultFontSize(FontSizeType type) const;
855 * @brief Set the font size scale.
857 * @param[in] scale The font size scale
859 void SetFontSizeScale(float scale);
862 * @brief Get the font size scale.
864 * @return The font size scale.
866 float GetFontSizeScale() const;
869 * @brief Sets the Placeholder text font size.
870 * @param[in] fontSize The placeholder text font size
871 * @param[in] type The font size type is point size or pixel size
873 void SetPlaceholderTextFontSize(float fontSize, FontSizeType type);
876 * @brief Retrieves the Placeholder text font size.
877 * @param[in] type The font size type
878 * @return The placeholder font size
880 float GetPlaceholderTextFontSize(FontSizeType type) const;
883 * @brief Sets the text's default color.
885 * @param color The default color.
887 void SetDefaultColor(const Vector4& color);
890 * @brief Retrieves the text's default color.
892 * @return The default color.
894 const Vector4& GetDefaultColor() const;
897 * @brief Set the text color
899 * @param textColor The text color
901 void SetPlaceholderTextColor(const Vector4& textColor);
904 * @brief Retrieve the text color
906 * @return The text color
908 const Vector4& GetPlaceholderTextColor() const;
911 * @brief Set the shadow offset.
913 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
915 void SetShadowOffset(const Vector2& shadowOffset);
918 * @brief Retrieve the shadow offset.
920 * @return The shadow offset.
922 const Vector2& GetShadowOffset() const;
925 * @brief Set the shadow color.
927 * @param[in] shadowColor The shadow color.
929 void SetShadowColor(const Vector4& shadowColor);
932 * @brief Retrieve the shadow color.
934 * @return The shadow color.
936 const Vector4& GetShadowColor() const;
939 * @brief Set the shadow blur radius.
941 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
943 void SetShadowBlurRadius(const float& shadowBlurRadius);
946 * @brief Retrieve the shadow blur radius.
948 * @return The shadow blur radius.
950 const float& GetShadowBlurRadius() const;
953 * @brief Set the underline color.
955 * @param[in] color color of underline.
957 void SetUnderlineColor(const Vector4& color);
960 * @brief Retrieve the underline color.
962 * @return The underline color.
964 const Vector4& GetUnderlineColor() const;
967 * @brief Set the underline enabled flag.
969 * @param[in] enabled The underline enabled flag.
971 void SetUnderlineEnabled(bool enabled);
974 * @brief Returns whether the text is underlined or not.
976 * @return The underline state.
978 bool IsUnderlineEnabled() const;
981 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
983 * @param[in] height The height in pixels of the underline
985 void SetUnderlineHeight(float height);
988 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
990 * @return The height of the underline, or 0 if height is not overrided.
992 float GetUnderlineHeight() const;
995 * @brief Set the outline color.
997 * @param[in] color color of outline.
999 void SetOutlineColor(const Vector4& color);
1002 * @brief Retrieve the outline color.
1004 * @return The outline color.
1006 const Vector4& GetOutlineColor() const;
1009 * @brief Set the outline width
1011 * @param[in] width The width in pixels of the outline, 0 indicates no outline
1013 void SetOutlineWidth(uint16_t width);
1016 * @brief Retrieves the width of an outline
1018 * @return The width of the outline.
1020 uint16_t GetOutlineWidth() const;
1023 * @brief Set the background color.
1025 * @param[in] color color of background.
1027 void SetBackgroundColor(const Vector4& color);
1030 * @brief Retrieve the background color.
1032 * @return The background color.
1034 const Vector4& GetBackgroundColor() const;
1037 * @brief Set the background enabled flag.
1039 * @param[in] enabled The background enabled flag.
1041 void SetBackgroundEnabled(bool enabled);
1044 * @brief Returns whether to enable text background or not.
1046 * @return Whether text background is enabled.
1048 bool IsBackgroundEnabled() const;
1051 * @brief Sets the emboss's properties string.
1053 * @note The string is stored to be recovered.
1055 * @param[in] embossProperties The emboss's properties string.
1057 void SetDefaultEmbossProperties(const std::string& embossProperties);
1060 * @brief Retrieves the emboss's properties string.
1062 * @return The emboss's properties string.
1064 const std::string& GetDefaultEmbossProperties() const;
1067 * @brief Sets the outline's properties string.
1069 * @note The string is stored to be recovered.
1071 * @param[in] outlineProperties The outline's properties string.
1073 void SetDefaultOutlineProperties(const std::string& outlineProperties);
1076 * @brief Retrieves the outline's properties string.
1078 * @return The outline's properties string.
1080 const std::string& GetDefaultOutlineProperties() const;
1083 * @brief Sets the default line spacing.
1085 * @param[in] lineSpacing The line spacing.
1087 * @return True if lineSpacing has been updated, false otherwise
1089 bool SetDefaultLineSpacing(float lineSpacing);
1092 * @brief Retrieves the default line spacing.
1094 * @return The line spacing.
1096 float GetDefaultLineSpacing() const;
1099 * @brief Sets the default line size.
1101 * @param[in] lineSize The line size.
1103 * @return True if lineSize has been updated, false otherwise
1105 bool SetDefaultLineSize(float lineSize);
1108 * @brief Retrieves the default line size.
1110 * @return The line size.
1112 float GetDefaultLineSize() const;
1115 * @brief Sets the input text's color.
1117 * @param[in] color The input text's color.
1119 void SetInputColor(const Vector4& color);
1122 * @brief Retrieves the input text's color.
1124 * @return The input text's color.
1126 const Vector4& GetInputColor() const;
1129 * @brief Sets the input text's font family name.
1131 * @param[in] fontFamily The text's font family name.
1133 void SetInputFontFamily(const std::string& fontFamily);
1136 * @brief Retrieves the input text's font family name.
1138 * @return The input text's font family name.
1140 const std::string& GetInputFontFamily() const;
1143 * @brief Sets the input font's weight.
1145 * @param[in] weight The input font's weight.
1147 void SetInputFontWeight(FontWeight weight);
1150 * @return Whether the font's weight has been defined.
1152 bool IsInputFontWeightDefined() const;
1155 * @brief Retrieves the input font's weight.
1157 * @return The input font's weight.
1159 FontWeight GetInputFontWeight() const;
1162 * @brief Sets the input font's width.
1164 * @param[in] width The input font's width.
1166 void SetInputFontWidth(FontWidth width);
1169 * @return Whether the font's width has been defined.
1171 bool IsInputFontWidthDefined() const;
1174 * @brief Retrieves the input font's width.
1176 * @return The input font's width.
1178 FontWidth GetInputFontWidth() const;
1181 * @brief Sets the input font's slant.
1183 * @param[in] slant The input font's slant.
1185 void SetInputFontSlant(FontSlant slant);
1188 * @return Whether the font's slant has been defined.
1190 bool IsInputFontSlantDefined() const;
1193 * @brief Retrieves the input font's slant.
1195 * @return The input font's slant.
1197 FontSlant GetInputFontSlant() const;
1200 * @brief Sets the input font's point size.
1202 * @param[in] size The input font's point size.
1204 void SetInputFontPointSize(float size);
1207 * @brief Retrieves the input font's point size.
1209 * @return The input font's point size.
1211 float GetInputFontPointSize() const;
1214 * @brief Sets the input line spacing.
1216 * @param[in] lineSpacing The line spacing.
1218 void SetInputLineSpacing(float lineSpacing);
1221 * @brief Retrieves the input line spacing.
1223 * @return The line spacing.
1225 float GetInputLineSpacing() const;
1228 * @brief Sets the input shadow's properties string.
1230 * @note The string is stored to be recovered.
1232 * @param[in] shadowProperties The shadow's properties string.
1234 void SetInputShadowProperties(const std::string& shadowProperties);
1237 * @brief Retrieves the input shadow's properties string.
1239 * @return The shadow's properties string.
1241 const std::string& GetInputShadowProperties() const;
1244 * @brief Sets the input underline's properties string.
1246 * @note The string is stored to be recovered.
1248 * @param[in] underlineProperties The underline's properties string.
1250 void SetInputUnderlineProperties(const std::string& underlineProperties);
1253 * @brief Retrieves the input underline's properties string.
1255 * @return The underline's properties string.
1257 const std::string& GetInputUnderlineProperties() const;
1260 * @brief Sets the input emboss's properties string.
1262 * @note The string is stored to be recovered.
1264 * @param[in] embossProperties The emboss's properties string.
1266 void SetInputEmbossProperties(const std::string& embossProperties);
1269 * @brief Retrieves the input emboss's properties string.
1271 * @return The emboss's properties string.
1273 const std::string& GetInputEmbossProperties() const;
1276 * @brief Sets input the outline's properties string.
1278 * @note The string is stored to be recovered.
1280 * @param[in] outlineProperties The outline's properties string.
1282 void SetInputOutlineProperties(const std::string& outlineProperties);
1285 * @brief Retrieves the input outline's properties string.
1287 * @return The outline's properties string.
1289 const std::string& GetInputOutlineProperties() const;
1292 * @brief Set the control's interface.
1294 * @param[in] controlInterface The control's interface.
1296 void SetControlInterface(ControlInterface* controlInterface);
1298 public: // Queries & retrieves.
1300 * @brief Return the layout engine.
1302 * @return A reference to the layout engine.
1304 Layout::Engine& GetLayoutEngine();
1307 * @brief Return a view of the text.
1309 * @return A reference to the view.
1314 * @copydoc Control::GetNaturalSize()
1316 Vector3 GetNaturalSize();
1319 * @copydoc Control::GetHeightForWidth()
1321 float GetHeightForWidth(float width);
1324 * @brief Calculates the point size for text for given layout()
1326 void FitPointSizeforLayout(Size layoutSize);
1329 * @brief Checks if the point size fits within the layout size.
1331 * @return Whether the point size fits within the layout size.
1333 bool CheckForTextFit(float pointSize, Size& layoutSize);
1336 * @brief Retrieves the text's number of lines for a given width.
1337 * @param[in] width The width of the text's area.
1338 * @ return The number of lines.
1340 int GetLineCount(float width);
1343 * @brief Retrieves the text's model.
1345 * @return A pointer to the text's model.
1347 const ModelInterface* const GetTextModel() const;
1350 * @brief Used to get scrolled distance by user input
1352 * @return Distance from last scroll offset to new scroll offset
1354 float GetScrollAmountByUserInput();
1357 * @brief Get latest scroll amount, control size and layout size
1359 * This method is used to get information of control's scroll
1360 * @param[out] scrollPosition The current scrolled position
1361 * @param[out] controlHeight The size of a UI control
1362 * @param[out] layoutHeight The size of a bounding box to layout text within.
1364 * @return Whether the text scroll position is changed or not after last update.
1366 bool GetTextScrollInfo(float& scrollPosition, float& controlHeight, float& layoutHeight);
1369 * @brief Used to set the hidden input option
1371 void SetHiddenInputOption(const Property::Map& options);
1374 * @brief Used to get the hidden input option
1376 void GetHiddenInputOption(Property::Map& options);
1379 * @brief Sets the Placeholder Properties.
1381 * @param[in] map The placeholder property map
1383 void SetPlaceholderProperty(const Property::Map& map);
1386 * @brief Retrieves the Placeholder Property map.
1388 * @param[out] map The property map
1390 void GetPlaceholderProperty(Property::Map& map);
1393 * @brief Checks text direction.
1394 * @return The text direction.
1396 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1399 * @brief Retrieves vertical line alignment
1400 * @return The vertical line alignment
1402 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1405 * @brief Sets vertical line alignment
1406 * @param[in] alignment The vertical line alignment for the text
1408 void SetVerticalLineAlignment(Toolkit::DevelText::VerticalLineAlignment::Type alignment);
1411 * @brief Retrieves ignoreSpaceAfterText value from model
1412 * @return The value of ignoreSpaceAfterText
1414 bool IsIgnoreSpacesAfterText() const;
1417 * @brief Sets ignoreSpaceAfterText value to model
1418 * @param[in] ignore The value of ignoreSpacesAfterText for the text
1420 void SetIgnoreSpacesAfterText(bool ignore);
1423 * @brief Retrieves matchSystemLanguageDirection value from model
1424 * @return The value of matchSystemLanguageDirection
1426 bool IsMatchSystemLanguageDirection() const;
1429 * @brief Sets matchSystemLanguageDirection value to model
1430 * @param[in] match The value of matchSystemLanguageDirection for the text
1432 void SetMatchSystemLanguageDirection(bool match);
1435 * @brief Sets layoutDirection value
1436 * @param[in] layoutDirection The value of system language direction
1438 void SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection);
1441 * @brief Retrieves if showing real text or not.
1442 * @return The value of showing real text.
1444 bool IsShowingRealText() const;
1446 public: // Relayout.
1448 * @brief Triggers a relayout which updates View (if necessary).
1450 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1451 * @param[in] size A the size of a bounding box to layout text within.
1452 * @param[in] layoutDirection The direction of the system language.
1454 * @return Whether the text model or decorations were updated.
1456 UpdateTextType Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT);
1459 * @brief Request a relayout using the ControlInterface.
1461 void RequestRelayout();
1463 public: // Input style change signals.
1465 * @return Whether the queue of input style changed signals is empty.
1467 bool IsInputStyleChangedSignalsQueueEmpty();
1470 * @brief Process all pending input style changed signals.
1472 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1473 * text controls. Text controls may send signals to state the input style has changed.
1475 void ProcessInputStyleChangedSignals();
1477 public: // Text-input Event Queuing.
1479 * @brief Called by editable UI controls when keyboard focus is gained.
1481 void KeyboardFocusGainEvent();
1484 * @brief Called by editable UI controls when focus is lost.
1486 void KeyboardFocusLostEvent();
1489 * @brief Called by editable UI controls when key events are received.
1491 * @param[in] event The key event.
1492 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1494 bool KeyEvent(const Dali::KeyEvent& event);
1497 * @brief Called by editable UI controls when a tap gesture occurs.
1498 * @param[in] tapCount The number of taps.
1499 * @param[in] x The x position relative to the top-left of the parent control.
1500 * @param[in] y The y position relative to the top-left of the parent control.
1502 void TapEvent(unsigned int tapCount, float x, float y);
1505 * @brief Called by editable UI controls when a pan gesture occurs.
1507 * @param[in] state The state of the gesture.
1508 * @param[in] displacement This distance panned since the last pan gesture.
1510 void PanEvent(GestureState state, const Vector2& displacement);
1513 * @brief Called by editable UI controls when a long press gesture occurs.
1515 * @param[in] state The state of the gesture.
1516 * @param[in] x The x position relative to the top-left of the parent control.
1517 * @param[in] y The y position relative to the top-left of the parent control.
1519 void LongPressEvent(GestureState state, float x, float y);
1522 * @brief Used to get the Primary cursor position.
1524 * @return Primary cursor position.
1526 CharacterIndex GetPrimaryCursorPosition() const;
1529 * @brief Used to set the Primary cursor position.
1531 * @param[in] index for the Primary cursor position.
1532 * @return[in] true if cursor position changed, false otherwise.
1534 bool SetPrimaryCursorPosition(CharacterIndex index);
1537 * @brief Creates a selection event.
1539 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1541 * @param[in] x The x position relative to the top-left of the parent control.
1542 * @param[in] y The y position relative to the top-left of the parent control.
1543 * @param[in] selection type like the whole text is selected or unselected.
1545 void SelectEvent(float x, float y, SelectionType selection);
1548 * @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
1550 void SetTextSelectionRange(const uint32_t* start, const uint32_t* end);
1553 * @copydoc Text::SelectableControlInterface::GetTextSelectionRange()
1555 Uint32Pair GetTextSelectionRange() const;
1558 * @copydoc Text::SelectableControlInterface::SelectWholeText()
1560 void SelectWholeText();
1563 * @copydoc Text::SelectableControlInterface::SelectNone()
1568 * @copydoc Text::SelectableControlInterface::GetSelectedText()
1570 string GetSelectedText() const;
1573 * @copydoc Text::EditableControlInterface::IsEditable()
1575 virtual bool IsEditable() const;
1578 * @copydoc Text::EditableControlInterface::SetEditable()
1580 virtual void SetEditable(bool editable);
1583 * @copydoc Dali::Toolkit::Internal::TextEditor::ScrollBy()
1585 virtual void ScrollBy(Vector2 scroll);
1588 * @copydoc Dali::Toolkit::Internal::TextEditor::GetHorizontalScrollPosition()
1590 float GetHorizontalScrollPosition();
1593 * @copydoc Dali::Toolkit::Internal::TextEditor::GetVerticalScrollPosition()
1595 float GetVerticalScrollPosition();
1598 * @brief Event received from input method context
1600 * @param[in] inputMethodContext The input method context.
1601 * @param[in] inputMethodContextEvent The event received.
1602 * @return A data struture indicating if update is needed, cursor position and current text.
1604 InputMethodContext::CallbackData OnInputMethodContextEvent(InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent);
1607 * @brief Event from Clipboard notifying an Item has been selected for pasting
1609 void PasteClipboardItemEvent();
1612 * @brief Return true when text control should clear key input focus when escape key is pressed.
1614 * @return Whether text control should clear key input focus or not when escape key is pressed.
1616 bool ShouldClearFocusOnEscape() const;
1619 * @brief Create an actor that renders the text background color
1621 * @return the created actor or an empty handle if no background color needs to be rendered.
1623 Actor CreateBackgroundActor();
1626 * @brief Used to reset the cursor position after setting a new text.
1628 * @param[in] cursorIndex Where to place the cursor.
1630 void ResetCursorPosition(CharacterIndex cursorIndex);
1633 * @brief The method acquires current position of cursor
1634 * @return unsigned value with cursor position
1636 CharacterIndex GetCursorPosition();
1638 protected: // Inherit from Text::Decorator::ControllerInterface.
1640 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1642 void GetTargetSize(Vector2& targetSize) override;
1645 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1647 void AddDecoration(Actor& actor, bool needsClipping) override;
1650 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1652 void DecorationEvent(HandleType handle, HandleState state, float x, float y) override;
1654 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1656 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1658 void TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::Buttons button) override;
1660 protected: // Inherit from HiddenText.
1662 * @brief Invoked from HiddenText when showing time of the last character was expired
1664 void DisplayTimeExpired() override;
1668 * @brief Called by editable UI controls when key events are received.
1670 * @param[in] text The text to insert.
1671 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1673 void InsertText(const std::string& text, InsertType type);
1676 * @brief Paste given string into Text model
1677 * @param[in] stringToPaste this string will be inserted into the text model
1679 void PasteText(const std::string& stringToPaste);
1682 * @brief Remove a given number of characters
1684 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1685 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1686 * style when pre-edit text is removed.
1688 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1689 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1690 * @param[in] type Whether to update the input style.
1691 * @return True if the remove was successful.
1693 bool RemoveText(int cursorOffset,
1694 int numberOfCharacters,
1695 UpdateInputStyleType type);
1698 * @brief Checks if text is selected and if so removes it.
1699 * @return true if text was removed
1701 bool RemoveSelectedText();
1703 private: // Relayout.
1705 * @brief Lays-out the text.
1707 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1709 * @param[in] size A the size of a bounding box to layout text within.
1710 * @param[in] operations The layout operations which need to be done.
1711 * @param[out] layoutSize The size of the laid-out text.
1713 bool DoRelayout(const Size& size,
1714 OperationsMask operations,
1718 * @brief Calulates the vertical offset to align the text inside the bounding box.
1720 * @param[in] size The size of the bounding box.
1722 void CalculateVerticalOffset(const Size& size);
1726 * @brief Process queued events which modify the model.
1728 void ProcessModifyEvents();
1731 * @brief Used to process an event queued from SetText()
1733 void TextReplacedEvent();
1736 * @brief Used to process an event queued from key events etc.
1738 void TextInsertedEvent();
1741 * @brief Used to process an event queued from backspace key etc.
1743 void TextDeletedEvent();
1746 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1748 * @param[in] keyCode The keycode for the key pressed
1749 * @return True if a character was deleted.
1751 bool DeleteEvent(int keyCode);
1753 private: // Helpers.
1755 * @brief Used to remove the text included the placeholder text.
1760 * @brief Helper to show the place holder text..
1762 void ShowPlaceholderText();
1765 * @brief Helper to clear font-specific data (only).
1767 void ClearFontData();
1770 * @brief Helper to clear text's style data.
1772 void ClearStyleData();
1775 * @brief Used to reset the scroll position after setting a new text.
1777 void ResetScrollPosition();
1779 private: // Private contructors & copy operator.
1781 * @brief Private constructor.
1786 * @brief Private constructor.
1788 Controller(ControlInterface* controlInterface);
1791 * @brief Private constructor.
1793 Controller(ControlInterface* controlInterface,
1794 EditableControlInterface* editableControlInterface,
1795 SelectableControlInterface* selectableControlInterface);
1798 Controller(const Controller& handle);
1801 Controller& operator=(const Controller& handle);
1803 protected: // Destructor.
1805 * @brief A reference counted object may only be deleted by calling Unreference().
1807 virtual ~Controller();
1810 struct Impl; ///< Made public for testing purposes
1813 struct EventHandler;
1814 struct InputFontHandler;
1815 struct PlaceholderHandler;
1824 } // namespace Toolkit
1828 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H