1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PARAGRAPH_PROCESSOR_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PARAGRAPH_PROCESSOR_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali-toolkit/internal/controls/text-view/text-view-impl.h>
33 namespace TextViewProcessor
37 * Creates a data structure with info to layout the paragraph, and data structures with useful info to modify the layout data structure if characters are added or removed.
39 * @param[in] paragraph The styled paragraph.
40 * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info and conversion from visual to logical order and vice versa (for RTL text).
41 * @param[out] paragraphLayoutInfo Layout info for the whole paragraph.
43 void CreateParagraphInfo( const MarkupProcessor::StyledTextArray& line,
44 TextView::RelayoutData& relayoutData,
45 ParagraphLayoutInfo& paragraphLayoutInfo );
48 * Updates the paragraph layout info.
50 * @param[in,out] paragraphLayoutInfo The paragraph layout info.
51 * @param[in] lineHeightOffset The offset added to the line height.
53 void UpdateLayoutInfo( ParagraphLayoutInfo& paragraphLayoutInfo, float lineHeightOffset );
56 * Removes a given number of words from the given paragraph.
58 * @pre \e wordIndex and \e wordIndex + \e numberOfWords can't exceed the bounds of the paragraph.
60 * @param[in] wordIndex Index to the word within the paragraph with the starting position to be deleted.
61 * @param[in] numberOfWords The number of words to be deleted.
62 * @param[in] lineHeightOffset The offset added to the line height. Needed to update the layout info.
63 * @param[in,out] paragraphLayout The input is the layout info of the paragraph. The output is the layout info of the paragraph without the removed words.
65 void RemoveWordsFromParagraph( std::size_t wordIndex,
66 std::size_t numberOfWords,
67 float lineHeightOffset,
68 ParagraphLayoutInfo& paragraphLayout );
71 * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
72 * @param[in] numberOfCharacters The number of characters to be deleted.
73 * @param[out] mergeWords Whether words need to be merged after removing characters.
74 * @param[out] mergeParagraphs Whether current paragraph need to be merged with the next one.
75 * @param[in,out] textInfoIndicesBegin Indices to the paragraph, word and characters from where to delete characters. It returns from where words need to be removed.
76 * @param[out] textInfoIndicesEnd If paragraphs or words need to be merged it returns info to delete them (If a word is merged, it has to be removed. Equal for paragraphs).
77 * @param[out] textInfoMergeIndicesBegin The indices to the first part of the paragraph and word to be merged.
78 * @param[out] textInfoMergeIndicesEnd The indices to the last part of the paragraph and word to be merged.
79 * @param[in,out] paragraphLayout Layout info of the paragraph where the word is located.
80 * @param[out] removedTextActorsFromFirstWord Stores removed text-actors of the word pointed by the 'begin' index.
81 * @param[out] removedTextActorsFromLastWord Stores removed text-actors of the word pointed by the 'end' index.
83 void RemoveCharactersFromParagraphInfo( TextView::RelayoutData& relayoutData,
84 std::size_t numberOfCharacters,
86 bool& mergeParagraphs,
87 TextInfoIndices& textInfoIndicesBegin,
88 TextInfoIndices& textInfoIndicesEnd,
89 TextInfoIndices& textInfoMergeIndicesBegin,
90 TextInfoIndices& textInfoMergeIndicesEnd,
91 ParagraphLayoutInfo& paragraphLayout,
92 std::vector<TextActor>& removedTextActorsFromFirstWord,
93 std::vector<TextActor>& removedTextActorsFromLastWord );
96 * Splits a given paragraph in two.
98 * @note It deletes whatever there is in the last part of the paragraph.
100 * @param[in] indices Index to the word within the paragraph and index to the character within the word to split the paragraph.
101 * @param[in] lineHeightOffset Additional space between lines. Needed to update layout info.
102 * @param[in,out] firstParagraphLayoutInfo The input is the layout info of the given paragraph. The output is the first part of the input paragraph.
103 * @param[in,out] lastParagraphLayoutInfo Layout info of the last part of the given paragraph.
105 void SplitParagraph( const TextInfoIndices& indices,
106 float lineHeightOffset,
107 ParagraphLayoutInfo& firstParagraphLayoutInfo,
108 ParagraphLayoutInfo& lastParagraphLayoutInfo );
111 * Merges the two given paragraphs by adding words of the last paragraph to the firs one.
113 * @note Does nothing if last part of the paragraph is empty.
114 * @note If the first part of the paragraph is empty it just copy the last part to it.
115 * @note it asserts if the last word of the first paragraph is a paragraph separator (new paragraph character)
117 * @param[in,out] firstParagraphLayoutInfo The input is the layout info of the first paragraph. The output is the layout info of the merged paragraph.
118 * @param[in] lastParagraphLayoutInfo Layout info of the last paragraph.
121 void MergeParagraph( ParagraphLayoutInfo& firstParagraphLayoutInfo,
122 const ParagraphLayoutInfo& lastParagraphLayoutInfo );
125 * Retrieves the layout information of the last word of the given paragraph.
127 * @param[in] paragraphLayoutInfo The paragraph layout.
129 * @return Layout information of the last word of the paragraph.
131 WordLayoutInfo GetLastWordLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
134 * Retrieves the layout information of the first character of the given paragraph.
136 * @param[in] paragraphLayoutInfo The paragraph layout.
138 * @return Layout information of the first character of the paragraph.
140 CharacterLayoutInfo GetFirstCharacterLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
143 * Retrieves the layout information of the last character of the given paragraph.
145 * @param[in] paragraphLayoutInfo The paragraph layout.
147 * @return Layout information of the last character of the paragraph.
149 CharacterLayoutInfo GetLastCharacterLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
152 * Collects text-actors from the given paragraphs and stores them into the text-actor vector.
154 * @param[out] textActors Stores the text-actors of the given paragraphs.
155 * @param[in] textLayoutInfo Whole text with the given paragraphs.
156 * @param[in] paragraphIndexBegin The first paragraph.
157 * @param[in] paragraphIndexEnd The last paragraph.
159 void CollectTextActorsFromParagraphs( std::vector<TextActor>& textActors, const TextLayoutInfo& textLayoutInfo, std::size_t paragraphIndexBegin, std::size_t paragraphIndexEnd );
161 } //namespace TextViewProcessor
163 } //namespace Internal
165 } //namespace Toolkit
169 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PARAGRAPH_PROCESSOR_H__