1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_H
5 * Copyright (c) 2020 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/public-api/text/text-enumerations.h>
27 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
28 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
29 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
30 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
31 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
32 #include <dali-toolkit/internal/text/hidden-text.h>
33 #include <dali-toolkit/internal/text/text-model-interface.h>
34 #include <dali-toolkit/internal/text/text-selectable-control-interface.h>
46 class ControlInterface;
47 class EditableControlInterface;
49 class RenderingController;
52 * @brief Text selection operations .
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.
79 * @brief Text related operations to be done in the relayout process.
83 NO_OPERATION = 0x0000,
84 CONVERT_TO_UTF32 = 0x0001,
86 VALIDATE_FONTS = 0x0004,
87 GET_LINE_BREAKS = 0x0008,
90 GET_GLYPH_METRICS = 0x0040,
92 UPDATE_LAYOUT_SIZE = 0x0100,
96 UPDATE_DIRECTION = 0x1000,
97 ALL_OPERATIONS = 0xFFFF
101 * @brief Used to distinguish between regular key events and InputMethodContext events
110 * @brief Used to specify whether to update the input style.
112 enum UpdateInputStyleType
115 DONT_UPDATE_INPUT_STYLE
119 * @brief Used to specify what has been updated after the Relayout() method has been called.
123 NONE_UPDATED = 0x0, ///< Nothing has been updated.
124 MODEL_UPDATED = 0x1, ///< The text's model has been updated.
125 DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
129 * @brief Different placeholder-text can be shown when the control is active/inactive.
133 PLACEHOLDER_TYPE_ACTIVE,
134 PLACEHOLDER_TYPE_INACTIVE,
138 * @brief Enumeration for Font Size Type.
142 POINT_SIZE, // The size of font in points.
143 PIXEL_SIZE // The size of font in pixels.
150 NO_ACTION, ///< Does no action if there is a tap on top of an area with no text.
151 HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
152 SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
164 TEXT_FIT_FONT_SIZE_TYPE
168 public: // Constructor.
171 * @brief Create a new instance of a Controller.
173 * @return A pointer to a new Controller.
175 static ControllerPtr New();
178 * @brief Create a new instance of a Controller.
180 * @param[in] controlInterface The control's interface.
182 * @return A pointer to a new Controller.
184 static ControllerPtr New( ControlInterface* controlInterface );
187 * @brief Create a new instance of a Controller.
189 * @param[in] controlInterface The control's interface.
190 * @param[in] editableControlInterface The editable control's interface.
191 * @param[in] selectableControlInterface The selectable control's interface.
193 * @return A pointer to a new Controller.
195 static ControllerPtr New( ControlInterface* controlInterface,
196 EditableControlInterface* editableControlInterface,
197 SelectableControlInterface* selectableControlInterface );
199 public: // Configure the text controller.
202 * @brief Called to enable text input.
204 * @note Selectable or editable controls should call this once after Controller::New().
205 * @param[in] decorator Used to create cursor, selection handle decorations etc.
206 * @param[in] inputMethodContext Used to manager ime.
208 void EnableTextInput( DecoratorPtr decorator, InputMethodContext& inputMethodContext );
211 * @brief Used to switch between bitmap & vector based glyphs
213 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
215 void SetGlyphType( TextAbstraction::GlyphType glyphType );
218 * @brief Enables/disables the mark-up processor.
220 * By default is disabled.
222 * @param[in] enable Whether to enable the mark-up processor.
224 void SetMarkupProcessorEnabled( bool enable );
227 * @brief Retrieves whether the mark-up processor is enabled.
229 * By default is disabled.
231 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
233 bool IsMarkupProcessorEnabled() const;
236 * @brief Enables/disables the auto text scrolling
238 * By default is disabled.
240 * @param[in] enable Whether to enable the auto scrolling
242 void SetAutoScrollEnabled( bool enable );
245 * @brief Retrieves whether auto text scrolling is enabled.
247 * By default is disabled.
249 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
251 bool IsAutoScrollEnabled() const;
254 * @brief Get direction of the text from the first line of text,
255 * @return bool rtl (right to left) is true
257 CharacterDirection GetAutoScrollDirection() const;
260 * @brief Get the alignment offset of the first line of text.
262 * @return The alignment offset.
264 float GetAutoScrollLineAlignment() const;
267 * @brief Enables the horizontal scrolling.
269 * @param[in] enable Whether to enable the horizontal scrolling.
271 void SetHorizontalScrollEnabled( bool enable );
274 * @brief Retrieves whether the horizontal scrolling is enabled.
276 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
278 bool IsHorizontalScrollEnabled() const;
281 * @brief Enables the vertical scrolling.
283 * @param[in] enable Whether to enable the vertical scrolling.
285 void SetVerticalScrollEnabled( bool enable );
288 * @brief Retrieves whether the verticall scrolling is enabled.
290 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
292 bool IsVerticalScrollEnabled() const;
295 * @brief Enables the smooth handle panning.
297 * @param[in] enable Whether to enable the smooth handle panning.
299 void SetSmoothHandlePanEnabled( bool enable );
302 * @brief Retrieves whether the smooth handle panning is enabled.
304 * @return @e true if the smooth handle panning is enabled.
306 bool IsSmoothHandlePanEnabled() const;
309 * @brief Sets the maximum number of characters that can be inserted into the TextModel
311 * @param[in] maxCharacters maximum number of characters to be accepted
313 void SetMaximumNumberOfCharacters( Length maxCharacters );
316 * @brief Sets the maximum number of characters that can be inserted into the TextModel
318 * @param[in] maxCharacters maximum number of characters to be accepted
320 int GetMaximumNumberOfCharacters();
323 * @brief Called to enable/disable cursor blink.
325 * @note Only editable controls should calls this.
326 * @param[in] enabled Whether the cursor should blink or not.
328 void SetEnableCursorBlink( bool enable );
331 * @brief Query whether cursor blink is enabled.
333 * @return Whether the cursor should blink or not.
335 bool GetEnableCursorBlink() const;
338 * @brief Whether to enable the multi-line layout.
340 * @param[in] enable \e true enables the multi-line (by default)
342 void SetMultiLineEnabled( bool enable );
345 * @return Whether the multi-line layout is enabled.
347 bool IsMultiLineEnabled() const;
350 * @brief Sets the text's horizontal alignment.
352 * @param[in] alignment The horizontal alignment.
354 void SetHorizontalAlignment( HorizontalAlignment::Type alignment );
357 * @copydoc ModelInterface::GetHorizontalAlignment()
359 HorizontalAlignment::Type GetHorizontalAlignment() const;
362 * @brief Sets the text's vertical alignment.
364 * @param[in] alignment The vertical alignment.
366 void SetVerticalAlignment( VerticalAlignment::Type alignment );
369 * @copydoc ModelInterface::GetVerticalAlignment()
371 VerticalAlignment::Type GetVerticalAlignment() const;
374 * @brief Sets the text's wrap mode
375 * @param[in] text wrap mode The unit of wrapping
377 void SetLineWrapMode( Text::LineWrap::Mode textWarpMode );
380 * @brief Retrieve text wrap mode previously set.
381 * @return text wrap mode
383 Text::LineWrap::Mode GetLineWrapMode() const;
386 * @brief Enable or disable the text elide.
388 * @param[in] enabled Whether to enable the text elide.
390 void SetTextElideEnabled( bool enabled );
393 * @copydoc ModelInterface::IsTextElideEnabled()
395 bool IsTextElideEnabled() const;
398 * @brief Enable or disable the text fit.
400 * @param[in] enabled Whether to enable the text fit.
402 void SetTextFitEnabled(bool enabled);
405 * @brief Whether the text fit is enabled or not.
407 * @return True if the text fit is enabled
409 bool IsTextFitEnabled() const;
412 * @brief Sets minimum size valid for text fit.
414 * @param[in] minimum size value.
415 * @param[in] type The font size type is point size or pixel size
417 void SetTextFitMinSize( float pointSize, FontSizeType type );
420 * @brief Retrieves the minimum point size valid for text fit.
422 * @return The minimum point size valid for text fit
424 float GetTextFitMinSize() const;
427 * @brief Sets maximum size valid for text fit.
429 * @param[in] maximum size value.
430 * @param[in] type The font size type is point size or pixel size
432 void SetTextFitMaxSize( float pointSize, FontSizeType type );
435 * @brief Retrieves the maximum point size valid for text fit.
437 * @return The maximum point size valid for text fit
439 float GetTextFitMaxSize() const;
442 * @brief Sets step size for font increase valid for text fit.
444 * @param[in] step size value.
445 * @param[in] type The font size type is point size or pixel size
447 void SetTextFitStepSize( float step, FontSizeType type );
450 * @brief Retrieves the step point size valid for text fit.
452 * @return The step point size valid for text fit
454 float GetTextFitStepSize() const;
457 * @brief Sets content size valid for text fit.
459 * @param[in] Content size value.
461 void SetTextFitContentSize(Vector2 size);
464 * @brief Retrieves the content size valid for text fit.
466 * @return The content size valid for text fit
468 Vector2 GetTextFitContentSize() const;
471 * @brief Enable or disable the placeholder text elide.
472 * @param enabled Whether to enable the placeholder text elide.
474 void SetPlaceholderTextElideEnabled( bool enabled );
477 * @brief Whether the placeholder text elide property is enabled.
478 * @return True if the placeholder text elide property is enabled, false otherwise.
480 bool IsPlaceholderTextElideEnabled() const;
483 * @brief Enable or disable the text selection.
484 * @param[in] enabled Whether to enable the text selection.
486 void SetSelectionEnabled( bool enabled );
489 * @brief Whether the text selection is enabled or not.
490 * @return True if the text selection is enabled
492 bool IsSelectionEnabled() const;
495 * @brief Enable or disable the text selection using Shift key.
496 * @param enabled Whether to enable the text selection using Shift key
498 void SetShiftSelectionEnabled( bool enabled );
501 * @brief Whether the text selection using Shift key is enabled or not.
502 * @return True if the text selection using Shift key is enabled
504 bool IsShiftSelectionEnabled() const;
507 * @brief Enable or disable the grab handles for text selection.
509 * @param[in] enabled Whether to enable the grab handles
511 void SetGrabHandleEnabled( bool enabled );
514 * @brief Returns whether the grab handles are enabled.
516 * @return True if the grab handles are enabled
518 bool IsGrabHandleEnabled() const;
521 * @brief Enable or disable the grab handles for text selection.
523 * @param[in] enabled Whether to enable the grab handles
525 void SetGrabHandlePopupEnabled( bool enabled );
528 * @brief Returns whether the grab handles are enabled.
530 * @return True if the grab handles are enabled
532 bool IsGrabHandlePopupEnabled() const;
535 * @brief Sets input type to password
537 * @note The string is displayed hidden character
539 * @param[in] passwordInput True if password input is enabled.
541 void SetInputModePassword( bool passwordInput );
544 * @brief Returns whether the input mode type is set as password.
546 * @return True if input mode type is password
548 bool IsInputModePassword();
551 * @brief Sets the action when there is a double tap event on top of a text area with no text.
553 * @param[in] action The action to do.
555 void SetNoTextDoubleTapAction( NoTextTap::Action action );
558 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
560 * @return The action to do.
562 NoTextTap::Action GetNoTextDoubleTapAction() const;
565 * @briefSets the action when there is a long press event on top of a text area with no text.
567 * @param[in] action The action to do.
569 void SetNoTextLongPressAction( NoTextTap::Action action );
572 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
574 * @return The action to do.
576 NoTextTap::Action GetNoTextLongPressAction() const;
579 * @brief Query if Underline settings were provided by string or map
580 * @return bool true if set by string
582 bool IsUnderlineSetByString();
585 * Set method underline setting were set by
586 * @param[in] bool, true if set by string
588 void UnderlineSetByString( bool setByString );
591 * @brief Query if shadow settings were provided by string or map
592 * @return bool true if set by string
594 bool IsShadowSetByString();
597 * Set method shadow setting were set by
598 * @param[in] bool, true if set by string
600 void ShadowSetByString( bool setByString );
603 * @brief Query if outline settings were provided by string or map
604 * @return bool true if set by string
606 bool IsOutlineSetByString();
609 * Set method outline setting were set by
610 * @param[in] bool, true if set by string
612 void OutlineSetByString( bool setByString );
615 * @brief Query if font style settings were provided by string or map
616 * @return bool true if set by string
618 bool IsFontStyleSetByString();
621 * Set method font style setting were set by
622 * @param[in] bool, true if set by string
624 void FontStyleSetByString( bool setByString );
629 * @brief Replaces any text previously set.
631 * @note This will be converted into UTF-32 when stored in the text model.
632 * @param[in] text A string of UTF-8 characters.
634 void SetText( const std::string& text );
637 * @brief Retrieve any text previously set.
639 * @param[out] text A string of UTF-8 characters.
641 void GetText( std::string& text ) const;
644 * @brief Replaces any placeholder text previously set.
646 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
647 * @param[in] text A string of UTF-8 characters.
649 void SetPlaceholderText( PlaceholderType type, const std::string& text );
652 * @brief Retrieve any placeholder text previously set.
654 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
655 * @param[out] A string of UTF-8 characters.
657 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
660 * @ brief Update the text after a font change
661 * @param[in] newDefaultFont The new font to change to
663 void UpdateAfterFontChange( const std::string& newDefaultFont );
666 * @brief The method acquires currently selected text
667 * @param selectedText variable to place selected text in
669 void RetrieveSelection( std::string& selectedText ) const;
672 * @brief The method sets selection in given range
673 * @param start index of first character
674 * @param end index of first character after selection
676 void SetSelection( int start, int end );
679 * @brief This method retrieve indexes of current selection
681 * @return a pair, where first element is left index of selection and second is the right one
683 std::pair< int, int > GetSelectionIndexes() const;
686 * Place string in system clipboard
687 * @param source std::string
689 void CopyStringToClipboard( const std::string& source );
692 * Place currently selected text in system clipboard
693 * @param deleteAfterSending flag pointing if text should be deleted after sending to clipboard
695 void SendSelectionToClipboard( bool deleteAfterSending );
697 public: // Default style & Input style
700 * @brief Set the default font family.
702 * @param[in] defaultFontFamily The default font family.
704 void SetDefaultFontFamily( const std::string& defaultFontFamily );
707 * @brief Retrieve the default font family.
709 * @return The default font family.
711 const std::string& GetDefaultFontFamily() const;
714 * @brief Sets the placeholder text font family.
715 * @param[in] placeholderTextFontFamily The placeholder text font family.
717 void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
720 * @brief Retrieves the placeholder text font family.
722 * @return The placeholder text font family
724 const std::string& GetPlaceholderFontFamily() const;
727 * @brief Sets the default font weight.
729 * @param[in] weight The font weight.
731 void SetDefaultFontWeight( FontWeight weight );
734 * @brief Whether the font's weight has been defined.
736 bool IsDefaultFontWeightDefined() const;
739 * @brief Retrieves the default font weight.
741 * @return The default font weight.
743 FontWeight GetDefaultFontWeight() const;
746 * @brief Sets the placeholder text font weight.
748 * @param[in] weight The font weight
750 void SetPlaceholderTextFontWeight( FontWeight weight );
753 * @brief Whether the font's weight has been defined.
755 * @return True if the placeholder text font weight is defined
757 bool IsPlaceholderTextFontWeightDefined() const;
760 * @brief Retrieves the placeholder text font weight.
762 * @return The placeholder text font weight
764 FontWeight GetPlaceholderTextFontWeight() const;
767 * @brief Sets the default font width.
769 * @param[in] width The font width.
771 void SetDefaultFontWidth( FontWidth width );
774 * @brief Whether the font's width has been defined.
776 bool IsDefaultFontWidthDefined() const;
779 * @brief Retrieves the default font width.
781 * @return The default font width.
783 FontWidth GetDefaultFontWidth() const;
786 * @brief Sets the placeholder text font width.
788 * @param[in] width The font width
790 void SetPlaceholderTextFontWidth( FontWidth width );
793 * @brief Whether the font's width has been defined.
795 * @return True if the placeholder text font width is defined
797 bool IsPlaceholderTextFontWidthDefined() const;
800 * @brief Retrieves the placeholder text font width.
802 * @return The placeholder text font width
804 FontWidth GetPlaceholderTextFontWidth() const;
807 * @brief Sets the default font slant.
809 * @param[in] slant The font slant.
811 void SetDefaultFontSlant( FontSlant slant );
814 * @brief Whether the font's slant has been defined.
816 bool IsDefaultFontSlantDefined() const;
819 * @brief Retrieves the default font slant.
821 * @return The default font slant.
823 FontSlant GetDefaultFontSlant() const;
826 * @brief Sets the placeholder text font slant.
828 * @param[in] slant The font slant
830 void SetPlaceholderTextFontSlant( FontSlant slant );
833 * @brief Whether the font's slant has been defined.
835 * @return True if the placeholder text font slant is defined
837 bool IsPlaceholderTextFontSlantDefined() const;
840 * @brief Retrieves the placeholder text font slant.
842 * @return The placeholder text font slant
844 FontSlant GetPlaceholderTextFontSlant() const;
847 * @brief Set the default font size.
849 * @param[in] fontSize The default font size
850 * @param[in] type The font size type is point size or pixel size
852 void SetDefaultFontSize( float fontSize, FontSizeType type );
855 * @brief Retrieve the default point size.
857 * @param[in] type The font size type
858 * @return The default point size.
860 float GetDefaultFontSize( FontSizeType type ) const;
863 * @brief Set the font size scale.
865 * @param[in] scale The font size scale
867 void SetFontSizeScale( float scale );
870 * @brief Get the font size scale.
872 * @return The font size scale.
874 float GetFontSizeScale() const;
877 * @brief Sets the Placeholder text font size.
878 * @param[in] fontSize The placeholder text font size
879 * @param[in] type The font size type is point size or pixel size
881 void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
884 * @brief Retrieves the Placeholder text font size.
885 * @param[in] type The font size type
886 * @return The placeholder font size
888 float GetPlaceholderTextFontSize( FontSizeType type ) const;
891 * @brief Sets the text's default color.
893 * @param color The default color.
895 void SetDefaultColor( const Vector4& color );
898 * @brief Retrieves the text's default color.
900 * @return The default color.
902 const Vector4& GetDefaultColor() const;
905 * @brief Set the text color
907 * @param textColor The text color
909 void SetPlaceholderTextColor( const Vector4& textColor );
912 * @brief Retrieve the text color
914 * @return The text color
916 const Vector4& GetPlaceholderTextColor() const;
919 * @brief Set the shadow offset.
921 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
923 void SetShadowOffset( const Vector2& shadowOffset );
926 * @brief Retrieve the shadow offset.
928 * @return The shadow offset.
930 const Vector2& GetShadowOffset() const;
933 * @brief Set the shadow color.
935 * @param[in] shadowColor The shadow color.
937 void SetShadowColor( const Vector4& shadowColor );
940 * @brief Retrieve the shadow color.
942 * @return The shadow color.
944 const Vector4& GetShadowColor() const;
947 * @brief Set the shadow blur radius.
949 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
951 void SetShadowBlurRadius( const float& shadowBlurRadius );
954 * @brief Retrieve the shadow blur radius.
956 * @return The shadow blur radius.
958 const float& GetShadowBlurRadius() const;
961 * @brief Set the underline color.
963 * @param[in] color color of underline.
965 void SetUnderlineColor( const Vector4& color );
968 * @brief Retrieve the underline color.
970 * @return The underline color.
972 const Vector4& GetUnderlineColor() const;
975 * @brief Set the underline enabled flag.
977 * @param[in] enabled The underline enabled flag.
979 void SetUnderlineEnabled( bool enabled );
982 * @brief Returns whether the text is underlined or not.
984 * @return The underline state.
986 bool IsUnderlineEnabled() const;
989 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
991 * @param[in] height The height in pixels of the underline
993 void SetUnderlineHeight( float height );
996 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
998 * @return The height of the underline, or 0 if height is not overrided.
1000 float GetUnderlineHeight() const;
1003 * @brief Set the outline color.
1005 * @param[in] color color of outline.
1007 void SetOutlineColor( const Vector4& color );
1010 * @brief Retrieve the outline color.
1012 * @return The outline color.
1014 const Vector4& GetOutlineColor() const;
1017 * @brief Set the outline width
1019 * @param[in] width The width in pixels of the outline, 0 indicates no outline
1021 void SetOutlineWidth( uint16_t width );
1024 * @brief Retrieves the width of an outline
1026 * @return The width of the outline.
1028 uint16_t GetOutlineWidth() const;
1031 * @brief Set the background color.
1033 * @param[in] color color of background.
1035 void SetBackgroundColor( const Vector4& color );
1038 * @brief Retrieve the background color.
1040 * @return The background color.
1042 const Vector4& GetBackgroundColor() const;
1045 * @brief Set the background enabled flag.
1047 * @param[in] enabled The background enabled flag.
1049 void SetBackgroundEnabled( bool enabled );
1052 * @brief Returns whether to enable text background or not.
1054 * @return Whether text background is enabled.
1056 bool IsBackgroundEnabled() const;
1059 * @brief Sets the emboss's properties string.
1061 * @note The string is stored to be recovered.
1063 * @param[in] embossProperties The emboss's properties string.
1065 void SetDefaultEmbossProperties( const std::string& embossProperties );
1068 * @brief Retrieves the emboss's properties string.
1070 * @return The emboss's properties string.
1072 const std::string& GetDefaultEmbossProperties() const;
1075 * @brief Sets the outline's properties string.
1077 * @note The string is stored to be recovered.
1079 * @param[in] outlineProperties The outline's properties string.
1081 void SetDefaultOutlineProperties( const std::string& outlineProperties );
1084 * @brief Retrieves the outline's properties string.
1086 * @return The outline's properties string.
1088 const std::string& GetDefaultOutlineProperties() const;
1091 * @brief Sets the default line spacing.
1093 * @param[in] lineSpacing The line spacing.
1095 * @return True if lineSpacing has been updated, false otherwise
1097 bool SetDefaultLineSpacing( float lineSpacing );
1100 * @brief Retrieves the default line spacing.
1102 * @return The line spacing.
1104 float GetDefaultLineSpacing() const;
1107 * @brief Sets the default line size.
1109 * @param[in] lineSize The line size.
1111 * @return True if lineSize has been updated, false otherwise
1113 bool SetDefaultLineSize( float lineSize );
1116 * @brief Retrieves the default line size.
1118 * @return The line size.
1120 float GetDefaultLineSize() const;
1123 * @brief Sets the input text's color.
1125 * @param[in] color The input text's color.
1127 void SetInputColor( const Vector4& color );
1130 * @brief Retrieves the input text's color.
1132 * @return The input text's color.
1134 const Vector4& GetInputColor() const;
1137 * @brief Sets the input text's font family name.
1139 * @param[in] fontFamily The text's font family name.
1141 void SetInputFontFamily( const std::string& fontFamily );
1144 * @brief Retrieves the input text's font family name.
1146 * @return The input text's font family name.
1148 const std::string& GetInputFontFamily() const;
1151 * @brief Sets the input font's weight.
1153 * @param[in] weight The input font's weight.
1155 void SetInputFontWeight( FontWeight weight );
1158 * @return Whether the font's weight has been defined.
1160 bool IsInputFontWeightDefined() const;
1163 * @brief Retrieves the input font's weight.
1165 * @return The input font's weight.
1167 FontWeight GetInputFontWeight() const;
1170 * @brief Sets the input font's width.
1172 * @param[in] width The input font's width.
1174 void SetInputFontWidth( FontWidth width );
1177 * @return Whether the font's width has been defined.
1179 bool IsInputFontWidthDefined() const;
1182 * @brief Retrieves the input font's width.
1184 * @return The input font's width.
1186 FontWidth GetInputFontWidth() const;
1189 * @brief Sets the input font's slant.
1191 * @param[in] slant The input font's slant.
1193 void SetInputFontSlant( FontSlant slant );
1196 * @return Whether the font's slant has been defined.
1198 bool IsInputFontSlantDefined() const;
1201 * @brief Retrieves the input font's slant.
1203 * @return The input font's slant.
1205 FontSlant GetInputFontSlant() const;
1208 * @brief Sets the input font's point size.
1210 * @param[in] size The input font's point size.
1212 void SetInputFontPointSize( float size );
1215 * @brief Retrieves the input font's point size.
1217 * @return The input font's point size.
1219 float GetInputFontPointSize() const;
1222 * @brief Sets the input line spacing.
1224 * @param[in] lineSpacing The line spacing.
1226 void SetInputLineSpacing( float lineSpacing );
1229 * @brief Retrieves the input line spacing.
1231 * @return The line spacing.
1233 float GetInputLineSpacing() const;
1236 * @brief Sets the input shadow's properties string.
1238 * @note The string is stored to be recovered.
1240 * @param[in] shadowProperties The shadow's properties string.
1242 void SetInputShadowProperties( const std::string& shadowProperties );
1245 * @brief Retrieves the input shadow's properties string.
1247 * @return The shadow's properties string.
1249 const std::string& GetInputShadowProperties() const;
1252 * @brief Sets the input underline's properties string.
1254 * @note The string is stored to be recovered.
1256 * @param[in] underlineProperties The underline's properties string.
1258 void SetInputUnderlineProperties( const std::string& underlineProperties );
1261 * @brief Retrieves the input underline's properties string.
1263 * @return The underline's properties string.
1265 const std::string& GetInputUnderlineProperties() const;
1268 * @brief Sets the input emboss's properties string.
1270 * @note The string is stored to be recovered.
1272 * @param[in] embossProperties The emboss's properties string.
1274 void SetInputEmbossProperties( const std::string& embossProperties );
1277 * @brief Retrieves the input emboss's properties string.
1279 * @return The emboss's properties string.
1281 const std::string& GetInputEmbossProperties() const;
1284 * @brief Sets input the outline's properties string.
1286 * @note The string is stored to be recovered.
1288 * @param[in] outlineProperties The outline's properties string.
1290 void SetInputOutlineProperties( const std::string& outlineProperties );
1293 * @brief Retrieves the input outline's properties string.
1295 * @return The outline's properties string.
1297 const std::string& GetInputOutlineProperties() const;
1300 * @brief Set the control's interface.
1302 * @param[in] controlInterface The control's interface.
1304 void SetControlInterface( ControlInterface* controlInterface );
1306 public: // Queries & retrieves.
1309 * @brief Return the layout engine.
1311 * @return A reference to the layout engine.
1313 Layout::Engine& GetLayoutEngine();
1316 * @brief Return a view of the text.
1318 * @return A reference to the view.
1323 * @copydoc Control::GetNaturalSize()
1325 Vector3 GetNaturalSize();
1328 * @copydoc Control::GetHeightForWidth()
1330 float GetHeightForWidth( float width );
1333 * @brief Calculates the point size for text for given layout()
1335 void FitPointSizeforLayout( Size layoutSize );
1338 * @brief Checks if the point size fits within the layout size.
1340 * @return Whether the point size fits within the layout size.
1342 bool CheckForTextFit( float pointSize, Size& layoutSize );
1345 * @brief Retrieves the text's number of lines for a given width.
1346 * @param[in] width The width of the text's area.
1347 * @ return The number of lines.
1349 int GetLineCount( float width );
1352 * @brief Retrieves the text's model.
1354 * @return A pointer to the text's model.
1356 const ModelInterface* const GetTextModel() const;
1359 * @brief Used to get scrolled distance by user input
1361 * @return Distance from last scroll offset to new scroll offset
1363 float GetScrollAmountByUserInput();
1366 * @brief Get latest scroll amount, control size and layout size
1368 * This method is used to get information of control's scroll
1369 * @param[out] scrollPosition The current scrolled position
1370 * @param[out] controlHeight The size of a UI control
1371 * @param[out] layoutHeight The size of a bounding box to layout text within.
1373 * @return Whether the text scroll position is changed or not after last update.
1375 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1378 * @brief Used to set the hidden input option
1380 void SetHiddenInputOption( const Property::Map& options );
1383 * @brief Used to get the hidden input option
1385 void GetHiddenInputOption( Property::Map& options );
1388 * @brief Sets the Placeholder Properties.
1390 * @param[in] map The placeholder property map
1392 void SetPlaceholderProperty( const Property::Map& map );
1395 * @brief Retrieves the Placeholder Property map.
1397 * @param[out] map The property map
1399 void GetPlaceholderProperty( Property::Map& map );
1402 * @brief Checks text direction.
1403 * @return The text direction.
1405 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1408 * @brief Retrieves vertical line alignment
1409 * @return The vertical line alignment
1411 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1414 * @brief Sets vertical line alignment
1415 * @param[in] alignment The vertical line alignment for the text
1417 void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment );
1420 * @brief Retrieves ignoreSpaceAfterText value from model
1421 * @return The value of ignoreSpaceAfterText
1423 bool IsIgnoreSpacesAfterText() const;
1426 * @brief Sets ignoreSpaceAfterText value to model
1427 * @param[in] ignore The value of ignoreSpacesAfterText for the text
1429 void SetIgnoreSpacesAfterText( bool ignore );
1432 * @brief Retrieves matchSystemLanguageDirection value from model
1433 * @return The value of matchSystemLanguageDirection
1435 bool IsMatchSystemLanguageDirection() const;
1438 * @brief Sets matchSystemLanguageDirection value to model
1439 * @param[in] match The value of matchSystemLanguageDirection for the text
1441 void SetMatchSystemLanguageDirection( bool match );
1444 * @brief Sets layoutDirection value
1445 * @param[in] layoutDirection The value of system language direction
1447 void SetLayoutDirection( Dali::LayoutDirection::Type layoutDirection );
1450 * @brief Retrieves if showing real text or not.
1451 * @return The value of showing real text.
1453 bool IsShowingRealText() const;
1455 public: // Relayout.
1458 * @brief Triggers a relayout which updates View (if necessary).
1460 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1461 * @param[in] size A the size of a bounding box to layout text within.
1462 * @param[in] layoutDirection The direction of the system language.
1464 * @return Whether the text model or decorations were updated.
1466 UpdateTextType Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT );
1469 * @brief Request a relayout using the ControlInterface.
1471 void RequestRelayout();
1473 public: // Input style change signals.
1476 * @return Whether the queue of input style changed signals is empty.
1478 bool IsInputStyleChangedSignalsQueueEmpty();
1481 * @brief Process all pending input style changed signals.
1483 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1484 * text controls. Text controls may send signals to state the input style has changed.
1486 void ProcessInputStyleChangedSignals();
1488 public: // Text-input Event Queuing.
1491 * @brief Called by editable UI controls when keyboard focus is gained.
1493 void KeyboardFocusGainEvent();
1496 * @brief Called by editable UI controls when focus is lost.
1498 void KeyboardFocusLostEvent();
1501 * @brief Called by editable UI controls when key events are received.
1503 * @param[in] event The key event.
1504 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1506 bool KeyEvent( const Dali::KeyEvent& event );
1509 * @brief Called by editable UI controls when a tap gesture occurs.
1510 * @param[in] tapCount The number of taps.
1511 * @param[in] x The x position relative to the top-left of the parent control.
1512 * @param[in] y The y position relative to the top-left of the parent control.
1514 void TapEvent( unsigned int tapCount, float x, float y );
1517 * @brief Called by editable UI controls when a pan gesture occurs.
1519 * @param[in] state The state of the gesture.
1520 * @param[in] displacement This distance panned since the last pan gesture.
1522 void PanEvent( GestureState state, const Vector2& displacement );
1525 * @brief Called by editable UI controls when a long press gesture occurs.
1527 * @param[in] state The state of the gesture.
1528 * @param[in] x The x position relative to the top-left of the parent control.
1529 * @param[in] y The y position relative to the top-left of the parent control.
1531 void LongPressEvent( GestureState state, float x, float y );
1534 * @brief Creates a selection event.
1536 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1538 * @param[in] x The x position relative to the top-left of the parent control.
1539 * @param[in] y The y position relative to the top-left of the parent control.
1540 * @param[in] selection type like the whole text is selected or unselected.
1542 void SelectEvent( float x, float y, SelectionType selection );
1545 * @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
1547 void SetTextSelectionRange(const uint32_t *start, const uint32_t *end);
1550 * @copydoc Text::SelectableControlInterface::GetTextSelectionRange()
1552 Uint32Pair GetTextSelectionRange() const;
1555 * @copydoc Text::SelectableControlInterface::SelectWholeText()
1557 void SelectWholeText();
1560 * @copydoc Text::SelectableControlInterface::SelectNone()
1565 * @copydoc Text::SelectableControlInterface::GetSelectedText()
1567 string GetSelectedText() const;
1570 * @copydoc Text::EditableControlInterface::IsEditable()
1572 virtual bool IsEditable() const;
1575 * @copydoc Text::EditableControlInterface::SetEditable()
1577 virtual void SetEditable( bool editable );
1580 * @copydoc Dali::Toolkit::Internal::TextEditor::ScrollBy()
1582 virtual void ScrollBy( Vector2 scroll );
1585 * @copydoc Dali::Toolkit::Internal::TextEditor::GetHorizontalScrollPosition()
1587 float GetHorizontalScrollPosition();
1590 * @copydoc Dali::Toolkit::Internal::TextEditor::GetVerticalScrollPosition()
1592 float GetVerticalScrollPosition();
1595 * @brief Event received from input method context
1597 * @param[in] inputMethodContext The input method context.
1598 * @param[in] inputMethodContextEvent The event received.
1599 * @return A data struture indicating if update is needed, cursor position and current text.
1601 InputMethodContext::CallbackData OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent );
1604 * @brief Event from Clipboard notifying an Item has been selected for pasting
1606 void PasteClipboardItemEvent();
1609 * @brief Return true when text control should clear key input focus when escape key is pressed.
1611 * @return Whether text control should clear key input focus or not when escape key is pressed.
1613 bool ShouldClearFocusOnEscape() const;
1616 * @brief Create an actor that renders the text background color
1618 * @return the created actor or an empty handle if no background color needs to be rendered.
1620 Actor CreateBackgroundActor();
1623 * @brief Used to reset the cursor position after setting a new text.
1625 * @param[in] cursorIndex Where to place the cursor.
1627 void ResetCursorPosition( CharacterIndex cursorIndex );
1630 * @brief The method acquires current position of cursor
1631 * @return unsigned value with cursor position
1633 CharacterIndex GetCursorPosition();
1635 protected: // Inherit from Text::Decorator::ControllerInterface.
1638 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1640 void GetTargetSize( Vector2& targetSize ) override;
1643 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1645 void AddDecoration( Actor& actor, bool needsClipping ) override;
1648 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1650 void DecorationEvent( HandleType handle, HandleState state, float x, float y ) override;
1652 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1655 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1657 void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button ) override;
1659 protected: // Inherit from HiddenText.
1662 * @brief Invoked from HiddenText when showing time of the last character was expired
1664 void DisplayTimeExpired() override;
1669 * @brief Called by editable UI controls when key events are received.
1671 * @param[in] text The text to insert.
1672 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1674 void InsertText( const std::string& text, InsertType type );
1677 * @brief Paste given string into Text model
1678 * @param[in] stringToPaste this string will be inserted into the text model
1680 void PasteText( const std::string& stringToPaste );
1683 * @brief Remove a given number of characters
1685 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1686 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1687 * style when pre-edit text is removed.
1689 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1690 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1691 * @param[in] type Whether to update the input style.
1692 * @return True if the remove was successful.
1694 bool RemoveText( int cursorOffset,
1695 int numberOfCharacters,
1696 UpdateInputStyleType type );
1699 * @brief Checks if text is selected and if so removes it.
1700 * @return true if text was removed
1702 bool RemoveSelectedText();
1704 private: // Relayout.
1707 * @brief Lays-out the text.
1709 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1711 * @param[in] size A the size of a bounding box to layout text within.
1712 * @param[in] operations The layout operations which need to be done.
1713 * @param[out] layoutSize The size of the laid-out text.
1715 bool DoRelayout( const Size& size,
1716 OperationsMask operations,
1720 * @brief Calulates the vertical offset to align the text inside the bounding box.
1722 * @param[in] size The size of the bounding box.
1724 void CalculateVerticalOffset( const Size& size );
1729 * @brief Process queued events which modify the model.
1731 void ProcessModifyEvents();
1734 * @brief Used to process an event queued from SetText()
1736 void TextReplacedEvent();
1739 * @brief Used to process an event queued from key events etc.
1741 void TextInsertedEvent();
1744 * @brief Used to process an event queued from backspace key etc.
1746 void TextDeletedEvent();
1749 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1751 * @param[in] keyCode The keycode for the key pressed
1752 * @return True if a character was deleted.
1754 bool DeleteEvent( int keyCode );
1756 private: // Helpers.
1759 * @brief Used to remove the text included the placeholder text.
1764 * @brief Helper to show the place holder text..
1766 void ShowPlaceholderText();
1769 * @brief Helper to clear font-specific data (only).
1771 void ClearFontData();
1774 * @brief Helper to clear text's style data.
1776 void ClearStyleData();
1779 * @brief Used to reset the scroll position after setting a new text.
1781 void ResetScrollPosition();
1783 private: // Private contructors & copy operator.
1786 * @brief Private constructor.
1791 * @brief Private constructor.
1793 Controller( ControlInterface* controlInterface );
1796 * @brief Private constructor.
1798 Controller( ControlInterface* controlInterface,
1799 EditableControlInterface* editableControlInterface,
1800 SelectableControlInterface* selectableControlInterface );
1803 Controller( const Controller& handle );
1806 Controller& operator=( const Controller& handle );
1808 protected: // Destructor.
1811 * @brief A reference counted object may only be deleted by calling Unreference().
1813 virtual ~Controller();
1817 struct Impl; ///< Made public for testing purposes
1821 struct EventHandler;
1822 struct InputFontHandler;
1823 struct PlaceholderHandler;
1830 } // namespace Toolkit
1834 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H