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 .
55 INTERACTIVE = 0x0000, ///< Select the word where the cursor is located.
56 ALL = 0x0001, ///< Select the whole text.
57 NONE = 0x0002, ///< Unselect the whole text.
58 RANGE = 0x0003 ///< Select the range text.
61 typedef IntrusivePtr<Controller> ControllerPtr;
64 * @brief A Text Controller is used by UI Controls which display text.
66 * It manipulates the Logical & Visual text models on behalf of the UI Controls.
67 * It provides a view of the text that can be used by rendering back-ends.
69 * For selectable/editable UI controls, the controller handles input events from the UI control
70 * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
72 * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
74 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
76 public: // Enumerated types.
78 * @brief Text related operations to be done in the relayout process.
82 NO_OPERATION = 0x0000,
83 CONVERT_TO_UTF32 = 0x0001,
85 VALIDATE_FONTS = 0x0004,
86 GET_LINE_BREAKS = 0x0008,
89 GET_GLYPH_METRICS = 0x0040,
91 UPDATE_LAYOUT_SIZE = 0x0100,
95 UPDATE_DIRECTION = 0x1000,
96 ALL_OPERATIONS = 0xFFFF
100 * @brief Used to distinguish between regular key events and InputMethodContext events
109 * @brief Used to specify whether to update the input style.
111 enum UpdateInputStyleType
114 DONT_UPDATE_INPUT_STYLE
118 * @brief Used to specify what has been updated after the Relayout() method has been called.
122 NONE_UPDATED = 0x0, ///< Nothing has been updated.
123 MODEL_UPDATED = 0x1, ///< The text's model has been updated.
124 DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
128 * @brief Different placeholder-text can be shown when the control is active/inactive.
132 PLACEHOLDER_TYPE_ACTIVE,
133 PLACEHOLDER_TYPE_INACTIVE,
137 * @brief Enumeration for Font Size Type.
141 POINT_SIZE, // The size of font in points.
142 PIXEL_SIZE // The size of font in pixels.
149 NO_ACTION, ///< Does no action if there is a tap on top of an area with no text.
150 HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
151 SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
163 TEXT_FIT_FONT_SIZE_TYPE
167 public: // Constructor.
169 * @brief Create a new instance of a Controller.
171 * @return A pointer to a new Controller.
173 static ControllerPtr New();
176 * @brief Create a new instance of a Controller.
178 * @param[in] controlInterface The control's interface.
180 * @return A pointer to a new Controller.
182 static ControllerPtr New(ControlInterface* controlInterface);
185 * @brief Create a new instance of a Controller.
187 * @param[in] controlInterface The control's interface.
188 * @param[in] editableControlInterface The editable control's interface.
189 * @param[in] selectableControlInterface The selectable control's interface.
190 * @param[in] anchorControlInterface The anchor control's interface.
192 * @return A pointer to a new Controller.
194 static ControllerPtr New(ControlInterface* controlInterface,
195 EditableControlInterface* editableControlInterface,
196 SelectableControlInterface* selectableControlInterface,
197 AnchorControlInterface* anchorControlInterface);
199 public: // Configure the text controller.
201 * @brief Called to enable text input.
203 * @note Selectable or editable controls should call this once after Controller::New().
204 * @param[in] decorator Used to create cursor, selection handle decorations etc.
205 * @param[in] inputMethodContext Used to manager ime.
207 void EnableTextInput(DecoratorPtr decorator, InputMethodContext& inputMethodContext);
210 * @brief Used to switch between bitmap & vector based glyphs
212 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
214 void SetGlyphType(TextAbstraction::GlyphType glyphType);
217 * @brief Enables/disables the mark-up processor.
219 * By default is disabled.
221 * @param[in] enable Whether to enable the mark-up processor.
223 void SetMarkupProcessorEnabled(bool enable);
226 * @brief Retrieves whether the mark-up processor is enabled.
228 * By default is disabled.
230 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
232 bool IsMarkupProcessorEnabled() const;
235 * @brief Retrieves whether the current text contains anchors.
237 * @return @e true if the current text contains anchors. @e false.
239 bool HasAnchors() const;
242 * @brief Enables/disables the auto text scrolling
244 * By default is disabled.
246 * @param[in] enable Whether to enable the auto scrolling
248 void SetAutoScrollEnabled(bool enable);
251 * @brief Retrieves whether auto text scrolling is enabled.
253 * By default is disabled.
255 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
257 bool IsAutoScrollEnabled() const;
260 * @brief Get direction of the text from the first line of text,
261 * @return bool rtl (right to left) is true
263 CharacterDirection GetAutoScrollDirection() const;
266 * @brief Get the alignment offset of the first line of text.
268 * @return The alignment offset.
270 float GetAutoScrollLineAlignment() const;
273 * @brief Enables the horizontal scrolling.
275 * @param[in] enable Whether to enable the horizontal scrolling.
277 void SetHorizontalScrollEnabled(bool enable);
280 * @brief Retrieves whether the horizontal scrolling is enabled.
282 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
284 bool IsHorizontalScrollEnabled() const;
287 * @brief Enables the vertical scrolling.
289 * @param[in] enable Whether to enable the vertical scrolling.
291 void SetVerticalScrollEnabled(bool enable);
294 * @brief Retrieves whether the verticall scrolling is enabled.
296 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
298 bool IsVerticalScrollEnabled() const;
301 * @brief Enables the smooth handle panning.
303 * @param[in] enable Whether to enable the smooth handle panning.
305 void SetSmoothHandlePanEnabled(bool enable);
308 * @brief Retrieves whether the smooth handle panning is enabled.
310 * @return @e true if the smooth handle panning is enabled.
312 bool IsSmoothHandlePanEnabled() const;
315 * @brief Sets the maximum number of characters that can be inserted into the TextModel
317 * @param[in] maxCharacters maximum number of characters to be accepted
319 void SetMaximumNumberOfCharacters(Length maxCharacters);
322 * @brief Sets the maximum number of characters that can be inserted into the TextModel
324 * @param[in] maxCharacters maximum number of characters to be accepted
326 int GetMaximumNumberOfCharacters();
329 * @brief Called to enable/disable cursor blink.
331 * @note Only editable controls should calls this.
332 * @param[in] enabled Whether the cursor should blink or not.
334 void SetEnableCursorBlink(bool enable);
337 * @brief Query whether cursor blink is enabled.
339 * @return Whether the cursor should blink or not.
341 bool GetEnableCursorBlink() const;
344 * @brief Whether to enable the multi-line layout.
346 * @param[in] enable \e true enables the multi-line (by default)
348 void SetMultiLineEnabled(bool enable);
351 * @return Whether the multi-line layout is enabled.
353 bool IsMultiLineEnabled() const;
356 * @brief Sets the text's horizontal alignment.
358 * @param[in] alignment The horizontal alignment.
360 void SetHorizontalAlignment(HorizontalAlignment::Type alignment);
363 * @copydoc ModelInterface::GetHorizontalAlignment()
365 HorizontalAlignment::Type GetHorizontalAlignment() const;
368 * @brief Sets the text's vertical alignment.
370 * @param[in] alignment The vertical alignment.
372 void SetVerticalAlignment(VerticalAlignment::Type alignment);
375 * @copydoc ModelInterface::GetVerticalAlignment()
377 VerticalAlignment::Type GetVerticalAlignment() const;
380 * @brief Sets the text's wrap mode
381 * @param[in] text wrap mode The unit of wrapping
383 void SetLineWrapMode(Text::LineWrap::Mode textWarpMode);
386 * @brief Retrieve text wrap mode previously set.
387 * @return text wrap mode
389 Text::LineWrap::Mode GetLineWrapMode() const;
392 * @brief Enable or disable the text elide.
394 * @param[in] enabled Whether to enable the text elide.
396 void SetTextElideEnabled(bool enabled);
399 * @copydoc ModelInterface::IsTextElideEnabled()
401 bool IsTextElideEnabled() const;
404 * @brief Enable or disable the text fit.
406 * @param[in] enabled Whether to enable the text fit.
408 void SetTextFitEnabled(bool enabled);
411 * @brief Whether the text fit is enabled or not.
413 * @return True if the text fit is enabled
415 bool IsTextFitEnabled() const;
418 * @brief Sets minimum size valid for text fit.
420 * @param[in] minimum size value.
421 * @param[in] type The font size type is point size or pixel size
423 void SetTextFitMinSize(float pointSize, FontSizeType type);
426 * @brief Retrieves the minimum point size valid for text fit.
428 * @return The minimum point size valid for text fit
430 float GetTextFitMinSize() const;
433 * @brief Sets maximum size valid for text fit.
435 * @param[in] maximum size value.
436 * @param[in] type The font size type is point size or pixel size
438 void SetTextFitMaxSize(float pointSize, FontSizeType type);
441 * @brief Retrieves the maximum point size valid for text fit.
443 * @return The maximum point size valid for text fit
445 float GetTextFitMaxSize() const;
448 * @brief Sets step size for font increase valid for text fit.
450 * @param[in] step size value.
451 * @param[in] type The font size type is point size or pixel size
453 void SetTextFitStepSize(float step, FontSizeType type);
456 * @brief Retrieves the step point size valid for text fit.
458 * @return The step point size valid for text fit
460 float GetTextFitStepSize() const;
463 * @brief Sets content size valid for text fit.
465 * @param[in] Content size value.
467 void SetTextFitContentSize(Vector2 size);
470 * @brief Retrieves the content size valid for text fit.
472 * @return The content size valid for text fit
474 Vector2 GetTextFitContentSize() const;
477 * @brief Enable or disable the placeholder text elide.
478 * @param enabled Whether to enable the placeholder text elide.
480 void SetPlaceholderTextElideEnabled(bool enabled);
483 * @brief Whether the placeholder text elide property is enabled.
484 * @return True if the placeholder text elide property is enabled, false otherwise.
486 bool IsPlaceholderTextElideEnabled() const;
489 * @brief Enable or disable the text selection.
490 * @param[in] enabled Whether to enable the text selection.
492 void SetSelectionEnabled(bool enabled);
495 * @brief Whether the text selection is enabled or not.
496 * @return True if the text selection is enabled
498 bool IsSelectionEnabled() const;
501 * @brief Enable or disable the text selection using Shift key.
502 * @param enabled Whether to enable the text selection using Shift key
504 void SetShiftSelectionEnabled(bool enabled);
507 * @brief Whether the text selection using Shift key is enabled or not.
508 * @return True if the text selection using Shift key is enabled
510 bool IsShiftSelectionEnabled() const;
513 * @brief Enable or disable the grab handles for text selection.
515 * @param[in] enabled Whether to enable the grab handles
517 void SetGrabHandleEnabled(bool enabled);
520 * @brief Returns whether the grab handles are enabled.
522 * @return True if the grab handles are enabled
524 bool IsGrabHandleEnabled() const;
527 * @brief Enable or disable the grab handles for text selection.
529 * @param[in] enabled Whether to enable the grab handles
531 void SetGrabHandlePopupEnabled(bool enabled);
534 * @brief Returns whether the grab handles are enabled.
536 * @return True if the grab handles are enabled
538 bool IsGrabHandlePopupEnabled() const;
541 * @brief Sets input type to password
543 * @note The string is displayed hidden character
545 * @param[in] passwordInput True if password input is enabled.
547 void SetInputModePassword(bool passwordInput);
550 * @brief Returns whether the input mode type is set as password.
552 * @return True if input mode type is password
554 bool IsInputModePassword();
557 * @brief Sets the action when there is a double tap event on top of a text area with no text.
559 * @param[in] action The action to do.
561 void SetNoTextDoubleTapAction(NoTextTap::Action action);
564 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
566 * @return The action to do.
568 NoTextTap::Action GetNoTextDoubleTapAction() const;
571 * @briefSets the action when there is a long press event on top of a text area with no text.
573 * @param[in] action The action to do.
575 void SetNoTextLongPressAction(NoTextTap::Action action);
578 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
580 * @return The action to do.
582 NoTextTap::Action GetNoTextLongPressAction() const;
585 * @brief Query if Underline settings were provided by string or map
586 * @return bool true if set by string
588 bool IsUnderlineSetByString();
591 * Set method underline setting were set by
592 * @param[in] bool, true if set by string
594 void UnderlineSetByString(bool setByString);
597 * @brief Query if shadow settings were provided by string or map
598 * @return bool true if set by string
600 bool IsShadowSetByString();
603 * Set method shadow setting were set by
604 * @param[in] bool, true if set by string
606 void ShadowSetByString(bool setByString);
609 * @brief Query if outline settings were provided by string or map
610 * @return bool true if set by string
612 bool IsOutlineSetByString();
615 * Set method outline setting were set by
616 * @param[in] bool, true if set by string
618 void OutlineSetByString(bool setByString);
621 * @brief Query if font style settings were provided by string or map
622 * @return bool true if set by string
624 bool IsFontStyleSetByString();
627 * Set method font style setting were set by
628 * @param[in] bool, true if set by string
630 void FontStyleSetByString(bool setByString);
634 * @brief Replaces any text previously set.
636 * @note This will be converted into UTF-32 when stored in the text model.
637 * @param[in] text A string of UTF-8 characters.
639 void SetText(const std::string& text);
642 * @brief Retrieve any text previously set.
644 * @param[out] text A string of UTF-8 characters.
646 void GetText(std::string& text) const;
649 * @brief Replaces any placeholder text previously set.
651 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
652 * @param[in] text A string of UTF-8 characters.
654 void SetPlaceholderText(PlaceholderType type, const std::string& text);
657 * @brief Retrieve any placeholder text previously set.
659 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
660 * @param[out] A string of UTF-8 characters.
662 void GetPlaceholderText(PlaceholderType type, std::string& text) const;
665 * @ brief Update the text after a font change
666 * @param[in] newDefaultFont The new font to change to
668 void UpdateAfterFontChange(const std::string& newDefaultFont);
671 * @brief The method acquires currently selected text
672 * @param selectedText variable to place selected text in
674 void RetrieveSelection(std::string& selectedText) const;
677 * @brief The method sets selection in given range
678 * @param start index of first character
679 * @param end index of first character after selection
681 void SetSelection(int start, int end);
684 * @brief This method retrieve indexes of current selection
686 * @return a pair, where first element is left index of selection and second is the right one
688 std::pair<int, int> GetSelectionIndexes() const;
691 * Place string in system clipboard
692 * @param source std::string
694 void CopyStringToClipboard(const std::string& source);
697 * Place currently selected text in system clipboard
698 * @param deleteAfterSending flag pointing if text should be deleted after sending to clipboard
700 void SendSelectionToClipboard(bool deleteAfterSending);
702 public: // Default style & Input style
704 * @brief Set the default font family.
706 * @param[in] defaultFontFamily The default font family.
708 void SetDefaultFontFamily(const std::string& defaultFontFamily);
711 * @brief Retrieve the default font family.
713 * @return The default font family.
715 const std::string& GetDefaultFontFamily() const;
718 * @brief Sets the placeholder text font family.
719 * @param[in] placeholderTextFontFamily The placeholder text font family.
721 void SetPlaceholderFontFamily(const std::string& placeholderTextFontFamily);
724 * @brief Retrieves the placeholder text font family.
726 * @return The placeholder text font family
728 const std::string& GetPlaceholderFontFamily() const;
731 * @brief Sets the default font weight.
733 * @param[in] weight The font weight.
735 void SetDefaultFontWeight(FontWeight weight);
738 * @brief Whether the font's weight has been defined.
740 bool IsDefaultFontWeightDefined() const;
743 * @brief Retrieves the default font weight.
745 * @return The default font weight.
747 FontWeight GetDefaultFontWeight() const;
750 * @brief Sets the placeholder text font weight.
752 * @param[in] weight The font weight
754 void SetPlaceholderTextFontWeight(FontWeight weight);
757 * @brief Whether the font's weight has been defined.
759 * @return True if the placeholder text font weight is defined
761 bool IsPlaceholderTextFontWeightDefined() const;
764 * @brief Retrieves the placeholder text font weight.
766 * @return The placeholder text font weight
768 FontWeight GetPlaceholderTextFontWeight() const;
771 * @brief Sets the default font width.
773 * @param[in] width The font width.
775 void SetDefaultFontWidth(FontWidth width);
778 * @brief Whether the font's width has been defined.
780 bool IsDefaultFontWidthDefined() const;
783 * @brief Retrieves the default font width.
785 * @return The default font width.
787 FontWidth GetDefaultFontWidth() const;
790 * @brief Sets the placeholder text font width.
792 * @param[in] width The font width
794 void SetPlaceholderTextFontWidth(FontWidth width);
797 * @brief Whether the font's width has been defined.
799 * @return True if the placeholder text font width is defined
801 bool IsPlaceholderTextFontWidthDefined() const;
804 * @brief Retrieves the placeholder text font width.
806 * @return The placeholder text font width
808 FontWidth GetPlaceholderTextFontWidth() const;
811 * @brief Sets the default font slant.
813 * @param[in] slant The font slant.
815 void SetDefaultFontSlant(FontSlant slant);
818 * @brief Whether the font's slant has been defined.
820 bool IsDefaultFontSlantDefined() const;
823 * @brief Retrieves the default font slant.
825 * @return The default font slant.
827 FontSlant GetDefaultFontSlant() const;
830 * @brief Sets the placeholder text font slant.
832 * @param[in] slant The font slant
834 void SetPlaceholderTextFontSlant(FontSlant slant);
837 * @brief Whether the font's slant has been defined.
839 * @return True if the placeholder text font slant is defined
841 bool IsPlaceholderTextFontSlantDefined() const;
844 * @brief Retrieves the placeholder text font slant.
846 * @return The placeholder text font slant
848 FontSlant GetPlaceholderTextFontSlant() const;
851 * @brief Set the default font size.
853 * @param[in] fontSize The default font size
854 * @param[in] type The font size type is point size or pixel size
856 void SetDefaultFontSize(float fontSize, FontSizeType type);
859 * @brief Retrieve the default point size.
861 * @param[in] type The font size type
862 * @return The default point size.
864 float GetDefaultFontSize(FontSizeType type) const;
867 * @brief Set the font size scale.
869 * @param[in] scale The font size scale
871 void SetFontSizeScale(float scale);
874 * @brief Get the font size scale.
876 * @return The font size scale.
878 float GetFontSizeScale() const;
881 * @brief Sets the Placeholder text font size.
882 * @param[in] fontSize The placeholder text font size
883 * @param[in] type The font size type is point size or pixel size
885 void SetPlaceholderTextFontSize(float fontSize, FontSizeType type);
888 * @brief Retrieves the Placeholder text font size.
889 * @param[in] type The font size type
890 * @return The placeholder font size
892 float GetPlaceholderTextFontSize(FontSizeType type) const;
895 * @brief Sets the text's default color.
897 * @param color The default color.
899 void SetDefaultColor(const Vector4& color);
902 * @brief Retrieves the text's default color.
904 * @return The default color.
906 const Vector4& GetDefaultColor() const;
909 * @brief Set the text color
911 * @param textColor The text color
913 void SetPlaceholderTextColor(const Vector4& textColor);
916 * @brief Retrieve the text color
918 * @return The text color
920 const Vector4& GetPlaceholderTextColor() const;
923 * @brief Set the shadow offset.
925 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
927 void SetShadowOffset(const Vector2& shadowOffset);
930 * @brief Retrieve the shadow offset.
932 * @return The shadow offset.
934 const Vector2& GetShadowOffset() const;
937 * @brief Set the shadow color.
939 * @param[in] shadowColor The shadow color.
941 void SetShadowColor(const Vector4& shadowColor);
944 * @brief Retrieve the shadow color.
946 * @return The shadow color.
948 const Vector4& GetShadowColor() const;
951 * @brief Set the shadow blur radius.
953 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
955 void SetShadowBlurRadius(const float& shadowBlurRadius);
958 * @brief Retrieve the shadow blur radius.
960 * @return The shadow blur radius.
962 const float& GetShadowBlurRadius() const;
965 * @brief Set the underline color.
967 * @param[in] color color of underline.
969 void SetUnderlineColor(const Vector4& color);
972 * @brief Retrieve the underline color.
974 * @return The underline color.
976 const Vector4& GetUnderlineColor() const;
979 * @brief Set the underline enabled flag.
981 * @param[in] enabled The underline enabled flag.
983 void SetUnderlineEnabled(bool enabled);
986 * @brief Returns whether the text is underlined or not.
988 * @return The underline state.
990 bool IsUnderlineEnabled() const;
993 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
995 * @param[in] height The height in pixels of the underline
997 void SetUnderlineHeight(float height);
1000 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
1002 * @return The height of the underline, or 0 if height is not overrided.
1004 float GetUnderlineHeight() const;
1007 * @brief Set the outline color.
1009 * @param[in] color color of outline.
1011 void SetOutlineColor(const Vector4& color);
1014 * @brief Retrieve the outline color.
1016 * @return The outline color.
1018 const Vector4& GetOutlineColor() const;
1021 * @brief Set the outline width
1023 * @param[in] width The width in pixels of the outline, 0 indicates no outline
1025 void SetOutlineWidth(uint16_t width);
1028 * @brief Retrieves the width of an outline
1030 * @return The width of the outline.
1032 uint16_t GetOutlineWidth() const;
1035 * @brief Set the background color.
1037 * @param[in] color color of background.
1039 void SetBackgroundColor(const Vector4& color);
1042 * @brief Retrieve the background color.
1044 * @return The background color.
1046 const Vector4& GetBackgroundColor() const;
1049 * @brief Set the background enabled flag.
1051 * @param[in] enabled The background enabled flag.
1053 void SetBackgroundEnabled(bool enabled);
1056 * @brief Returns whether to enable text background or not.
1058 * @return Whether text background is enabled.
1060 bool IsBackgroundEnabled() const;
1063 * @brief Sets the emboss's properties string.
1065 * @note The string is stored to be recovered.
1067 * @param[in] embossProperties The emboss's properties string.
1069 void SetDefaultEmbossProperties(const std::string& embossProperties);
1072 * @brief Retrieves the emboss's properties string.
1074 * @return The emboss's properties string.
1076 const std::string& GetDefaultEmbossProperties() const;
1079 * @brief Sets the outline's properties string.
1081 * @note The string is stored to be recovered.
1083 * @param[in] outlineProperties The outline's properties string.
1085 void SetDefaultOutlineProperties(const std::string& outlineProperties);
1088 * @brief Retrieves the outline's properties string.
1090 * @return The outline's properties string.
1092 const std::string& GetDefaultOutlineProperties() const;
1095 * @brief Sets the default line spacing.
1097 * @param[in] lineSpacing The line spacing.
1099 * @return True if lineSpacing has been updated, false otherwise
1101 bool SetDefaultLineSpacing(float lineSpacing);
1104 * @brief Retrieves the default line spacing.
1106 * @return The line spacing.
1108 float GetDefaultLineSpacing() const;
1111 * @brief Sets the default line size.
1113 * @param[in] lineSize The line size.
1115 * @return True if lineSize has been updated, false otherwise
1117 bool SetDefaultLineSize(float lineSize);
1120 * @brief Retrieves the default line size.
1122 * @return The line size.
1124 float GetDefaultLineSize() const;
1127 * @brief Sets the input text's color.
1129 * @param[in] color The input text's color.
1131 void SetInputColor(const Vector4& color);
1134 * @brief Retrieves the input text's color.
1136 * @return The input text's color.
1138 const Vector4& GetInputColor() const;
1141 * @brief Sets the input text's font family name.
1143 * @param[in] fontFamily The text's font family name.
1145 void SetInputFontFamily(const std::string& fontFamily);
1148 * @brief Retrieves the input text's font family name.
1150 * @return The input text's font family name.
1152 const std::string& GetInputFontFamily() const;
1155 * @brief Sets the input font's weight.
1157 * @param[in] weight The input font's weight.
1159 void SetInputFontWeight(FontWeight weight);
1162 * @return Whether the font's weight has been defined.
1164 bool IsInputFontWeightDefined() const;
1167 * @brief Retrieves the input font's weight.
1169 * @return The input font's weight.
1171 FontWeight GetInputFontWeight() const;
1174 * @brief Sets the input font's width.
1176 * @param[in] width The input font's width.
1178 void SetInputFontWidth(FontWidth width);
1181 * @return Whether the font's width has been defined.
1183 bool IsInputFontWidthDefined() const;
1186 * @brief Retrieves the input font's width.
1188 * @return The input font's width.
1190 FontWidth GetInputFontWidth() const;
1193 * @brief Sets the input font's slant.
1195 * @param[in] slant The input font's slant.
1197 void SetInputFontSlant(FontSlant slant);
1200 * @return Whether the font's slant has been defined.
1202 bool IsInputFontSlantDefined() const;
1205 * @brief Retrieves the input font's slant.
1207 * @return The input font's slant.
1209 FontSlant GetInputFontSlant() const;
1212 * @brief Sets the input font's point size.
1214 * @param[in] size The input font's point size.
1216 void SetInputFontPointSize(float size);
1219 * @brief Retrieves the input font's point size.
1221 * @return The input font's point size.
1223 float GetInputFontPointSize() const;
1226 * @brief Sets the input line spacing.
1228 * @param[in] lineSpacing The line spacing.
1230 void SetInputLineSpacing(float lineSpacing);
1233 * @brief Retrieves the input line spacing.
1235 * @return The line spacing.
1237 float GetInputLineSpacing() const;
1240 * @brief Sets the input shadow's properties string.
1242 * @note The string is stored to be recovered.
1244 * @param[in] shadowProperties The shadow's properties string.
1246 void SetInputShadowProperties(const std::string& shadowProperties);
1249 * @brief Retrieves the input shadow's properties string.
1251 * @return The shadow's properties string.
1253 const std::string& GetInputShadowProperties() const;
1256 * @brief Sets the input underline's properties string.
1258 * @note The string is stored to be recovered.
1260 * @param[in] underlineProperties The underline's properties string.
1262 void SetInputUnderlineProperties(const std::string& underlineProperties);
1265 * @brief Retrieves the input underline's properties string.
1267 * @return The underline's properties string.
1269 const std::string& GetInputUnderlineProperties() const;
1272 * @brief Sets the input emboss's properties string.
1274 * @note The string is stored to be recovered.
1276 * @param[in] embossProperties The emboss's properties string.
1278 void SetInputEmbossProperties(const std::string& embossProperties);
1281 * @brief Retrieves the input emboss's properties string.
1283 * @return The emboss's properties string.
1285 const std::string& GetInputEmbossProperties() const;
1288 * @brief Sets input the outline's properties string.
1290 * @note The string is stored to be recovered.
1292 * @param[in] outlineProperties The outline's properties string.
1294 void SetInputOutlineProperties(const std::string& outlineProperties);
1297 * @brief Retrieves the input outline's properties string.
1299 * @return The outline's properties string.
1301 const std::string& GetInputOutlineProperties() const;
1304 * @brief Set the control's interface.
1306 * @param[in] controlInterface The control's interface.
1308 void SetControlInterface(ControlInterface* controlInterface);
1311 * @brief Set the anchor control's interface.
1313 * @param[in] anchorControlInterface The control's interface.
1315 void SetAnchorControlInterface(AnchorControlInterface* anchorControlInterface);
1317 public: // Queries & retrieves.
1319 * @brief Return the layout engine.
1321 * @return A reference to the layout engine.
1323 Layout::Engine& GetLayoutEngine();
1326 * @brief Return a view of the text.
1328 * @return A reference to the view.
1333 * @copydoc Control::GetNaturalSize()
1335 Vector3 GetNaturalSize();
1338 * @copydoc Control::GetHeightForWidth()
1340 float GetHeightForWidth(float width);
1343 * @brief Calculates the point size for text for given layout()
1345 void FitPointSizeforLayout(Size layoutSize);
1348 * @brief Checks if the point size fits within the layout size.
1350 * @return Whether the point size fits within the layout size.
1352 bool CheckForTextFit(float pointSize, Size& layoutSize);
1355 * @brief Retrieves the text's number of lines for a given width.
1356 * @param[in] width The width of the text's area.
1357 * @ return The number of lines.
1359 int GetLineCount(float width);
1362 * @brief Retrieves the text's model.
1364 * @return A pointer to the text's model.
1366 const ModelInterface* const GetTextModel() const;
1369 * @brief Used to get scrolled distance by user input
1371 * @return Distance from last scroll offset to new scroll offset
1373 float GetScrollAmountByUserInput();
1376 * @brief Get latest scroll amount, control size and layout size
1378 * This method is used to get information of control's scroll
1379 * @param[out] scrollPosition The current scrolled position
1380 * @param[out] controlHeight The size of a UI control
1381 * @param[out] layoutHeight The size of a bounding box to layout text within.
1383 * @return Whether the text scroll position is changed or not after last update.
1385 bool GetTextScrollInfo(float& scrollPosition, float& controlHeight, float& layoutHeight);
1388 * @brief Used to set the hidden input option
1390 void SetHiddenInputOption(const Property::Map& options);
1393 * @brief Used to get the hidden input option
1395 void GetHiddenInputOption(Property::Map& options);
1398 * @brief Used to set the input filter option
1400 void SetInputFilterOption(const Property::Map& options);
1403 * @brief Used to get the input filter option
1405 void GetInputFilterOption(Property::Map& options);
1408 * @brief Sets the Placeholder Properties.
1410 * @param[in] map The placeholder property map
1412 void SetPlaceholderProperty(const Property::Map& map);
1415 * @brief Retrieves the Placeholder Property map.
1417 * @param[out] map The property map
1419 void GetPlaceholderProperty(Property::Map& map);
1422 * @brief Checks text direction.
1423 * @return The text direction.
1425 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1428 * @brief Retrieves vertical line alignment
1429 * @return The vertical line alignment
1431 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1434 * @brief Sets vertical line alignment
1435 * @param[in] alignment The vertical line alignment for the text
1437 void SetVerticalLineAlignment(Toolkit::DevelText::VerticalLineAlignment::Type alignment);
1440 * @brief Retrieves ellipsis position
1441 * @return The ellipsis position
1443 Toolkit::DevelText::EllipsisPosition::Type GetEllipsisPosition() const;
1446 * @brief Sets ellipsis position
1447 * @param[in] ellipsisPosition The ellipsis position for the text
1449 void SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type ellipsisPosition);
1452 * @brief Retrieves ignoreSpaceAfterText value from model
1453 * @return The value of ignoreSpaceAfterText
1455 bool IsIgnoreSpacesAfterText() const;
1458 * @brief Sets ignoreSpaceAfterText value to model
1459 * @param[in] ignore The value of ignoreSpacesAfterText for the text
1461 void SetIgnoreSpacesAfterText(bool ignore);
1464 * @brief Sets SetMatchLayoutDirection value to model
1465 * @param[in] match The value of matchLayoutDirection for the text
1467 void SetMatchLayoutDirection(DevelText::MatchLayoutDirection type);
1470 * @brief Retrieves matchLayoutDirection value from model
1471 * @return The value of matchLayoutDirection
1473 DevelText::MatchLayoutDirection GetMatchLayoutDirection() const;
1476 * @brief Sets layoutDirection type value.
1477 * @param[in] layoutDirection The value of the layout direction type.
1479 void SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection);
1482 * @brief Gets layoutDirection type value.
1483 * @param[in] actor The actor which will get the layout direction type.
1484 * @return The value of the layout direction type.
1486 Dali::LayoutDirection::Type GetLayoutDirection(Dali::Actor& actor) const;
1489 * @brief Sets the layout direction changed.
1491 void ChangedLayoutDirection();
1494 * @brief Retrieves if showing real text or not.
1495 * @return The value of showing real text.
1497 bool IsShowingRealText() const;
1499 public: // Relayout.
1501 * @brief Triggers a relayout which updates View (if necessary).
1503 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1504 * @param[in] size A the size of a bounding box to layout text within.
1505 * @param[in] layoutDirection The direction of the system language.
1507 * @return Whether the text model or decorations were updated.
1509 UpdateTextType Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT);
1512 * @brief Request a relayout using the ControlInterface.
1514 void RequestRelayout();
1516 public: // Input style change signals.
1518 * @return Whether the queue of input style changed signals is empty.
1520 bool IsInputStyleChangedSignalsQueueEmpty();
1523 * @brief Process all pending input style changed signals.
1525 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1526 * text controls. Text controls may send signals to state the input style has changed.
1528 void ProcessInputStyleChangedSignals();
1530 public: // Text-input Event Queuing.
1532 * @brief Called by editable UI controls when keyboard focus is gained.
1534 void KeyboardFocusGainEvent();
1537 * @brief Called by editable UI controls when focus is lost.
1539 void KeyboardFocusLostEvent();
1542 * @brief Called by editable UI controls when key events are received.
1544 * @param[in] event The key event.
1545 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1547 bool KeyEvent(const Dali::KeyEvent& event);
1550 * @brief Called by anchor when a tap gesture occurs.
1551 * @param[in] x The x position relative to the top-left of the parent control.
1552 * @param[in] y The y position relative to the top-left of the parent control.
1554 void AnchorEvent(float x, float y);
1557 * @brief Called by editable UI controls when a tap gesture occurs.
1558 * @param[in] tapCount The number of taps.
1559 * @param[in] x The x position relative to the top-left of the parent control.
1560 * @param[in] y The y position relative to the top-left of the parent control.
1562 void TapEvent(unsigned int tapCount, float x, float y);
1565 * @brief Called by editable UI controls when a pan gesture occurs.
1567 * @param[in] state The state of the gesture.
1568 * @param[in] displacement This distance panned since the last pan gesture.
1570 void PanEvent(GestureState state, const Vector2& displacement);
1573 * @brief Called by editable UI controls when a long press gesture occurs.
1575 * @param[in] state The state of the gesture.
1576 * @param[in] x The x position relative to the top-left of the parent control.
1577 * @param[in] y The y position relative to the top-left of the parent control.
1579 void LongPressEvent(GestureState state, float x, float y);
1582 * @brief Used to get the Primary cursor position.
1584 * @return Primary cursor position.
1586 CharacterIndex GetPrimaryCursorPosition() const;
1589 * @brief Used to set the Primary cursor position.
1591 * @param[in] index for the Primary cursor position.
1592 * @param[in] focused true if UI control has gained focus to receive key event, false otherwise.
1593 * @return[in] true if cursor position changed, false otherwise.
1595 bool SetPrimaryCursorPosition(CharacterIndex index, bool focused);
1598 * @brief Creates a selection event.
1600 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1602 * @param[in] x The x position relative to the top-left of the parent control.
1603 * @param[in] y The y position relative to the top-left of the parent control.
1604 * @param[in] selection type like the whole text is selected or unselected.
1606 void SelectEvent(float x, float y, SelectionType selection);
1609 * @brief Creates a selection event with a selection index.
1611 * It could be called from the SelectText().
1612 * The start and end parameters are passed through the event.
1614 * @param[in] start The start selection position.
1615 * @param[in] end The end selection position.
1616 * @param[in] selection type like the range.
1618 void SelectEvent(const uint32_t start, const uint32_t end, SelectionType selection);
1621 * @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
1623 void SetTextSelectionRange(const uint32_t* start, const uint32_t* end);
1626 * @copydoc Text::SelectableControlInterface::GetTextSelectionRange()
1628 Uint32Pair GetTextSelectionRange() const;
1631 * @copydoc Text::SelectableControlInterface::SelectWholeText()
1633 void SelectWholeText();
1636 * @copydoc Text::SelectableControlInterface::SelectNone()
1641 * @copydoc Text::SelectableControlInterface::SelectText()
1643 void SelectText(const uint32_t start, const uint32_t end);
1646 * @copydoc Text::SelectableControlInterface::GetSelectedText()
1648 string GetSelectedText() const;
1651 * @copydoc Text::EditableControlInterface::IsEditable()
1653 virtual bool IsEditable() const;
1656 * @copydoc Text::EditableControlInterface::SetEditable()
1658 virtual void SetEditable(bool editable);
1661 * @copydoc Dali::Toolkit::Internal::TextEditor::ScrollBy()
1663 virtual void ScrollBy(Vector2 scroll);
1666 * @copydoc Dali::Toolkit::Internal::TextEditor::GetHorizontalScrollPosition()
1668 float GetHorizontalScrollPosition();
1671 * @copydoc Dali::Toolkit::Internal::TextEditor::GetVerticalScrollPosition()
1673 float GetVerticalScrollPosition();
1676 * @brief Event received from input method context
1678 * @param[in] inputMethodContext The input method context.
1679 * @param[in] inputMethodContextEvent The event received.
1680 * @return A data struture indicating if update is needed, cursor position and current text.
1682 InputMethodContext::CallbackData OnInputMethodContextEvent(InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent);
1685 * @brief Event from Clipboard notifying an Item has been selected for pasting
1687 void PasteClipboardItemEvent();
1690 * @brief Return true when text control should clear key input focus when escape key is pressed.
1692 * @return Whether text control should clear key input focus or not when escape key is pressed.
1694 bool ShouldClearFocusOnEscape() const;
1697 * @brief Create an actor that renders the text background color
1699 * @return the created actor or an empty handle if no background color needs to be rendered.
1701 Actor CreateBackgroundActor();
1704 * @brief Used to reset the cursor position after setting a new text.
1706 * @param[in] cursorIndex Where to place the cursor.
1708 void ResetCursorPosition(CharacterIndex cursorIndex);
1711 * @brief The method acquires current position of cursor
1712 * @return unsigned value with cursor position
1714 CharacterIndex GetCursorPosition();
1716 protected: // Inherit from Text::Decorator::ControllerInterface.
1718 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1720 void GetTargetSize(Vector2& targetSize) override;
1723 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1725 void AddDecoration(Actor& actor, bool needsClipping) override;
1728 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1730 void DecorationEvent(HandleType handle, HandleState state, float x, float y) override;
1732 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1734 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1736 void TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::Buttons button) override;
1738 protected: // Inherit from HiddenText.
1740 * @brief Invoked from HiddenText when showing time of the last character was expired
1742 void DisplayTimeExpired() override;
1746 * @brief Called by editable UI controls when key events are received.
1748 * @param[in] text The text to insert.
1749 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1751 void InsertText(const std::string& text, InsertType type);
1754 * @brief Paste given string into Text model
1755 * @param[in] stringToPaste this string will be inserted into the text model
1757 void PasteText(const std::string& stringToPaste);
1760 * @brief Remove a given number of characters
1762 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1763 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1764 * style when pre-edit text is removed.
1766 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1767 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1768 * @param[in] type Whether to update the input style.
1769 * @return True if the remove was successful.
1771 bool RemoveText(int cursorOffset,
1772 int numberOfCharacters,
1773 UpdateInputStyleType type);
1776 * @brief Checks if text is selected and if so removes it.
1777 * @return true if text was removed
1779 bool RemoveSelectedText();
1782 * @brief Update anchor position from given number of inserted characters.
1784 * @param[in] numberOfCharacters The number of inserted characters.
1785 * @param[in] previousCursorIndex A cursor position before event occurs.
1787 void InsertTextAnchor(int numberOfCharacters,
1788 CharacterIndex previousCursorIndex);
1791 * @brief Update anchor position from given number of removed characters.
1793 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1794 * @param[in] numberOfCharacters The number of removed characters.
1795 * @param[in] previousCursorIndex A cursor position before event occurs.
1797 void RemoveTextAnchor(int cursorOffset,
1798 int numberOfCharacters,
1799 CharacterIndex previousCursorIndex);
1801 private: // Relayout.
1803 * @brief Lays-out the text.
1805 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1807 * @param[in] size A the size of a bounding box to layout text within.
1808 * @param[in] operations The layout operations which need to be done.
1809 * @param[out] layoutSize The size of the laid-out text.
1811 bool DoRelayout(const Size& size,
1812 OperationsMask operations,
1816 * @brief Calulates the vertical offset to align the text inside the bounding box.
1818 * @param[in] size The size of the bounding box.
1820 void CalculateVerticalOffset(const Size& size);
1824 * @brief Process queued events which modify the model.
1826 void ProcessModifyEvents();
1829 * @brief Used to process an event queued from SetText()
1831 void TextReplacedEvent();
1834 * @brief Used to process an event queued from key events etc.
1836 void TextInsertedEvent();
1839 * @brief Used to process an event queued from backspace key etc.
1841 void TextDeletedEvent();
1844 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1846 * @param[in] keyCode The keycode for the key pressed
1847 * @return True if a character was deleted.
1849 bool DeleteEvent(int keyCode);
1851 private: // Helpers.
1853 * @brief Used to remove the text included the placeholder text.
1858 * @brief Helper to show the place holder text..
1860 void ShowPlaceholderText();
1863 * @brief Helper to clear font-specific data (only).
1865 void ClearFontData();
1868 * @brief Helper to clear text's style data.
1870 void ClearStyleData();
1873 * @brief Used to reset the scroll position after setting a new text.
1875 void ResetScrollPosition();
1877 private: // Private contructors & copy operator.
1879 * @brief Private constructor.
1884 * @brief Private constructor.
1886 Controller(ControlInterface* controlInterface);
1889 * @brief Private constructor.
1891 Controller(ControlInterface* controlInterface,
1892 EditableControlInterface* editableControlInterface,
1893 SelectableControlInterface* selectableControlInterface,
1894 AnchorControlInterface* anchorControlInterface);
1897 Controller(const Controller& handle);
1900 Controller& operator=(const Controller& handle);
1902 protected: // Destructor.
1904 * @brief A reference counted object may only be deleted by calling Unreference().
1906 virtual ~Controller();
1909 struct Impl; ///< Made public for testing purposes
1912 struct EventHandler;
1913 struct InputFontHandler;
1914 struct PlaceholderHandler;
1923 } // namespace Toolkit
1927 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H