Merge "Fix a crash in ImageVisual in case of an invalid image and changed to render...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / bidirectional-support.h
1 #ifndef __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_SUPPORT_H__
2 #define __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_SUPPORT_H__
3
4 /*
5  * Copyright (c) 2015 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/text/bidirectional-line-info-run.h>
26 #include <dali-toolkit/internal/text/bidirectional-paragraph-info-run.h>
27 #include <dali-toolkit/internal/text/line-run.h>
28 #include <dali-toolkit/internal/text/script-run.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Text
37 {
38
39 /**
40  * Sets the bidirectional info into the logical model.
41  *
42  * @param[in] text Vector of UTF-32 characters.
43  * @param[in] scripts Vector containing the script runs for the whole text.
44  * @param[in] lineBreakInfo The line break info.
45  * @param[in] startIndex The character from where the bidirectional info is set.
46  * @param[in] numberOfCharacters The number of characters.
47  * @param[out] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
48  */
49 void SetBidirectionalInfo( const Vector<Character>& text,
50                            const Vector<ScriptRun>& scripts,
51                            const Vector<LineBreakInfo>& lineBreakInfo,
52                            CharacterIndex startIndex,
53                            Length numberOfCharacters,
54                            Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo );
55
56 /**
57  * Sets the visual to logical map tables.
58  *
59  * Any map tables previously set are removed.
60  * It sets the paragraph's direction to each line.
61  *
62  * @pre The @p logicalModel needs to have a text set.
63  * @pre The @p logicalModel needs to have the bidirectional info indices for each paragraph set.
64  * @pre The @p visualModel needs to have the laid-out lines info set.
65  *
66  * @param[in] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
67  * @param[in] startIndex The character from where the bidirectional info is set.
68  * @param[in] numberOfCharacters The number of characters.
69  * @param[in,out] lineRuns The line runs converted to characters.
70  * @param[out] lineInfoRuns line runs with the visual to logical conversion maps.
71  */
72 void ReorderLines( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
73                    CharacterIndex startIndex,
74                    Length numberOfCharacters,
75                    Vector<LineRun>& lineRuns,
76                    Vector<BidirectionalLineInfoRun>& lineInfoRuns );
77
78 /**
79  * @brief Replaces any character in the right to left paragraphs which could be mirrored.
80  *
81  * @param[in] text The text.
82  * @param[in] directions Vector with the direction of each paragraph.
83  * @param[in] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
84  * @param[in] startIndex The character from where the text is mirrored.
85  * @param[in] numberOfCharacters The number of characters.
86  * @param[out] mirroredText The mirroredText.
87  *
88  * @return @e true if a character has been replaced.
89  */
90 bool GetMirroredText( const Vector<Character>& text,
91                       const Vector<CharacterDirection>& directions,
92                       const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
93                       CharacterIndex startIndex,
94                       Length numberOfCharacters,
95                       Vector<Character>& mirroredText );
96
97 /**
98  * @brief Retrieves the character's directions.
99  *
100  * @pre The @p logicalModel needs to have a text set.
101  * @pre The @p logicalModel needs to have the bidirectional info indices for each paragraph set.
102  *
103  * @param[in] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
104  * @param[in] totalNumberOfCharacters The number of characters of the whole text.
105  * @param[in] startIndex The character from where the direction info is set.
106  * @param[in] numberOfCharacters The number of characters.
107  * @param[out] directions The direction, @e false is left to right and @e true is right to left, of each character of the paragraph.
108  */
109 void GetCharactersDirection( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
110                              Length totalNumberOfCharacters,
111                              CharacterIndex startIndex,
112                              Length numberOfCharacters,
113                              Vector<CharacterDirection>& directions );
114
115 } // namespace Text
116
117 } // namespace Toolkit
118
119 } // namespace Dali
120
121 #endif // __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_SUPPORT_H__