1 #ifndef DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H
2 #define DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/dali-vector.h>
23 #include <dali/public-api/math/vector2.h>
26 #include <dali-toolkit/public-api/text/text-enumerations.h>
27 #include <dali-toolkit/internal/text/line-run.h>
28 #include <dali-toolkit/internal/text/metrics.h>
45 * @brief LayoutEngine is responsible for calculating the visual position of glyphs in layout.
58 * @brief Create a new instance of a LayoutEngine.
63 * @brief Virtual destructor.
68 * @brief Provide the wrapper around FontClient used to get metrics
70 * @param[in] metrics Used to get metrics
72 void SetMetrics( MetricsPtr& metrics );
75 * @brief Choose the required layout.
77 * @param[in] layout The required layout.
79 void SetLayout( Type layout );
82 * @brief Query the required layout.
84 * @return The required layout.
86 Type GetLayout() const;
89 * @brief Sets the width of the cursor.
91 * @param[in] width The width of the cursor in pixels.
93 void SetCursorWidth( int width );
96 * @brief Retrieves the width of the cursor.
98 * @return The width of the cursor in pixels.
100 int GetCursorWidth() const;
103 * @brief Store the visual position of glyphs in the VisualModel.
105 * @param[in] layoutParameters The parameters needed to layout the text.
106 * @param[out] glyphPositions The positions of all the glyphs.
107 * @param[out] lines The laid-out lines.
108 * @param[out] layoutSize The size of the text after it has been laid-out.
109 * @param[in] elideTextEnabled Whether the text elide is enabled.
111 * @return \e true if the text has been re-laid-out. \e false means the given width is too small to layout even a single character.
113 bool LayoutText( const Parameters& layoutParameters,
114 Vector<Vector2>& glyphPositions,
115 Vector<LineRun>& lines,
117 bool elideTextEnabled );
120 * @brief Re-lays out those lines with right to left characters.
122 * It doesn't change the phisical position of the glyphs in the model but sets their new position.
124 * @param[in] layoutParameters The parameters needed to layout the text.
125 * @param[in] startIndex Character index of the line from where the lines are reordered.
126 * @param[in] numberOfCharacters The number of characters.
127 * @param[in,out] glyphPositions The positions of all the glyphs.
129 void ReLayoutRightToLeftLines( const Parameters& layoutParameters,
130 CharacterIndex startIndex,
131 Length numberOfCharacters,
132 Vector<Vector2>& glyphPositions );
135 * @brief Aligns the laid out lines.
137 * @param[in] size The size of the container where the text is laid-out.
138 * @param[in] startIndex Character index of the line from where the lines are aligned.
139 * @param[in] numberOfCharacters The number of characters.
140 * @param[in] horizontalAlignment The horizontal alignment.
141 * @param[in,out] lines The laid-out lines.
142 * @param[out] alignmentOffset The alignment offset.
144 void Align( const Size& size,
145 CharacterIndex startIndex,
146 Length numberOfCharacters,
147 Text::HorizontalAlignment::Type horizontalAlignment,
148 Vector<LineRun>& lines,
149 float& alignmentOffset );
152 * @brief Sets the default line spacing.
154 * @param[in] lineSpacing The line spacing.
156 void SetDefaultLineSpacing( float lineSpacing );
159 * @brief Retrieves the default line spacing.
161 * @return The line spacing.
163 float GetDefaultLineSpacing() const;
168 Engine( const Engine& handle );
171 Engine& operator=( const Engine& handle );
179 } // namespace Layout
183 } // namespace Toolkit
187 #endif // DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H