5ca41603373e01351b0b6aaa2e86a3876175d6c8
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-view / text-view-processor.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_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 "text-view-impl.h"
23 #include "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  * Creates a data structure with info to layout the text, and data structures with useful info to modify the layout data structure if characters are added or removed.
39  *
40  * @param[in] text The given styled text.
41  * @param[in] layoutParameters Layout configuration.
42  * @param[out] relayoutData Natural size (metrics), layout, text-actor info and conversion from visual to logical order and vice versa (for RTL text).
43  */
44 void CreateTextInfo( const MarkupProcessor::StyledTextArray& text,
45                      const TextView::LayoutParameters& layoutParameters,
46                      TextView::RelayoutData& relayoutData );
47
48 /**
49  *  Updates the layout data structures with the new inserted text.
50  *
51  * @note Does nothing if text has no characters.
52  * @note It asserts if position is bigger than the number of characters of the whole text.
53  *
54  * @param[in] position Where the text is going to be inserted.
55  * @param[in] text New styled text to be inserted.
56  * @param[in] layoutParameters Layout configuration.
57  * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info and conversion from visual to logical order and vice versa (for RTL text).
58  */
59 void UpdateTextInfo( std::size_t position,
60                      const MarkupProcessor::StyledTextArray& text,
61                      const TextView::LayoutParameters& layoutParameters,
62                      TextView::RelayoutData& relayoutData );
63
64 /**
65  *  Updates the layout data structures by removing text.
66  *
67  * @note Does nothing if number of characters to be deleted is zero.
68  * @note It asserts if trying to delete text out of bounds.
69  *
70  * @param[in] position Position of the first character to be removed.
71  * @param[in] numberOfCharacters The number of characters to be removed.
72  * @param[in] layoutParameters Layout configuration.
73  * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info and conversion from visual to logical order and vice versa (for RTL text).
74  * @param[in] clearText Whether to clear text-actor's text before insert the text-actors into the cache.
75  */
76 void UpdateTextInfo( std::size_t position,
77                      std::size_t numberOfCharacters,
78                      const TextView::LayoutParameters& layoutParameters,
79                      TextView::RelayoutData& relayoutData,
80                      TextOperationOnRemove clearText );
81
82 /**
83  * Updates the layout data structures by replacing text.
84  *
85  * @param[in] position Position of the first character to be replaced.
86  * @param[in] numberOfCharacters The number of characters to be replaced.
87  * @param[in] text The new styled text.
88  * @param[in] layoutParameters Layout configuration.
89  * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info and conversion from visual to logical order and vice versa (for RTL text).
90  */
91 void UpdateTextInfo( std::size_t position,
92                      std::size_t numberOfCharacters,
93                      const MarkupProcessor::StyledTextArray& text,
94                      const TextView::LayoutParameters& layoutParameters,
95                      TextView::RelayoutData& relayoutData );
96
97 /**
98  * Updates the layout data structure by modifying the space between lines.
99  *
100  * @param[in] lineHeightOffset The new space between lines.
101  * @param[in,out] textLayoutInfo Layout info for all groups of characters, words, groups of words, lines and the whole text.
102  */
103 void UpdateTextInfo( float lineHeightOffset,
104                      TextLayoutInfo& textLayoutInfo );
105
106 /**
107  * Updates the text-actor data structures by replacing the style.
108  *
109  * @note This operation is called only if the new style doesn't modify the metrics. Consequently it doesn't modify any size info.
110  *
111  * @param[in] style The new style.
112  * @param[in] mask The style mask.
113  * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
114  */
115 void UpdateTextInfo( const TextStyle& style,
116                      TextStyle::Mask mask,
117                      TextView::RelayoutData& relayoutData );
118
119 /**
120  * Traverse all text initializing all non initialized text-actor handles.
121  *
122  * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
123  */
124 void InitializeTextActorInfo( TextView::RelayoutData& relayoutData );
125
126 } // namespace TextViewProcessor
127
128 } // namespace Internal
129
130 } // namespace Toolkit
131
132 } // namespace Dali
133
134 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_H__