[dali_1.4.10] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / layouts / layout-parameters.h
1 #ifndef DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H
2 #define DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H
3
4 /*
5  * Copyright (c) 2017 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/math/vector2.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/text/text-enumerations.h>
26 #include <dali-toolkit/internal/text/text-definitions.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Text
35 {
36
37 struct BidirectionalLineInfoRun;
38
39 namespace Layout
40 {
41
42 /**
43  * @brief Struct used to pass parameters.
44  */
45 struct Parameters
46 {
47   /**
48    * Constructor with the needed parameters to layout the text.
49    *
50    * @param[in] boundingBox The size of the box containing the text.
51    * @param[in] textBuffer The text buffer.
52    * @param[in] lineBreakInfoBuffer The line break info.
53    * @param[in] wordBreakInfoBuffer The word break info.
54    * @param[in] characterDirectionBuffer Vector with the direction of each character.
55    * @param[in] glyphsBuffer Vector with glyphs.
56    * @param[in] glyphsToCharactersBuffer Vector with indices pointing the first character of each glyph.
57    * @param[in] charactersPerGlyphBuffer Vector with the number of characters that forms each glyph.
58    * @param[in] charactersToGlyphsBuffer Vector with indices pointing the first glyph of each character.
59    * @param[in] glyphsPerCharacterBuffer Vector with the number of glyphs shaped from the character.
60    * @param[in] totalNumberOfGlyphs The number of glyphs.
61    * @param[in] horizontalAlignment The horizontal alignment.
62    * @param[in] lineWrapMode The text wrap mode.
63    * @param[in] outlineWidth The outline width.
64    * @param[in] ignoreSpaceAfterText Whether ignoring spaces after text or not.
65    * @param[in] matchSystemLanguageDirection Whether match align for system language direction or not..
66    */
67   Parameters( const Vector2& boundingBox,
68               const Character* const textBuffer,
69               const LineBreakInfo* const lineBreakInfoBuffer,
70               const WordBreakInfo* const wordBreakInfoBuffer,
71               const CharacterDirection* const characterDirectionBuffer,
72               const GlyphInfo* const glyphsBuffer,
73               const CharacterIndex* const glyphsToCharactersBuffer,
74               const Length* const charactersPerGlyphBuffer,
75               const GlyphIndex* const charactersToGlyphsBuffer,
76               const Length* const glyphsPerCharacterBuffer,
77               Length totalNumberOfGlyphs,
78               Text::HorizontalAlignment::Type horizontalAlignment,
79               Text::LineWrap::Mode lineWrapMode,
80               float outlineWidth,
81               bool ignoreSpaceAfterText,
82               bool matchSystemLanguageDirection )
83   : boundingBox( boundingBox ),
84     textBuffer( textBuffer ),
85     lineBreakInfoBuffer( lineBreakInfoBuffer ),
86     wordBreakInfoBuffer( wordBreakInfoBuffer ),
87     characterDirectionBuffer( characterDirectionBuffer ),
88     glyphsBuffer( glyphsBuffer ),
89     glyphsToCharactersBuffer( glyphsToCharactersBuffer ),
90     charactersPerGlyphBuffer( charactersPerGlyphBuffer ),
91     charactersToGlyphsBuffer( charactersToGlyphsBuffer ),
92     glyphsPerCharacterBuffer( glyphsPerCharacterBuffer ),
93     lineBidirectionalInfoRunsBuffer( NULL ),
94     numberOfBidirectionalInfoRuns( 0u ),
95     startGlyphIndex( 0u ),
96     numberOfGlyphs( 0u ),
97     totalNumberOfGlyphs( totalNumberOfGlyphs ),
98     horizontalAlignment( horizontalAlignment ),
99     startLineIndex( 0u ),
100     estimatedNumberOfLines( 0u ),
101     lineWrapMode( lineWrapMode ),
102     outlineWidth( outlineWidth ),
103     isLastNewParagraph( false ),
104     ignoreSpaceAfterText( ignoreSpaceAfterText ),
105     matchSystemLanguageDirection ( matchSystemLanguageDirection )
106   {}
107
108   Vector2                         boundingBox;                     ///< The size of the box containing the text.
109   const Character* const          textBuffer;                      ///< The text buffer.
110   const LineBreakInfo* const      lineBreakInfoBuffer;             ///< The line break info.
111   const WordBreakInfo* const      wordBreakInfoBuffer;             ///< The word break info.
112   const CharacterDirection* const characterDirectionBuffer;        ///< Vector with the direction of each character.
113   const GlyphInfo* const          glyphsBuffer;                    ///< Vector with glyphs.
114   const CharacterIndex* const     glyphsToCharactersBuffer;        ///< Vector with indices pointing the first character of each glyph.
115   const Length* const             charactersPerGlyphBuffer;        ///< Vector with the number of characters that forms each glyph.
116   const GlyphIndex* const         charactersToGlyphsBuffer;        ///< Vector with indices pointing the first glyph of each character.
117   const Length* const             glyphsPerCharacterBuffer;        ///< Vector with the number of glyphs shaped from the character.
118   BidirectionalLineInfoRun*       lineBidirectionalInfoRunsBuffer; ///< Bidirectional conversion tables per line.
119   Length                          numberOfBidirectionalInfoRuns;   ///< The number of lines with bidirectional info.
120   GlyphIndex                      startGlyphIndex;                 ///< Index to the first glyph to layout.
121   Length                          numberOfGlyphs;                  ///< The number of glyphs to layout.
122   Length                          totalNumberOfGlyphs;             ///< The number of glyphs.
123   HorizontalAlignment::Type       horizontalAlignment;             ///< The horizontal alignment.
124   LineIndex                       startLineIndex;                  ///< The line index where to insert the new lines.
125   Length                          estimatedNumberOfLines;          ///< The estimated number of lines.
126   Text::LineWrap::Mode            lineWrapMode;                    ///< The line wrap mode for moving to next line.
127   float                           outlineWidth;                    ///< The outline width.
128   bool                            isLastNewParagraph:1;            ///< Whether the last character is a new paragraph character.
129   bool                            ignoreSpaceAfterText:1;          ///< Whether ignoring spaces after text or not. Default is true.
130   bool                            matchSystemLanguageDirection:1;  ///< Whether match align for system language direction or not. Default is false.
131 };
132
133 } // namespace Layout
134
135 } // namespace Text
136
137 } // namespace Toolkit
138
139 } // namespace Dali
140
141 #endif // DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H