1 #ifndef DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
2 #define DALI_TOOLKIT_TEXT_MODEL_INTERFACE_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/math/vector2.h>
25 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
26 #include <dali-toolkit/internal/text/line-run.h>
27 #include <dali-toolkit/internal/text/script-run.h>
28 #include <dali-toolkit/internal/text/strikethrough-glyph-run.h>
29 #include <dali-toolkit/internal/text/text-definitions.h>
30 #include <dali-toolkit/public-api/text/text-enumerations.h>
39 * @brief Interface class used to retrieve the text's model from the text-controller.
45 * @brief Virtual destructor.
47 virtual ~ModelInterface()
52 * @brief Retrives the control's size.
54 * @return The control's size.
56 virtual const Size& GetControlSize() const = 0;
59 * @brief Retrives the layout's size.
61 * @return The layout's size.
63 virtual const Size& GetLayoutSize() const = 0;
66 * @brief Retrieves the text's scroll position.
68 * @return The scroll position.
70 virtual const Vector2& GetScrollPosition() const = 0;
73 * @brief Retrieves the text's horizontal alignment.
75 * @return The horizontal alignment.
77 virtual HorizontalAlignment::Type GetHorizontalAlignment() const = 0;
80 * @brief Retrieves the text's vertical alignment.
82 * @return The vertical alignment.
84 virtual VerticalAlignment::Type GetVerticalAlignment() const = 0;
87 * @brief Retrieves the text's vertical line alignment.
89 * @return The vertical line alignment.
91 virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const = 0;
94 * @brief Retrieves ellipsis position for text.
96 * @return The ellipsis position.
98 virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
101 * @brief Whether the text elide property is enabled.
103 * @return @e true if the text elide property is enabled, @e false otherwise.
105 virtual bool IsTextElideEnabled() const = 0;
108 * @brief Retrieves the number of laid-out lines.
110 * @return The number of laid-out lines.
112 virtual Length GetNumberOfLines() const = 0;
115 * @brief Retrieves the laid-out lines.
117 * @return A pointer to the vector with the laid-out lines.
119 virtual const LineRun* const GetLines() const = 0;
122 * @brief Retrieves the number of script runs.
124 * @return The number of script runs.
126 virtual Length GetNumberOfScripts() const = 0;
129 * @brief Retrieves the script runs.
131 * @return A pointer to the vector with the runs of characters with the same script..
133 virtual const ScriptRun* const GetScriptRuns() const = 0;
136 * @brief Retrieves the number of laid-out glyphs.
138 * @return The number of laid-out glyphs.
140 virtual Length GetNumberOfGlyphs() const = 0;
143 * @brief Retrieves the start index of laid-out glyphs.
145 * @return The start index of laid-out glyphs.
147 virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
150 * @brief Retrieves the end index of laid-out glyphs.
152 * @return The end index of laid-out glyphs.
154 virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
157 * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
159 * @return The first middle index of elided glyphs, index before ellipsis of middle.
161 virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
164 * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
166 * @return The second middle index of elided glyphs, index of ellipsis of middle.
168 virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
171 * @brief Retrieves the laid-out glyphs.
173 * @return A pointer to the vector with the laid-out glyphs.
175 virtual const GlyphInfo* const GetGlyphs() const = 0;
178 * @brief Retrieves the text layout.
180 * @return A pointer to the vector with the positions for each glyph.
182 virtual const Vector2* const GetLayout() const = 0;
185 * @brief Retrieves the vector of colors.
187 * @return Pointer to the vector of colors.
189 virtual const Vector4* const GetColors() const = 0;
192 * @brief Retrieves the vector of indices to the vector of colors.
194 * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
196 virtual const ColorIndex* const GetColorIndices() const = 0;
199 * @brief Retrieves the vector of background colors.
201 * @return Pointer to the vector of background colors.
203 virtual const Vector4* const GetBackgroundColors() const = 0;
206 * @brief Retrieves the vector of indices to the vector of background colors.
208 * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
210 virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
213 * @brief checks if there is background colors set using markup.
215 * @return boolean if there is background colors set using markup .
217 virtual bool const IsMarkupBackgroundColorSet() const = 0;
220 * @brief Retrieves the text's default color.
222 * @return The default color.
224 virtual const Vector4& GetDefaultColor() const = 0;
227 * @brief Retrieves the shadow offset, 0 indicates no shadow.
229 * @return The shadow offset.
231 virtual const Vector2& GetShadowOffset() const = 0;
234 * @brief Retrieves the shadow color.
236 * @return The shadow color.
238 virtual const Vector4& GetShadowColor() const = 0;
241 * @brief Retrieve the shadow blur radius.
243 * @return The shadow blur radius.
245 virtual const float& GetShadowBlurRadius() const = 0;
248 * @brief Retrieves the underline color.
250 * @return The underline color.
252 virtual const Vector4& GetUnderlineColor() const = 0;
255 * @brief Returns whether underline is enabled or not.
257 * @return The underline state.
259 virtual bool IsUnderlineEnabled() const = 0;
262 * @brief Retrieves the underline height override
264 * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
266 virtual float GetUnderlineHeight() const = 0;
269 * @brief Retrieves the underline type override.
271 * @return Returns the override type for an underline.
273 virtual Text::Underline::Type GetUnderlineType() const = 0;
276 * @brief Retrieves the dashed underline width override
278 * @return Returns the override width for the dashed underline.
280 virtual float GetDashedUnderlineWidth() const = 0;
283 * @brief Retrieves the dashed underline gap override
285 * @return Returns the override gap for the dashed underline.
287 virtual float GetDashedUnderlineGap() const = 0;
290 * @brief Retrieves the number of underline runs.
292 * @return The number of underline runs.
294 virtual Length GetNumberOfUnderlineRuns() const = 0;
297 * @brief Retrieves the underline runs.
299 * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
300 * @param[in] index Index of the first underline run to be copied.
301 * @param[in] numberOfRuns Number of underline runs to be copied.
303 virtual void GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const = 0;
306 * @brief Retrieve the outline color.
308 * @return The outline color.
310 virtual const Vector4& GetOutlineColor() const = 0;
313 * @brief Retrieves the width of an outline
315 * @return The width of the outline.
317 virtual uint16_t GetOutlineWidth() const = 0;
320 * @brief Retrieves the background color.
322 * @return The background color.
324 virtual const Vector4& GetBackgroundColor() const = 0;
327 * @brief Returns whether background is enabled or not.
329 * @return The background state.
331 virtual bool IsBackgroundEnabled() const = 0;
334 * @brief Returns whether markup-processor is enabled or not.
336 * @return The markup-processor state.
338 virtual bool IsMarkupProcessorEnabled() const = 0;
341 * @brief Returns the hyphens glyph info.
343 * @return hyphens glyph info.
345 virtual const GlyphInfo* GetHyphens() const = 0;
348 * @brief Returns the indices of the hyphen in the text.
350 * @return the hyphen indices.
352 virtual const Length* GetHyphenIndices() const = 0;
355 * @brief Returns number of hyphens to add in text.
357 * @return number of hyphens.
359 virtual Length GetHyphensCount() const = 0;
362 * @brief Retrieves the strikethrough color.
364 * @return The strikethrough color.
366 virtual const Vector4& GetStrikethroughColor() const = 0;
369 * @brief Returns whether strikethrough is enabled or not.
371 * @return The strikethrough state.
373 virtual bool IsStrikethroughEnabled() const = 0;
376 * @brief Retrieves the strikethrough height override
378 * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
380 virtual float GetStrikethroughHeight() const = 0;
383 * @brief Retrieves the number of strikethrough runs.
385 * @return The number of strikethrough runs.
387 virtual Length GetNumberOfStrikethroughRuns() const = 0;
390 * @brief Retrieves the strikethrough runs.
392 * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied.
393 * @param[in] index Index of the first strikethrough run to be copied.
394 * @param[in] numberOfRuns Number of strikethrough runs to be copied.
396 virtual void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const = 0;
399 * @brief Retrieves the character spacing.
401 * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
403 * @return The character spacing.
405 virtual const float GetCharacterSpacing() const = 0;
408 * @brief Retrieves the text buffer.
410 * @return The text buffer.
412 virtual const Character* GetTextBuffer() const = 0;
415 * @brief Retrieves the Glyphs to Characters Array.
417 * @return The GlyphsToCharacters.
419 virtual const Vector<CharacterIndex>& GetGlyphsToCharacters() const = 0;
424 } // namespace Toolkit
428 #endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H