Split dali-toolkit into Base & Optional
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-view / text-view-line-processor.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_LINE_PROCESSOR_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_LINE_PROCESSOR_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
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
10 //
11 //     http://floralicense.org/license/
12 //
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.
18 //
19
20 // INTERNAL INCLUDES
21 #include "text-view-impl.h"
22 #include "text-view-processor-types.h"
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal
31 {
32
33 namespace TextViewProcessor
34 {
35
36 /**
37  * Updates the line layout size info.
38  *
39  * @param[in,out] lineLayoutInfo The line layout info.
40  * @param[in] lineHeightOffset The line height offset.
41  */
42 void UpdateLineLayoutInfo( TextViewProcessor::LineLayoutInfo& lineLayoutInfo, float lineHeightOffset );
43
44 /**
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.
46  *
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.
50  */
51 void CreateLineInfo( const MarkupProcessor::StyledTextArray& line,
52                      TextView::RelayoutData& relayoutData,
53                      TextViewProcessor::LineLayoutInfo& lineLayoutInfo );
54
55 /**
56  * Removes a given number of groups of words from the given line.
57  *
58  * @pre \e groupIndex and \e groupIndex + \e numberOfGroups can't exceed the bounds of the line.
59  *
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.
64  */
65 void RemoveWordGroupsFromLine( std::size_t groupIndex,
66                                std::size_t numberOfGroups,
67                                const PointSize& lineHeightOffset,
68                                LineLayoutInfo& lineLayout );
69
70 /**
71  * Splits a given line in two.
72  *
73  * @note It deletes whatever there is in the last part of the line.
74  *
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).
79  */
80 void SplitLine( const TextInfoIndices& indices,
81                 const PointSize& lineHeightOffset,
82                 LineLayoutInfo& firstLineLayoutInfo,
83                 LineLayoutInfo& lastLineLayoutInfo );
84
85 /**
86  * Merges the two given lines by adding groups of words of the last line to the firs one.
87  *
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)
91  *
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.
94  *
95  */
96 void MergeLine( LineLayoutInfo& firstLineLineLayoutInfo,
97                 const LineLayoutInfo& lastLineLayoutInfo );
98
99 /**
100  * Retrieves the layout information of the last word of the given line.
101  *
102  * @param[in] lineLayoutInfo The line layout.
103  *
104  * @return Layout information of the last word of the line.
105  */
106 WordLayoutInfo GetLastWordLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
107
108 /**
109  * Retrieves the layout information of the first character of the given line.
110  *
111  * @param[in] lineLayoutInfo The line layout.
112  *
113  * @return Layout information of the first character of the line.
114  */
115 CharacterLayoutInfo GetFirstCharacterLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
116
117 /**
118  * Retrieves the layout information of the last character of the given line.
119  *
120  * @param[in] lineLayoutInfo The line layout.
121  *
122  * @return Layout information of the last character of the line.
123  */
124 CharacterLayoutInfo GetLastCharacterLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
125
126 /**
127  * Collects text-actors from the given lines and stores them into the text-actor vector.
128  *
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.
133  */
134 void CollectTextActorsFromLines( std::vector<TextActor>& textActors, const TextLayoutInfo& textLayoutInfo, std::size_t lineIndexBegin, std::size_t lineIndexEnd );
135
136 } //namespace TextViewProcessor
137
138 } //namespace Internal
139
140 } //namespace Toolkit
141
142 } //namespace Dali
143
144 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_LINE_PROCESSOR_H__