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/font-description-run.h>
29 #include <dali-toolkit/internal/text/font-run.h>
30 #include <dali-toolkit/internal/text/line-run.h>
31 #include <dali-toolkit/internal/text/script-run.h>
32 #include <dali-toolkit/internal/text/strikethrough-glyph-run.h>
33 #include <dali-toolkit/internal/text/text-definitions.h>
34 #include <dali-toolkit/internal/text/underlined-glyph-run.h>
35 #include <dali-toolkit/public-api/text/text-enumerations.h>
44 * @brief Interface class used to retrieve the text's model from the text-controller.
50 * @brief Virtual destructor.
52 virtual ~ModelInterface()
57 * @brief Retrives the control's size.
59 * @return The control's size.
61 virtual const Size& GetControlSize() const = 0;
64 * @brief Retrives the layout's size.
66 * @return The layout's size.
68 virtual const Size& GetLayoutSize() const = 0;
71 * @brief Retrieves the text's scroll position.
73 * @return The scroll position.
75 virtual const Vector2& GetScrollPosition() const = 0;
78 * @brief Retrieves the text's horizontal alignment.
80 * @return The horizontal alignment.
82 virtual HorizontalAlignment::Type GetHorizontalAlignment() const = 0;
85 * @brief Retrieves the text's vertical alignment.
87 * @return The vertical alignment.
89 virtual VerticalAlignment::Type GetVerticalAlignment() const = 0;
92 * @brief Retrieves the text's vertical line alignment.
94 * @return The vertical line alignment.
96 virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const = 0;
99 * @brief Retrieves ellipsis position for text.
101 * @return The ellipsis position.
103 virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
106 * @brief Whether the text elide property is enabled.
108 * @return @e true if the text elide property is enabled, @e false otherwise.
110 virtual bool IsTextElideEnabled() const = 0;
113 * @brief Retrieves the number of laid-out lines.
115 * @return The number of laid-out lines.
117 virtual Length GetNumberOfLines() const = 0;
120 * @brief Retrieves the laid-out lines.
122 * @return A pointer to the vector with the laid-out lines.
124 virtual const LineRun* GetLines() const = 0;
127 * @brief Retrieves the number of script runs.
129 * @return The number of script runs.
131 virtual Length GetNumberOfScripts() const = 0;
134 * @brief Retrieves the script runs.
136 * @return A pointer to the vector with the runs of characters with the same script..
138 virtual const ScriptRun* GetScriptRuns() const = 0;
141 * @brief Retrieves the number of laid-out glyphs.
143 * @return The number of laid-out glyphs.
145 virtual Length GetNumberOfGlyphs() const = 0;
148 * @brief Retrieves the start index of laid-out glyphs.
150 * @return The start index of laid-out glyphs.
152 virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
155 * @brief Retrieves the end index of laid-out glyphs.
157 * @return The end index of laid-out glyphs.
159 virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
162 * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
164 * @return The first middle index of elided glyphs, index before ellipsis of middle.
166 virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
169 * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
171 * @return The second middle index of elided glyphs, index of ellipsis of middle.
173 virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
176 * @brief Retrieves the laid-out glyphs.
178 * @return A pointer to the vector with the laid-out glyphs.
180 virtual const GlyphInfo* GetGlyphs() const = 0;
183 * @brief Retrieves the text layout.
185 * @return A pointer to the vector with the positions for each glyph.
187 virtual const Vector2* GetLayout() const = 0;
190 * @brief Retrieves the vector of colors.
192 * @return Pointer to the vector of colors.
194 virtual const Vector4* GetColors() const = 0;
197 * @brief Retrieves the vector of indices to the vector of colors.
199 * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
201 virtual const ColorIndex* GetColorIndices() const = 0;
204 * @brief Retrieves the vector of background colors.
206 * @return Pointer to the vector of background colors.
208 virtual const Vector4* GetBackgroundColors() const = 0;
211 * @brief Retrieves the vector of indices to the vector of background colors.
213 * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
215 virtual const ColorIndex* GetBackgroundColorIndices() const = 0;
218 * @brief checks if there is background colors set using markup.
220 * @return boolean if there is background colors set using markup .
222 virtual bool IsMarkupBackgroundColorSet() const = 0;
225 * @brief Retrieves the text's default color.
227 * @return The default color.
229 virtual const Vector4& GetDefaultColor() const = 0;
232 * @brief Retrieves the shadow offset, 0 indicates no shadow.
234 * @return The shadow offset.
236 virtual const Vector2& GetShadowOffset() const = 0;
239 * @brief Retrieves the shadow color.
241 * @return The shadow color.
243 virtual const Vector4& GetShadowColor() const = 0;
246 * @brief Retrieve the shadow blur radius.
248 * @return The shadow blur radius.
250 virtual const float& GetShadowBlurRadius() const = 0;
253 * @brief Retrieves the underline color.
255 * @return The underline color.
257 virtual const Vector4& GetUnderlineColor() const = 0;
260 * @brief Returns whether underline is enabled or not.
262 * @return The underline state.
264 virtual bool IsUnderlineEnabled() const = 0;
267 * @brief checks if there is underline set using markup.
269 * @return boolean if there is underline set using markup.
271 virtual bool IsMarkupUnderlineSet() const = 0;
274 * @brief Retrieves the underline height override
276 * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
278 virtual float GetUnderlineHeight() const = 0;
281 * @brief Retrieves the underline type override.
283 * @return Returns the override type for an underline.
285 virtual Text::Underline::Type GetUnderlineType() const = 0;
288 * @brief Retrieves the dashed underline width override
290 * @return Returns the override width for the dashed underline.
292 virtual float GetDashedUnderlineWidth() const = 0;
295 * @brief Retrieves the dashed underline gap override
297 * @return Returns the override gap for the dashed underline.
299 virtual float GetDashedUnderlineGap() const = 0;
302 * @brief Retrieves the number of underline runs.
304 * @return The number of underline runs.
306 virtual Length GetNumberOfUnderlineRuns() const = 0;
309 * @brief Retrieves the underline runs.
311 * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
312 * @param[in] index Index of the first underline run to be copied.
313 * @param[in] numberOfRuns Number of underline runs to be copied.
315 virtual void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const = 0;
318 * @brief Retrieve the outline color.
320 * @return The outline color.
322 virtual const Vector4& GetOutlineColor() const = 0;
325 * @brief Retrieves the width of an outline
327 * @return The width of the outline.
329 virtual uint16_t GetOutlineWidth() const = 0;
332 * @brief Retrieves the background color.
334 * @return The background color.
336 virtual const Vector4& GetBackgroundColor() const = 0;
339 * @brief Returns whether background is enabled or not.
341 * @return The background state.
343 virtual bool IsBackgroundEnabled() const = 0;
346 * @brief Returns whether markup-processor is enabled or not.
348 * @return The markup-processor state.
350 virtual bool IsMarkupProcessorEnabled() const = 0;
353 * @brief Retrieves whether the spanned-text is placed.
355 * By default is disabled.
357 * @return @e true if the spanned-text is placed, otherwise returns @e false.
359 virtual bool IsSpannedTextPlaced() const = 0;
362 * @brief Returns the hyphens glyph info.
364 * @return hyphens glyph info.
366 virtual const GlyphInfo* GetHyphens() const = 0;
369 * @brief Returns the indices of the hyphen in the text.
371 * @return the hyphen indices.
373 virtual const Length* GetHyphenIndices() const = 0;
376 * @brief Returns number of hyphens to add in text.
378 * @return number of hyphens.
380 virtual Length GetHyphensCount() const = 0;
383 * @brief Retrieves the strikethrough color.
385 * @return The strikethrough color.
387 virtual const Vector4& GetStrikethroughColor() const = 0;
390 * @brief Returns whether strikethrough is enabled or not.
392 * @return The strikethrough state.
394 virtual bool IsStrikethroughEnabled() const = 0;
397 * @brief checks if there is strikethrough set using markup.
399 * @return boolean if there is strikethrough set using markup.
401 virtual bool IsMarkupStrikethroughSet() const = 0;
404 * @brief Retrieves the strikethrough height override
406 * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
408 virtual float GetStrikethroughHeight() const = 0;
411 * @brief Retrieves the number of strikethrough runs.
413 * @return The number of strikethrough runs.
415 virtual Length GetNumberOfStrikethroughRuns() const = 0;
418 * @brief Retrieves the number of bounded paragraph runs.
420 * @return The number of bounded paragraph runs.
422 virtual Length GetNumberOfBoundedParagraphRuns() const = 0;
425 * @brief Retrieves the reference for bounded paragraph runs.
427 * @return The reference for bounded paragraph runs.
429 virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const = 0;
432 * @brief Retrieves the number of character-spacing glyph runs.
434 * @return The number of character-spacing glyph runs.
436 virtual Length GetNumberOfCharacterSpacingGlyphRuns() const = 0;
439 * @brief Retrieves the reference for character-spacing glyph runs.
441 * @return The reference for character-spacing glyph runs.
443 virtual const Vector<CharacterSpacingGlyphRun>& GetCharacterSpacingGlyphRuns() const = 0;
446 * @brief Retrieves the strikethrough runs.
448 * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied.
449 * @param[in] index Index of the first strikethrough run to be copied.
450 * @param[in] numberOfRuns Number of strikethrough runs to be copied.
452 virtual void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const = 0;
455 * @brief Retrieves the character spacing.
457 * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
459 * @return The character spacing.
461 virtual float GetCharacterSpacing() const = 0;
464 * @brief Retrieves the text buffer.
466 * @return The text buffer.
468 virtual const Character* GetTextBuffer() const = 0;
471 * @brief Retrieves the Glyphs to Characters Array.
473 * @return The GlyphsToCharacters.
475 virtual const Vector<CharacterIndex>& GetGlyphsToCharacters() const = 0;
478 * @brief Retrieves the reference for font runs.
480 * @return The reference for font runs.
482 virtual const Vector<FontRun>& GetFontRuns() const = 0;
485 * @brief Retrieves the reference for font description runs.
487 * @return The reference for font description runs.
489 virtual const Vector<FontDescriptionRun>& GetFontDescriptionRuns() const = 0;
494 } // namespace Toolkit
498 #endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H