1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_H
5 * Copyright (c) 2017 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/imf-manager.h>
23 #include <dali/public-api/events/gesture.h>
26 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
27 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
28 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
29 #include <dali-toolkit/internal/text/layouts/layout-wrap-mode.h>
30 #include <dali-toolkit/internal/text/hidden-text.h>
31 #include <dali-toolkit/internal/text/text-model-interface.h>
44 class ControlInterface;
45 class EditableControlInterface;
47 class RenderingController;
49 typedef IntrusivePtr<Controller> ControllerPtr;
52 * @brief A Text Controller is used by UI Controls which display text.
54 * It manipulates the Logical & Visual text models on behalf of the UI Controls.
55 * It provides a view of the text that can be used by rendering back-ends.
57 * For selectable/editable UI controls, the controller handles input events from the UI control
58 * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
60 * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
62 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
64 public: // Enumerated types.
67 * @brief Text related operations to be done in the relayout process.
71 NO_OPERATION = 0x0000,
72 CONVERT_TO_UTF32 = 0x0001,
74 VALIDATE_FONTS = 0x0004,
75 GET_LINE_BREAKS = 0x0008,
76 GET_WORD_BREAKS = 0x0010,
79 GET_GLYPH_METRICS = 0x0080,
81 UPDATE_LAYOUT_SIZE = 0x0200,
85 UPDATE_DIRECTION = 0x2000,
86 ALL_OPERATIONS = 0xFFFF
90 * @brief Used to distinguish between regular key events and IMF events
99 * @brief Used to specify whether to update the input style.
101 enum UpdateInputStyleType
104 DONT_UPDATE_INPUT_STYLE
108 * @brief Used to specify what has been updated after the Relayout() method has been called.
112 NONE_UPDATED = 0x0, ///< Nothing has been updated.
113 MODEL_UPDATED = 0x1, ///< The text's model has been updated.
114 DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
118 * @brief Different placeholder-text can be shown when the control is active/inactive.
122 PLACEHOLDER_TYPE_ACTIVE,
123 PLACEHOLDER_TYPE_INACTIVE,
127 * @brief Enumeration for Font Size Type.
131 POINT_SIZE, // The size of font in points.
132 PIXEL_SIZE // The size of font in pixels.
139 NO_ACTION, ///< Does no action if there is a tap on top of an area with no text.
140 HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
141 SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
145 public: // Constructor.
148 * @brief Create a new instance of a Controller.
150 * @return A pointer to a new Controller.
152 static ControllerPtr New();
155 * @brief Create a new instance of a Controller.
157 * @param[in] controlInterface The control's interface.
159 * @return A pointer to a new Controller.
161 static ControllerPtr New( ControlInterface* controlInterface );
164 * @brief Create a new instance of a Controller.
166 * @param[in] controlInterface The control's interface.
167 * @param[in] editableControlInterface The editable control's interface.
169 * @return A pointer to a new Controller.
171 static ControllerPtr New( ControlInterface* controlInterface,
172 EditableControlInterface* editableControlInterface );
174 public: // Configure the text controller.
177 * @brief Called to enable text input.
179 * @note Selectable or editable controls should call this once after Controller::New().
180 * @param[in] decorator Used to create cursor, selection handle decorations etc.
182 void EnableTextInput( DecoratorPtr decorator );
185 * @brief Used to switch between bitmap & vector based glyphs
187 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
189 void SetGlyphType( TextAbstraction::GlyphType glyphType );
192 * @brief Enables/disables the mark-up processor.
194 * By default is disabled.
196 * @param[in] enable Whether to enable the mark-up processor.
198 void SetMarkupProcessorEnabled( bool enable );
201 * @brief Retrieves whether the mark-up processor is enabled.
203 * By default is disabled.
205 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
207 bool IsMarkupProcessorEnabled() const;
210 * @brief Enables/disables the auto text scrolling
212 * By default is disabled.
214 * @param[in] enable Whether to enable the auto scrolling
216 void SetAutoScrollEnabled( bool enable );
219 * @brief Retrieves whether auto text scrolling is enabled.
221 * By default is disabled.
223 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
225 bool IsAutoScrollEnabled() const;
228 * @brief Get direction of the text from the first line of text,
229 * @return bool rtl (right to left) is true
231 CharacterDirection GetAutoScrollDirection() const;
234 * @brief Get the alignment offset of the first line of text.
236 * @return The alignment offset.
238 float GetAutoScrollLineAlignment() const;
241 * @brief Enables the horizontal scrolling.
243 * @param[in] enable Whether to enable the horizontal scrolling.
245 void SetHorizontalScrollEnabled( bool enable );
248 * @brief Retrieves whether the horizontal scrolling is enabled.
250 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
252 bool IsHorizontalScrollEnabled() const;
255 * @brief Enables the vertical scrolling.
257 * @param[in] enable Whether to enable the vertical scrolling.
259 void SetVerticalScrollEnabled( bool enable );
262 * @brief Retrieves whether the verticall scrolling is enabled.
264 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
266 bool IsVerticalScrollEnabled() const;
269 * @brief Enables the smooth handle panning.
271 * @param[in] enable Whether to enable the smooth handle panning.
273 void SetSmoothHandlePanEnabled( bool enable );
276 * @brief Retrieves whether the smooth handle panning is enabled.
278 * @return @e true if the smooth handle panning is enabled.
280 bool IsSmoothHandlePanEnabled() const;
283 * @brief Sets the maximum number of characters that can be inserted into the TextModel
285 * @param[in] maxCharacters maximum number of characters to be accepted
287 void SetMaximumNumberOfCharacters( Length maxCharacters );
290 * @brief Sets the maximum number of characters that can be inserted into the TextModel
292 * @param[in] maxCharacters maximum number of characters to be accepted
294 int GetMaximumNumberOfCharacters();
297 * @brief Called to enable/disable cursor blink.
299 * @note Only editable controls should calls this.
300 * @param[in] enabled Whether the cursor should blink or not.
302 void SetEnableCursorBlink( bool enable );
305 * @brief Query whether cursor blink is enabled.
307 * @return Whether the cursor should blink or not.
309 bool GetEnableCursorBlink() const;
312 * @brief Whether to enable the multi-line layout.
314 * @param[in] enable \e true enables the multi-line (by default)
316 void SetMultiLineEnabled( bool enable );
319 * @return Whether the multi-line layout is enabled.
321 bool IsMultiLineEnabled() const;
324 * @brief Sets the text's horizontal alignment.
326 * @param[in] alignment The horizontal alignment.
328 void SetHorizontalAlignment( Layout::HorizontalAlignment alignment );
331 * @copydoc ModelInterface::GetHorizontalAlignment()
333 Layout::HorizontalAlignment GetHorizontalAlignment() const;
336 * @brief Sets the text's vertical alignment.
338 * @param[in] alignment The vertical alignment.
340 void SetVerticalAlignment( Layout::VerticalAlignment alignment );
343 * @copydoc ModelInterface::GetVerticalAlignment()
345 Layout::VerticalAlignment GetVerticalAlignment() const;
348 * @brief Sets the text's wrap mode
349 * @param[in] text wrap mode The unit of wrapping
351 void SetLineWrapMode( Layout::LineWrap::Mode textWarpMode );
354 * @brief Retrieve text wrap mode previously set.
355 * @return text wrap mode
357 Layout::LineWrap::Mode GetLineWrapMode() const;
360 * @brief Enable or disable the text elide.
362 * @param[in] enabled Whether to enable the text elide.
364 void SetTextElideEnabled( bool enabled );
367 * @copydoc ModelInterface::IsTextElideEnabled()
369 bool IsTextElideEnabled() const;
372 * @brief Enable or disable the placeholder text elide.
373 * @param enabled Whether to enable the placeholder text elide.
375 void SetPlaceholderTextElideEnabled( bool enabled );
378 * @brief Whether the placeholder text elide property is enabled.
379 * @return True if the placeholder text elide property is enabled, false otherwise.
381 bool IsPlaceholderTextElideEnabled() const;
384 * @brief Enable or disable the text selection.
385 * @param[in] enabled Whether to enable the text selection.
387 void SetSelectionEnabled( bool enabled );
390 * @brief Whether the text selection is enabled or not.
391 * @return True if the text selection is enabled
393 bool IsSelectionEnabled() const;
396 * @brief Sets input type to password
398 * @note The string is displayed hidden character
400 * @param[in] passwordInput True if password input is enabled.
402 void SetInputModePassword( bool passwordInput );
405 * @brief Returns whether the input mode type is set as password.
407 * @return True if input mode type is password
409 bool IsInputModePassword();
412 * @brief Sets the action when there is a double tap event on top of a text area with no text.
414 * @param[in] action The action to do.
416 void SetNoTextDoubleTapAction( NoTextTap::Action action );
419 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
421 * @return The action to do.
423 NoTextTap::Action GetNoTextDoubleTapAction() const;
426 * @briefSets the action when there is a long press event on top of a text area with no text.
428 * @param[in] action The action to do.
430 void SetNoTextLongPressAction( NoTextTap::Action action );
433 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
435 * @return The action to do.
437 NoTextTap::Action GetNoTextLongPressAction() const;
440 * @brief Query if Underline settings were provided by string or map
441 * @return bool true if set by string
443 bool IsUnderlineSetByString();
446 * Set method underline setting were set by
447 * @param[in] bool, true if set by string
449 void UnderlineSetByString( bool setByString );
452 * @brief Query if shadow settings were provided by string or map
453 * @return bool true if set by string
455 bool IsShadowSetByString();
458 * Set method shadow setting were set by
459 * @param[in] bool, true if set by string
461 void ShadowSetByString( bool setByString );
464 * @brief Query if outline settings were provided by string or map
465 * @return bool true if set by string
467 bool IsOutlineSetByString();
470 * Set method outline setting were set by
471 * @param[in] bool, true if set by string
473 void OutlineSetByString( bool setByString );
476 * @brief Query if font style settings were provided by string or map
477 * @return bool true if set by string
479 bool IsFontStyleSetByString();
482 * Set method font style setting were set by
483 * @param[in] bool, true if set by string
485 void FontStyleSetByString( bool setByString );
490 * @brief Replaces any text previously set.
492 * @note This will be converted into UTF-32 when stored in the text model.
493 * @param[in] text A string of UTF-8 characters.
495 void SetText( const std::string& text );
498 * @brief Retrieve any text previously set.
500 * @param[out] text A string of UTF-8 characters.
502 void GetText( std::string& text ) const;
505 * @brief Replaces any placeholder text previously set.
507 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
508 * @param[in] text A string of UTF-8 characters.
510 void SetPlaceholderText( PlaceholderType type, const std::string& text );
513 * @brief Retrieve any placeholder text previously set.
515 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
516 * @param[out] A string of UTF-8 characters.
518 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
521 * @ brief Update the text after a font change
522 * @param[in] newDefaultFont The new font to change to
524 void UpdateAfterFontChange( const std::string& newDefaultFont );
526 public: // Default style & Input style
529 * @brief Set the default font family.
531 * @param[in] defaultFontFamily The default font family.
533 void SetDefaultFontFamily( const std::string& defaultFontFamily );
536 * @brief Retrieve the default font family.
538 * @return The default font family.
540 const std::string& GetDefaultFontFamily() const;
543 * @brief Sets the placeholder text font family.
544 * @param[in] placeholderTextFontFamily The placeholder text font family.
546 void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
549 * @brief Retrieves the placeholder text font family.
551 * @return The placeholder text font family
553 const std::string& GetPlaceholderFontFamily() const;
556 * @brief Sets the default font weight.
558 * @param[in] weight The font weight.
560 void SetDefaultFontWeight( FontWeight weight );
563 * @brief Whether the font's weight has been defined.
565 bool IsDefaultFontWeightDefined() const;
568 * @brief Retrieves the default font weight.
570 * @return The default font weight.
572 FontWeight GetDefaultFontWeight() const;
575 * @brief Sets the placeholder text font weight.
577 * @param[in] weight The font weight
579 void SetPlaceholderTextFontWeight( FontWeight weight );
582 * @brief Whether the font's weight has been defined.
584 * @return True if the placeholder text font weight is defined
586 bool IsPlaceholderTextFontWeightDefined() const;
589 * @brief Retrieves the placeholder text font weight.
591 * @return The placeholder text font weight
593 FontWeight GetPlaceholderTextFontWeight() const;
596 * @brief Sets the default font width.
598 * @param[in] width The font width.
600 void SetDefaultFontWidth( FontWidth width );
603 * @brief Whether the font's width has been defined.
605 bool IsDefaultFontWidthDefined() const;
608 * @brief Retrieves the default font width.
610 * @return The default font width.
612 FontWidth GetDefaultFontWidth() const;
615 * @brief Sets the placeholder text font width.
617 * @param[in] width The font width
619 void SetPlaceholderTextFontWidth( FontWidth width );
622 * @brief Whether the font's width has been defined.
624 * @return True if the placeholder text font width is defined
626 bool IsPlaceholderTextFontWidthDefined() const;
629 * @brief Retrieves the placeholder text font width.
631 * @return The placeholder text font width
633 FontWidth GetPlaceholderTextFontWidth() const;
636 * @brief Sets the default font slant.
638 * @param[in] slant The font slant.
640 void SetDefaultFontSlant( FontSlant slant );
643 * @brief Whether the font's slant has been defined.
645 bool IsDefaultFontSlantDefined() const;
648 * @brief Retrieves the default font slant.
650 * @return The default font slant.
652 FontSlant GetDefaultFontSlant() const;
655 * @brief Sets the placeholder text font slant.
657 * @param[in] slant The font slant
659 void SetPlaceholderTextFontSlant( FontSlant slant );
662 * @brief Whether the font's slant has been defined.
664 * @return True if the placeholder text font slant is defined
666 bool IsPlaceholderTextFontSlantDefined() const;
669 * @brief Retrieves the placeholder text font slant.
671 * @return The placeholder text font slant
673 FontSlant GetPlaceholderTextFontSlant() const;
676 * @brief Set the default font size.
678 * @param[in] fontSize The default font size
679 * @param[in] type The font size type is point size or pixel size
681 void SetDefaultFontSize( float fontSize, FontSizeType type );
684 * @brief Retrieve the default point size.
686 * @param[in] type The font size type
687 * @return The default point size.
689 float GetDefaultFontSize( FontSizeType type ) const;
692 * @brief Sets the Placeholder text font size.
693 * @param[in] fontSize The placeholder text font size
694 * @param[in] type The font size type is point size or pixel size
696 void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
699 * @brief Retrieves the Placeholder text font size.
700 * @param[in] type The font size type
701 * @return The placeholder font size
703 float GetPlaceholderTextFontSize( FontSizeType type ) const;
706 * @brief Sets the text's default color.
708 * @param color The default color.
710 void SetDefaultColor( const Vector4& color );
713 * @brief Retrieves the text's default color.
715 * @return The default color.
717 const Vector4& GetDefaultColor() const;
720 * @brief Set the text color
722 * @param textColor The text color
724 void SetPlaceholderTextColor( const Vector4& textColor );
727 * @brief Retrieve the text color
729 * @return The text color
731 const Vector4& GetPlaceholderTextColor() const;
734 * @brief Set the shadow offset.
736 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
738 void SetShadowOffset( const Vector2& shadowOffset );
741 * @brief Retrieve the shadow offset.
743 * @return The shadow offset.
745 const Vector2& GetShadowOffset() const;
748 * @brief Set the shadow color.
750 * @param[in] shadowColor The shadow color.
752 void SetShadowColor( const Vector4& shadowColor );
755 * @brief Retrieve the shadow color.
757 * @return The shadow color.
759 const Vector4& GetShadowColor() const;
762 * @brief Set the underline color.
764 * @param[in] color color of underline.
766 void SetUnderlineColor( const Vector4& color );
769 * @brief Retrieve the underline color.
771 * @return The underline color.
773 const Vector4& GetUnderlineColor() const;
776 * @brief Set the underline enabled flag.
778 * @param[in] enabled The underline enabled flag.
780 void SetUnderlineEnabled( bool enabled );
783 * @brief Returns whether the text is underlined or not.
785 * @return The underline state.
787 bool IsUnderlineEnabled() const;
790 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
792 * @param[in] height The height in pixels of the underline
794 void SetUnderlineHeight( float height );
797 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
799 * @return The height of the underline, or 0 if height is not overrided.
801 float GetUnderlineHeight() const;
804 * @brief Set the outline color.
806 * @param[in] color color of outline.
808 void SetOutlineColor( const Vector4& color );
811 * @brief Retrieve the outline color.
813 * @return The outline color.
815 const Vector4& GetOutlineColor() const;
818 * @brief Set the outline width
820 * @param[in] width The width in pixels of the outline, 0 indicates no outline
822 void SetOutlineWidth( float width );
825 * @brief Retrieves the width of an outline
827 * @return The width of the outline.
829 float GetOutlineWidth() const;
832 * @brief Sets the emboss's properties string.
834 * @note The string is stored to be recovered.
836 * @param[in] embossProperties The emboss's properties string.
838 void SetDefaultEmbossProperties( const std::string& embossProperties );
841 * @brief Retrieves the emboss's properties string.
843 * @return The emboss's properties string.
845 const std::string& GetDefaultEmbossProperties() const;
848 * @brief Sets the outline's properties string.
850 * @note The string is stored to be recovered.
852 * @param[in] outlineProperties The outline's properties string.
854 void SetDefaultOutlineProperties( const std::string& outlineProperties );
857 * @brief Retrieves the outline's properties string.
859 * @return The outline's properties string.
861 const std::string& GetDefaultOutlineProperties() const;
864 * @brief Sets the default line spacing.
866 * @param[in] lineSpacing The line spacing.
868 void SetDefaultLineSpacing( float lineSpacing );
871 * @brief Retrieves the default line spacing.
873 * @return The line spacing.
875 float GetDefaultLineSpacing() const;
878 * @brief Sets the input text's color.
880 * @param[in] color The input text's color.
882 void SetInputColor( const Vector4& color );
885 * @brief Retrieves the input text's color.
887 * @return The input text's color.
889 const Vector4& GetInputColor() const;
892 * @brief Sets the input text's font family name.
894 * @param[in] fontFamily The text's font family name.
896 void SetInputFontFamily( const std::string& fontFamily );
899 * @brief Retrieves the input text's font family name.
901 * @return The input text's font family name.
903 const std::string& GetInputFontFamily() const;
906 * @brief Sets the input font's weight.
908 * @param[in] weight The input font's weight.
910 void SetInputFontWeight( FontWeight weight );
913 * @return Whether the font's weight has been defined.
915 bool IsInputFontWeightDefined() const;
918 * @brief Retrieves the input font's weight.
920 * @return The input font's weight.
922 FontWeight GetInputFontWeight() const;
925 * @brief Sets the input font's width.
927 * @param[in] width The input font's width.
929 void SetInputFontWidth( FontWidth width );
932 * @return Whether the font's width has been defined.
934 bool IsInputFontWidthDefined() const;
937 * @brief Retrieves the input font's width.
939 * @return The input font's width.
941 FontWidth GetInputFontWidth() const;
944 * @brief Sets the input font's slant.
946 * @param[in] slant The input font's slant.
948 void SetInputFontSlant( FontSlant slant );
951 * @return Whether the font's slant has been defined.
953 bool IsInputFontSlantDefined() const;
956 * @brief Retrieves the input font's slant.
958 * @return The input font's slant.
960 FontSlant GetInputFontSlant() const;
963 * @brief Sets the input font's point size.
965 * @param[in] size The input font's point size.
967 void SetInputFontPointSize( float size );
970 * @brief Retrieves the input font's point size.
972 * @return The input font's point size.
974 float GetInputFontPointSize() const;
977 * @brief Sets the input line spacing.
979 * @param[in] lineSpacing The line spacing.
981 void SetInputLineSpacing( float lineSpacing );
984 * @brief Retrieves the input line spacing.
986 * @return The line spacing.
988 float GetInputLineSpacing() const;
991 * @brief Sets the input shadow's properties string.
993 * @note The string is stored to be recovered.
995 * @param[in] shadowProperties The shadow's properties string.
997 void SetInputShadowProperties( const std::string& shadowProperties );
1000 * @brief Retrieves the input shadow's properties string.
1002 * @return The shadow's properties string.
1004 const std::string& GetInputShadowProperties() const;
1007 * @brief Sets the input underline's properties string.
1009 * @note The string is stored to be recovered.
1011 * @param[in] underlineProperties The underline's properties string.
1013 void SetInputUnderlineProperties( const std::string& underlineProperties );
1016 * @brief Retrieves the input underline's properties string.
1018 * @return The underline's properties string.
1020 const std::string& GetInputUnderlineProperties() const;
1023 * @brief Sets the input emboss's properties string.
1025 * @note The string is stored to be recovered.
1027 * @param[in] embossProperties The emboss's properties string.
1029 void SetInputEmbossProperties( const std::string& embossProperties );
1032 * @brief Retrieves the input emboss's properties string.
1034 * @return The emboss's properties string.
1036 const std::string& GetInputEmbossProperties() const;
1039 * @brief Sets input the outline's properties string.
1041 * @note The string is stored to be recovered.
1043 * @param[in] outlineProperties The outline's properties string.
1045 void SetInputOutlineProperties( const std::string& outlineProperties );
1048 * @brief Retrieves the input outline's properties string.
1050 * @return The outline's properties string.
1052 const std::string& GetInputOutlineProperties() const;
1055 * @brief Set the control's interface.
1057 * @param[in] controlInterface The control's interface.
1059 void SetControlInterface( ControlInterface* controlInterface );
1061 public: // Queries & retrieves.
1064 * @brief Return the layout engine.
1066 * @return A reference to the layout engine.
1068 Layout::Engine& GetLayoutEngine();
1071 * @brief Return a view of the text.
1073 * @return A reference to the view.
1078 * @copydoc Control::GetNaturalSize()
1080 Vector3 GetNaturalSize();
1083 * @copydoc Control::GetHeightForWidth()
1085 float GetHeightForWidth( float width );
1088 * @brief Retrieves the text's number of lines for a given width.
1089 * @param[in] width The width of the text's area.
1090 * @ return The number of lines.
1092 int GetLineCount( float width );
1095 * @brief Retrieves the text's model.
1097 * @return A pointer to the text's model.
1099 const ModelInterface* const GetTextModel() const;
1102 * @brief Used to get scrolled distance by user input
1104 * @return Distance from last scroll offset to new scroll offset
1106 float GetScrollAmountByUserInput();
1109 * @brief Get latest scroll amount, control size and layout size
1111 * This method is used to get information of control's scroll
1112 * @param[out] scrollPosition The current scrolled position
1113 * @param[out] controlHeight The size of a UI control
1114 * @param[out] layoutHeight The size of a bounding box to layout text within.
1116 * @return Whether the text scroll position is changed or not after last update.
1118 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1121 * @brief Used to set the hidden input option
1123 void SetHiddenInputOption( const Property::Map& options );
1126 * @brief Used to get the hidden input option
1128 void GetHiddenInputOption( Property::Map& options );
1131 * @brief Sets the Placeholder Properties.
1133 * @param[in] map The placeholder property map
1135 void SetPlaceholderProperty( const Property::Map& map );
1138 * @brief Retrieves the Placeholder Property map.
1140 * @param[out] map The property map
1142 void GetPlaceholderProperty( Property::Map& map );
1144 public: // Relayout.
1147 * @brief Triggers a relayout which updates View (if necessary).
1149 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1150 * @param[in] size A the size of a bounding box to layout text within.
1152 * @return Whether the text model or decorations were updated.
1154 UpdateTextType Relayout( const Size& size );
1157 * @brief Request a relayout using the ControlInterface.
1159 void RequestRelayout();
1161 public: // Input style change signals.
1164 * @return Whether the queue of input style changed signals is empty.
1166 bool IsInputStyleChangedSignalsQueueEmpty();
1169 * @brief Process all pending input style changed signals.
1171 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1172 * text controls. Text controls may send signals to state the input style has changed.
1174 void ProcessInputStyleChangedSignals();
1176 public: // Text-input Event Queuing.
1179 * @brief Called by editable UI controls when keyboard focus is gained.
1181 void KeyboardFocusGainEvent();
1184 * @brief Called by editable UI controls when focus is lost.
1186 void KeyboardFocusLostEvent();
1189 * @brief Called by editable UI controls when key events are received.
1191 * @param[in] event The key event.
1192 * @param[in] type Used to distinguish between regular key events and IMF events.
1194 bool KeyEvent( const Dali::KeyEvent& event );
1197 * @brief Called by editable UI controls when a tap gesture occurs.
1198 * @param[in] tapCount The number of taps.
1199 * @param[in] x The x position relative to the top-left of the parent control.
1200 * @param[in] y The y position relative to the top-left of the parent control.
1202 void TapEvent( unsigned int tapCount, float x, float y );
1205 * @brief Called by editable UI controls when a pan gesture occurs.
1207 * @param[in] state The state of the gesture.
1208 * @param[in] displacement This distance panned since the last pan gesture.
1210 void PanEvent( Gesture::State state, const Vector2& displacement );
1213 * @brief Called by editable UI controls when a long press gesture occurs.
1215 * @param[in] state The state of the gesture.
1216 * @param[in] x The x position relative to the top-left of the parent control.
1217 * @param[in] y The y position relative to the top-left of the parent control.
1219 void LongPressEvent( Gesture::State state, float x, float y );
1222 * @brief Event received from IMF manager
1224 * @param[in] imfManager The IMF manager.
1225 * @param[in] imfEvent The event received.
1226 * @return A data struture indicating if update is needed, cursor position and current text.
1228 ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
1231 * @brief Event from Clipboard notifying an Item has been selected for pasting
1233 void PasteClipboardItemEvent();
1236 * @brief Return true when text control should clear key input focus when escape key is pressed.
1238 * @return Whether text control should clear key input focus or not when escape key is pressed.
1240 bool ShouldClearFocusOnEscape() const;
1242 protected: // Inherit from Text::Decorator::ControllerInterface.
1245 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1247 virtual void GetTargetSize( Vector2& targetSize );
1250 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1252 virtual void AddDecoration( Actor& actor, bool needsClipping );
1255 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1257 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1259 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1262 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1264 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1266 protected: // Inherit from HiddenText.
1269 * @brief Invoked from HiddenText when showing time of the last character was expired
1271 virtual void DisplayTimeExpired();
1276 * @brief Called by editable UI controls when key events are received.
1278 * @param[in] text The text to insert.
1279 * @param[in] type Used to distinguish between regular key events and IMF events.
1281 void InsertText( const std::string& text, InsertType type );
1284 * @brief Paste given string into Text model
1285 * @param[in] stringToPaste this string will be inserted into the text model
1287 void PasteText( const std::string& stringToPaste );
1290 * @brief Remove a given number of characters
1292 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1293 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1294 * style when pre-edit text is removed.
1296 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1297 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1298 * @param[in] type Whether to update the input style.
1299 * @return True if the remove was successful.
1301 bool RemoveText( int cursorOffset,
1302 int numberOfCharacters,
1303 UpdateInputStyleType type );
1306 * @brief Checks if text is selected and if so removes it.
1307 * @return true if text was removed
1309 bool RemoveSelectedText();
1311 private: // Relayout.
1314 * @brief Lays-out the text.
1316 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1318 * @param[in] size A the size of a bounding box to layout text within.
1319 * @param[in] operations The layout operations which need to be done.
1320 * @param[out] layoutSize The size of the laid-out text.
1322 bool DoRelayout( const Size& size,
1323 OperationsMask operations,
1327 * @brief Calulates the vertical offset to align the text inside the bounding box.
1329 * @param[in] size The size of the bounding box.
1331 void CalculateVerticalOffset( const Size& size );
1336 * @brief Process queued events which modify the model.
1338 void ProcessModifyEvents();
1341 * @brief Used to process an event queued from SetText()
1343 void TextReplacedEvent();
1346 * @brief Used to process an event queued from key events etc.
1348 void TextInsertedEvent();
1351 * @brief Used to process an event queued from backspace key etc.
1353 void TextDeletedEvent();
1356 * @brief Creates a selection event.
1358 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1360 * @param[in] x The x position relative to the top-left of the parent control.
1361 * @param[in] y The y position relative to the top-left of the parent control.
1362 * @param[in] selectAll Whether the whole text is selected.
1364 void SelectEvent( float x, float y, bool selectAll );
1367 * @brief Helper to KeyEvent() to handle the backspace case.
1369 * @return True if a character was deleted.
1371 bool BackspaceKeyEvent();
1373 private: // Helpers.
1376 * @brief Used to remove the text included the placeholder text.
1381 * @brief Helper to show the place holder text..
1383 void ShowPlaceholderText();
1386 * @brief Helper to clear font-specific data (only).
1388 void ClearFontData();
1391 * @brief Helper to clear text's style data.
1393 void ClearStyleData();
1396 * @brief Used to reset the cursor position after setting a new text.
1398 * @param[in] cursorIndex Where to place the cursor.
1400 void ResetCursorPosition( CharacterIndex cursorIndex );
1403 * @brief Used to reset the scroll position after setting a new text.
1405 void ResetScrollPosition();
1407 private: // Private contructors & copy operator.
1410 * @brief Private constructor.
1415 * @brief Private constructor.
1417 Controller( ControlInterface* controlInterface );
1420 * @brief Private constructor.
1422 Controller( ControlInterface* controlInterface,
1423 EditableControlInterface* editableControlInterface );
1426 Controller( const Controller& handle );
1429 Controller& operator=( const Controller& handle );
1431 protected: // Destructor.
1434 * @brief A reference counted object may only be deleted by calling Unreference().
1436 virtual ~Controller();
1446 } // namespace Toolkit
1450 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H