X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=base%2Fdali-toolkit%2Finternal%2Fcontrols%2Ftext-view%2Ftext-view-processor-types.h;h=15005cce26bdb9e9944407f4f436e7e076510764;hp=0498cc081dfe625836b04cf1f1290289635af41f;hb=refs%2Ftags%2Fsubmit%2Ftizen_common%2F20140925.141856;hpb=e58fa784d19a558e35f458ecf6d262a2344beb4f diff --git a/base/dali-toolkit/internal/controls/text-view/text-view-processor-types.h b/base/dali-toolkit/internal/controls/text-view/text-view-processor-types.h index 0498cc0..15005cc 100644 --- a/base/dali-toolkit/internal/controls/text-view/text-view-processor-types.h +++ b/base/dali-toolkit/internal/controls/text-view/text-view-processor-types.h @@ -1,53 +1,54 @@ #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__ #define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // INTERNAL INCLUDES -#include -#include +#include +#include namespace Dali { +class TextStyle; + namespace Toolkit { namespace Internal { -namespace TextViewProcessor +namespace TextProcessor { +// Forward declarations. +struct BidirectionalParagraphInfo; +struct BidirectionalLineInfo; +} // namespace TextProcessor -/** - * Whether the direction is Right To Left or Left To Right. - */ -enum Direction +namespace TextViewProcessor { - LTR, ///< Left To Right direction. - RTL ///< Right To Left direction. -}; /** - * Whether the text is a new line character, a white space or normal text. + * Whether the text is a new paragraph character '\n', a white space or normal text. */ enum TextSeparatorType { - LineSeparator, + ParagraphSeparator, WordSeparator, NoSeparator }; @@ -69,14 +70,15 @@ struct TextInfoIndices { /** * Default constructor. + * + * Initializes all members to their default values. */ TextInfoIndices(); /** * Constructor. */ - TextInfoIndices( std::size_t lineIndex, - std::size_t groupIndex, + TextInfoIndices( std::size_t paragraphIndex, std::size_t wordIndex, std::size_t characterIndex ); @@ -88,10 +90,44 @@ struct TextInfoIndices */ bool operator==( const TextInfoIndices& indices ) const; - std::size_t mLineIndex; - std::size_t mGroupIndex; - std::size_t mWordIndex; - std::size_t mCharacterIndex; + std::size_t mParagraphIndex; ///< The paragraph index within the text. + std::size_t mWordIndex; ///< The word index within the paragraph. + std::size_t mCharacterIndex; ///< The character index within the word. + std::size_t mCharacterParagraphIndex; ///< The character index within the paragraph. +}; + +/** + * Stores gradient info. + * + * Used to fade in/out text-actors. + */ +struct GradientInfo +{ + /** + * Default constructor. + * + * Initializes all members to their default values. + */ + GradientInfo(); + + /** + * Default destructor. + */ + ~GradientInfo(); + + /** + * Copy constructor + */ + GradientInfo( const GradientInfo& info ); + + /** + * Assignment operator. + */ + GradientInfo& operator=( const GradientInfo& info ); + + Vector4 mGradientColor; ///< Gradient color. + Vector2 mStartPoint; ///< Gradient start point. + Vector2 mEndPoint; ///< Gradient end point. }; /** @@ -108,6 +144,13 @@ struct CharacterLayoutInfo CharacterLayoutInfo(); /** + * Default destructor. + * + * Deletes the gradient info. + */ + ~CharacterLayoutInfo(); + + /** * Copy constructor. */ CharacterLayoutInfo( const CharacterLayoutInfo& character ); @@ -117,30 +160,25 @@ struct CharacterLayoutInfo */ CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character ); - // Natural size (metrics) of the glyph. - float mHeight; ///< Natural height of the character. - float mAdvance; ///< Natural horizontal distance from origin of current character and the next one. - float mBearing; ///< Natural vertical distance from the baseline to the top of the glyph's bbox. - - // Size of the text-actor (may be modified by a scale factor). - Vector3 mPosition; ///< Position within the text-view - Vector2 mOffset; ///< Alignment and justification offset. - Size mSize; ///< Size of this character. + // Metrics of the glyph. + Size mSize; ///< Height of the font and advance (the horizontal distance from the origin of the current character and the next one). + float mBearing; ///< Vertical distance from the baseline to the top of the glyph's boundary box. float mAscender; ///< Distance from the base line to the top of the line. float mUnderlineThickness; ///< The underline's thickness. float mUnderlinePosition; ///< The underline's position. - RenderableActor mGlyphActor; ///< Handle to a text-actor. - MarkupProcessor::StyledText mStyledText; ///< Stores the text and its style. - float mColorAlpha; ///< Alpha component for the initial text color when text is faded. - Vector4 mGradientColor; ///< Gradient color. - Vector2 mStartPoint; ///< Gradient start point. - Vector2 mEndPoint; ///< Gradient end point. + // Position and alignment offset. It depends on the lay-out. + Vector3 mPosition; ///< Position within the text-view + Vector2 mOffset; ///< Alignment and justification offset. - bool mIsVisible:1; ///< Whether the text-actor is visible. - bool mSetText:1; ///< Whether a new text needs to be set in the text-actor. - bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor. - bool mIsColorGlyph:1; ///< Whether this character is an emoticon. + RenderableActor mGlyphActor; ///< Handle to a text-actor. + float mColorAlpha; ///< Alpha component for the initial text color when text is faded. + GradientInfo* mGradientInfo; ///< Stores gradient info. + + bool mIsVisible:1; ///< Whether the text-actor is visible. + bool mSetText:1; ///< Whether a new text needs to be set in the text-actor. + bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor. + bool mIsColorGlyph:1; ///< Whether this character is an emoticon. }; typedef std::vector CharacterLayoutInfoContainer; @@ -157,6 +195,13 @@ struct WordLayoutInfo WordLayoutInfo(); /** + * Default destructor. + * + * Clears all characters. + */ + ~WordLayoutInfo(); + + /** * Copy constructor. */ WordLayoutInfo( const WordLayoutInfo& word ); @@ -169,69 +214,90 @@ struct WordLayoutInfo Size mSize; ///< Size of the word. float mAscender; ///< Max of all ascenders of all characters. TextSeparatorType mType; ///< Whether this word is a word separator, a line separator or is not a separator. + std::size_t mFirstCharacter; ///< Index to the first character of the word within the paragraph. CharacterLayoutInfoContainer mCharactersLayoutInfo; ///< Layout info for all characters. }; typedef std::vector WordLayoutInfoContainer; /** - * Layout information for a group of words. + * Stores the reordered layout for right to left text. */ -struct WordGroupLayoutInfo +struct RightToLeftParagraphLayout { - /** - * Default constructor. - * - * Initializes all members to their default values. - */ - WordGroupLayoutInfo(); + RightToLeftParagraphLayout() + : mWordsLayoutInfo(), + mText(), + mTextStyles(), + mPreviousLayoutCleared( false ) + { + } + + WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words. + Text mText; ///< Stores the text. + Vector mTextStyles; ///< Stores the style per each character. + bool mPreviousLayoutCleared:1; ///< Whether the previous right to left layout has been cleared. /** - * Copy constructor. - */ - WordGroupLayoutInfo( const WordGroupLayoutInfo& group ); - - /** - * Assignment operator. + * Clears the word layout vector, the text and the vector of styles. */ - WordGroupLayoutInfo& operator=( const WordGroupLayoutInfo& group ); - - Size mSize; ///< Size of the group of words. - float mAscender; ///< Max of all ascenders of all words. - Direction mDirection; ///< Whether this group of words is Right To Left or Left To Right. - WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words. - std::size_t mNumberOfCharacters; ///< Stores the number of characters. + void Clear(); }; -typedef std::vector WordGroupLayoutInfoContainer; /** - * Layout information for a line. + * Layout information for a paragraph. */ -struct LineLayoutInfo +struct ParagraphLayoutInfo { /** * Default constructor. * * Initializes all members to their default values. */ - LineLayoutInfo(); + ParagraphLayoutInfo(); + + /** + * Default destructor. + * + * Clears all words, deletes all text styles, the paragraph bidirectional info and all bidirectional infor for each line. + */ + ~ParagraphLayoutInfo(); /** * Copy constructor. */ - LineLayoutInfo( const LineLayoutInfo& line ); + ParagraphLayoutInfo( const ParagraphLayoutInfo& paragraph ); /** * Assignment operator. */ - LineLayoutInfo& operator=( const LineLayoutInfo& line ); + ParagraphLayoutInfo& operator=( const ParagraphLayoutInfo& paragraph ); - Size mSize; ///< Size of the line. - float mAscender; ///< Max of all ascenders of all groups of words. - float mLineHeightOffset; ///< Line height offset. - WordGroupLayoutInfoContainer mWordGroupsLayoutInfo; ///< Layout info for all groups of words. - std::size_t mNumberOfCharacters; ///< Stores the number of characters. + /** + * Deletes the bidirectional info for each line. + */ + void ClearBidirectionalInfo(); + +private: + + /** + * Deletes all text styles. + */ + void ClearStyles(); + +public: + Size mSize; ///< Size of the paragraph. + float mAscender; ///< Max of all ascenders of all words. + float mLineHeightOffset; ///< Line height offset. + std::size_t mFirstCharacter; ///< Index to the first character of the paragraph. + std::size_t mNumberOfCharacters; ///< Stores the number of characters. + WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words. + Text mText; ///< Stores the text. + Vector mTextStyles; ///< Stores the style per each character. + RightToLeftParagraphLayout* mRightToLeftLayout; ///< Stores the reordered layout for the paragraph. + TextProcessor::BidirectionalParagraphInfo* mBidirectionalParagraphInfo; ///< Contains bidirectional info for the whole paragraph. Set to NULL if the paragraph has left to right characters only. + Vector mBidirectionalLinesInfo; ///< Contains bidirectional info for each laid-out line. }; -typedef std::vector LineLayoutInfoContainer; +typedef std::vector ParagraphLayoutInfoContainer; /** * Layout information for the whole text. @@ -246,6 +312,13 @@ struct TextLayoutInfo TextLayoutInfo(); /** + * Defualt destructor. + * + * Clears the paragraph vector, the ellipsis text and deletes all ellipsis styles. + */ + ~TextLayoutInfo(); + + /** * Copy constructor. */ TextLayoutInfo( const TextLayoutInfo& text ); @@ -255,12 +328,21 @@ struct TextLayoutInfo */ TextLayoutInfo& operator=( const TextLayoutInfo& text ); - Size mWholeTextSize; ///< width and height of the whole text. - float mMaxWordWidth; ///< maximum width between all words. - LineLayoutInfoContainer mLinesLayoutInfo; ///< Layout information for all lines. - std::size_t mNumberOfCharacters; ///< Stores the number of characters. - float mMaxItalicsOffset; ///< When rendering text-view in offscreen an extra width offset is needed to prevent italic characters to be cut if they are in the right edge. - WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text. +private: + /** + * Deletes all the ellipsis text styles. + */ + void ClearStyles(); + +public: + Size mWholeTextSize; ///< width and height of the whole text. + float mMaxWordWidth; ///< maximum width between all words. + float mMaxItalicsOffset; ///< When rendering text-view in offscreen an extra width offset is needed to prevent italic characters to be cut if they are in the right edge. + std::size_t mNumberOfCharacters; ///< Stores the number of characters. + ParagraphLayoutInfoContainer mParagraphsLayoutInfo; ///< Layout information for all paragraphs. + WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text. + Dali::Text mEllipsisText; ///< The ellipsis text. + Vector mEllipsisTextStyles; ///< Stores the style per each character of the ellipsis text. }; } // namespace TextViewProcessor