X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=base%2Fdali-toolkit%2Finternal%2Fcontrols%2Ftext-view%2Frelayout-utilities.h;h=515018612e61a8e9af75a184da3d8b56c6fa4d09;hb=d7651d60bfb31322e76337e503ba5e11fc4d70bc;hp=79fdc369aecef5f32ef58a4302b1a02dfb9c9f9f;hpb=0f217b9896d284c667e1251ee617e4ddadd4c9e3;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/base/dali-toolkit/internal/controls/text-view/relayout-utilities.h b/base/dali-toolkit/internal/controls/text-view/relayout-utilities.h index 79fdc36..5150186 100644 --- a/base/dali-toolkit/internal/controls/text-view/relayout-utilities.h +++ b/base/dali-toolkit/internal/controls/text-view/relayout-utilities.h @@ -19,8 +19,9 @@ */ // INTERNAL INCLUDES +#include +#include #include -#include namespace Dali { @@ -40,15 +41,15 @@ namespace TextViewRelayout extern const float MINIMUM_FADE_BOUNDARY; // When the fade boundary is the same as the text-view boundary, this constant reduces it in order to avoid a zero division. /** - * Define the type of line wrap. + * Define how to wrap a paragraph in lines. */ enum HorizontalWrapType { - WrapByCharacter, ///< Wrap a line per character (It may split a word in two). - WrapByWord, ///< Wrap a line by word. - WrapByWordAndSplit, ///< Wrap the line by word and split a word if it doesn't fit. - WrapByLine, ///< Wrap the line when a \n is found. - WrapByLineAndSplit ///< Wrap the line when a \n is found and split if it doesn't fit. + WrapByCharacter, ///< Wrap the paragraph per character (It may split a word in two). + WrapByWord, ///< Wrap the paragraph by word. + WrapByWordAndSplit, ///< Wrap the paragraph by word and split a word if it doesn't fit. + WrapByParagraphCharacter, ///< Wrap the paragraph when a '\n' is found. + WrapByParagraphCharacterAndSplit ///< Wrap the paragraph when a '\n' is found and split if it doesn't fit. }; /** @@ -83,18 +84,18 @@ struct RelayoutParameters */ ~RelayoutParameters(); - Vector3 mPositionOffset; ///< Offset (position.x + size.width, position.y, position.z) of the previous text-actor. - Size mLineSize; ///< Current line's size. - Size mWordSize; ///< Current word's size. - Size mCharacterSize; ///< Current character's size. - TextViewProcessor::TextInfoIndices mIndices; ///< Current indices to line, word and character. - std::size_t mCharacterGlobalIndex; ///< Index to a single character within the whole text. - bool mIsFirstCharacter:1; ///< Whether is the first character of the whole text. - bool mIsFirstCharacterOfWord:1; ///< Whether is the first character of the word. - bool mIsNewLine:1; ///< Whether the current character is the first character of a new line. - bool mIsNewLineCharacter:1; ///< Whether the current character is a new line character. - bool mIsWhiteSpace:1; ///< Whether the current character is a white space. - bool mIsVisible:1; ///< Whether the current character is visible. + Vector3 mPositionOffset; ///< Offset (position.x + size.width, position.y, position.z) of the previous text-actor. + Size mParagraphSize; ///< Current paragraphs's size. + Size mWordSize; ///< Current word's size. + Size mCharacterSize; ///< Current character's size. + TextViewProcessor::TextInfoIndices mIndices; ///< Current indices to paragraph, word and character. + std::size_t mCharacterGlobalIndex; ///< Index to a single character within the whole text. + bool mIsFirstCharacter:1; ///< Whether is the first character of the whole text. + bool mIsFirstCharacterOfWord:1; ///< Whether is the first character of the word. + bool mIsNewLine:1; ///< Whether the current character is the first character of a new line. + bool mIsNewParagraphCharacter:1; ///< Whether the current character is a new paragraph character. + bool mIsWhiteSpace:1; ///< Whether the current character is a white space. + bool mIsVisible:1; ///< Whether the current character is visible. }; /** @@ -160,10 +161,10 @@ struct EllipsizeParameters Vector3 mPosition; ///< Position of the first character of the ellipsize text. float mLineDescender; ///< Distance from the base line to the bottom. - float mLineWidth; ///< Current laid out line's width. + float mLineWidth; ///< Current line's width. Size mEllipsizeBoundary; ///< Where to start to ellipsize a line. - std::size_t mFirstIndex; ///< Global index within the whole text of the first character of the laid out line. - std::size_t mLastIndex; ///< Global index within the whole text of the last character of the laid out line. + std::size_t mFirstIndex; ///< Global index within the whole text of the first character of the line. + std::size_t mLastIndex; ///< Global index within the whole text of the last character of the line. bool mEllipsizeLine:1; ///< Whether current line must be ellipsized. bool mIsLineWidthFullyVisible:1; ///< Whether current line fits in text-view's width. bool mIsLineHeightFullyVisible:1; ///< Whether current line fits in text-view's height. @@ -174,7 +175,7 @@ struct EllipsizeParameters }; /** - * Stores underline info for a group of consecutive characters in the same laid out line. + * Stores underline info for a group of consecutive characters in the same line. */ struct UnderlineInfo { @@ -219,50 +220,57 @@ struct TextUnderlineStatus std::vector mUnderlineInfo; ///< Underline info for each group of consecutive underlined characters. std::size_t mCharacterGlobalIndex; ///< Global index (within the whole text) to current character. - std::size_t mLineGlobalIndex; ///< Index to current laid out line. It takes into account the current layout configuration (is not the number of \n) + std::size_t mLineGlobalIndex; ///< Index to current line. It takes into account the current layout configuration (is not the number of \n) bool mCurrentUnderlineStatus:1; ///< Whether current character is underlined. }; /** - * Stores layout information of the piece of a line. + * Stores layout information of a line. */ -struct SubLineLayoutInfo +struct LineLayoutInfo { /** * Default constructor. * * Initializes each member to its default. */ - SubLineLayoutInfo(); + LineLayoutInfo(); /** * Empty destructor. * * @note Added to increase coverage. */ - ~SubLineLayoutInfo(); + ~LineLayoutInfo(); - float mLineLength; ///< The length of the portion of the line which fits on the text-view width. - float mMaxCharHeight; ///< The maximum height of all characters of the portion of line which fits on the text-view width. - float mMaxAscender; ///< The maximum ascender of all characters of the portion of line which fits on the text-view width. + float mLineLength; ///< The length of the portion of the paragraph which fits on the text-view width. + float mMaxCharHeight; ///< The maximum height of all characters of the portion of the paragraph which fits on the text-view width. + float mMaxAscender; ///< The maximum ascender of all characters of the portion of the paragraph which fits on the text-view width. }; /** - * Calculates the layout info of the portion of the line which fits on the text-view width. + * Calculates the layout info of the portion of the paragraph which fits on the text-view width. * * @param[in] parentWidth Text-view width * @param[in] indices Indices to the word and character. - * @param[in] lineLayoutInfo Layout info for the line. - * @param[in] splitPolicy Whether a line is wraped by word, by character or by word and character. + * @param[in] paragraphLayoutInfo Layout info for the paragraph. + * @param[in] splitPolicy Whether a paragraph is wraped by word, by character or by word and character. * @param[in] shrinkFactor Shrink factor used. - * @param[out] layoutInfo Layout information of the part of the line which fits in the text-view width. + * @param[out] layoutInfo Layout information of the part of the paragraph which fits in the text-view width. */ -void CalculateSubLineLayout( float parentWidth, - const TextViewProcessor::TextInfoIndices& indices, - const TextViewProcessor::LineLayoutInfo& lineLayoutInfo, - HorizontalWrapType splitPolicy, - float shrinkFactor, - SubLineLayoutInfo& layoutInfo ); +void CalculateLineLayout( float parentWidth, + const TextViewProcessor::TextInfoIndices& indices, + const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo, + HorizontalWrapType splitPolicy, + float shrinkFactor, + LineLayoutInfo& layoutInfo ); + +/** + * Reorders the text layout of each line of each paragraph of the text. + * + * @param[in,out] relayoutData The text-view's data structures. + */ +void ReorderRightToLeftLayout( TextView::RelayoutData& relayoutData ); /** * Calculates the \e x offset position for the whole text. @@ -358,12 +366,14 @@ void UpdateLayoutInfoTable( Vector4& minMaxXY, * * @param[in] layoutParameters The layout parameters. * @param[in] characterLayoutInfo Character layout info. + * @param[in] style The style of the character. Used to get the color (and alpha) of the character. * @param[in,out] relayoutParameters Temporary layout parameters. * @param[in,out] fadeParameters Temporary fade parameters. * @param[in,out] relayoutData The text-view's data structures. */ void CalculateVisibilityForFade( const Internal::TextView::LayoutParameters& layoutParameters, TextViewProcessor::CharacterLayoutInfo& characterLayoutInfo, + const TextStyle& style, RelayoutParameters& relayoutParameters, FadeParameters& fadeParameters, TextView::RelayoutData& relayoutData ); @@ -391,7 +401,11 @@ void CreateEllipsizeTextActor( const EllipsizeParameters& ellipsizeParameters, TextView::RelayoutData& relayoutData ); /** + * Replace the text which exceeds the boundary by the ellipsis text. * + * @param[in] layoutParameters The layout parameters. + * @param[in,out] ellipsisParameters Temporary ellipsis parameters. + * @param[in,out] relayoutData The text-view's data structures. */ void EllipsizeLine( const TextView::LayoutParameters& layoutParameters, EllipsizeParameters& ellipsizeParameters,