X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fvisual-model-impl.h;h=eebbe18c1108ab97d7b473c709eee6e7913cf8b9;hp=6a96094edcd39dfd4566399f9d6c2d22ba25c6f4;hb=HEAD;hpb=fb87251cfeff34418a36798700b81786e522018a diff --git a/dali-toolkit/internal/text/visual-model-impl.h b/dali-toolkit/internal/text/visual-model-impl.h index 6a96094..7ef55b5 100644 --- a/dali-toolkit/internal/text/visual-model-impl.h +++ b/dali-toolkit/internal/text/visual-model-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_VISUAL_MODEL_IMPL_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -26,8 +26,12 @@ #include // INTERNAL INCLUDES +#include #include #include +#include +#include +#include // DEVEL INCLUDES #include @@ -140,6 +144,15 @@ public: Length& numberOfLines) const; /** + * @brief Retrieves the line index where the glyph is laid-out. + * + * @param[in] glyphIndex The glyph's index. + * + * @return The line index. + */ + LineIndex GetLineOfGlyph(GlyphIndex glyphIndex); + + /** * @brief Retrieves the lines where the given range of glyphs is laid out. * * The size of the @p lines buffer needs to be big enough to copy the @p numberOfLines. @@ -170,9 +183,9 @@ public: * @param[in] index Index of the first underline run to be copied. * @param[in] numberOfRuns Number of underline runs to be copied. */ - void GetUnderlineRuns(GlyphRun* underlineRuns, - UnderlineRunIndex index, - Length numberOfRuns) const; + void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, + UnderlineRunIndex index, + Length numberOfRuns) const; // Size interface @@ -205,6 +218,20 @@ public: const Vector2& GetLayoutSize() const; /** + * @brief Sets the size of height for width. + * + * @param[in] size The text's height for width size. + */ + void SetHeightForWidth(const Vector2& size); + + /** + * @brief Retrieves the height for width size. + * + * @return The text's height for width size. + */ + const Vector2& GetHeightForWidth() const; + + /** * @brief Set the text's color * * @param[in] textColor The text's color @@ -301,6 +328,27 @@ public: void SetUnderlineHeight(float height); /** + * @brief Set the override used for underline type. + * + * @param[in] underlineType The type of the underline. + */ + void SetUnderlineType(Text::Underline::Type type); + + /** + * @brief Set the override used for the width of the dashes of the dashed underline. + * + * @param[in] width width of the dashes. + */ + void SetDashedUnderlineWidth(float width); + + /** + * @brief Set the override used for the gap between the dashes of the dashed underline. + * + * @param[in] gap gap between the dashes. + */ + void SetDashedUnderlineGap(float gap); + + /** * @brief Retrieves the underline height override * * @return Returns the override height for an underline, 0 indicates that font metrics will determine the height @@ -308,6 +356,27 @@ public: float GetUnderlineHeight() const; /** + * @brief Retrieves the underline type override. + * + * @return Returns the override type for the underline. + */ + Text::Underline::Type GetUnderlineType() const; + + /** + * @brief Retrieves the dashed underline width. + * + * @return Returns the override width for the dashed underline. + */ + float GetDashedUnderlineWidth() const; + + /** + * @brief Retrieves the dashed underline gap. + * + * @return Returns the override gap for the dashed underline. + */ + float GetDashedUnderlineGap() const; + + /** * @brief Retrieves the number of underline runs. * * @return The number of underline runs. @@ -315,6 +384,13 @@ public: Length GetNumberOfUnderlineRuns() const; /** + * @brief Sets the text's outline offset. + * + * @param[in] outlineOffset The outline offset. + */ + void SetOutlineOffset(const Vector2& outlineOffset); + + /** * @brief Set the outline color. * * @param[in] color color of outline. @@ -322,6 +398,13 @@ public: void SetOutlineColor(const Vector4& color); /** + * @brief Retrieves the text's outline offset. + * + * @return The text's outline offset. + */ + const Vector2& GetOutlineOffset() const; + + /** * @brief Retrieve the outline color. * * @return The outline color. @@ -343,6 +426,20 @@ public: 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 Sets the text's background color. * * @param[in] color The text's background color. @@ -508,6 +605,104 @@ public: * @return Returns the override height for a strikethrough, 0 indicates that font metrics will determine the height */ float GetStrikethroughHeight() const; + /** + * @brief Set the override used for character spacing. + * + * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed). + * + * @param[in] characterSpacing The character spacing. + */ + void SetCharacterSpacing(float characterSpacing); + + /** + * @brief Retrieves the characterSpacing. + * + * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed). + * + * @return Returns the characterSpacing. + */ + const float GetCharacterSpacing() const; + + /** + * @brief Retrieves the Glyphs to Characters Array. + * + * @return The GlyphsToCharacters. + */ + const Vector& GetGlyphsToCharacters() const; + + /** + * @brief Retrieves the strikethrough runs. + * + * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied. + * @param[in] index Index of the first strikethrough run to be copied. + * @param[in] numberOfRuns Number of strikethrough runs to be copied. + */ + void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, + StrikethroughRunIndex index, + Length numberOfRuns) const; + + /** + * @brief Retrieves the number of strikethrough runs. + * + * @return The number of strikethrough runs. + */ + Length GetNumberOfStrikethroughRuns() const; + + /** + * @brief Retrieves the number of character-spacing glyph runs. + * + * @return The number of character-spacing glyph runs. + */ + Length GetNumberOfCharacterSpacingGlyphRuns() const; + + /** + * @brief Retrieves the reference for character-spacing glyph runs. + * + * @return The reference for character-spacing glyph runs. + */ + const Vector& GetCharacterSpacingGlyphRuns() const; + + /** + * @brief Sets the cutout flag. + * + * @param[in] enable true if cutouted. + */ + void SetCutoutEnabled(bool enable); + + /** + * @brief Returns whether the text is cutouted or not. + * + * @return cutout state. + */ + bool IsCutoutEnabled() const; + + /** + * @brief Sets the background with cutout flag. + * + * @param[in] enable true if background enabled. + */ + void SetBackgroundWithCutoutEnabled(bool enable); + + /** + * @brief Returns whether the text is cutouted or not. + * + * @return True if enabled. + */ + bool IsBackgroundWithCutoutEnabled() const; + + /** + * @brief Sets the Color of background with cutout. + * + * @param[in] color The color to set. + */ + void SetBackgroundColorWithCutout(const Vector4& color); + + /** + * @brief Retrieves the Color of background with cutout. + * + * @return The color. + */ + const Vector4& GetBackgroundColorWithCutout() const; protected: /** @@ -528,35 +723,43 @@ private: VisualModel& operator=(const VisualModel& handle); public: - Vector mGlyphs; ///< For each glyph, the font's id, glyph's index within the font and glyph's metrics. - Vector mGlyphsToCharacters; ///< For each glyph, the index of the first character. - Vector mCharactersToGlyph; ///< For each character, the index of the first glyph. - Vector mCharactersPerGlyph; ///< For each glyph, the number of characters that form the glyph. - Vector mGlyphsPerCharacter; ///< For each character, the number of glyphs that are shaped. - Vector mGlyphPositions; ///< For each glyph, the position. - Vector mLines; ///< The laid out lines. - Vector mUnderlineRuns; ///< Runs of glyphs that are underlined. - Vector mColors; ///< Colors of the glyphs. - Vector mColorIndices; ///< Indices to the vector of colors for each glyphs. - Vector mBackgroundColors; ///< Background colors of the glyphs. - Vector mBackgroundColorIndices; ///< Indices to the vector of background colors for each glyphs. - - Vector4 mTextColor; ///< The text color - Vector4 mShadowColor; ///< Color of drop shadow - Vector4 mUnderlineColor; ///< Color of underline - Vector4 mOutlineColor; ///< Color of outline - Vector4 mBackgroundColor; ///< Color of text background - Vector4 mStrikethroughColor; ///< Color of text background - Size mControlSize; ///< The size of the UI control. - Vector2 mShadowOffset; ///< Offset for drop shadow, 0 indicates no shadow - float mUnderlineHeight; ///< Fixed height for underline to override font metrics. - float mStrikethroughHeight; ///< Fixed height for strikethrough to override font metrics. - float mShadowBlurRadius; ///< Blur radius of shadow, 0 indicates no blur. - uint16_t mOutlineWidth; ///< Width of outline. + Vector mGlyphs; ///< For each glyph, the font's id, glyph's index within the font and glyph's metrics. + Vector mGlyphsToCharacters; ///< For each glyph, the index of the first character. + Vector mCharactersToGlyph; ///< For each character, the index of the first glyph. + Vector mCharactersPerGlyph; ///< For each glyph, the number of characters that form the glyph. + Vector mGlyphsPerCharacter; ///< For each character, the number of glyphs that are shaped. + Vector mGlyphPositions; ///< For each glyph, the position. + Vector mLines; ///< The laid out lines. + Vector mUnderlineRuns; ///< Runs of glyphs that are underlined. + Vector mColors; ///< Colors of the glyphs. + Vector mColorIndices; ///< Indices to the vector of colors for each glyphs. + Vector mBackgroundColors; ///< Background colors of the glyphs. + Vector mBackgroundColorIndices; ///< Indices to the vector of background colors for each glyphs. + Vector4 mTextColor; ///< The text color + Vector4 mShadowColor; ///< Color of drop shadow + Vector4 mUnderlineColor; ///< Color of underline + Vector4 mOutlineColor; ///< Color of outline + Vector4 mBackgroundColor; ///< Color of text background + Vector4 mStrikethroughColor; ///< Color of text background + Size mControlSize; ///< The size of the UI control. + Vector2 mShadowOffset; ///< Offset for drop shadow, 0 indicates no shadow + Vector2 mOutlineOffset; ///< Offset for outline + float mUnderlineHeight; ///< Fixed height for underline to override font metrics. + float mStrikethroughHeight; ///< Fixed height for strikethrough to override font metrics. + Text::Underline::Type mUnderlineType; ///< The type of the underline. + float mDashedUnderlineWidth; ///< The width of the dashes of the dashed underline. + float mDashedUnderlineGap; ///< The gap between the dashes of the dashed underline. + float mShadowBlurRadius; ///< Blur radius of shadow, 0 indicates no blur. + float mOutlineBlurRadius; ///< Blur radius of outline, 0 indicates no blur. + uint16_t mOutlineWidth; ///< Width of outline. + Vector mStrikethroughRuns; ///< Runs of glyphs that have strikethrough. + Vector mCharacterSpacingRuns; ///< Runs of glyphs that have character-spacing. + Vector4 mBackgroundColorWithCutout; ///< Background color with cutout. private: - Size mNaturalSize; ///< Size of the text with no line wrapping. - Size mLayoutSize; ///< Size of the laid-out text considering the layout properties set. + Size mNaturalSize; ///< Size of the text with no line wrapping. + Size mLayoutSize; ///< Size of the laid-out text considering the layout properties set. + Size mHeightForWidth; ///< Size of the text last calculated using GetHeightForWidth. // Caches to increase performance in some consecutive operations. LineIndex mCachedLineIndex; ///< Used to increase performance in consecutive calls to GetLineOfGlyph() or GetLineOfCharacter() with consecutive glyphs or characters. @@ -569,12 +772,15 @@ private: bool mTextElideEnabled : 1; ///< Whether the text's elide is enabled. public: - bool mUnderlineEnabled : 1; ///< Underline enabled flag - bool mUnderlineColorSet : 1; ///< Has the underline color been explicitly set? - bool mBackgroundEnabled : 1; ///< Background enabled flag - bool mMarkupProcessorEnabled : 1; ///< Markup-processor enabled flag - HyphenInfo mHyphen; ///< Contains hyphen glyph info & the character index to draw hyphen after. - bool mStrikethroughEnabled : 1; ///< Strikethrough enabled flag + bool mUnderlineEnabled : 1; ///< Underline enabled flag + bool mUnderlineColorSet : 1; ///< Has the underline color been explicitly set? + bool mBackgroundEnabled : 1; ///< Background enabled flag + bool mMarkupProcessorEnabled : 1; ///< Markup-processor enabled flag + HyphenInfo mHyphen; ///< Contains hyphen glyph info & the character index to draw hyphen after. + bool mStrikethroughEnabled : 1; ///< Strikethrough enabled flag + float mCharacterSpacing; ///< Contains the value of the character spacing. + bool mCutoutEnabled : 1; ///< Cutout enabled flag + bool mBackgroundWithCutoutEnabled : 1; ///< Background with cutout enabled flag. }; } // namespace Text