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/bounded-paragraph-run.h>
27 #include <dali-toolkit/internal/text/character-spacing-glyph-run.h>
28 #include <dali-toolkit/internal/text/line-run.h>
29 #include <dali-toolkit/internal/text/script-run.h>
30 #include <dali-toolkit/internal/text/strikethrough-glyph-run.h>
31 #include <dali-toolkit/internal/text/text-definitions.h>
32 #include <dali-toolkit/internal/text/underlined-glyph-run.h>
33 #include <dali-toolkit/public-api/text/text-enumerations.h>
42 * @brief Interface class used to retrieve the text's model from the text-controller.
48 * @brief Virtual destructor.
50 virtual ~ModelInterface()
55 * @brief Retrives the control's size.
57 * @return The control's size.
59 virtual const Size& GetControlSize() const = 0;
62 * @brief Retrives the layout's size.
64 * @return The layout's size.
66 virtual const Size& GetLayoutSize() const = 0;
69 * @brief Retrieves the text's scroll position.
71 * @return The scroll position.
73 virtual const Vector2& GetScrollPosition() const = 0;
76 * @brief Retrieves the text's horizontal alignment.
78 * @return The horizontal alignment.
80 virtual HorizontalAlignment::Type GetHorizontalAlignment() const = 0;
83 * @brief Retrieves the text's vertical alignment.
85 * @return The vertical alignment.
87 virtual VerticalAlignment::Type GetVerticalAlignment() const = 0;
90 * @brief Retrieves the text's vertical line alignment.
92 * @return The vertical line alignment.
94 virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const = 0;
97 * @brief Retrieves ellipsis position for text.
99 * @return The ellipsis position.
101 virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
104 * @brief Whether the text elide property is enabled.
106 * @return @e true if the text elide property is enabled, @e false otherwise.
108 virtual bool IsTextElideEnabled() const = 0;
111 * @brief Retrieves the number of laid-out lines.
113 * @return The number of laid-out lines.
115 virtual Length GetNumberOfLines() const = 0;
118 * @brief Retrieves the laid-out lines.
120 * @return A pointer to the vector with the laid-out lines.
122 virtual const LineRun* const GetLines() const = 0;
125 * @brief Retrieves the number of script runs.
127 * @return The number of script runs.
129 virtual Length GetNumberOfScripts() const = 0;
132 * @brief Retrieves the script runs.
134 * @return A pointer to the vector with the runs of characters with the same script..
136 virtual const ScriptRun* const GetScriptRuns() const = 0;
139 * @brief Retrieves the number of laid-out glyphs.
141 * @return The number of laid-out glyphs.
143 virtual Length GetNumberOfGlyphs() const = 0;
146 * @brief Retrieves the start index of laid-out glyphs.
148 * @return The start index of laid-out glyphs.
150 virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
153 * @brief Retrieves the end index of laid-out glyphs.
155 * @return The end index of laid-out glyphs.
157 virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
160 * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
162 * @return The first middle index of elided glyphs, index before ellipsis of middle.
164 virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
167 * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
169 * @return The second middle index of elided glyphs, index of ellipsis of middle.
171 virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
174 * @brief Retrieves the laid-out glyphs.
176 * @return A pointer to the vector with the laid-out glyphs.
178 virtual const GlyphInfo* const GetGlyphs() const = 0;
181 * @brief Retrieves the text layout.
183 * @return A pointer to the vector with the positions for each glyph.
185 virtual const Vector2* const GetLayout() const = 0;
188 * @brief Retrieves the vector of colors.
190 * @return Pointer to the vector of colors.
192 virtual const Vector4* const GetColors() const = 0;
195 * @brief Retrieves the vector of indices to the vector of colors.
197 * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
199 virtual const ColorIndex* const GetColorIndices() const = 0;
202 * @brief Retrieves the vector of background colors.
204 * @return Pointer to the vector of background colors.
206 virtual const Vector4* const GetBackgroundColors() const = 0;
209 * @brief Retrieves the vector of indices to the vector of background colors.
211 * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
213 virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
216 * @brief checks if there is background colors set using markup.
218 * @return boolean if there is background colors set using markup .
220 virtual bool const IsMarkupBackgroundColorSet() const = 0;
223 * @brief Retrieves the text's default color.
225 * @return The default color.
227 virtual const Vector4& GetDefaultColor() const = 0;
230 * @brief Retrieves the shadow offset, 0 indicates no shadow.
232 * @return The shadow offset.
234 virtual const Vector2& GetShadowOffset() const = 0;
237 * @brief Retrieves the shadow color.
239 * @return The shadow color.
241 virtual const Vector4& GetShadowColor() const = 0;
244 * @brief Retrieve the shadow blur radius.
246 * @return The shadow blur radius.
248 virtual const float& GetShadowBlurRadius() const = 0;
251 * @brief Retrieves the underline color.
253 * @return The underline color.
255 virtual const Vector4& GetUnderlineColor() const = 0;
258 * @brief Returns whether underline is enabled or not.
260 * @return The underline state.
262 virtual bool IsUnderlineEnabled() const = 0;
265 * @brief checks if there is underline set using markup.
267 * @return boolean if there is underline set using markup.
269 virtual bool const IsMarkupUnderlineSet() const = 0;
272 * @brief Retrieves the underline height override
274 * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
276 virtual float GetUnderlineHeight() const = 0;
279 * @brief Retrieves the underline type override.
281 * @return Returns the override type for an underline.
283 virtual Text::Underline::Type GetUnderlineType() const = 0;
286 * @brief Retrieves the dashed underline width override
288 * @return Returns the override width for the dashed underline.
290 virtual float GetDashedUnderlineWidth() const = 0;
293 * @brief Retrieves the dashed underline gap override
295 * @return Returns the override gap for the dashed underline.
297 virtual float GetDashedUnderlineGap() const = 0;
300 * @brief Retrieves the number of underline runs.
302 * @return The number of underline runs.
304 virtual Length GetNumberOfUnderlineRuns() const = 0;
307 * @brief Retrieves the underline runs.
309 * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
310 * @param[in] index Index of the first underline run to be copied.
311 * @param[in] numberOfRuns Number of underline runs to be copied.
313 virtual void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const = 0;
316 * @brief Retrieve the outline color.
318 * @return The outline color.
320 virtual const Vector4& GetOutlineColor() const = 0;
323 * @brief Retrieves the width of an outline
325 * @return The width of the outline.
327 virtual uint16_t GetOutlineWidth() const = 0;
330 * @brief Retrieves the background color.
332 * @return The background color.
334 virtual const Vector4& GetBackgroundColor() const = 0;
337 * @brief Returns whether background is enabled or not.
339 * @return The background state.
341 virtual bool IsBackgroundEnabled() const = 0;
344 * @brief Returns whether markup-processor is enabled or not.
346 * @return The markup-processor state.
348 virtual bool IsMarkupProcessorEnabled() const = 0;
351 * @brief Returns the hyphens glyph info.
353 * @return hyphens glyph info.
355 virtual const GlyphInfo* GetHyphens() const = 0;
358 * @brief Returns the indices of the hyphen in the text.
360 * @return the hyphen indices.
362 virtual const Length* GetHyphenIndices() const = 0;
365 * @brief Returns number of hyphens to add in text.
367 * @return number of hyphens.
369 virtual Length GetHyphensCount() const = 0;
372 * @brief Retrieves the strikethrough color.
374 * @return The strikethrough color.
376 virtual const Vector4& GetStrikethroughColor() const = 0;
379 * @brief Returns whether strikethrough is enabled or not.
381 * @return The strikethrough state.
383 virtual bool IsStrikethroughEnabled() const = 0;
386 * @brief checks if there is strikethrough set using markup.
388 * @return boolean if there is strikethrough set using markup.
390 virtual bool const IsMarkupStrikethroughSet() const = 0;
393 * @brief Retrieves the strikethrough height override
395 * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
397 virtual float GetStrikethroughHeight() const = 0;
400 * @brief Retrieves the number of strikethrough runs.
402 * @return The number of strikethrough runs.
404 virtual Length GetNumberOfStrikethroughRuns() const = 0;
407 * @brief Retrieves the number of bounded paragraph runs.
409 * @return The number of bounded paragraph runs.
411 virtual Length GetNumberOfBoundedParagraphRuns() const = 0;
414 * @brief Retrieves the reference for bounded paragraph runs.
416 * @return The reference for bounded paragraph runs.
418 virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const = 0;
421 * @brief Retrieves the number of character-spacing glyph runs.
423 * @return The number of character-spacing glyph runs.
425 virtual Length GetNumberOfCharacterSpacingGlyphRuns() const = 0;
428 * @brief Retrieves the reference for character-spacing glyph runs.
430 * @return The reference for character-spacing glyph runs.
432 virtual const Vector<CharacterSpacingGlyphRun>& GetCharacterSpacingGlyphRuns() const = 0;
435 * @brief Retrieves the strikethrough runs.
437 * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied.
438 * @param[in] index Index of the first strikethrough run to be copied.
439 * @param[in] numberOfRuns Number of strikethrough runs to be copied.
441 virtual void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const = 0;
444 * @brief Retrieves the character spacing.
446 * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
448 * @return The character spacing.
450 virtual const float GetCharacterSpacing() const = 0;
453 * @brief Retrieves the text buffer.
455 * @return The text buffer.
457 virtual const Character* GetTextBuffer() const = 0;
460 * @brief Retrieves the Glyphs to Characters Array.
462 * @return The GlyphsToCharacters.
464 virtual const Vector<CharacterIndex>& GetGlyphsToCharacters() const = 0;
469 } // namespace Toolkit
473 #endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H