X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fvisual-model-impl.h;h=5aa90af4c37c5f7d978284cb3cfe95e57e39f3c7;hb=2512aa2794f3c5ea5841542b9ed9c8c32973540b;hp=fb9f7bcc71556bb6cc22fd45a7560af1dd5a7178;hpb=cd7d41bc8e0a0816da28401207091344fbbe0b2c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/visual-model-impl.h b/dali-toolkit/internal/text/visual-model-impl.h index fb9f7bc..ebddb35 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. @@ -21,24 +21,32 @@ // EXTERNAL INCLUDES #include #include +#include #include #include // INTERNAL INCLUDES +#include #include +#include +#include + +// DEVEL INCLUDES +#include namespace Dali { - -struct Vector2; - namespace Toolkit { - namespace Text { +struct HyphenInfo +{ + Vector glyph; + Vector position; + Vector index; +}; -struct LineRun; class VisualModel; typedef IntrusivePtr VisualModelPtr; @@ -52,7 +60,6 @@ typedef IntrusivePtr VisualModelPtr; class VisualModel : public RefObject { public: - /** * @brief Create a new instance of a VisualModel. * @@ -63,43 +70,28 @@ public: // Glyph interface. /** - * @brief Replaces any glyphs previously set. - * - * @note If the number of glyphs is zero, all buffers are cleared. - * @note If one pointer is NULL and the number of glyphs is not zero, the buffer is not touched. - * - * @param[in] glyphs An array of glyphs in the visual order. - * @param[in] characterIndices An array containing the first character in the logical model that each glyph relates to. - * @param[in] charactersPerGlyph An array containing the number of characters per glyph. - * @param[in] numberOfGlyphs The number of glyphs. - */ - void SetGlyphs( const GlyphInfo* glyphs, - const CharacterIndex* characterIndices, - const Length* charactersPerGlyph, - Length numberOfGlyphs ); - - /** * @brief Creates the character to glyph conversion table. * * @pre The glyphs per character table needs to be created first. * + * @param[in] startIndex The character from where the conversion table is created. + * @param[in] startGlyphIndex The glyph from where the conversion table is created. * @param[in] numberOfCharacters The number of characters. */ - void CreateCharacterToGlyphTable( Length numberOfCharacters = 0u ); + void CreateCharacterToGlyphTable(CharacterIndex startIndex, + GlyphIndex startGlyphIndex, + Length numberOfCharacters); /** * @brief Creates an array containing the number of glyphs per character. * + * @param[in] startIndex The character from where the table is created. + * @param[in] startGlyphIndex The glyph from where the conversion table is created. * @param[in] numberOfCharacters The number of characters. */ - void CreateGlyphsPerCharacterTable( Length numberOfCharacters = 0u ); - - /** - * @brief Retrieves the number of glyphs. - * - * @return The number of glyphs. - */ - Length GetNumberOfGlyphs() const; + void CreateGlyphsPerCharacterTable(CharacterIndex startIndex, + GlyphIndex startGlyphIndex, + Length numberOfCharacters); /** * @brief Retrieves glyphs in the given buffer. @@ -109,439 +101,570 @@ 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 + + /** + * @brief Retrieves the glyph positions. + * + * @pre The size of the @p positions buffer needs to be big enough to copy the @p numberOfGlyphs positions. + * @param[out] glyphPositions Pointer to a buffer where the glyph positions are copied. + * @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; + + // 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. + * @param[in] numberOfGlyphs The number of glyph. + * @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; /** - * @brief Retrieves a glyph. + * @brief Retrieves the lines where the given range of glyphs is laid out. * - * @param[in] glyphIndex Index to a glyph. + * The size of the @p lines buffer needs to be big enough to copy the @p numberOfLines. * - * @return A glyph. + * @param[out] lines Pointer to a buffer where the lines are copied. + * @param[in] glyphIndex Index to the first glyphs of the range. + * @param[in] numberOfGlyphs Number of glyphs in the range. */ - const GlyphInfo& GetGlyphInfo( GlyphIndex glyphIndex ) const; + void GetLinesOfGlyphRange(LineRun* lines, + GlyphIndex glyphIndex, + Length numberOfGlyphs) const; /** - * @brief Replaces glyphs. + * @brief Retrieves the line index where the character is laid-out. * - * If the @p numberOfGlyphsToRemove is zero, this operation is like an insert. - * If the @p numberOfGlyphsToInsert is zero, this operation is like a remove. + * @param[in] characterIndex The character's index. * - * @param[in] glyphIndex Where to replace the glyphs. - * @param[in] numberOfGlyphsToRemove The number of glyphs to be removed. - * @param[in] glyphs Pointer to a buffer with the new glyphs. - * @param[in] numberOfCharacters Pointer to a buffer with the number of characters per glyph. - * @param[in] numberOfGlyphsToInsert The number of new glyphs in the buffer. + * @return The line index. */ - void ReplaceGlyphs( GlyphIndex glyphIndex, - Length numberOfGlyphsToRemove, - const GlyphInfo* const glyphs, - const Length* const numberOfCharacters, - Length numberOfGlyphsToInsert ); + LineIndex GetLineOfCharacter(CharacterIndex characterIndex); - // Character <--> Glyph conversion + // Underline runs /** - * @brief Retrieves the first character in the logical model which a glyph represents. + * @brief Retrieves the underline runs. * - * @note After shaping several characters may be represented by the same glyph. - * Alternatively several glyphs may be required to display a character. - * @param[in] glyphIndex The glyph index. - * @return The character index. + * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied. + * @param[in] index Index of the first underline run to be copied. + * @param[in] numberOfRuns Number of underline runs to be copied. */ - CharacterIndex GetCharacterIndex( GlyphIndex glyphIndex ) const; + void GetUnderlineRuns(GlyphRun* underlineRuns, + UnderlineRunIndex index, + Length numberOfRuns) const; + + // Size interface /** - * @brief Query the number of characters the glyph represents. + * @brief Sets the natural size. * - * @param[in] glyphIndex The glyph index. - * @return The number of characters represented by the glyph. + * @param[in] size The text's natural size. */ - Length GetCharactersPerGlyph( GlyphIndex glyphIndex ) const; + void SetNaturalSize(const Vector2& size); /** - * @brief Retrieves the first glyph in the visual model which represents a given character. + * @brief Retrieves the natural size. * - * @note After shaping several characters may be represented by the same glyph. - * Alternatively several glyphs may be required to display a character. - * @param[in] characterIndex The character index. - * @return The glyph index. + * @return The text's natural size. */ - GlyphIndex GetGlyphIndex( CharacterIndex characterIndex ) const; + const Vector2& GetNaturalSize() const; /** - * @brief Retrieves the whole or part of the character to glyph conversion map. + * @brief Sets the text's layout size. * - * The size of the buffer needs to be big enough to copy the @p numberOfCharacters. + * @param[in] size The text's size. + */ + void SetLayoutSize(const Vector2& size); + + /** + * @brief Retrieves the text's layout size. * - * @param[out] characterToGlyphMap Pointer to a buffer where the conversion map is copied. - * @param[in] characterIndex Index to the first character. - * @param[in] numberOfCharacters The number of characters. + * @return The text's size. */ - void GetCharacterToGlyphMap( GlyphIndex* characterToGlyphMap, - CharacterIndex characterIndex, - Length numberOfCharacters ) const; + const Vector2& GetLayoutSize() const; /** - * @brief Retrieves the whole or part of the glyph to character conversion map. + * @brief Set the text's color * - * The size of the buffer needs to be big enough to copy the @p numberOfGlyphs. + * @param[in] textColor The text's color + */ + void SetTextColor(const Vector4& textColor); + + /** + * @brief Retrieve the text's color * - * @param[out] glyphToCharacter Pointer to a buffer where the conversion map is copied. - * @param[in] glyphIndex Index to the first glyph. - * @param[in] numberOfGlyphs The number of glyphs. + * @return The text's color */ - void GetGlyphToCharacterMap( CharacterIndex* glyphToCharacter, - GlyphIndex glyphIndex, - Length numberOfGlyphs ) const; + const Vector4& GetTextColor() const; /** - * @brief Retrieves for each glyph the number of characters the glyph represents. + * @brief Sets the text's shadow offset. * - * @param[out] charactersPerGlyph Pointer to a buffer where the number of characters for each glyph are copied. - * @param[in] glyphIndex Index to the first glyph. - * @param[in] numberOfGlyphs The number of glyphs. + * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow. */ - void GetCharactersPerGlyphMap( Length* charactersPerGlyph, - GlyphIndex glyphIndex, - Length numberOfGlyphs ) const; + void SetShadowOffset(const Vector2& shadowOffset); /** - * @brief Retrieves for each character the number of glyphs the character is shaped. + * @brief Retrieves the text's shadow offset. * - * @param[out] glyphsPerCharacter Pointer to a buffer where the number of glyphs for each character are copied. - * @param[in] characterIndex Index to the first character. - * @param[in] numberOfCharacters The number of characters. + * @return The text's shadow offset, 0,0 indicates no shadow. */ - void GetGlyphsPerCharacterMap( Length* glyphsPerCharacter, - CharacterIndex characterIndex, - Length numberOfCharacters ) const; + const Vector2& GetShadowOffset() const; - // Position interface + /** + * @brief Sets the text's shadow color. + * + * @param[in] shadowColor The shadow color. + */ + void SetShadowColor(const Vector4& shadowColor); /** - * @brief Replaces any glyph positions previously set. + * @brief Retrieves the text's shadow color. * - * @note If the number of glyphs is zero the position buffer is cleared. + * @return The text's shadow color. + */ + const Vector4& GetShadowColor() const; + + /** + * @brief Set the shadow blur radius. * - * @param[in] glyphPositions An array of visual positions for each glyph. - * @param[in] numberOfGlyphs The number of positions. + * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur. */ - void SetGlyphPositions( const Vector2* glyphPositions, - Length numberOfGlyphs ); + void SetShadowBlurRadius(const float& shadowBlurRadius); /** - * @brief Retrieves the number of glyph positions set. + * @brief Retrieve the shadow blur radius. * - * @note This may be less than the number of glyphs in the model. - * @return The number of glyphs. + * @return The shadow blur radius. */ - Length GetNumberOfGlyphPositions() const; + const float& GetShadowBlurRadius() const; /** - * @brief Retrieves the glyph positions. + * @brief Sets the text's underline color. * - * @pre The size of the @p positions buffer needs to be big enough to copy the @p numberOfGlyphs positions. - * @param[out] glyphPositions Pointer to a buffer where the glyph positions are copied. - * @param[in] glyphIndex Index to the first glyph position. - * @param[in] numberOfGlyphs The number of positions to be copied. + * @param[in] color The text's underline color. */ - void GetGlyphPositions( Vector2* glyphPositions, - GlyphIndex glyphIndex, - Length numberOfGlyphs ) const; + void SetUnderlineColor(const Vector4& color); /** - * @brief Retrieve the glyph's position of the given glyph. + * @brief Retrieves the text's underline color. * - * @param[in] glyphIndex Index to the glyph. + * @return The text's underline color. + */ + const Vector4& GetUnderlineColor() const; + + /** + * @brief Sets the text underline flag. * - * @return The glyph's position. + * @param[in] enabled true if underlined. */ - const Vector2& GetGlyphPosition( GlyphIndex glyphIndex ) const; + void SetUnderlineEnabled(bool enabled); /** - * @brief Replaces glyph's positions. + * @brief Returns whether the text is underlined or not. * - * If the @p numberOfGlyphsToRemove is zero, this operation is like an insert. - * If the @p numberOfGlyphsToInsert is zero, this operation is like a remove. + * @return underline state. + */ + bool IsUnderlineEnabled() const; + + /** + * @brief Clear the caches. + */ + void ClearCaches(); + + /** + * @brief Set the override used for underline height, 0 indicates height will be come from font metrics * - * @param[in] glyphIndex Where to replace the glyph's positions. - * @param[in] numberOfGlyphsToRemove The number of glyph's positions to be removed. - * @param[in] positions Pointer to a buffer with the new glyph's positions. - * @param[in] numberOfGlyphsToInsert The number of new glyph's positions in the buffer. + * @param[in] height The height in pixels of the underline */ - void ReplaceGlyphPositions( GlyphIndex glyphIndex, - Length numberOfGlyphsToRemove, - const Vector2* const positions, - Length numberOfGlyphsToInsert ); + void SetUnderlineHeight(float height); - // Line interface. + /** + * @brief Set the override used for underline type. + * + * @param[in] underlineType The type of the underline. + */ + void SetUnderlineType(Text::Underline::Type type); /** - * @brief Sets the lines. + * @brief Set the override used for the width of the dashes of the dashed underline. * - * Replaces any lines previously set. + * @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. * - * Every line is an item run containing the index to the first glyph of the line and the number of glyphs. + * @param[in] gap gap between the dashes. + */ + void SetDashedUnderlineGap(float gap); + + /** + * @brief Retrieves the underline height override * - * @note If the number of lines is zero or the pointer is NULL, the lines buffer is cleared. + * @return Returns the override height for an underline, 0 indicates that font metrics will determine the height + */ + float GetUnderlineHeight() const; + + /** + * @brief Retrieves the underline type override. * - * @param[in] lines Pointer to a buffer containing all the line runs. - * @param[in] numberOfLines The number of lines in the buffer. + * @return Returns the override type for the underline. */ - void SetLines( const LineRun* const lines, - Length numberOfLines ); + Text::Underline::Type GetUnderlineType() const; /** - * @brief Retrieves the number of lines of the whole text. + * @brief Retrieves the dashed underline width. * - * @return The number of lines. + * @return Returns the override width for the dashed underline. */ - Length GetNumberOfLines() const; + float GetDashedUnderlineWidth() const; /** - * @brief Retrieves lines. + * @brief Retrieves the dashed underline gap. * - * The size of the @p lines buffer needs to be big enough to copy the @p numberOfLines. + * @return Returns the override gap for the dashed underline. + */ + float GetDashedUnderlineGap() const; + + /** + * @brief Retrieves the number of underline runs. * - * @param[out] lines Pointer to a buffer where the lines are copied. - * @param[in] lineIndex Index to the first line. - * @param[in] numberOfLines Number of lines to be copied. + * @return The number of underline runs. */ - void GetLines( LineRun* lines, - LineIndex lineIndex, - Length numberOfLines ) const; + Length GetNumberOfUnderlineRuns() const; /** - * @brief Retrieves the number of lines and the index to the first line where the given range of glyphs is laid out. + * @brief Set the outline color. * - * @param[in] glyphIndex Index to the first glyph. - * @param[in] numberOfGlyphs The number of glyph. - * @param[out] firstLine Index to the line containing the glyph index. - * @param[out] numberOfLines The number of lines. + * @param[in] color color of outline. */ - void GetNumberOfLines( GlyphIndex glyphIndex, - Length numberOfGlyphs, - LineIndex& firstLine, - Length& numberOfLines ) const; + void SetOutlineColor(const Vector4& color); + /** - * @brief Retrieves the lines where the given range of glyphs is laid out. + * @brief Retrieve the outline color. * - * The size of the @p lines buffer needs to be big enough to copy the @p numberOfLines. + * @return The outline color. + */ + const Vector4& GetOutlineColor() const; + + /** + * @brief Set the outline width * - * @param[out] lines Pointer to a buffer where the lines are copied. - * @param[in] glyphIndex Index to the first glyphs of the range. - * @param[in] numberOfGlyphs Number of glyphs in the range. + * @param[in] width The width in pixels of the outline, 0 indicates no outline */ - void GetLinesOfGlyphRange( LineRun* lines, - GlyphIndex glyphIndex, - Length numberOfGlyphs ) const; + void SetOutlineWidth(uint16_t width); /** - * @brief Retrieves the line index where the glyph is laid-out. + * @brief Retrieves the width of an outline * - * @param[in] glyphIndex The glyph's index. + * @return The width of the outline. + */ + uint16_t GetOutlineWidth() const; + + /** + * @brief Sets the text's background color. * - * @return The line index. + * @param[in] color The text's background color. */ - LineIndex GetLineOfGlyph( GlyphIndex glyphIndex ); + void SetBackgroundColor(const Vector4& color); /** - * @brief Retrieves the line index where the character is laid-out. + * @brief Retrieves the text's background color. * - * @param[in] characterIndex The character's index. + * @return The text's background color. + */ + const Vector4& GetBackgroundColor() const; + + /** + * @brief Sets whether the text has a background or not. * - * @return The line index. + * @param[in] enabled true if the text has a background. */ - LineIndex GetLineOfCharacter( CharacterIndex characterIndex ); + void SetBackgroundEnabled(bool enabled); /** - * @brief Replaces lines for the given range of glyphs. + * @brief Returns whether the text has a background or not. * - * If the @p numberOfGlyphsToRemove is zero, this operation is like an insert. - * If the @p numberOfGlyphsToInsert is zero, this operation is like a remove. + * @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] glyphIndex Index of the first glyph where to replace the line info. - * @param[in] numberOfGlyphsToRemove The number of glyphs to be the line info removed. - * @param[in] lines Pointer to a buffer with the lines. - * @param[in] numberOfGlyphsToInsert The number of characters to be the line info inserted. + * @param[in] enabled true if the text has a markup-processor. */ - void ReplaceLines( GlyphIndex glyphIndex, - Length numberOfGlyphsToRemove, - const LineRun* const lines, - Length numberOfGlyphsToInsert ); + void SetMarkupProcessorEnabled(bool enabled); - // Size interface + /** + * @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 the natural size. + * @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. * - * @param[in] size The text's natural size. + * @return The ellipsis position. */ - void SetNaturalSize( const Vector2& size ); + Toolkit::DevelText::EllipsisPosition::Type GetEllipsisPosition() const; /** - * @brief Retrieves the natural size. + * @brief Enable or disable the text elide. * - * @return The text's natural size. + * @param[in] enabled Whether to enable the text elide. */ - const Vector2& GetNaturalSize() const; + void SetTextElideEnabled(bool enabled); /** - * @brief Sets the text's actual size after it has been laid out. + * @brief Whether the text elide property is enabled. * - * @param[in] size The text's size. + * @return @e true if the text elide property is enabled, @e false otherwise. */ - void SetActualSize( const Vector2& size ); + bool IsTextElideEnabled() const; /** - * @brief Retrieves the text's actual size after it has been laid out. + * @brief Sets the start index of laid-out glyphs. * - * @return The text's size. + * @param[in] startIndexOfElidedGlyphs The start index of laid-out glyphs. */ - const Vector2& GetActualSize() const; + void SetStartIndexOfElidedGlyphs(GlyphIndex startIndexOfElidedGlyphs); /** - * @brief Set the text's color + * @brief Sets the end index of elided glyphs. * - * @param[in] textColor The text's color + * @param[in] endIndexOfElidedGlyphs The end index of elided glyphs. */ - void SetTextColor( const Vector4& textColor ); + void SetEndIndexOfElidedGlyphs(GlyphIndex endIndexOfElidedGlyphs); /** - * @brief Retrieve the text's color + * @brief Sets the first middle index of elided glyphs, index before ellipsis of middle. * - * @return The text's color + * @param[in] firstMiddleIndexOfElidedGlyphs The first middle index of elided glyphs, index before ellipsis of middle. */ - const Vector4& GetTextColor() const; + void SetFirstMiddleIndexOfElidedGlyphs(GlyphIndex firstMiddleIndexOfElidedGlyphs); /** - * @brief Sets the text's shadow offset. + * @brief Sets the second middle index of elided glyphs, index of ellipsis of middle. * - * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow. + * @param[in] secondMiddleIndexOfElidedGlyphs The second middle index of elided glyphs, index of ellipsis of middle. */ - void SetShadowOffset( const Vector2& shadowOffset ); + void SetSecondMiddleIndexOfElidedGlyphs(GlyphIndex secondMiddleIndexOfElidedGlyphs); /** - * @brief Retrieves the text's shadow offset. + * @brief Retrieves the start index of laid-out glyphs. * - * @return The text's shadow offset, 0,0 indicates no shadow. + * @return The start index of laid-out glyphs. */ - const Vector2& GetShadowOffset() const; + GlyphIndex GetStartIndexOfElidedGlyphs() const; /** - * @brief Sets the text's shadow color. + * @brief Retrieves the end index of laid-out glyphs. * - * @param[in] shadowColor The shadow color. + * @return The end index of laid-out glyphs. */ - void SetShadowColor( const Vector4& shadowColor ); + GlyphIndex GetEndIndexOfElidedGlyphs() const; /** - * @brief Retrieves the text's shadow color. + * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle. * - * @return The text's shadow color. + * @return The first middle index of elided glyphs, index before ellipsis of middle. */ - const Vector4& GetShadowColor() const; + GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const; /** - * @brief Sets the text's underline color. + * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle. * - * @param[in] color The text's underline color. + * @return The second middle index of elided glyphs, index of ellipsis of middle. */ - void SetUnderlineColor( const Vector4& color ); + GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const; /** - * @brief Retrieves the text's underline color. + * @brief Sets the text's strikethrough color. * - * @return The text's underline color. + * @param[in] color The text's strikethrough color. */ - const Vector4& GetUnderlineColor() const; + void SetStrikethroughColor(const Vector4& color); /** - * @brief Sets the text underline flag. + * @brief Retrieves the text's strikethrough color. * - * @param[in] enabled true if underlined. + * @return The text's strikethrough color. */ - void SetUnderlineEnabled( bool enabled ); + const Vector4& GetStrikethroughColor() const; /** - * @brief Returns whether the text is underlined or not. + * @brief Sets the text strikethrough flag. * - * @return underline state. + * @param[in] enabled true if strikethrough. */ - bool IsUnderlineEnabled() const; + void SetStrikethroughEnabled(bool enabled); /** - * @brief Clear the caches. + * @brief Returns whether the text is strikethrough or not. + * + * @return strikethrough state. */ - void ClearCaches(); + bool IsStrikethroughEnabled() const; /** - * @brief Set the override used for underline height, 0 indicates height will be come from font metrics + * @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 underline + * @param[in] height The height in pixels of the strikethrough */ - void SetUnderlineHeight( float height ); + void SetStrikethroughHeight(float height); /** - * @brief Retrieves the underline height override + * @brief Retrieves the strikethrough height override * - * @return Returns the override height for an underline, 0 indicates that font metrics will determine the height + * @return Returns the override height for a strikethrough, 0 indicates that font metrics will determine the height */ - float GetUnderlineHeight() const; + 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); -protected: + /** + * @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; +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. - - Vector4 mTextColor; ///< The text color - Vector4 mShadowColor; ///< Color of drop shadow - Vector4 mUnderlineColor; ///< Color of underline - 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. private: - - Size mNaturalSize; ///< Size of the text with no line wrapping. - Size mActualSize; ///< 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: - - bool mUnderlineEnabled:1; ///< Underline enabled flag - bool mUnderlineColorSet:1; ///< Has the underline color been explicitly set? + 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. +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 @@ -550,4 +673,4 @@ public: } // namespace Dali -#endif // __DALI_TOOLKIT_TEXT_VISUAL_MODEL_IMPL_H__ +#endif // DALI_TOOLKIT_TEXT_VISUAL_MODEL_IMPL_H