Mirroring bidirectional text.
[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 class LogicalModel;
40 class VisualModel;
41
42 /**
43  * Sets the bidirectional info into the logical model.
44  *
45  * @param[in] text Vector of UTF-32 characters.
46  * @param[in] scripts Vector containing the script runs for the whole text.
47  * @param[in] lineBreakInfo The line break info.
48  * @param[out] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
49  */
50 void SetBidirectionalInfo( const Vector<Character>& text,
51                            const Vector<ScriptRun>& scripts,
52                            const Vector<LineBreakInfo>& lineBreakInfo,
53                            Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo );
54
55 /**
56  * Replaces the bidirectional info from the logical model.
57  *
58  * @pre The @p model needs to have a text set.
59  * @pre The @p model needs to have the line break info set.
60  *
61  * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
62  * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
63  *
64  * @param[in,out] model The text's logical model.
65  * @param[in] characterIndex Index to the first character.
66  * @param[in] numberOfCharactersToRemove The number of characters removed from the text.
67  * @param[in] numberOfCharactersToInsert The number of characters inserted in the text.
68  */
69 void ReplaceBidirectionalInfo( LogicalModel& model,
70                                CharacterIndex characterIndex,
71                                Length numberOfCharactersToRemove,
72                                Length numberOfCharactersToInsert );
73
74 /**
75  * Sets the visual to logical and logical to visual map tables.
76  *
77  * Any map tables previously set are removed.
78  *
79  * @pre The @p logicalModel needs to have a text set.
80  * @pre The @p logicalModel needs to have the bidirectional info indices for each paragraph set.
81  * @pre The @p visualModel needs to have the laid-out lines info set.
82  *
83  * @param[in] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
84  * @param[in] lineRuns The line runs converted to characters.
85  * @param[out] lineInfoRuns line runs with the visual to logical and logical to visual conversion maps.
86  */
87 void ReorderLines( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
88                    const Vector<LineRun>& lineRuns,
89                    Vector<BidirectionalLineInfoRun>& lineInfoRuns );
90
91 /**
92  * Replaces the visual to logical and logical to visual map tables.
93  *
94  * @pre The @p logicalModel needs to have a text set.
95  * @pre The @p logicalModel needs to have the line break info set.
96  * @pre The @p visualModel needs to have the laid-out lines info set.
97  *
98  * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
99  * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
100  *
101  * @param[in,out] logicalModel The text's logical model.
102  * @param[in] visualModel The text's visual model.
103  * @param[in] characterIndex Index to the first character.
104  * @param[in] numberOfCharactersToRemove The number of characters removed from the text.
105  * @param[in] numberOfCharactersToInsert The number of characters inserted in the text.
106  */
107 void ReorderLines( LogicalModel& logicalModel,
108                    const VisualModel& visualModel,
109                    CharacterIndex characterIndex,
110                    Length numberOfCharactersToRemove,
111                    Length numberOfCharactersToInsert );
112
113 /**
114  * @brief Replaces any character which could be mirrored.
115  *
116  * @param[in] text The text.
117  * @param[in] mirroredText The mirroredText.
118  *
119  * @return @e true if a character has been replaced.
120  */
121 bool GetMirroredText( const Vector<Character>& text,
122                       Vector<Character>& mirroredText );
123 } // namespace Text
124
125 } // namespace Toolkit
126
127 } // namespace Dali
128
129 #endif // __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_SUPPORT_H__