Add GetCharacterIndexAtPosition API
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / text / text-geometry-devel.h
1 #ifndef DALI_TOOLKIT_TEXT_GEOMETRY_DEVEL_H
2 #define DALI_TOOLKIT_TEXT_GEOMETRY_DEVEL_H
3
4 /*
5  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 //INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
23 #include <dali-toolkit/public-api/controls/text-controls/text-editor.h>
24 #include <dali-toolkit/public-api/controls/text-controls/text-field.h>
25
26 namespace Dali
27 {
28 namespace Toolkit
29 {
30 namespace Text
31 {
32 namespace TextGeometry
33 {
34
35   /**
36    * @brief Get the line bounding rectangle.
37    * if the requested index is out of range or the line is not yet rendered, a rect of {0, 0, 0, 0} is returned.
38    *
39    * @param[in] editor the editor controller that contains the line.
40    * @param[in] lineIndex line index to which we want to calculate the geometry for.
41    * @return bounding rectangle.
42    */
43    DALI_TOOLKIT_API Rect<float> GetLineBoundingRectangle(TextEditor editor, const uint32_t lineIndex);
44
45   /**
46    * @brief Get the line bounding rectangle.
47    * if the requested index is out of range or the line is not yet rendered, a rect of {0, 0, 0, 0} is returned.
48    *
49    * @param[in] label the label controller that contains the line.
50    * @param[in] lineIndex line index to which we want to calculate the geometry for.
51    * @return bounding rectangle.
52    */
53    DALI_TOOLKIT_API Rect<float> GetLineBoundingRectangle(TextLabel label, const uint32_t lineIndex);
54
55   /**
56    * @brief Get the line bounding rectangle.
57    * if the requested index is out of range or the line is not yet rendered, a rect of {0, 0, 0, 0} is returned.
58    *
59    * @param[in] field the field controller that contains the line.
60    * @param[in] lineIndex line index to which we want to calculate the geometry for.
61    * @return bounding rectangle.
62    */
63    DALI_TOOLKIT_API Rect<float> GetLineBoundingRectangle(TextField field, const uint32_t lineIndex);
64
65   /**
66    * @brief Get the character bounding rectangle.
67    * If the text is not yet rendered or the index > text.Count(); a rect of {0, 0, 0, 0} is returned.
68    *
69    * @param[in] label text model containing text info.
70    * @param[in] charIndex character index to which we want to calculate the geometry for.
71    * @return bounding rectangle.
72    */
73    DALI_TOOLKIT_API Rect<float> GetCharacterBoundingRectangle(TextLabel label, const uint32_t charIndex);
74
75   /**
76    * @brief Get the character bounding rectangle.
77    * If the text is not yet rendered or the index > text.Count(); a rect of {0, 0, 0, 0} is returned.
78    *
79    * @param[in] field text model containing text info.
80    * @param[in] charIndex character index to which we want to calculate the geometry for.
81    * @return bounding rectangle.
82    */
83    DALI_TOOLKIT_API Rect<float> GetCharacterBoundingRectangle(TextField field, const uint32_t charIndex);
84
85   /**
86    * @brief Get the character bounding rectangle.
87    * If the text is not yet rendered or the index > text.Count(); a rect of {0, 0, 0, 0} is returned.
88    *
89    * @param[in] editor text model containing text info.
90    * @param[in] charIndex character index to which we want to calculate the geometry for.
91    * @return bounding rectangle.
92    */
93    DALI_TOOLKIT_API Rect<float> GetCharacterBoundingRectangle(TextEditor editor, const uint32_t charIndex);
94
95   /**
96    * @brief Get the character index.
97    * If the text is not yet rendered or the text is empty, -1 is returned.
98    *
99    * @param[in] label text model containing text info.
100    * @param[in] visualX visual x position.
101    * @param[in] visualY visual y position.
102    * @return character index.
103    */
104    DALI_TOOLKIT_API int GetCharacterIndexAtPosition(TextLabel label, float visualX, float visualY);
105
106   /**
107    * @brief Get the character index.
108    * If the text is not yet rendered or the text is empty, -1 is returned.
109    *
110    * @param[in] field text model containing text info.
111    * @param[in] visualX visual x position.
112    * @param[in] visualY visual y position.
113    * @return character index.
114    */
115   DALI_TOOLKIT_API int GetCharacterIndexAtPosition(TextField field, float visualX, float visualY);
116
117   /**
118    * @brief Get the character index.
119    * If the text is not yet rendered or the text is empty, -1 is returned.
120    *
121    * @param[in] editor text model containing text info.
122    * @param[in] visualX visual x position.
123    * @param[in] visualY visual y position.
124    * @return character index.
125    */
126   DALI_TOOLKIT_API int GetCharacterIndexAtPosition(TextEditor editor, float visualX, float visualY);
127
128
129 } // namespace TextGeometry
130
131 } // namespace Text
132
133 } // namespace Toolkit
134
135 } // namespace Dali
136
137 #endif //DALI_TOOLKIT_TEXT_GEOMETRY_DEVEL_H