5deb666b42af50952eead4d8070df28587c872c2
[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) 2016 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 #include <dali-toolkit/internal/text/layouts/layout-wrap-mode.h>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Text
36 {
37
38 struct BidirectionalLineInfoRun;
39
40 namespace Layout
41 {
42
43 /**
44  * @brief Struct used to pass parameters.
45  */
46 struct Parameters
47 {
48   /**
49    * Constructor with the needed parameters to layout the text.
50    *
51    * @param[in] boundingBox The size of the box containing the text.
52    * @param[in] textBuffer The text buffer.
53    * @param[in] lineBreakInfoBuffer The line break info.
54    * @param[in] wordBreakInfoBuffer The word break info.
55    * @param[in] characterDirectionBuffer Vector with the direction of each character.
56    * @param[in] glyphsBuffer Vector with glyphs.
57    * @param[in] glyphsToCharactersBuffer Vector with indices pointing the first character of each glyph.
58    * @param[in] charactersPerGlyphBuffer Vector with the number of characters that forms each glyph.
59    * @param[in] charactersToGlyphsBuffer Vector with indices pointing the first glyph of each character.
60    * @param[in] glyphsPerCharacterBuffer Vector with the number of glyphs shaped from the character.
61    * @param[in] totalNumberOfGlyphs The number of glyphs.
62    * @param[in] horizontalAlignment The horizontal alignment.
63    * @param[in] lineWrapMode The text wrap mode.
64    */
65   Parameters( const Vector2& boundingBox,
66               const Character* const textBuffer,
67               const LineBreakInfo* const lineBreakInfoBuffer,
68               const WordBreakInfo* const wordBreakInfoBuffer,
69               const CharacterDirection* const characterDirectionBuffer,
70               const GlyphInfo* const glyphsBuffer,
71               const CharacterIndex* const glyphsToCharactersBuffer,
72               const Length* const charactersPerGlyphBuffer,
73               const GlyphIndex* const charactersToGlyphsBuffer,
74               const Length* const glyphsPerCharacterBuffer,
75               Length totalNumberOfGlyphs,
76               Text::HorizontalAlignment::Type horizontalAlignment,
77               LineWrap::Mode lineWrapMode )
78   : boundingBox( boundingBox ),
79     textBuffer( textBuffer ),
80     lineBreakInfoBuffer( lineBreakInfoBuffer ),
81     wordBreakInfoBuffer( wordBreakInfoBuffer ),
82     characterDirectionBuffer( characterDirectionBuffer ),
83     glyphsBuffer( glyphsBuffer ),
84     glyphsToCharactersBuffer( glyphsToCharactersBuffer ),
85     charactersPerGlyphBuffer( charactersPerGlyphBuffer ),
86     charactersToGlyphsBuffer( charactersToGlyphsBuffer ),
87     glyphsPerCharacterBuffer( glyphsPerCharacterBuffer ),
88     lineBidirectionalInfoRunsBuffer( NULL ),
89     numberOfBidirectionalInfoRuns( 0u ),
90     startGlyphIndex( 0u ),
91     numberOfGlyphs( 0u ),
92     totalNumberOfGlyphs( totalNumberOfGlyphs ),
93     horizontalAlignment( horizontalAlignment ),
94     startLineIndex( 0u ),
95     estimatedNumberOfLines( 0u ),
96     lineWrapMode( lineWrapMode ),
97     isLastNewParagraph( false )
98   {}
99
100   Vector2                         boundingBox;                     ///< The size of the box containing the text.
101   const Character* const          textBuffer;                      ///< The text buffer.
102   const LineBreakInfo* const      lineBreakInfoBuffer;             ///< The line break info.
103   const WordBreakInfo* const      wordBreakInfoBuffer;             ///< The word break info.
104   const CharacterDirection* const characterDirectionBuffer;        ///< Vector with the direction of each character.
105   const GlyphInfo* const          glyphsBuffer;                    ///< Vector with glyphs.
106   const CharacterIndex* const     glyphsToCharactersBuffer;        ///< Vector with indices pointing the first character of each glyph.
107   const Length* const             charactersPerGlyphBuffer;        ///< Vector with the number of characters that forms each glyph.
108   const GlyphIndex* const         charactersToGlyphsBuffer;        ///< Vector with indices pointing the first glyph of each character.
109   const Length* const             glyphsPerCharacterBuffer;        ///< Vector with the number of glyphs shaped from the character.
110   BidirectionalLineInfoRun*       lineBidirectionalInfoRunsBuffer; ///< Bidirectional conversion tables per line.
111   Length                          numberOfBidirectionalInfoRuns;   ///< The number of lines with bidirectional info.
112   GlyphIndex                      startGlyphIndex;                 ///< Index to the first glyph to layout.
113   Length                          numberOfGlyphs;                  ///< The number of glyphs to layout.
114   Length                          totalNumberOfGlyphs;             ///< The number of glyphs.
115   HorizontalAlignment::Type       horizontalAlignment;             ///< The horizontal alignment.
116   LineIndex                       startLineIndex;                  ///< The line index where to insert the new lines.
117   Length                          estimatedNumberOfLines;          ///< The estimated number of lines.
118   LineWrap::Mode                  lineWrapMode;                    ///< The line wrap mode for moving to next line.
119   bool                            isLastNewParagraph;              ///< Whether the last character is a new paragraph character.
120 };
121
122 } // namespace Layout
123
124 } // namespace Text
125
126 } // namespace Toolkit
127
128 } // namespace Dali
129
130 #endif // DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H