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/internal/text/underlined-glyph-run.h>
31 #include <dali-toolkit/public-api/text/text-enumerations.h>
40 * @brief Interface class used to retrieve the text's model from the text-controller.
46 * @brief Virtual destructor.
48 virtual ~ModelInterface()
53 * @brief Retrives the control's size.
55 * @return The control's size.
57 virtual const Size& GetControlSize() const = 0;
60 * @brief Retrives the layout's size.
62 * @return The layout's size.
64 virtual const Size& GetLayoutSize() const = 0;
67 * @brief Retrieves the text's scroll position.
69 * @return The scroll position.
71 virtual const Vector2& GetScrollPosition() const = 0;
74 * @brief Retrieves the text's horizontal alignment.
76 * @return The horizontal alignment.
78 virtual HorizontalAlignment::Type GetHorizontalAlignment() const = 0;
81 * @brief Retrieves the text's vertical alignment.
83 * @return The vertical alignment.
85 virtual VerticalAlignment::Type GetVerticalAlignment() const = 0;
88 * @brief Retrieves the text's vertical line alignment.
90 * @return The vertical line alignment.
92 virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const = 0;
95 * @brief Retrieves ellipsis position for text.
97 * @return The ellipsis position.
99 virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
102 * @brief Whether the text elide property is enabled.
104 * @return @e true if the text elide property is enabled, @e false otherwise.
106 virtual bool IsTextElideEnabled() const = 0;
109 * @brief Retrieves the number of laid-out lines.
111 * @return The number of laid-out lines.
113 virtual Length GetNumberOfLines() const = 0;
116 * @brief Retrieves the laid-out lines.
118 * @return A pointer to the vector with the laid-out lines.
120 virtual const LineRun* const GetLines() const = 0;
123 * @brief Retrieves the number of script runs.
125 * @return The number of script runs.
127 virtual Length GetNumberOfScripts() const = 0;
130 * @brief Retrieves the script runs.
132 * @return A pointer to the vector with the runs of characters with the same script..
134 virtual const ScriptRun* const GetScriptRuns() const = 0;
137 * @brief Retrieves the number of laid-out glyphs.
139 * @return The number of laid-out glyphs.
141 virtual Length GetNumberOfGlyphs() const = 0;
144 * @brief Retrieves the start index of laid-out glyphs.
146 * @return The start index of laid-out glyphs.
148 virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
151 * @brief Retrieves the end index of laid-out glyphs.
153 * @return The end index of laid-out glyphs.
155 virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
158 * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
160 * @return The first middle index of elided glyphs, index before ellipsis of middle.
162 virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
165 * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
167 * @return The second middle index of elided glyphs, index of ellipsis of middle.
169 virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
172 * @brief Retrieves the laid-out glyphs.
174 * @return A pointer to the vector with the laid-out glyphs.
176 virtual const GlyphInfo* const GetGlyphs() const = 0;
179 * @brief Retrieves the text layout.
181 * @return A pointer to the vector with the positions for each glyph.
183 virtual const Vector2* const GetLayout() const = 0;
186 * @brief Retrieves the vector of colors.
188 * @return Pointer to the vector of colors.
190 virtual const Vector4* const GetColors() const = 0;
193 * @brief Retrieves the vector of indices to the vector of colors.
195 * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
197 virtual const ColorIndex* const GetColorIndices() const = 0;
200 * @brief Retrieves the vector of background colors.
202 * @return Pointer to the vector of background colors.
204 virtual const Vector4* const GetBackgroundColors() const = 0;
207 * @brief Retrieves the vector of indices to the vector of background colors.
209 * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
211 virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
214 * @brief checks if there is background colors set using markup.
216 * @return boolean if there is background colors set using markup .
218 virtual bool const IsMarkupBackgroundColorSet() const = 0;
221 * @brief Retrieves the text's default color.
223 * @return The default color.
225 virtual const Vector4& GetDefaultColor() const = 0;
228 * @brief Retrieves the shadow offset, 0 indicates no shadow.
230 * @return The shadow offset.
232 virtual const Vector2& GetShadowOffset() const = 0;
235 * @brief Retrieves the shadow color.
237 * @return The shadow color.
239 virtual const Vector4& GetShadowColor() const = 0;
242 * @brief Retrieve the shadow blur radius.
244 * @return The shadow blur radius.
246 virtual const float& GetShadowBlurRadius() const = 0;
249 * @brief Retrieves the underline color.
251 * @return The underline color.
253 virtual const Vector4& GetUnderlineColor() const = 0;
256 * @brief Returns whether underline is enabled or not.
258 * @return The underline state.
260 virtual bool IsUnderlineEnabled() const = 0;
263 * @brief Retrieves the underline height override
265 * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
267 virtual float GetUnderlineHeight() const = 0;
270 * @brief Retrieves the underline type override.
272 * @return Returns the override type for an underline.
274 virtual Text::Underline::Type GetUnderlineType() const = 0;
277 * @brief Retrieves the dashed underline width override
279 * @return Returns the override width for the dashed underline.
281 virtual float GetDashedUnderlineWidth() const = 0;
284 * @brief Retrieves the dashed underline gap override
286 * @return Returns the override gap for the dashed underline.
288 virtual float GetDashedUnderlineGap() const = 0;
291 * @brief Retrieves the number of underline runs.
293 * @return The number of underline runs.
295 virtual Length GetNumberOfUnderlineRuns() const = 0;
298 * @brief Retrieves the underline runs.
300 * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
301 * @param[in] index Index of the first underline run to be copied.
302 * @param[in] numberOfRuns Number of underline runs to be copied.
304 virtual void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const = 0;
307 * @brief Retrieve the outline color.
309 * @return The outline color.
311 virtual const Vector4& GetOutlineColor() const = 0;
314 * @brief Retrieves the width of an outline
316 * @return The width of the outline.
318 virtual uint16_t GetOutlineWidth() const = 0;
321 * @brief Retrieves the background color.
323 * @return The background color.
325 virtual const Vector4& GetBackgroundColor() const = 0;
328 * @brief Returns whether background is enabled or not.
330 * @return The background state.
332 virtual bool IsBackgroundEnabled() const = 0;
335 * @brief Returns whether markup-processor is enabled or not.
337 * @return The markup-processor state.
339 virtual bool IsMarkupProcessorEnabled() const = 0;
342 * @brief Returns the hyphens glyph info.
344 * @return hyphens glyph info.
346 virtual const GlyphInfo* GetHyphens() const = 0;
349 * @brief Returns the indices of the hyphen in the text.
351 * @return the hyphen indices.
353 virtual const Length* GetHyphenIndices() const = 0;
356 * @brief Returns number of hyphens to add in text.
358 * @return number of hyphens.
360 virtual Length GetHyphensCount() const = 0;
363 * @brief Retrieves the strikethrough color.
365 * @return The strikethrough color.
367 virtual const Vector4& GetStrikethroughColor() const = 0;
370 * @brief Returns whether strikethrough is enabled or not.
372 * @return The strikethrough state.
374 virtual bool IsStrikethroughEnabled() const = 0;
377 * @brief Retrieves the strikethrough height override
379 * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
381 virtual float GetStrikethroughHeight() const = 0;
384 * @brief Retrieves the number of strikethrough runs.
386 * @return The number of strikethrough runs.
388 virtual Length GetNumberOfStrikethroughRuns() const = 0;
391 * @brief Retrieves the strikethrough runs.
393 * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied.
394 * @param[in] index Index of the first strikethrough run to be copied.
395 * @param[in] numberOfRuns Number of strikethrough runs to be copied.
397 virtual void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const = 0;
400 * @brief Retrieves the character spacing.
402 * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
404 * @return The character spacing.
406 virtual const float GetCharacterSpacing() const = 0;
409 * @brief Retrieves the text buffer.
411 * @return The text buffer.
413 virtual const Character* GetTextBuffer() const = 0;
416 * @brief Retrieves the Glyphs to Characters Array.
418 * @return The GlyphsToCharacters.
420 virtual const Vector<CharacterIndex>& GetGlyphsToCharacters() const = 0;
425 } // namespace Toolkit
429 #endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H