Remove redundant orientation settings as default camera already looks at stage
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-view / text-view-paragraph-processor.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PARAGRAPH_PROCESSOR_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PARAGRAPH_PROCESSOR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
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
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/controls/text-view/text-view-impl.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal
31 {
32
33 namespace TextViewProcessor
34 {
35
36 /**
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.
38  *
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.
41  */
42 void CreateParagraphInfo( TextView::RelayoutData& relayoutData,
43                           ParagraphLayoutInfo& paragraphLayoutInfo );
44
45 /**
46  * Updates the paragraph layout info.
47  *
48  * @param[in,out] paragraphLayoutInfo The paragraph layout info.
49  * @param[in] lineHeightOffset The offset added to the line height.
50  */
51 void UpdateLayoutInfo( ParagraphLayoutInfo& paragraphLayoutInfo, float lineHeightOffset );
52
53 /**
54  * Removes a given number of words from the given paragraph.
55  *
56  * @pre \e wordIndex and \e wordIndex + \e numberOfWords can't exceed the bounds of the paragraph.
57  *
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.
62  */
63 void RemoveWordsFromParagraph( std::size_t wordIndex,
64                                std::size_t numberOfWords,
65                                float lineHeightOffset,
66                                ParagraphLayoutInfo& paragraphLayout );
67
68 /**
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.
80  */
81 void RemoveCharactersFromParagraphInfo( TextView::RelayoutData& relayoutData,
82                                         std::size_t numberOfCharacters,
83                                         bool& mergeWords,
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 );
92
93 /**
94  * Splits a given paragraph in two.
95  *
96  * @note It deletes whatever there is in the last part of the paragraph.
97  *
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.
102  */
103 void SplitParagraph( const TextInfoIndices& indices,
104                      float lineHeightOffset,
105                      ParagraphLayoutInfo& firstParagraphLayoutInfo,
106                      ParagraphLayoutInfo& lastParagraphLayoutInfo );
107
108 /**
109  * Merges the two given paragraphs by adding words of the last paragraph to the firs one.
110  *
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)
114  *
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.
117  *
118  */
119 void MergeParagraph( ParagraphLayoutInfo& firstParagraphLayoutInfo,
120                      const ParagraphLayoutInfo& lastParagraphLayoutInfo );
121
122 /**
123  * Retrieves the layout information of the last word of the given paragraph.
124  *
125  * @param[in] paragraphLayoutInfo The paragraph layout.
126  *
127  * @return Layout information of the last word of the paragraph.
128  */
129 WordLayoutInfo GetLastWordLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
130
131 /**
132  * Retrieves the layout information of the first character of the given paragraph.
133  *
134  * @param[in] paragraphLayoutInfo The paragraph layout.
135  *
136  * @return Layout information of the first character of the paragraph.
137  */
138 CharacterLayoutInfo GetFirstCharacterLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
139
140 /**
141  * Retrieves the layout information of the last character of the given paragraph.
142  *
143  * @param[in] paragraphLayoutInfo The paragraph layout.
144  *
145  * @return Layout information of the last character of the paragraph.
146  */
147 CharacterLayoutInfo GetLastCharacterLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
148
149 /**
150  * Collects text-actors from the given paragraphs and stores them into the text-actor vector.
151  *
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.
156  */
157 void CollectTextActorsFromParagraphs( std::vector<TextActor>& textActors, const TextLayoutInfo& textLayoutInfo, std::size_t paragraphIndexBegin, std::size_t paragraphIndexEnd );
158
159 } //namespace TextViewProcessor
160
161 } //namespace Internal
162
163 } //namespace Toolkit
164
165 } //namespace Dali
166
167 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PARAGRAPH_PROCESSOR_H__