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,out] relayoutData Natural size (metrics), layout, text-actor info and conversion from visual to logical order and vice versa (for RTL text).
40 * @param[out] paragraphLayoutInfo Layout info for the whole paragraph.
42 void CreateParagraphInfo( TextView::RelayoutData& relayoutData,
43 ParagraphLayoutInfo& paragraphLayoutInfo );
46 * Updates the paragraph layout info.
48 * @param[in,out] paragraphLayoutInfo The paragraph layout info.
49 * @param[in] lineHeightOffset The offset added to the line height.
51 void UpdateLayoutInfo( ParagraphLayoutInfo& paragraphLayoutInfo, float lineHeightOffset );
54 * Removes a given number of words from the given paragraph.
56 * @pre \e wordIndex and \e wordIndex + \e numberOfWords can't exceed the bounds of the paragraph.
58 * @param[in] wordIndex Index to the word within the paragraph with the starting position to be deleted.
59 * @param[in] numberOfWords The number of words to be deleted.
60 * @param[in] lineHeightOffset The offset added to the line height. Needed to update the layout info.
61 * @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.
63 void RemoveWordsFromParagraph( std::size_t wordIndex,
64 std::size_t numberOfWords,
65 float lineHeightOffset,
66 ParagraphLayoutInfo& paragraphLayout );
69 * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
70 * @param[in] numberOfCharacters The number of characters to be deleted.
71 * @param[out] mergeWords Whether words need to be merged after removing characters.
72 * @param[out] mergeParagraphs Whether current paragraph need to be merged with the next one.
73 * @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.
74 * @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).
75 * @param[out] textInfoMergeIndicesBegin The indices to the first part of the paragraph and word to be merged.
76 * @param[out] textInfoMergeIndicesEnd The indices to the last part of the paragraph and word to be merged.
77 * @param[in,out] paragraphLayout Layout info of the paragraph where the word is located.
78 * @param[out] removedTextActorsFromFirstWord Stores removed text-actors of the word pointed by the 'begin' index.
79 * @param[out] removedTextActorsFromLastWord Stores removed text-actors of the word pointed by the 'end' index.
81 void RemoveCharactersFromParagraphInfo( TextView::RelayoutData& relayoutData,
82 std::size_t numberOfCharacters,
84 bool& mergeParagraphs,
85 TextInfoIndices& textInfoIndicesBegin,
86 TextInfoIndices& textInfoIndicesEnd,
87 TextInfoIndices& textInfoMergeIndicesBegin,
88 TextInfoIndices& textInfoMergeIndicesEnd,
89 ParagraphLayoutInfo& paragraphLayout,
90 std::vector<TextActor>& removedTextActorsFromFirstWord,
91 std::vector<TextActor>& removedTextActorsFromLastWord );
94 * Splits a given paragraph in two.
96 * @note It deletes whatever there is in the last part of the paragraph.
98 * @param[in] indices Index to the word within the paragraph and index to the character within the word to split the paragraph.
99 * @param[in] lineHeightOffset Additional space between lines. Needed to update layout info.
100 * @param[in,out] firstParagraphLayoutInfo The input is the layout info of the given paragraph. The output is the first part of the input paragraph.
101 * @param[in,out] lastParagraphLayoutInfo Layout info of the last part of the given paragraph.
103 void SplitParagraph( const TextInfoIndices& indices,
104 float lineHeightOffset,
105 ParagraphLayoutInfo& firstParagraphLayoutInfo,
106 ParagraphLayoutInfo& lastParagraphLayoutInfo );
109 * Merges the two given paragraphs by adding words of the last paragraph to the firs one.
111 * @note Does nothing if last part of the paragraph is empty.
112 * @note If the first part of the paragraph is empty it just copy the last part to it.
113 * @note it asserts if the last word of the first paragraph is a paragraph separator (new paragraph character)
115 * @param[in,out] firstParagraphLayoutInfo The input is the layout info of the first paragraph. The output is the layout info of the merged paragraph.
116 * @param[in] lastParagraphLayoutInfo Layout info of the last paragraph.
119 void MergeParagraph( ParagraphLayoutInfo& firstParagraphLayoutInfo,
120 const ParagraphLayoutInfo& lastParagraphLayoutInfo );
123 * Retrieves the layout information of the last word of the given paragraph.
125 * @param[in] paragraphLayoutInfo The paragraph layout.
127 * @return Layout information of the last word of the paragraph.
129 WordLayoutInfo GetLastWordLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
132 * Retrieves the layout information of the first character of the given paragraph.
134 * @param[in] paragraphLayoutInfo The paragraph layout.
136 * @return Layout information of the first character of the paragraph.
138 CharacterLayoutInfo GetFirstCharacterLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
141 * Retrieves the layout information of the last character of the given paragraph.
143 * @param[in] paragraphLayoutInfo The paragraph layout.
145 * @return Layout information of the last character of the paragraph.
147 CharacterLayoutInfo GetLastCharacterLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
150 * Collects text-actors from the given paragraphs and stores them into the text-actor vector.
152 * @param[out] textActors Stores the text-actors of the given paragraphs.
153 * @param[in] textLayoutInfo Whole text with the given paragraphs.
154 * @param[in] paragraphIndexBegin The first paragraph.
155 * @param[in] paragraphIndexEnd The last paragraph.
157 void CollectTextActorsFromParagraphs( std::vector<TextActor>& textActors, const TextLayoutInfo& textLayoutInfo, std::size_t paragraphIndexBegin, std::size_t paragraphIndexEnd );
159 } //namespace TextViewProcessor
161 } //namespace Internal
163 } //namespace Toolkit
167 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PARAGRAPH_PROCESSOR_H__