1 #ifndef __DALI_TOOLKIT_TEXT_CURSOR_HELPER_FUNCTIONS_H__
2 #define __DALI_TOOLKIT_TEXT_CURSOR_HELPER_FUNCTIONS_H__
5 * Copyright (c) 2016 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-toolkit/internal/text/logical-model-impl.h>
23 #include <dali-toolkit/internal/text/metrics.h>
24 #include <dali-toolkit/internal/text/visual-model-impl.h>
42 primaryCursorHeight( 0.f ),
43 secondaryCursorHeight( 0.f ),
44 isSecondaryCursor( false )
50 Vector2 primaryPosition; ///< The primary cursor's position.
51 Vector2 secondaryPosition; ///< The secondary cursor's position.
52 float lineOffset; ///< The vertical offset where the line containing the cursor starts.
53 float lineHeight; ///< The height of the line where the cursor is placed.
54 float primaryCursorHeight; ///< The primary cursor's height.
55 float secondaryCursorHeight; ///< The secondary cursor's height.
56 bool isSecondaryCursor; ///< Whether the secondary cursor is valid.
60 * @brief Retrieves the closest line for a given touch point.
62 * It returns the first line if the touch point is above the text and the last line if the touch point is below.
64 * @return A line index.
66 LineIndex GetClosestLine( VisualModelPtr visualModel,
70 * @brief Retrieves the cursor's logical position for a given touch point x,y
72 * @param[in] visualModel The visual model.
73 * @param[in] logicalModel The logical model.
74 * @param[in] metrics A wrapper around FontClient used to get metrics.
75 * @param[in] visualX The touch point x.
76 * @param[in] visualY The touch point y.
78 * @return The logical cursor position (in characters). 0 is just before the first character, a value equal to the number of characters is just after the last character.
80 CharacterIndex GetClosestCursorIndex( VisualModelPtr visualModel,
81 LogicalModelPtr logicalModel,
88 * @brief Calculates the cursor's position for a given character index in the logical order.
90 * It retrieves as well the line's height and the cursor's height and
91 * if there is a valid alternative cursor, its position and height.
93 * @param[in] logical The logical cursor position (in characters). 0 is just before the first character, a value equal to the number of characters is just after the last character.
94 * @param[out] cursorInfo The line's height, the cursor's height, the cursor's position and whether there is an alternative cursor.
96 void GetCursorPosition( VisualModelPtr visualModel,
97 LogicalModelPtr logicalModel,
99 CharacterIndex logical,
100 CursorInfo& cursorInfo );
105 void FindSelectionIndices( VisualModelPtr visualModel,
106 LogicalModelPtr logicalModel,
110 CharacterIndex& startIndex,
111 CharacterIndex& endIndex );
115 } // namespace Toolkit
119 #endif // __DALI_TOOLKIT_TEXT_CURSOR_HELPER_FUNCTIONS_H__