Fixed crash in case that overshoot scroll is not enabled
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-view / text-view-processor-helper-functions.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_HELPER_FUNCTIONS_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_HELPER_FUNCTIONS_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/public-api/actors/text-actor.h>
23 #include <dali-toolkit/internal/controls/text-view/text-view-processor-types.h>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal
32 {
33
34 namespace TextViewProcessor
35 {
36
37 /**
38  * Enum type used to update a size adding other one.
39  * If the grow type is \e GrowWidth, size's widths are added and size's height is the max of both.
40  * Alternativelly if grow type is \e GrowHeight heights are added and width is the max of both.
41  */
42 enum SizeGrowType
43 {
44   GrowWidth,
45   GrowHeight,
46 };
47
48 /**
49  * Updates the size of a character, word, line or the whole text with a given size.
50  *
51  * For characters, words, and lines the new height will be the maximum of both sizes
52  * and the new width will be the sum of both.
53  *
54  * For the whole text, the new height will be the sum of both and the new width the max of both.
55  *
56  * The \e type parameter speficies which type of update is required.
57  *
58  * @param[in,out] size1 The current size to be updated.
59  * @param[in] size2 The size of a character, word, or a line.
60  * @param[in] type Type of update.
61  */
62 void UpdateSize( Size& size1, const Size& size2, SizeGrowType type = GrowWidth );
63
64 /**
65  * Return the type of separator (white space, new line or no separator) for the given character.
66  *
67  * @param[in] character The given character.
68  *
69  * @return The type of separator.
70  */
71 TextSeparatorType GetTextSeparatorType( const Character& character );
72
73 /**
74  * Choose a suitable font family name for the given character.
75  *
76  * It may modify the text-style of the given character by setting a suitable font-family.
77  *
78  * @param[in] character The character.
79  * @param[in,out] style The style of the character.
80  */
81 void ChooseFontFamilyName( const Character& character, TextStyle& style );
82
83 /**
84  * Retrieves the line, word and character indices for the given global character's index.
85  *
86  * i.e. The retrieved indices for the character 18 (j) for the following text would be: 2, 0, 2, 0
87  *
88  *  a b c d
89  *  e f g h
90  *  i j k l
91  *  m n o p
92  *
93  * @param[in] index The global character index.
94  * @param[in] textLayoutInfo Contains info about the number of characters per word, and line.
95  * @param[out] indices Index to the line, word and character within the word where the given character is located.
96  */
97 void GetIndicesFromGlobalCharacterIndex( std::size_t index,
98                                          const TextLayoutInfo& textLayoutInfo,
99                                          TextInfoIndices& indices );
100
101 /**
102  * Clear the text of the given text-actors.
103  *
104  * @param[in] textActors The given text-actors.
105  */
106 void ClearText( std::vector<TextActor>& textActors );
107
108 } //namespace TextViewProcessor
109
110 } //namespace Internal
111
112 } //namespace Toolkit
113
114 } //namespace Dali
115
116 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_HELPER_FUNCTIONS_H__