1 #ifndef DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H
2 #define DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H
5 * Copyright (c) 2022 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/actors/actor-enumerations.h>
23 #include <dali/public-api/common/dali-vector.h>
24 #include <dali/public-api/math/vector2.h>
27 #include <dali-toolkit/internal/text/line-run.h>
28 #include <dali-toolkit/internal/text/metrics.h>
29 #include <dali-toolkit/public-api/text/text-enumerations.h>
32 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
45 * @brief LayoutEngine is responsible for calculating the visual position of glyphs in layout.
57 * @brief Create a new instance of a LayoutEngine.
62 * @brief Virtual destructor.
67 * @brief Provide the wrapper around FontClient used to get metrics
69 * @param[in] metrics Used to get metrics
71 void SetMetrics(MetricsPtr& metrics);
74 * @brief Choose the required layout.
76 * @param[in] layout The required layout.
78 void SetLayout(Type layout);
81 * @brief Query the required layout.
83 * @return The required layout.
85 Type GetLayout() const;
88 * @brief Sets the width of the cursor.
90 * @param[in] width The width of the cursor in pixels.
92 void SetCursorWidth(int width);
95 * @brief Retrieves the width of the cursor.
97 * @return The width of the cursor in pixels.
99 int GetCursorWidth() const;
102 * @brief Store the visual position of glyphs in the VisualModel.
104 * Builds the bidirectional info and reorders RTL lines.
106 * @param[in,out] layoutParameters The parameters needed to layout the text.
107 * @param[out] layoutSize The size of the text after it has been laid-out.
108 * @param[in] elideTextEnabled Whether the text elide is enabled.
109 * @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
110 * @param[in] isAutoScrollMaxTextureExceeded If isAutoScrollMaxTextureExceeded is true, enable ellipsis during auro scroll.
111 * @param[in] ellipsisPosition The location of the text ellipsis
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(Parameters& layoutParameters,
117 bool elideTextEnabled,
118 bool& isAutoScrollEnabled,
119 bool isAutoScrollMaxTextureExceeded,
120 DevelText::EllipsisPosition::Type ellipsisPosition);
123 * @brief Aligns the laid out lines.
125 * @param[in] size The size of the container where the text is laid-out.
126 * @param[in] startIndex Character index of the line from where the lines are aligned.
127 * @param[in] numberOfCharacters The number of characters.
128 * @param[in] horizontalAlignment The horizontal alignment.
129 * @param[in,out] lines The laid-out lines.
130 * @param[out] alignmentOffset The alignment offset.
131 * @param[in] layoutDirection The direction of the layout.
132 * @param[in] matchLayoutDirection Whether match align for layout direction or not.
134 void Align(const Size& size,
135 CharacterIndex startIndex,
136 Length numberOfCharacters,
137 Text::HorizontalAlignment::Type horizontalAlignment,
138 Vector<LineRun>& lines,
139 float& alignmentOffset,
140 Dali::LayoutDirection::Type layoutDirection,
141 bool matchLayoutDirection);
144 * @brief Sets the default line spacing.
146 * @param[in] lineSpacing The line spacing.
148 void SetDefaultLineSpacing(float lineSpacing);
151 * @brief Retrieves the default line spacing.
153 * @return The line spacing.
155 float GetDefaultLineSpacing() const;
158 * @brief Sets the default line size.
160 * @param[in] lineSize The line size.
162 void SetDefaultLineSize(float lineSize);
165 * @brief Retrieves the default line size.
167 * @return The line size.
169 float GetDefaultLineSize() const;
172 * @brief Sets relative line size to the original line size.
174 * @param[in] relativeLineSize The relative line size.
176 void SetRelativeLineSize(float relativeLineSize);
179 * @brief Retrieves the relative line size.
181 * @return The relative line size.
183 float GetRelativeLineSize() const;
187 Engine(const Engine& handle);
190 Engine& operator=(const Engine& handle);
197 } // namespace Layout
201 } // namespace Toolkit
205 #endif // DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H