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 Flora License, Version 1.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://floralicense.org/license/
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.
21 #include "text-view-impl.h"
22 #include "text-view-processor-types.h"
33 namespace TextViewProcessor
37 * Updates the line layout size info.
39 * @param[in,out] lineLayoutInfo The line layout info.
40 * @param[in] lineHeightOffset The line height offset.
42 void UpdateLineLayoutInfo( TextViewProcessor::LineLayoutInfo& lineLayoutInfo, float lineHeightOffset );
45 * 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.
47 * @param[in] line The styled line.
48 * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info and conversion from visual to logical order and vice versa (for RTL text).
49 * @param[out] lineLayoutInfo Layout info for the whole line.
51 void CreateLineInfo( const MarkupProcessor::StyledTextArray& line,
52 TextView::RelayoutData& relayoutData,
53 TextViewProcessor::LineLayoutInfo& lineLayoutInfo );
56 * Removes a given number of groups of words from the given line.
58 * @pre \e groupIndex and \e groupIndex + \e numberOfGroups can't exceed the bounds of the line.
60 * @param[in] groupIndex Index to the group of words within the line with the starting position to be deleted.
61 * @param[in] numberOfGroups The number of group 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 group of words.
65 void RemoveWordGroupsFromLine( std::size_t groupIndex,
66 std::size_t numberOfGroups,
67 const PointSize& lineHeightOffset,
68 LineLayoutInfo& lineLayout );
71 * Splits a given line in two.
73 * @note It deletes whatever there is in the last part of the line.
75 * @param[in] indices Index to the group of words within the line, index to the word and index to the character within the word to split the line.
76 * @param[in] lineHeightOffset Additional space between lines. Needed to update layout info.
77 * @param[in,out] firstLineLayoutInfo The input is the layout info of the given line. The output is the first part of the input line (from the group of words \e 0 to the group of words \e groupPosition).
78 * @param[in,out] lastLineLayoutInfo Layout info of the last part of the given line ( from the group of words \e groupPosition + \e 1 to the end of the line).
80 void SplitLine( const TextInfoIndices& indices,
81 const PointSize& lineHeightOffset,
82 LineLayoutInfo& firstLineLayoutInfo,
83 LineLayoutInfo& lastLineLayoutInfo );
86 * Merges the two given lines by adding groups of words of the last line to the firs one.
88 * @note Does nothing if last part of the line is empty.
89 * @note If the first part of the line is empty it just copy the last part to it.
90 * @note it asserts if the last word of the first group is a line separator (new line character)
92 * @param[in,out] firstLineLineLayoutInfo The input is the layout info of the first line. The output is the layout info of the merged line.
93 * @param[in] lastLineLayoutInfo Layout info of the last line.
96 void MergeLine( LineLayoutInfo& firstLineLineLayoutInfo,
97 const LineLayoutInfo& lastLineLayoutInfo );
100 * Retrieves the layout information of the last word of the given line.
102 * @param[in] lineLayoutInfo The line layout.
104 * @return Layout information of the last word of the line.
106 WordLayoutInfo GetLastWordLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
109 * Retrieves the layout information of the first character of the given line.
111 * @param[in] lineLayoutInfo The line layout.
113 * @return Layout information of the first character of the line.
115 CharacterLayoutInfo GetFirstCharacterLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
118 * Retrieves the layout information of the last character of the given line.
120 * @param[in] lineLayoutInfo The line layout.
122 * @return Layout information of the last character of the line.
124 CharacterLayoutInfo GetLastCharacterLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
127 * Collects text-actors from the given lines and stores them into the text-actor vector.
129 * @param[out] textActors Stores the text-actors of the given lines.
130 * @param[in] textLayoutInfo Whole text with the given lines.
131 * @param[in] lineIndexBegin The first line.
132 * @param[in] lineIndexEnd The last line.
134 void CollectTextActorsFromLines( std::vector<TextActor>& textActors, const TextLayoutInfo& textLayoutInfo, std::size_t lineIndexBegin, std::size_t lineIndexEnd );
136 } //namespace TextViewProcessor
138 } //namespace Internal
140 } //namespace Toolkit
144 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_LINE_PROCESSOR_H__