1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_LINE_PROCESSOR_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_LINE_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 line, and data structures with useful info to modify the layout data structure if characters are added or removed.
39 * @param[in] line The styled line.
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] lineLayoutInfo Layout info for the whole line.
43 void CreateLineInfo( const MarkupProcessor::StyledTextArray& line,
44 TextView::RelayoutData& relayoutData,
45 LineLayoutInfo& lineLayoutInfo );
48 * Updates the line layout size info.
50 * @param[in,out] lineLayoutInfo The line layout info.
51 * @param[in] lineHeightOffset The line height offset.
53 void UpdateLayoutInfo( LineLayoutInfo& lineLayoutInfo, float lineHeightOffset );
56 * Removes a given number of words from the given line.
58 * @pre \e wordIndex and \e wordIndex + \e numberOfWords can't exceed the bounds of the line.
60 * @param[in] wordIndex Index to the word within the line with the starting position to be deleted.
61 * @param[in] numberOfWords The number of words to be deleted.
62 * @param[in] lineHeightOffset Additional space between lines. Needed to update layout info.
63 * @param[in,out] lineLayout The input is the layout info of the line. The output is the layout info of the line without the removed words.
65 void RemoveWordsFromLine( std::size_t wordIndex,
66 std::size_t numberOfWords,
67 float lineHeightOffset,
68 LineLayoutInfo& lineLayout );
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] mergeLines Whether current line need to be merged with the next one.
75 * @param[in,out] textInfoIndicesBegin Indices to the line, word and characters from where to delete characters. It returns from where words need to be removed.
76 * @param[out] textInfoIndicesEnd If lines or words need to be merged it returns info to delete them (If a word is merged, it has to be removed. Equal for lines).
77 * @param[out] textInfoMergeIndicesBegin The indices to the first part of the line and word to be merged.
78 * @param[out] textInfoMergeIndicesEnd The indices to the last part of the line and word to be merged.
79 * @param[in,out] lineLayout Layout info of the line 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 RemoveCharactersFromLineInfo( TextView::RelayoutData& relayoutData,
84 std::size_t numberOfCharacters,
87 TextInfoIndices& textInfoIndicesBegin,
88 TextInfoIndices& textInfoIndicesEnd,
89 TextInfoIndices& textInfoMergeIndicesBegin,
90 TextInfoIndices& textInfoMergeIndicesEnd,
91 LineLayoutInfo& lineLayout,
92 std::vector<TextActor>& removedTextActorsFromFirstWord,
93 std::vector<TextActor>& removedTextActorsFromLastWord );
96 * Splits a given line in two.
98 * @note It deletes whatever there is in the last part of the line.
100 * @param[in] indices Index to the word within the line and index to the character within the word to split the line.
101 * @param[in] lineHeightOffset Additional space between lines. Needed to update layout info.
102 * @param[in,out] firstLineLayoutInfo The input is the layout info of the given line. The output is the first part of the input line.
103 * @param[in,out] lastLineLayoutInfo Layout info of the last part of the given line.
105 void SplitLine( const TextInfoIndices& indices,
106 const PointSize& lineHeightOffset,
107 LineLayoutInfo& firstLineLayoutInfo,
108 LineLayoutInfo& lastLineLayoutInfo );
111 * Merges the two given lines by adding words of the last line to the firs one.
113 * @note Does nothing if last part of the line is empty.
114 * @note If the first part of the line is empty it just copy the last part to it.
115 * @note it asserts if the last word of the first line is a line separator (new line character)
117 * @param[in,out] firstLineLineLayoutInfo The input is the layout info of the first line. The output is the layout info of the merged line.
118 * @param[in] lastLineLayoutInfo Layout info of the last line.
121 void MergeLine( LineLayoutInfo& firstLineLineLayoutInfo,
122 const LineLayoutInfo& lastLineLayoutInfo );
125 * Retrieves the layout information of the last word of the given line.
127 * @param[in] lineLayoutInfo The line layout.
129 * @return Layout information of the last word of the line.
131 WordLayoutInfo GetLastWordLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
134 * Retrieves the layout information of the first character of the given line.
136 * @param[in] lineLayoutInfo The line layout.
138 * @return Layout information of the first character of the line.
140 CharacterLayoutInfo GetFirstCharacterLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
143 * Retrieves the layout information of the last character of the given line.
145 * @param[in] lineLayoutInfo The line layout.
147 * @return Layout information of the last character of the line.
149 CharacterLayoutInfo GetLastCharacterLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
152 * Collects text-actors from the given lines and stores them into the text-actor vector.
154 * @param[out] textActors Stores the text-actors of the given lines.
155 * @param[in] textLayoutInfo Whole text with the given lines.
156 * @param[in] lineIndexBegin The first line.
157 * @param[in] lineIndexEnd The last line.
159 void CollectTextActorsFromLines( std::vector<TextActor>& textActors, const TextLayoutInfo& textLayoutInfo, std::size_t lineIndexBegin, std::size_t lineIndexEnd );
161 } //namespace TextViewProcessor
163 } //namespace Internal
165 } //namespace Toolkit
169 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_LINE_PROCESSOR_H__