X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fcontroller%2Ftext-controller.h;h=b8ff325264a6ad0e9ee15dfa213ee3078c772941;hb=HEAD;hp=09305d252796da4c87e9083a27e3c412fc64ec06;hpb=020b07151378db83ab8e12eb3e2d51db0ed69996;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/controller/text-controller.h b/dali-toolkit/internal/text/controller/text-controller.h index 09305d2..20ad0f0 100644 --- a/dali-toolkit/internal/text/controller/text-controller.h +++ b/dali-toolkit/internal/text/controller/text-controller.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -19,7 +19,10 @@ */ // EXTERNAL INCLUDES +#include +#include #include +#include #include // INTERNAL INCLUDES @@ -68,7 +71,12 @@ typedef IntrusivePtr ControllerPtr; * * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface. */ -class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer +class Controller : public RefObject, + public Decorator::ControllerInterface, + public TextSelectionPopupCallbackInterface, + public HiddenText::Observer, + public ConnectionTracker, + public Integration::Processor { public: // Enumerated types. /** @@ -433,6 +441,20 @@ public: // Configure the text controller. bool IsTextFitEnabled() const; /** + * @brief Sets current line size. + * + * @param[in] lineSize line size value to store the MinLineSize set by user when TextFitArray is enabled. + */ + void SetCurrentLineSize(float lineSize); + + /** + * @brief Retrieves the current line size. + * + * @return The current line size + */ + float GetCurrentLineSize() const; + + /** * @brief Sets minimum size valid for text fit. * * @param[in] minimum size value. @@ -513,6 +535,41 @@ public: // Configure the text controller. bool IsTextFitChanged() const; /** + * @brief Sets line size valid for text fit. + * + * @param[in] lineSize line size value + */ + void SetTextFitLineSize(float lineSize); + + /** + * @brief Enable or disable the text fit array. + * + * @param[in] enabled Whether to enable the text fit array. + */ + void SetTextFitArrayEnabled(bool enabled); + + /** + * @brief Whether the text fit array is enabled or not. + * + * @return True if the text fit array is enabled. + */ + bool IsTextFitArrayEnabled() const; + + /** + * @brief Sets the text fit array. + * + * @param[in] fitOptions The list of text fit options. + */ + void SetTextFitArray(std::vector& fitOptions); + + /** + * @brief Retrieve the text fit array. + * + * @return The list of text fit options. + */ + std::vector& GetTextFitArray(); + + /** * @brief Sets disabled color opacity. * * @param[in] opacity The color opacity value in disabled state. @@ -753,6 +810,22 @@ public: // Update. void GetText(std::string& text) const; /** + * @brief Retrieves number of characters previously set. + * + * @return A length of string of UTF-32 characters. + */ + Length GetNumberOfCharacters() const; + + /** + * @brief Set the @p spannedText + * the spanned text contains content (text) and format (spans with ranges) + * the text is copied into text-controller and the spans are applied on ranges + * + * @param[in] spannedText the text with spans. + */ + void SetSpannedText(const Text::Spanned& spannedText); + + /** * @brief Replaces any placeholder text previously set. * * @param[in] type Different placeholder-text can be shown when the control is active/inactive. @@ -819,7 +892,7 @@ public: // Default style & Input style * * @return The default font family. */ - const std::string& GetDefaultFontFamily() const; + std::string GetDefaultFontFamily() const; /** * @brief Sets the placeholder text font family. @@ -832,7 +905,7 @@ public: // Default style & Input style * * @return The placeholder text font family */ - const std::string& GetPlaceholderFontFamily() const; + std::string GetPlaceholderFontFamily() const; /** * @brief Sets the default font weight. @@ -1027,6 +1100,34 @@ public: // Default style & Input style const Vector4& GetDefaultColor() const; /** + * @brief Sets the anchor's default color. + * + * @param color The anchor color. + */ + void SetAnchorColor(const Vector4& color); + + /** + * @brief Retrieves the anchor's default color. + * + * @return The anchor color. + */ + const Vector4& GetAnchorColor() const; + + /** + * @brief Sets the anchor's clicked color. + * + * @param color The anchor color. + */ + void SetAnchorClickedColor(const Vector4& color); + + /** + * @brief Retrieves the anchor's clicked color. + * + * @return The anchor color. + */ + const Vector4& GetAnchorClickedColor() const; + + /** * @brief Sets the user interaction enabled. * * @param enabled whether to enable the user interaction. @@ -1179,6 +1280,20 @@ public: // Default style & Input style float GetDashedUnderlineGap() const; /** + * @brief Set the outline offset. + * + * @param[in] outlineOffset The outline offset. + */ + void SetOutlineOffset(const Vector2& outlineOffset); + + /** + * @brief Retrieve the outline offset. + * + * @return The outline offset. + */ + const Vector2& GetOutlineOffset() const; + + /** * @brief Set the outline color. * * @param[in] color color of outline. @@ -1207,6 +1322,20 @@ public: // Default style & Input style uint16_t GetOutlineWidth() const; /** + * @brief Set the outline blur radius. + * + * @param[in] outlineBlurRadius The outline blur radius, 0,0 indicates no blur. + */ + void SetOutlineBlurRadius(const float& outlineBlurRadius); + + /** + * @brief Retrieve the outline blur radius. + * + * @return The outline blur radius. + */ + const float& GetOutlineBlurRadius() const; + + /** * @brief Set the background color. * * @param[in] color color of background. @@ -1248,7 +1377,7 @@ public: // Default style & Input style * * @return The emboss's properties string. */ - const std::string& GetDefaultEmbossProperties() const; + std::string GetDefaultEmbossProperties() const; /** * @brief Sets the outline's properties string. @@ -1264,7 +1393,7 @@ public: // Default style & Input style * * @return The outline's properties string. */ - const std::string& GetDefaultOutlineProperties() const; + std::string GetDefaultOutlineProperties() const; /** * @brief Sets the default line spacing. @@ -1340,7 +1469,7 @@ public: // Default style & Input style * * @return The input text's font family name. */ - const std::string& GetInputFontFamily() const; + std::string GetInputFontFamily() const; /** * @brief Sets the input font's weight. @@ -1403,8 +1532,9 @@ public: // Default style & Input style * @brief Sets the input font's point size. * * @param[in] size The input font's point size. + * @param[in] defaultFontSizeUpdated True If the default font size is updated and sets the input point size, false otherwise. */ - void SetInputFontPointSize(float size); + void SetInputFontPointSize(float size, bool defaultFontSizeUpdated = false); /** * @brief Retrieves the input font's point size. @@ -1441,7 +1571,7 @@ public: // Default style & Input style * * @return The shadow's properties string. */ - const std::string& GetInputShadowProperties() const; + std::string GetInputShadowProperties() const; /** * @brief Sets the input underline's properties string. @@ -1457,7 +1587,7 @@ public: // Default style & Input style * * @return The underline's properties string. */ - const std::string& GetInputUnderlineProperties() const; + std::string GetInputUnderlineProperties() const; /** * @brief Sets the input emboss's properties string. @@ -1473,7 +1603,7 @@ public: // Default style & Input style * * @return The emboss's properties string. */ - const std::string& GetInputEmbossProperties() const; + std::string GetInputEmbossProperties() const; /** * @brief Sets input the outline's properties string. @@ -1489,7 +1619,7 @@ public: // Default style & Input style * * @return The outline's properties string. */ - const std::string& GetInputOutlineProperties() const; + std::string GetInputOutlineProperties() const; /** * @brief Sets the input strikethrough's properties string. @@ -1505,7 +1635,7 @@ public: // Default style & Input style * * @return The strikethrough's properties string. */ - const std::string& GetInputStrikethroughProperties() const; + std::string GetInputStrikethroughProperties() const; /** * @brief Set the control's interface. @@ -1539,6 +1669,41 @@ public: // Default style & Input style */ const float GetCharacterSpacing() const; + /** + * @brief Sets the visual transform offset. + * + * @param[in] offset The offset. + */ + void SetVisualTransformOffset(Vector2 offset); + + /** + * @brief Sets whether background color with cutout is enabled. + * + * @param[in] enable True if enabled. + */ + void SetBackgroundWithCutoutEnabled(bool enable); + + /** + * @brief Whether background color with cutout is enabled. + * + * @return True if enabled. + */ + bool IsBackgroundWithCutoutEnabled() const; + + /** + * @brief Sets whether background color with cutout. + * + * @param[in] color The color to set. + */ + void SetBackgroundColorWithCutout(const Vector4& color); + + /** + * @brief Retrieves background color with cutout. + * + * @return The color. + */ + const Vector4 GetBackgroundColorWithCutout() const; + public: // Queries & retrieves. /** * @brief Return the layout engine. @@ -1570,6 +1735,11 @@ public: // Queries & retrieves. void FitPointSizeforLayout(Size layoutSize); /** + * @brief Calculates the point size for text for given layout() using fit array. + */ + void FitArrayPointSizeforLayout(Size layoutSize); + + /** * @brief Checks if the point size fits within the layout size. * * @return Whether the point size fits within the layout size. @@ -1588,7 +1758,7 @@ public: // Queries & retrieves. * * @return A pointer to the text's model. */ - const ModelInterface* const GetTextModel() const; + const ModelInterface* GetTextModel() const; /** * @brief Used to get scrolled distance by user input @@ -1686,6 +1856,42 @@ public: // Queries & retrieves. void SetIgnoreSpacesAfterText(bool ignore); /** + * @brief Retrieves removeFrontInset value from model + * @return The value of removeFrontInset + */ + bool IsRemoveFrontInset() const; + + /** + * @brief Sets removeFrontInset value to model + * @param[in] remove The value of removeFrontInset for the text + */ + void SetRemoveFrontInset(bool remove); + + /** + * @brief Retrieves removeBackInset value from model + * @return The value of removeBackInset + */ + bool IsRemoveBackInset() const; + + /** + * @brief Sets removeBackInset value to model + * @param[in] remove The value of removeBackInset for the text + */ + void SetRemoveBackInset(bool remove); + + /** + * @brief Retrieves cutout value to model + * @return The value of cutout for the text + */ + bool IsTextCutout() const; + + /** + * @brief Sets cutout value to model + * @param[in] cutout The value of cutout for the text + */ + void SetTextCutout(bool cutout); + + /** * @brief Sets SetMatchLayoutDirection value to model * @param[in] match The value of matchLayoutDirection for the text */ @@ -1733,6 +1939,34 @@ public: // Queries & retrieves. Vector GetTextPosition(CharacterIndex startIndex, CharacterIndex endIndex); /** + * @brief Get the line bounding rectangle. + * if the requested index is out of range or the line is not yet rendered, a rect of {0, 0, 0, 0} is returned. + * + * @param[in] lineIndex line index to which we want to calculate the geometry for. + * @return bounding rectangle. + */ + Rect GetLineBoundingRectangle(const uint32_t lineIndex); + + /** + * @brief Get the char bounding rectangle. + * If the text is not yet rendered or the index > text.Count(); a rect of {0, 0, 0, 0} is returned. + * + * @param[in] charIndex character index to which we want to calculate the geometry for. + * @return bounding rectangle. + */ + Rect GetCharacterBoundingRectangle(const uint32_t charIndex); + + /** + * @brief Get the character index. + * If the text is not yet rendered or the text is empty, -1 is returned. + * + * @param[in] visualX visual x position. + * @param[in] visualY visual y position. + * @return character index. + */ + int GetCharacterIndexAtPosition(float visualX, float visualY); + + /** * @brief Gets the bounding box of a specific text range. * * @param[in] startIndex start index of the text requested to get bounding box to. @@ -1747,6 +1981,11 @@ public: // Queries & retrieves. void ChangedLayoutDirection(); /** + * @brief Clear font and style data. + */ + void ResetFontAndStyleData(); + + /** * @brief Retrieves if showing real text or not. * @return The value of showing real text. */ @@ -1776,12 +2015,22 @@ public: // Input style change signals. bool IsInputStyleChangedSignalsQueueEmpty(); /** - * @brief Process all pending input style changed signals. + * @brief Request process all pending input style changed signals. * - * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the + * Request to calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the * text controls. Text controls may send signals to state the input style has changed. + * + * The signal will be execute next idle time, or skip if we fail to add idler. */ - void ProcessInputStyleChangedSignals(); + void RequestProcessInputStyleChangedSignals(); + +private: + /** + * @brief Callbacks called on idle. + * + * If there are notifications of change of input style on the queue, Toolkit::TextField::InputStyleChangedSignal() are emitted. + */ + void OnIdleSignal(); public: // Text-input Event Queuing. /** @@ -1948,8 +2197,14 @@ public: // Text-input Event Queuing. /** * @brief Event from Clipboard notifying an Item has been selected for pasting + * + * @param[in] id The id of the data request. + * @param[in] mimeType The mime type of data received. + * @param[in] data The data received. + * @note + * This event is executed by receiving the Clipboard's DataReceivedSignal. */ - void PasteClipboardItemEvent(); + void PasteClipboardItemEvent(uint32_t id, const char* mimeType, const char* data); /** * @brief Return true when text control should clear key input focus when escape key is pressed. @@ -2022,6 +2277,20 @@ protected: // Inherit from HiddenText. */ void DisplayTimeExpired() override; +protected: // Inherit from Integration::Processor + /** + * @copydoc Dali::Integration::Processor::Process() + */ + void Process(bool postProcess) override; + + /** + * @copydoc Dali::Integration::Processor::GetProcessorName() + */ + std::string_view GetProcessorName() const override + { + return "Text::Controller"; + } + private: // Private contructors & copy operator. /** * @brief Private constructor. @@ -2066,8 +2335,9 @@ private: struct PlaceholderHandler; struct Relayouter; struct TextUpdater; + struct SpannableHandler; - Impl* mImpl; + std::unique_ptr mImpl{nullptr}; }; } // namespace Dali::Toolkit::Text