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>
24 #include <dali/public-api/actors/actor-enumerations.h>
27 #include <dali-toolkit/public-api/text/text-enumerations.h>
28 #include <dali-toolkit/internal/text/line-run.h>
29 #include <dali-toolkit/internal/text/metrics.h>
46 * @brief LayoutEngine is responsible for calculating the visual position of glyphs in layout.
59 * @brief Create a new instance of a LayoutEngine.
64 * @brief Virtual destructor.
69 * @brief Provide the wrapper around FontClient used to get metrics
71 * @param[in] metrics Used to get metrics
73 void SetMetrics( MetricsPtr& metrics );
76 * @brief Choose the required layout.
78 * @param[in] layout The required layout.
80 void SetLayout( Type layout );
83 * @brief Query the required layout.
85 * @return The required layout.
87 Type GetLayout() const;
90 * @brief Sets the width of the cursor.
92 * @param[in] width The width of the cursor in pixels.
94 void SetCursorWidth( int width );
97 * @brief Retrieves the width of the cursor.
99 * @return The width of the cursor in pixels.
101 int GetCursorWidth() const;
104 * @brief Store the visual position of glyphs in the VisualModel.
106 * @param[in] layoutParameters The parameters needed to layout the text.
107 * @param[out] glyphPositions The positions of all the glyphs.
108 * @param[out] lines The laid-out lines.
109 * @param[out] layoutSize The size of the text after it has been laid-out.
110 * @param[in] elideTextEnabled Whether the text elide is enabled.
111 * @param[in,out] isAutoScrollEnabled If the isAutoScrollEnabled is true and the height of the text exceeds the boundaries of the control the text is elided and the isAutoScrollEnabled is set to false to disable the autoscroll
113 * @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.
115 bool LayoutText( const Parameters& layoutParameters,
116 Vector<Vector2>& glyphPositions,
117 Vector<LineRun>& lines,
119 bool elideTextEnabled,
120 bool& isAutoScrollEnabled );
123 * @brief Re-lays out those lines with right to left characters.
125 * It doesn't change the phisical position of the glyphs in the model but sets their new position.
127 * @param[in] layoutParameters The parameters needed to layout the text.
128 * @param[in] startIndex Character index of the line from where the lines are reordered.
129 * @param[in] numberOfCharacters The number of characters.
130 * @param[in,out] glyphPositions The positions of all the glyphs.
132 void ReLayoutRightToLeftLines( const Parameters& layoutParameters,
133 CharacterIndex startIndex,
134 Length numberOfCharacters,
135 Vector<Vector2>& glyphPositions );
138 * @brief Aligns the laid out lines.
140 * @param[in] size The size of the container where the text is laid-out.
141 * @param[in] startIndex Character index of the line from where the lines are aligned.
142 * @param[in] numberOfCharacters The number of characters.
143 * @param[in] horizontalAlignment The horizontal alignment.
144 * @param[in,out] lines The laid-out lines.
145 * @param[out] alignmentOffset The alignment offset.
146 * @param[in] layoutDirection The direction of the system language.
147 * @param[in] matchSystemLanguageDirection Whether match align for system language direction or not.
149 void Align( const Size& size,
150 CharacterIndex startIndex,
151 Length numberOfCharacters,
152 Text::HorizontalAlignment::Type horizontalAlignment,
153 Vector<LineRun>& lines,
154 float& alignmentOffset,
155 Dali::LayoutDirection::Type layoutDirection,
156 bool matchSystemLanguageDirection );
159 * @brief Sets the default line spacing.
161 * @param[in] lineSpacing The line spacing.
163 void SetDefaultLineSpacing( float lineSpacing );
166 * @brief Retrieves the default line spacing.
168 * @return The line spacing.
170 float GetDefaultLineSpacing() const;
175 Engine( const Engine& handle );
178 Engine& operator=( const Engine& handle );
186 } // namespace Layout
190 } // namespace Toolkit
194 #endif // DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H