X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.h;h=63a77a4459f540c42f5a898c921965ddff365c2f;hp=6a986f5c81a5eb6c4a1e2b8ffb5f9a14020b1f5c;hb=91a31a5bdf35ebea5818c3809467b6fb74a547a2;hpb=f38b85e43af2185f8455c58906fa63c8e50f9899 diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h old mode 100755 new mode 100644 index 6a986f5..63a77a4 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,39 +23,39 @@ #include // INTERNAL INCLUDES -#include -#include #include +#include #include #include -#include #include +#include +#include +#include #include +#include +#include namespace Dali { - namespace Toolkit { - namespace Text { - class Controller; class ControlInterface; class EditableControlInterface; class View; class RenderingController; - /** +/** * @brief Text selection operations . */ - enum SelectionType - { - INTERACTIVE = 0x0000, - ALL = 0x0001, - NONE = 0x0002 - }; +enum SelectionType +{ + INTERACTIVE = 0x0000, + ALL = 0x0001, + NONE = 0x0002 +}; typedef IntrusivePtr ControllerPtr; @@ -73,7 +73,6 @@ typedef IntrusivePtr ControllerPtr; class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer { public: // Enumerated types. - /** * @brief Text related operations to be done in the relayout process. */ @@ -138,8 +137,8 @@ public: // Enumerated types. */ enum FontSizeType { - POINT_SIZE, // The size of font in points. - PIXEL_SIZE // The size of font in pixels. + POINT_SIZE, // The size of font in points. + PIXEL_SIZE // The size of font in pixels. }; struct NoTextTap @@ -165,7 +164,6 @@ public: // Enumerated types. }; public: // Constructor. - /** * @brief Create a new instance of a Controller. * @@ -180,21 +178,24 @@ public: // Constructor. * * @return A pointer to a new Controller. */ - static ControllerPtr New( ControlInterface* controlInterface ); + static ControllerPtr New(ControlInterface* controlInterface); /** * @brief Create a new instance of a Controller. * * @param[in] controlInterface The control's interface. * @param[in] editableControlInterface The editable control's interface. + * @param[in] selectableControlInterface The selectable control's interface. + * @param[in] anchorControlInterface The anchor control's interface. * * @return A pointer to a new Controller. */ - static ControllerPtr New( ControlInterface* controlInterface, - EditableControlInterface* editableControlInterface ); + static ControllerPtr New(ControlInterface* controlInterface, + EditableControlInterface* editableControlInterface, + SelectableControlInterface* selectableControlInterface, + AnchorControlInterface* anchorControlInterface); public: // Configure the text controller. - /** * @brief Called to enable text input. * @@ -202,14 +203,14 @@ public: // Configure the text controller. * @param[in] decorator Used to create cursor, selection handle decorations etc. * @param[in] inputMethodContext Used to manager ime. */ - void EnableTextInput( DecoratorPtr decorator, InputMethodContext& inputMethodContext ); + void EnableTextInput(DecoratorPtr decorator, InputMethodContext& inputMethodContext); /** * @brief Used to switch between bitmap & vector based glyphs * * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different. */ - void SetGlyphType( TextAbstraction::GlyphType glyphType ); + void SetGlyphType(TextAbstraction::GlyphType glyphType); /** * @brief Enables/disables the mark-up processor. @@ -218,7 +219,7 @@ public: // Configure the text controller. * * @param[in] enable Whether to enable the mark-up processor. */ - void SetMarkupProcessorEnabled( bool enable ); + void SetMarkupProcessorEnabled(bool enable); /** * @brief Retrieves whether the mark-up processor is enabled. @@ -230,13 +231,20 @@ public: // Configure the text controller. bool IsMarkupProcessorEnabled() const; /** + * @brief Retrieves whether the current text contains anchors. + * + * @return @e true if the current text contains anchors. @e false. + */ + bool HasAnchors() const; + + /** * @brief Enables/disables the auto text scrolling * * By default is disabled. * * @param[in] enable Whether to enable the auto scrolling */ - void SetAutoScrollEnabled( bool enable ); + void SetAutoScrollEnabled(bool enable); /** * @brief Retrieves whether auto text scrolling is enabled. @@ -265,7 +273,7 @@ public: // Configure the text controller. * * @param[in] enable Whether to enable the horizontal scrolling. */ - void SetHorizontalScrollEnabled( bool enable ); + void SetHorizontalScrollEnabled(bool enable); /** * @brief Retrieves whether the horizontal scrolling is enabled. @@ -279,7 +287,7 @@ public: // Configure the text controller. * * @param[in] enable Whether to enable the vertical scrolling. */ - void SetVerticalScrollEnabled( bool enable ); + void SetVerticalScrollEnabled(bool enable); /** * @brief Retrieves whether the verticall scrolling is enabled. @@ -293,7 +301,7 @@ public: // Configure the text controller. * * @param[in] enable Whether to enable the smooth handle panning. */ - void SetSmoothHandlePanEnabled( bool enable ); + void SetSmoothHandlePanEnabled(bool enable); /** * @brief Retrieves whether the smooth handle panning is enabled. @@ -307,7 +315,7 @@ public: // Configure the text controller. * * @param[in] maxCharacters maximum number of characters to be accepted */ - void SetMaximumNumberOfCharacters( Length maxCharacters ); + void SetMaximumNumberOfCharacters(Length maxCharacters); /** * @brief Sets the maximum number of characters that can be inserted into the TextModel @@ -322,7 +330,7 @@ public: // Configure the text controller. * @note Only editable controls should calls this. * @param[in] enabled Whether the cursor should blink or not. */ - void SetEnableCursorBlink( bool enable ); + void SetEnableCursorBlink(bool enable); /** * @brief Query whether cursor blink is enabled. @@ -336,7 +344,7 @@ public: // Configure the text controller. * * @param[in] enable \e true enables the multi-line (by default) */ - void SetMultiLineEnabled( bool enable ); + void SetMultiLineEnabled(bool enable); /** * @return Whether the multi-line layout is enabled. @@ -348,7 +356,7 @@ public: // Configure the text controller. * * @param[in] alignment The horizontal alignment. */ - void SetHorizontalAlignment( HorizontalAlignment::Type alignment ); + void SetHorizontalAlignment(HorizontalAlignment::Type alignment); /** * @copydoc ModelInterface::GetHorizontalAlignment() @@ -360,7 +368,7 @@ public: // Configure the text controller. * * @param[in] alignment The vertical alignment. */ - void SetVerticalAlignment( VerticalAlignment::Type alignment ); + void SetVerticalAlignment(VerticalAlignment::Type alignment); /** * @copydoc ModelInterface::GetVerticalAlignment() @@ -371,7 +379,7 @@ public: // Configure the text controller. * @brief Sets the text's wrap mode * @param[in] text wrap mode The unit of wrapping */ - void SetLineWrapMode( Text::LineWrap::Mode textWarpMode ); + void SetLineWrapMode(Text::LineWrap::Mode textWarpMode); /** * @brief Retrieve text wrap mode previously set. @@ -384,7 +392,7 @@ public: // Configure the text controller. * * @param[in] enabled Whether to enable the text elide. */ - void SetTextElideEnabled( bool enabled ); + void SetTextElideEnabled(bool enabled); /** * @copydoc ModelInterface::IsTextElideEnabled() @@ -411,7 +419,7 @@ public: // Configure the text controller. * @param[in] minimum size value. * @param[in] type The font size type is point size or pixel size */ - void SetTextFitMinSize( float pointSize, FontSizeType type ); + void SetTextFitMinSize(float pointSize, FontSizeType type); /** * @brief Retrieves the minimum point size valid for text fit. @@ -426,7 +434,7 @@ public: // Configure the text controller. * @param[in] maximum size value. * @param[in] type The font size type is point size or pixel size */ - void SetTextFitMaxSize( float pointSize, FontSizeType type ); + void SetTextFitMaxSize(float pointSize, FontSizeType type); /** * @brief Retrieves the maximum point size valid for text fit. @@ -441,7 +449,7 @@ public: // Configure the text controller. * @param[in] step size value. * @param[in] type The font size type is point size or pixel size */ - void SetTextFitStepSize( float step, FontSizeType type ); + void SetTextFitStepSize(float step, FontSizeType type); /** * @brief Retrieves the step point size valid for text fit. @@ -468,7 +476,7 @@ public: // Configure the text controller. * @brief Enable or disable the placeholder text elide. * @param enabled Whether to enable the placeholder text elide. */ - void SetPlaceholderTextElideEnabled( bool enabled ); + void SetPlaceholderTextElideEnabled(bool enabled); /** * @brief Whether the placeholder text elide property is enabled. @@ -480,7 +488,7 @@ public: // Configure the text controller. * @brief Enable or disable the text selection. * @param[in] enabled Whether to enable the text selection. */ - void SetSelectionEnabled( bool enabled ); + void SetSelectionEnabled(bool enabled); /** * @brief Whether the text selection is enabled or not. @@ -492,7 +500,7 @@ public: // Configure the text controller. * @brief Enable or disable the text selection using Shift key. * @param enabled Whether to enable the text selection using Shift key */ - void SetShiftSelectionEnabled( bool enabled ); + void SetShiftSelectionEnabled(bool enabled); /** * @brief Whether the text selection using Shift key is enabled or not. @@ -505,7 +513,7 @@ public: // Configure the text controller. * * @param[in] enabled Whether to enable the grab handles */ - void SetGrabHandleEnabled( bool enabled ); + void SetGrabHandleEnabled(bool enabled); /** * @brief Returns whether the grab handles are enabled. @@ -519,7 +527,7 @@ public: // Configure the text controller. * * @param[in] enabled Whether to enable the grab handles */ - void SetGrabHandlePopupEnabled( bool enabled ); + void SetGrabHandlePopupEnabled(bool enabled); /** * @brief Returns whether the grab handles are enabled. @@ -535,7 +543,7 @@ public: // Configure the text controller. * * @param[in] passwordInput True if password input is enabled. */ - void SetInputModePassword( bool passwordInput ); + void SetInputModePassword(bool passwordInput); /** * @brief Returns whether the input mode type is set as password. @@ -549,7 +557,7 @@ public: // Configure the text controller. * * @param[in] action The action to do. */ - void SetNoTextDoubleTapAction( NoTextTap::Action action ); + void SetNoTextDoubleTapAction(NoTextTap::Action action); /** * @brief Retrieves the action when there is a double tap event on top of a text area with no text. @@ -563,7 +571,7 @@ public: // Configure the text controller. * * @param[in] action The action to do. */ - void SetNoTextLongPressAction( NoTextTap::Action action ); + void SetNoTextLongPressAction(NoTextTap::Action action); /** * @brief Retrieves the action when there is a long press event on top of a text area with no text. @@ -582,7 +590,7 @@ public: // Configure the text controller. * Set method underline setting were set by * @param[in] bool, true if set by string */ - void UnderlineSetByString( bool setByString ); + void UnderlineSetByString(bool setByString); /** * @brief Query if shadow settings were provided by string or map @@ -594,7 +602,7 @@ public: // Configure the text controller. * Set method shadow setting were set by * @param[in] bool, true if set by string */ - void ShadowSetByString( bool setByString ); + void ShadowSetByString(bool setByString); /** * @brief Query if outline settings were provided by string or map @@ -606,7 +614,7 @@ public: // Configure the text controller. * Set method outline setting were set by * @param[in] bool, true if set by string */ - void OutlineSetByString( bool setByString ); + void OutlineSetByString(bool setByString); /** * @brief Query if font style settings were provided by string or map @@ -618,24 +626,23 @@ public: // Configure the text controller. * Set method font style setting were set by * @param[in] bool, true if set by string */ - void FontStyleSetByString( bool setByString ); + void FontStyleSetByString(bool setByString); public: // Update. - /** * @brief Replaces any text previously set. * * @note This will be converted into UTF-32 when stored in the text model. * @param[in] text A string of UTF-8 characters. */ - void SetText( const std::string& text ); + void SetText(const std::string& text); /** * @brief Retrieve any text previously set. * * @param[out] text A string of UTF-8 characters. */ - void GetText( std::string& text ) const; + void GetText(std::string& text) const; /** * @brief Replaces any placeholder text previously set. @@ -643,7 +650,7 @@ public: // Update. * @param[in] type Different placeholder-text can be shown when the control is active/inactive. * @param[in] text A string of UTF-8 characters. */ - void SetPlaceholderText( PlaceholderType type, const std::string& text ); + void SetPlaceholderText(PlaceholderType type, const std::string& text); /** * @brief Retrieve any placeholder text previously set. @@ -651,22 +658,53 @@ public: // Update. * @param[in] type Different placeholder-text can be shown when the control is active/inactive. * @param[out] A string of UTF-8 characters. */ - void GetPlaceholderText( PlaceholderType type, std::string& text ) const; + void GetPlaceholderText(PlaceholderType type, std::string& text) const; /** * @ brief Update the text after a font change * @param[in] newDefaultFont The new font to change to */ - void UpdateAfterFontChange( const std::string& newDefaultFont ); + void UpdateAfterFontChange(const std::string& newDefaultFont); -public: // Default style & Input style + /** + * @brief The method acquires currently selected text + * @param selectedText variable to place selected text in + */ + void RetrieveSelection(std::string& selectedText) const; + + /** + * @brief The method sets selection in given range + * @param start index of first character + * @param end index of first character after selection + */ + void SetSelection(int start, int end); + + /** + * @brief This method retrieve indexes of current selection + * + * @return a pair, where first element is left index of selection and second is the right one + */ + std::pair GetSelectionIndexes() const; + + /** + * Place string in system clipboard + * @param source std::string + */ + void CopyStringToClipboard(const std::string& source); + + /** + * Place currently selected text in system clipboard + * @param deleteAfterSending flag pointing if text should be deleted after sending to clipboard + */ + void SendSelectionToClipboard(bool deleteAfterSending); +public: // Default style & Input style /** * @brief Set the default font family. * * @param[in] defaultFontFamily The default font family. */ - void SetDefaultFontFamily( const std::string& defaultFontFamily ); + void SetDefaultFontFamily(const std::string& defaultFontFamily); /** * @brief Retrieve the default font family. @@ -679,7 +717,7 @@ public: // Default style & Input style * @brief Sets the placeholder text font family. * @param[in] placeholderTextFontFamily The placeholder text font family. */ - void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily ); + void SetPlaceholderFontFamily(const std::string& placeholderTextFontFamily); /** * @brief Retrieves the placeholder text font family. @@ -693,7 +731,7 @@ public: // Default style & Input style * * @param[in] weight The font weight. */ - void SetDefaultFontWeight( FontWeight weight ); + void SetDefaultFontWeight(FontWeight weight); /** * @brief Whether the font's weight has been defined. @@ -712,7 +750,7 @@ public: // Default style & Input style * * @param[in] weight The font weight */ - void SetPlaceholderTextFontWeight( FontWeight weight ); + void SetPlaceholderTextFontWeight(FontWeight weight); /** * @brief Whether the font's weight has been defined. @@ -733,7 +771,7 @@ public: // Default style & Input style * * @param[in] width The font width. */ - void SetDefaultFontWidth( FontWidth width ); + void SetDefaultFontWidth(FontWidth width); /** * @brief Whether the font's width has been defined. @@ -752,7 +790,7 @@ public: // Default style & Input style * * @param[in] width The font width */ - void SetPlaceholderTextFontWidth( FontWidth width ); + void SetPlaceholderTextFontWidth(FontWidth width); /** * @brief Whether the font's width has been defined. @@ -773,7 +811,7 @@ public: // Default style & Input style * * @param[in] slant The font slant. */ - void SetDefaultFontSlant( FontSlant slant ); + void SetDefaultFontSlant(FontSlant slant); /** * @brief Whether the font's slant has been defined. @@ -792,7 +830,7 @@ public: // Default style & Input style * * @param[in] slant The font slant */ - void SetPlaceholderTextFontSlant( FontSlant slant ); + void SetPlaceholderTextFontSlant(FontSlant slant); /** * @brief Whether the font's slant has been defined. @@ -814,7 +852,7 @@ public: // Default style & Input style * @param[in] fontSize The default font size * @param[in] type The font size type is point size or pixel size */ - void SetDefaultFontSize( float fontSize, FontSizeType type ); + void SetDefaultFontSize(float fontSize, FontSizeType type); /** * @brief Retrieve the default point size. @@ -822,28 +860,42 @@ public: // Default style & Input style * @param[in] type The font size type * @return The default point size. */ - float GetDefaultFontSize( FontSizeType type ) const; + float GetDefaultFontSize(FontSizeType type) const; + + /** + * @brief Set the font size scale. + * + * @param[in] scale The font size scale + */ + void SetFontSizeScale(float scale); + + /** + * @brief Get the font size scale. + * + * @return The font size scale. + */ + float GetFontSizeScale() const; /** * @brief Sets the Placeholder text font size. * @param[in] fontSize The placeholder text font size * @param[in] type The font size type is point size or pixel size */ - void SetPlaceholderTextFontSize( float fontSize, FontSizeType type ); + void SetPlaceholderTextFontSize(float fontSize, FontSizeType type); /** * @brief Retrieves the Placeholder text font size. * @param[in] type The font size type * @return The placeholder font size */ - float GetPlaceholderTextFontSize( FontSizeType type ) const; + float GetPlaceholderTextFontSize(FontSizeType type) const; /** * @brief Sets the text's default color. * * @param color The default color. */ - void SetDefaultColor( const Vector4& color ); + void SetDefaultColor(const Vector4& color); /** * @brief Retrieves the text's default color. @@ -857,7 +909,7 @@ public: // Default style & Input style * * @param textColor The text color */ - void SetPlaceholderTextColor( const Vector4& textColor ); + void SetPlaceholderTextColor(const Vector4& textColor); /** * @brief Retrieve the text color @@ -871,7 +923,7 @@ public: // Default style & Input style * * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow. */ - void SetShadowOffset( const Vector2& shadowOffset ); + void SetShadowOffset(const Vector2& shadowOffset); /** * @brief Retrieve the shadow offset. @@ -885,7 +937,7 @@ public: // Default style & Input style * * @param[in] shadowColor The shadow color. */ - void SetShadowColor( const Vector4& shadowColor ); + void SetShadowColor(const Vector4& shadowColor); /** * @brief Retrieve the shadow color. @@ -899,7 +951,7 @@ public: // Default style & Input style * * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur. */ - void SetShadowBlurRadius( const float& shadowBlurRadius ); + void SetShadowBlurRadius(const float& shadowBlurRadius); /** * @brief Retrieve the shadow blur radius. @@ -913,7 +965,7 @@ public: // Default style & Input style * * @param[in] color color of underline. */ - void SetUnderlineColor( const Vector4& color ); + void SetUnderlineColor(const Vector4& color); /** * @brief Retrieve the underline color. @@ -927,7 +979,7 @@ public: // Default style & Input style * * @param[in] enabled The underline enabled flag. */ - void SetUnderlineEnabled( bool enabled ); + void SetUnderlineEnabled(bool enabled); /** * @brief Returns whether the text is underlined or not. @@ -941,7 +993,7 @@ public: // Default style & Input style * * @param[in] height The height in pixels of the underline */ - void SetUnderlineHeight( float height ); + void SetUnderlineHeight(float height); /** * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics @@ -955,7 +1007,7 @@ public: // Default style & Input style * * @param[in] color color of outline. */ - void SetOutlineColor( const Vector4& color ); + void SetOutlineColor(const Vector4& color); /** * @brief Retrieve the outline color. @@ -969,7 +1021,7 @@ public: // Default style & Input style * * @param[in] width The width in pixels of the outline, 0 indicates no outline */ - void SetOutlineWidth( uint16_t width ); + void SetOutlineWidth(uint16_t width); /** * @brief Retrieves the width of an outline @@ -983,7 +1035,7 @@ public: // Default style & Input style * * @param[in] color color of background. */ - void SetBackgroundColor( const Vector4& color ); + void SetBackgroundColor(const Vector4& color); /** * @brief Retrieve the background color. @@ -997,7 +1049,7 @@ public: // Default style & Input style * * @param[in] enabled The background enabled flag. */ - void SetBackgroundEnabled( bool enabled ); + void SetBackgroundEnabled(bool enabled); /** * @brief Returns whether to enable text background or not. @@ -1013,7 +1065,7 @@ public: // Default style & Input style * * @param[in] embossProperties The emboss's properties string. */ - void SetDefaultEmbossProperties( const std::string& embossProperties ); + void SetDefaultEmbossProperties(const std::string& embossProperties); /** * @brief Retrieves the emboss's properties string. @@ -1029,7 +1081,7 @@ public: // Default style & Input style * * @param[in] outlineProperties The outline's properties string. */ - void SetDefaultOutlineProperties( const std::string& outlineProperties ); + void SetDefaultOutlineProperties(const std::string& outlineProperties); /** * @brief Retrieves the outline's properties string. @@ -1045,7 +1097,7 @@ public: // Default style & Input style * * @return True if lineSpacing has been updated, false otherwise */ - bool SetDefaultLineSpacing( float lineSpacing ); + bool SetDefaultLineSpacing(float lineSpacing); /** * @brief Retrieves the default line spacing. @@ -1055,11 +1107,27 @@ public: // Default style & Input style float GetDefaultLineSpacing() const; /** + * @brief Sets the default line size. + * + * @param[in] lineSize The line size. + * + * @return True if lineSize has been updated, false otherwise + */ + bool SetDefaultLineSize(float lineSize); + + /** + * @brief Retrieves the default line size. + * + * @return The line size. + */ + float GetDefaultLineSize() const; + + /** * @brief Sets the input text's color. * * @param[in] color The input text's color. */ - void SetInputColor( const Vector4& color ); + void SetInputColor(const Vector4& color); /** * @brief Retrieves the input text's color. @@ -1073,7 +1141,7 @@ public: // Default style & Input style * * @param[in] fontFamily The text's font family name. */ - void SetInputFontFamily( const std::string& fontFamily ); + void SetInputFontFamily(const std::string& fontFamily); /** * @brief Retrieves the input text's font family name. @@ -1087,7 +1155,7 @@ public: // Default style & Input style * * @param[in] weight The input font's weight. */ - void SetInputFontWeight( FontWeight weight ); + void SetInputFontWeight(FontWeight weight); /** * @return Whether the font's weight has been defined. @@ -1106,7 +1174,7 @@ public: // Default style & Input style * * @param[in] width The input font's width. */ - void SetInputFontWidth( FontWidth width ); + void SetInputFontWidth(FontWidth width); /** * @return Whether the font's width has been defined. @@ -1125,7 +1193,7 @@ public: // Default style & Input style * * @param[in] slant The input font's slant. */ - void SetInputFontSlant( FontSlant slant ); + void SetInputFontSlant(FontSlant slant); /** * @return Whether the font's slant has been defined. @@ -1144,7 +1212,7 @@ public: // Default style & Input style * * @param[in] size The input font's point size. */ - void SetInputFontPointSize( float size ); + void SetInputFontPointSize(float size); /** * @brief Retrieves the input font's point size. @@ -1158,7 +1226,7 @@ public: // Default style & Input style * * @param[in] lineSpacing The line spacing. */ - void SetInputLineSpacing( float lineSpacing ); + void SetInputLineSpacing(float lineSpacing); /** * @brief Retrieves the input line spacing. @@ -1174,7 +1242,7 @@ public: // Default style & Input style * * @param[in] shadowProperties The shadow's properties string. */ - void SetInputShadowProperties( const std::string& shadowProperties ); + void SetInputShadowProperties(const std::string& shadowProperties); /** * @brief Retrieves the input shadow's properties string. @@ -1190,7 +1258,7 @@ public: // Default style & Input style * * @param[in] underlineProperties The underline's properties string. */ - void SetInputUnderlineProperties( const std::string& underlineProperties ); + void SetInputUnderlineProperties(const std::string& underlineProperties); /** * @brief Retrieves the input underline's properties string. @@ -1206,7 +1274,7 @@ public: // Default style & Input style * * @param[in] embossProperties The emboss's properties string. */ - void SetInputEmbossProperties( const std::string& embossProperties ); + void SetInputEmbossProperties(const std::string& embossProperties); /** * @brief Retrieves the input emboss's properties string. @@ -1222,7 +1290,7 @@ public: // Default style & Input style * * @param[in] outlineProperties The outline's properties string. */ - void SetInputOutlineProperties( const std::string& outlineProperties ); + void SetInputOutlineProperties(const std::string& outlineProperties); /** * @brief Retrieves the input outline's properties string. @@ -1236,10 +1304,16 @@ public: // Default style & Input style * * @param[in] controlInterface The control's interface. */ - void SetControlInterface( ControlInterface* controlInterface ); + void SetControlInterface(ControlInterface* controlInterface); -public: // Queries & retrieves. + /** + * @brief Set the anchor control's interface. + * + * @param[in] anchorControlInterface The control's interface. + */ + void SetAnchorControlInterface(AnchorControlInterface* anchorControlInterface); +public: // Queries & retrieves. /** * @brief Return the layout engine. * @@ -1262,26 +1336,26 @@ public: // Queries & retrieves. /** * @copydoc Control::GetHeightForWidth() */ - float GetHeightForWidth( float width ); + float GetHeightForWidth(float width); /** * @brief Calculates the point size for text for given layout() */ - void FitPointSizeforLayout( Size layoutSize ); + void FitPointSizeforLayout(Size layoutSize); /** * @brief Checks if the point size fits within the layout size. * * @return Whether the point size fits within the layout size. */ - bool CheckForTextFit( float pointSize, Size& layoutSize ); + bool CheckForTextFit(float pointSize, Size& layoutSize); /** * @brief Retrieves the text's number of lines for a given width. * @param[in] width The width of the text's area. * @ return The number of lines. */ - int GetLineCount( float width ); + int GetLineCount(float width); /** * @brief Retrieves the text's model. @@ -1307,31 +1381,41 @@ public: // Queries & retrieves. * * @return Whether the text scroll position is changed or not after last update. */ - bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight ); + bool GetTextScrollInfo(float& scrollPosition, float& controlHeight, float& layoutHeight); /** * @brief Used to set the hidden input option */ - void SetHiddenInputOption( const Property::Map& options ); + void SetHiddenInputOption(const Property::Map& options); /** * @brief Used to get the hidden input option */ - void GetHiddenInputOption( Property::Map& options ); + void GetHiddenInputOption(Property::Map& options); + + /** + * @brief Used to set the input filter option + */ + void SetInputFilterOption(const Property::Map& options); + + /** + * @brief Used to get the input filter option + */ + void GetInputFilterOption(Property::Map& options); /** * @brief Sets the Placeholder Properties. * * @param[in] map The placeholder property map */ - void SetPlaceholderProperty( const Property::Map& map ); + void SetPlaceholderProperty(const Property::Map& map); /** * @brief Retrieves the Placeholder Property map. * * @param[out] map The property map */ - void GetPlaceholderProperty( Property::Map& map ); + void GetPlaceholderProperty(Property::Map& map); /** * @brief Checks text direction. @@ -1349,7 +1433,19 @@ public: // Queries & retrieves. * @brief Sets vertical line alignment * @param[in] alignment The vertical line alignment for the text */ - void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment ); + void SetVerticalLineAlignment(Toolkit::DevelText::VerticalLineAlignment::Type alignment); + + /** + * @brief Retrieves ellipsis position + * @return The ellipsis position + */ + Toolkit::DevelText::EllipsisPosition::Type GetEllipsisPosition() const; + + /** + * @brief Sets ellipsis position + * @param[in] ellipsisPosition The ellipsis position for the text + */ + void SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type ellipsisPosition); /** * @brief Retrieves ignoreSpaceAfterText value from model @@ -1361,25 +1457,37 @@ public: // Queries & retrieves. * @brief Sets ignoreSpaceAfterText value to model * @param[in] ignore The value of ignoreSpacesAfterText for the text */ - void SetIgnoreSpacesAfterText( bool ignore ); + void SetIgnoreSpacesAfterText(bool ignore); + + /** + * @brief Sets SetMatchLayoutDirection value to model + * @param[in] match The value of matchLayoutDirection for the text + */ + void SetMatchLayoutDirection(DevelText::MatchLayoutDirection type); + + /** + * @brief Retrieves matchLayoutDirection value from model + * @return The value of matchLayoutDirection + */ + DevelText::MatchLayoutDirection GetMatchLayoutDirection() const; /** - * @brief Retrieves matchSystemLanguageDirection value from model - * @return The value of matchSystemLanguageDirection + * @brief Sets layoutDirection type value. + * @param[in] layoutDirection The value of the layout direction type. */ - bool IsMatchSystemLanguageDirection() const; + void SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection); /** - * @brief Sets matchSystemLanguageDirection value to model - * @param[in] match The value of matchSystemLanguageDirection for the text + * @brief Gets layoutDirection type value. + * @param[in] actor The actor which will get the layout direction type. + * @return The value of the layout direction type. */ - void SetMatchSystemLanguageDirection( bool match ); + Dali::LayoutDirection::Type GetLayoutDirection(Dali::Actor& actor) const; /** - * @brief Sets layoutDirection value - * @param[in] layoutDirection The value of system language direction + * @brief Sets the layout direction changed. */ - void SetLayoutDirection( Dali::LayoutDirection::Type layoutDirection ); + void ChangedLayoutDirection(); /** * @brief Retrieves if showing real text or not. @@ -1388,7 +1496,6 @@ public: // Queries & retrieves. bool IsShowingRealText() const; public: // Relayout. - /** * @brief Triggers a relayout which updates View (if necessary). * @@ -1398,7 +1505,7 @@ public: // Relayout. * * @return Whether the text model or decorations were updated. */ - UpdateTextType Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT ); + UpdateTextType Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT); /** * @brief Request a relayout using the ControlInterface. @@ -1406,7 +1513,6 @@ public: // Relayout. void RequestRelayout(); public: // Input style change signals. - /** * @return Whether the queue of input style changed signals is empty. */ @@ -1421,7 +1527,6 @@ public: // Input style change signals. void ProcessInputStyleChangedSignals(); public: // Text-input Event Queuing. - /** * @brief Called by editable UI controls when keyboard focus is gained. */ @@ -1438,7 +1543,14 @@ public: // Text-input Event Queuing. * @param[in] event The key event. * @param[in] type Used to distinguish between regular key events and InputMethodContext events. */ - bool KeyEvent( const Dali::KeyEvent& event ); + bool KeyEvent(const Dali::KeyEvent& event); + + /** + * @brief Called by anchor when a tap gesture occurs. + * @param[in] x The x position relative to the top-left of the parent control. + * @param[in] y The y position relative to the top-left of the parent control. + */ + void AnchorEvent(float x, float y); /** * @brief Called by editable UI controls when a tap gesture occurs. @@ -1446,7 +1558,7 @@ public: // Text-input Event Queuing. * @param[in] x The x position relative to the top-left of the parent control. * @param[in] y The y position relative to the top-left of the parent control. */ - void TapEvent( unsigned int tapCount, float x, float y ); + void TapEvent(unsigned int tapCount, float x, float y); /** * @brief Called by editable UI controls when a pan gesture occurs. @@ -1454,7 +1566,7 @@ public: // Text-input Event Queuing. * @param[in] state The state of the gesture. * @param[in] displacement This distance panned since the last pan gesture. */ - void PanEvent( Gesture::State state, const Vector2& displacement ); + void PanEvent(GestureState state, const Vector2& displacement); /** * @brief Called by editable UI controls when a long press gesture occurs. @@ -1463,7 +1575,22 @@ public: // Text-input Event Queuing. * @param[in] x The x position relative to the top-left of the parent control. * @param[in] y The y position relative to the top-left of the parent control. */ - void LongPressEvent( Gesture::State state, float x, float y ); + void LongPressEvent(GestureState state, float x, float y); + + /** + * @brief Used to get the Primary cursor position. + * + * @return Primary cursor position. + */ + CharacterIndex GetPrimaryCursorPosition() const; + + /** + * @brief Used to set the Primary cursor position. + * + * @param[in] index for the Primary cursor position. + * @return[in] true if cursor position changed, false otherwise. + */ + bool SetPrimaryCursorPosition(CharacterIndex index); /** * @brief Creates a selection event. @@ -1474,7 +1601,57 @@ public: // Text-input Event Queuing. * @param[in] y The y position relative to the top-left of the parent control. * @param[in] selection type like the whole text is selected or unselected. */ - void SelectEvent( float x, float y, SelectionType selection ); + void SelectEvent(float x, float y, SelectionType selection); + + /** + * @copydoc Text::SelectableControlInterface::SetTextSelectionRange() + */ + void SetTextSelectionRange(const uint32_t* start, const uint32_t* end); + + /** + * @copydoc Text::SelectableControlInterface::GetTextSelectionRange() + */ + Uint32Pair GetTextSelectionRange() const; + + /** + * @copydoc Text::SelectableControlInterface::SelectWholeText() + */ + void SelectWholeText(); + + /** + * @copydoc Text::SelectableControlInterface::SelectNone() + */ + void SelectNone(); + + /** + * @copydoc Text::SelectableControlInterface::GetSelectedText() + */ + string GetSelectedText() const; + + /** + * @copydoc Text::EditableControlInterface::IsEditable() + */ + virtual bool IsEditable() const; + + /** + * @copydoc Text::EditableControlInterface::SetEditable() + */ + virtual void SetEditable(bool editable); + + /** + * @copydoc Dali::Toolkit::Internal::TextEditor::ScrollBy() + */ + virtual void ScrollBy(Vector2 scroll); + + /** + * @copydoc Dali::Toolkit::Internal::TextEditor::GetHorizontalScrollPosition() + */ + float GetHorizontalScrollPosition(); + + /** + * @copydoc Dali::Toolkit::Internal::TextEditor::GetVerticalScrollPosition() + */ + float GetVerticalScrollPosition(); /** * @brief Event received from input method context @@ -1483,7 +1660,7 @@ public: // Text-input Event Queuing. * @param[in] inputMethodContextEvent The event received. * @return A data struture indicating if update is needed, cursor position and current text. */ - InputMethodContext::CallbackData OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent ); + InputMethodContext::CallbackData OnInputMethodContextEvent(InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent); /** * @brief Event from Clipboard notifying an Item has been selected for pasting @@ -1505,58 +1682,60 @@ public: // Text-input Event Queuing. Actor CreateBackgroundActor(); /** - * @brief Retrive Selected text. + * @brief Used to reset the cursor position after setting a new text. * - * @return The seleced text. + * @param[in] cursorIndex Where to place the cursor. */ - std::string GetSelectedText(); + void ResetCursorPosition(CharacterIndex cursorIndex); -protected: // Inherit from Text::Decorator::ControllerInterface. + /** + * @brief The method acquires current position of cursor + * @return unsigned value with cursor position + */ + CharacterIndex GetCursorPosition(); +protected: // Inherit from Text::Decorator::ControllerInterface. /** * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize() */ - virtual void GetTargetSize( Vector2& targetSize ); + void GetTargetSize(Vector2& targetSize) override; /** * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration() */ - virtual void AddDecoration( Actor& actor, bool needsClipping ); + void AddDecoration(Actor& actor, bool needsClipping) override; /** * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent() */ - virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y ); + void DecorationEvent(HandleType handle, HandleState state, float x, float y) override; protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface. - /** * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched() */ - virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button ); + void TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::Buttons button) override; protected: // Inherit from HiddenText. - /** * @brief Invoked from HiddenText when showing time of the last character was expired */ - virtual void DisplayTimeExpired(); + void DisplayTimeExpired() override; private: // Update. - /** * @brief Called by editable UI controls when key events are received. * * @param[in] text The text to insert. * @param[in] type Used to distinguish between regular key events and InputMethodContext events. */ - void InsertText( const std::string& text, InsertType type ); + void InsertText(const std::string& text, InsertType type); /** * @brief Paste given string into Text model * @param[in] stringToPaste this string will be inserted into the text model */ - void PasteText( const std::string& stringToPaste ); + void PasteText(const std::string& stringToPaste); /** * @brief Remove a given number of characters @@ -1570,9 +1749,9 @@ private: // Update. * @param[in] type Whether to update the input style. * @return True if the remove was successful. */ - bool RemoveText( int cursorOffset, - int numberOfCharacters, - UpdateInputStyleType type ); + bool RemoveText(int cursorOffset, + int numberOfCharacters, + UpdateInputStyleType type); /** * @brief Checks if text is selected and if so removes it. @@ -1580,8 +1759,27 @@ private: // Update. */ bool RemoveSelectedText(); -private: // Relayout. + /** + * @brief Update anchor position from given number of inserted characters. + * + * @param[in] numberOfCharacters The number of inserted characters. + * @param[in] previousCursorIndex A cursor position before event occurs. + */ + void InsertTextAnchor(int numberOfCharacters, + CharacterIndex previousCursorIndex); + + /** + * @brief Update anchor position from given number of removed characters. + * + * @param[in] cursorOffset Start position from the current cursor position to start deleting characters. + * @param[in] numberOfCharacters The number of removed characters. + * @param[in] previousCursorIndex A cursor position before event occurs. + */ + void RemoveTextAnchor(int cursorOffset, + int numberOfCharacters, + CharacterIndex previousCursorIndex); +private: // Relayout. /** * @brief Lays-out the text. * @@ -1591,19 +1789,18 @@ private: // Relayout. * @param[in] operations The layout operations which need to be done. * @param[out] layoutSize The size of the laid-out text. */ - bool DoRelayout( const Size& size, - OperationsMask operations, - Size& layoutSize ); + bool DoRelayout(const Size& size, + OperationsMask operations, + Size& layoutSize); /** * @brief Calulates the vertical offset to align the text inside the bounding box. * * @param[in] size The size of the bounding box. */ - void CalculateVerticalOffset( const Size& size ); + void CalculateVerticalOffset(const Size& size); private: // Events. - /** * @brief Process queued events which modify the model. */ @@ -1630,10 +1827,9 @@ private: // Events. * @param[in] keyCode The keycode for the key pressed * @return True if a character was deleted. */ - bool DeleteEvent( int keyCode ); + bool DeleteEvent(int keyCode); private: // Helpers. - /** * @brief Used to remove the text included the placeholder text. */ @@ -1655,19 +1851,11 @@ private: // Helpers. void ClearStyleData(); /** - * @brief Used to reset the cursor position after setting a new text. - * - * @param[in] cursorIndex Where to place the cursor. - */ - void ResetCursorPosition( CharacterIndex cursorIndex ); - - /** * @brief Used to reset the scroll position after setting a new text. */ void ResetScrollPosition(); private: // Private contructors & copy operator. - /** * @brief Private constructor. */ @@ -1676,32 +1864,37 @@ private: // Private contructors & copy operator. /** * @brief Private constructor. */ - Controller( ControlInterface* controlInterface ); + Controller(ControlInterface* controlInterface); /** * @brief Private constructor. */ - Controller( ControlInterface* controlInterface, - EditableControlInterface* editableControlInterface ); + Controller(ControlInterface* controlInterface, + EditableControlInterface* editableControlInterface, + SelectableControlInterface* selectableControlInterface, + AnchorControlInterface* anchorControlInterface); // Undefined - Controller( const Controller& handle ); + Controller(const Controller& handle); // Undefined - Controller& operator=( const Controller& handle ); + Controller& operator=(const Controller& handle); protected: // Destructor. - /** * @brief A reference counted object may only be deleted by calling Unreference(). */ virtual ~Controller(); public: - struct Impl; ///< Made public for testing purposes private: + struct EventHandler; + struct InputFontHandler; + struct PlaceholderHandler; + struct Relayouter; + struct TextUpdater; Impl* mImpl; };