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