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=b024307cd7e0bbe30b3eb117caa5f8a5454e278e;hb=4bc73f2e78812b262f09830bb2b1d87034f34496;hpb=534e542d7dcc1a1507a0e5e6845d49c06a15d326 diff --git a/dali-toolkit/internal/text/visual-model-impl.h b/dali-toolkit/internal/text/visual-model-impl.h index b024307..eebbe18 100644 --- a/dali-toolkit/internal/text/visual-model-impl.h +++ b/dali-toolkit/internal/text/visual-model-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_TEXT_VISUAL_MODEL_IMPL_H__ -#define __DALI_TOOLKIT_TEXT_VISUAL_MODEL_IMPL_H__ +#ifndef DALI_TOOLKIT_TEXT_VISUAL_MODEL_IMPL_H +#define DALI_TOOLKIT_TEXT_VISUAL_MODEL_IMPL_H /* - * Copyright (c) 2015 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,17 +26,28 @@ #include // INTERNAL INCLUDES -#include +#include #include +#include +#include +#include +#include + +// DEVEL INCLUDES +#include namespace Dali { - namespace Toolkit { - namespace Text { +struct HyphenInfo +{ + Vector glyph; + Vector position; + Vector index; +}; class VisualModel; typedef IntrusivePtr VisualModelPtr; @@ -51,7 +62,6 @@ typedef IntrusivePtr VisualModelPtr; class VisualModel : public RefObject { public: - /** * @brief Create a new instance of a VisualModel. * @@ -70,9 +80,9 @@ public: * @param[in] startGlyphIndex The glyph from where the conversion table is created. * @param[in] numberOfCharacters The number of characters. */ - void CreateCharacterToGlyphTable( CharacterIndex startIndex, - GlyphIndex startGlyphIndex, - Length numberOfCharacters ); + void CreateCharacterToGlyphTable(CharacterIndex startIndex, + GlyphIndex startGlyphIndex, + Length numberOfCharacters); /** * @brief Creates an array containing the number of glyphs per character. @@ -81,9 +91,9 @@ public: * @param[in] startGlyphIndex The glyph from where the conversion table is created. * @param[in] numberOfCharacters The number of characters. */ - void CreateGlyphsPerCharacterTable( CharacterIndex startIndex, - GlyphIndex startGlyphIndex, - Length numberOfCharacters ); + void CreateGlyphsPerCharacterTable(CharacterIndex startIndex, + GlyphIndex startGlyphIndex, + Length numberOfCharacters); /** * @brief Retrieves glyphs in the given buffer. @@ -93,9 +103,9 @@ public: * @param[in] glyphIndex Index to the first glyph. * @param[in] numberOfGlyphs Number of glyphs to be copied. */ - void GetGlyphs( GlyphInfo* glyphs, - GlyphIndex glyphIndex, - Length numberOfGlyphs ) const; + void GetGlyphs(GlyphInfo* glyphs, + GlyphIndex glyphIndex, + Length numberOfGlyphs) const; // Position interface @@ -107,13 +117,20 @@ public: * @param[in] glyphIndex Index to the first glyph position. * @param[in] numberOfGlyphs The number of positions to be copied. */ - void GetGlyphPositions( Vector2* glyphPositions, - GlyphIndex glyphIndex, - Length numberOfGlyphs ) const; + void GetGlyphPositions(Vector2* glyphPositions, + GlyphIndex glyphIndex, + Length numberOfGlyphs) const; // Line interface. /** + * @brief Retrieves the total number of lines. + * + * @return The number of lines. + */ + Length GetTotalNumberOfLines() const; + + /** * @brief Retrieves the number of lines and the index to the first line where the given range of glyphs is laid out. * * @param[in] glyphIndex Index to the first glyph. @@ -121,10 +138,19 @@ public: * @param[out] firstLine Index to the line containing the glyph index. * @param[out] numberOfLines The number of lines. */ - void GetNumberOfLines( GlyphIndex glyphIndex, - Length numberOfGlyphs, - LineIndex& firstLine, - Length& numberOfLines ) const; + void GetNumberOfLines(GlyphIndex glyphIndex, + Length numberOfGlyphs, + LineIndex& firstLine, + 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. @@ -135,9 +161,9 @@ public: * @param[in] glyphIndex Index to the first glyphs of the range. * @param[in] numberOfGlyphs Number of glyphs in the range. */ - void GetLinesOfGlyphRange( LineRun* lines, - GlyphIndex glyphIndex, - Length numberOfGlyphs ) const; + void GetLinesOfGlyphRange(LineRun* lines, + GlyphIndex glyphIndex, + Length numberOfGlyphs) const; /** * @brief Retrieves the line index where the character is laid-out. @@ -146,7 +172,7 @@ public: * * @return The line index. */ - LineIndex GetLineOfCharacter( CharacterIndex characterIndex ); + LineIndex GetLineOfCharacter(CharacterIndex characterIndex); // Underline runs @@ -157,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 @@ -168,7 +194,7 @@ public: * * @param[in] size The text's natural size. */ - void SetNaturalSize( const Vector2& size ); + void SetNaturalSize(const Vector2& size); /** * @brief Retrieves the natural size. @@ -182,7 +208,7 @@ public: * * @param[in] size The text's size. */ - void SetLayoutSize( const Vector2& size ); + void SetLayoutSize(const Vector2& size); /** * @brief Retrieves the text's layout size. @@ -196,7 +222,7 @@ public: * * @param[in] textColor The text's color */ - void SetTextColor( const Vector4& textColor ); + void SetTextColor(const Vector4& textColor); /** * @brief Retrieve the text's color @@ -210,7 +236,7 @@ public: * * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow. */ - void SetShadowOffset( const Vector2& shadowOffset ); + void SetShadowOffset(const Vector2& shadowOffset); /** * @brief Retrieves the text's shadow offset. @@ -224,7 +250,7 @@ public: * * @param[in] shadowColor The shadow color. */ - void SetShadowColor( const Vector4& shadowColor ); + void SetShadowColor(const Vector4& shadowColor); /** * @brief Retrieves the text's shadow color. @@ -234,11 +260,25 @@ public: const Vector4& GetShadowColor() const; /** + * @brief Set the shadow blur radius. + * + * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur. + */ + void SetShadowBlurRadius(const float& shadowBlurRadius); + + /** + * @brief Retrieve the shadow blur radius. + * + * @return The shadow blur radius. + */ + const float& GetShadowBlurRadius() const; + + /** * @brief Sets the text's underline color. * * @param[in] color The text's underline color. */ - void SetUnderlineColor( const Vector4& color ); + void SetUnderlineColor(const Vector4& color); /** * @brief Retrieves the text's underline color. @@ -252,7 +292,7 @@ public: * * @param[in] enabled true if underlined. */ - void SetUnderlineEnabled( bool enabled ); + void SetUnderlineEnabled(bool enabled); /** * @brief Returns whether the text is underlined or not. @@ -271,7 +311,28 @@ public: * * @param[in] height The height in pixels of the underline */ - void SetUnderlineHeight( float height ); + 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 @@ -280,58 +341,356 @@ public: */ float GetUnderlineHeight() const; -protected: + /** + * @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. + */ + Length GetNumberOfUnderlineRuns() const; + + /** + * @brief Set the outline color. + * + * @param[in] color color of outline. + */ + void SetOutlineColor(const Vector4& color); + + /** + * @brief Retrieve the outline color. + * + * @return The outline color. + */ + const Vector4& GetOutlineColor() const; + + /** + * @brief Set the outline width + * + * @param[in] width The width in pixels of the outline, 0 indicates no outline + */ + void SetOutlineWidth(uint16_t width); + + /** + * @brief Retrieves the width of an outline + * + * @return The width of the outline. + */ + uint16_t GetOutlineWidth() const; + + /** + * @brief Sets the text's background color. + * + * @param[in] color The text's background color. + */ + void SetBackgroundColor(const Vector4& color); + + /** + * @brief Retrieves the text's background color. + * + * @return The text's background color. + */ + const Vector4& GetBackgroundColor() const; + + /** + * @brief Sets whether the text has a background or not. + * + * @param[in] enabled true if the text has a background. + */ + void SetBackgroundEnabled(bool enabled); + + /** + * @brief Returns whether the text has a background or not. + * + * @return whether the text has a background or not. + */ + bool IsBackgroundEnabled() const; + + /** + * @brief Sets whether the text has a markup-processor or not. + * + * @param[in] enabled true if the text has a markup-processor. + */ + void SetMarkupProcessorEnabled(bool enabled); + + /** + * @brief Returns whether the text has a markup-processor or not. + * + * @return whether the text has a markup-processor or not. + */ + bool IsMarkupProcessorEnabled() const; + + /** + * @brief Sets ellipsis position + * @param[in] ellipsisPosition The ellipsis position for the text + */ + void SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type ellipsisPosition); + + /** + * @brief Retrieves ellipsis position for text. + * + * @return The ellipsis position. + */ + Toolkit::DevelText::EllipsisPosition::Type GetEllipsisPosition() const; + + /** + * @brief Enable or disable the text elide. + * + * @param[in] enabled Whether to enable the text elide. + */ + void SetTextElideEnabled(bool enabled); + + /** + * @brief Whether the text elide property is enabled. + * + * @return @e true if the text elide property is enabled, @e false otherwise. + */ + bool IsTextElideEnabled() const; + + /** + * @brief Sets the start index of laid-out glyphs. + * + * @param[in] startIndexOfElidedGlyphs The start index of laid-out glyphs. + */ + void SetStartIndexOfElidedGlyphs(GlyphIndex startIndexOfElidedGlyphs); + + /** + * @brief Sets the end index of elided glyphs. + * + * @param[in] endIndexOfElidedGlyphs The end index of elided glyphs. + */ + void SetEndIndexOfElidedGlyphs(GlyphIndex endIndexOfElidedGlyphs); + + /** + * @brief Sets the first middle index of elided glyphs, index before ellipsis of middle. + * + * @param[in] firstMiddleIndexOfElidedGlyphs The first middle index of elided glyphs, index before ellipsis of middle. + */ + void SetFirstMiddleIndexOfElidedGlyphs(GlyphIndex firstMiddleIndexOfElidedGlyphs); + + /** + * @brief Sets the second middle index of elided glyphs, index of ellipsis of middle. + * + * @param[in] secondMiddleIndexOfElidedGlyphs The second middle index of elided glyphs, index of ellipsis of middle. + */ + void SetSecondMiddleIndexOfElidedGlyphs(GlyphIndex secondMiddleIndexOfElidedGlyphs); + + /** + * @brief Retrieves the start index of laid-out glyphs. + * + * @return The start index of laid-out glyphs. + */ + GlyphIndex GetStartIndexOfElidedGlyphs() const; + + /** + * @brief Retrieves the end index of laid-out glyphs. + * + * @return The end index of laid-out glyphs. + */ + GlyphIndex GetEndIndexOfElidedGlyphs() const; + + /** + * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle. + * + * @return The first middle index of elided glyphs, index before ellipsis of middle. + */ + GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const; + + /** + * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle. + * + * @return The second middle index of elided glyphs, index of ellipsis of middle. + */ + GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const; + + /** + * @brief Sets the text's strikethrough color. + * + * @param[in] color The text's strikethrough color. + */ + void SetStrikethroughColor(const Vector4& color); + + /** + * @brief Retrieves the text's strikethrough color. + * + * @return The text's strikethrough color. + */ + const Vector4& GetStrikethroughColor() const; + + /** + * @brief Sets the text strikethrough flag. + * + * @param[in] enabled true if strikethrough. + */ + void SetStrikethroughEnabled(bool enabled); + + /** + * @brief Returns whether the text is strikethrough or not. + * + * @return strikethrough state. + */ + bool IsStrikethroughEnabled() const; + + /** + * @brief Set the override used for strikethrough height, 0 indicates height will be come from font metrics + * + * @param[in] height The height in pixels of the strikethrough + */ + void SetStrikethroughHeight(float height); + + /** + * @brief Retrieves the strikethrough height override + * + * @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; + +protected: + /** * @brief A reference counted object may only be deleted by calling Unreference(). */ virtual ~VisualModel(); private: - /** * @brief Private constructor. */ VisualModel(); // Undefined - VisualModel( const VisualModel& handle ); + VisualModel(const VisualModel& handle); // Undefined - VisualModel& operator=( const VisualModel& handle ); + 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. - - Vector4 mTextColor; ///< The text color - Vector4 mShadowColor; ///< Color of drop shadow - Vector4 mUnderlineColor; ///< Color of underline - 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. + 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. + 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. + uint16_t mOutlineWidth; ///< Width of outline. + Vector mStrikethroughRuns; ///< Runs of glyphs that have strikethrough. + Vector mCharacterSpacingRuns; ///< Runs of glyphs that have character-spacing. 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. // 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. -public: + DevelText::EllipsisPosition::Type mEllipsisPosition; ///< Where is the location the text elide + GlyphIndex mStartIndexOfElidedGlyphs; ///< The start index of elided glyphs. + GlyphIndex mEndIndexOfElidedGlyphs; ///< The end index of elided glyphs. + GlyphIndex mFirstMiddleIndexOfElidedGlyphs; ///< The first end index of elided glyphs, index before ellipsis of middle. + GlyphIndex mSecondMiddleIndexOfElidedGlyphs; ///< The first end index of elided glyphs, index of ellipsis of middle. + bool mTextElideEnabled : 1; ///< Whether the text's elide is enabled. - bool mUnderlineEnabled:1; ///< Underline enabled flag - bool mUnderlineColorSet:1; ///< Has the underline color been explicitly set? +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 + float mCharacterSpacing; ///< Contains the value of the character spacing. }; } // namespace Text @@ -340,4 +699,4 @@ public: } // namespace Dali -#endif // __DALI_TOOLKIT_TEXT_VISUAL_MODEL_IMPL_H__ +#endif // DALI_TOOLKIT_TEXT_VISUAL_MODEL_IMPL_H