#define DALI_TOOLKIT_TEXT_CURSOR_HELPER_FUNCTIONS_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali-toolkit/internal/text/logical-model-impl.h>
#include <dali-toolkit/internal/text/metrics.h>
#include <dali-toolkit/internal/text/visual-model-impl.h>
+#include <dali-toolkit/internal/text/glyph-metrics-helper.h>
namespace Dali
{
-
namespace Toolkit
{
-
namespace Text
{
-
struct CharacterHitTest
{
/**
CursorInfo()
: primaryPosition(),
secondaryPosition(),
- lineOffset( 0.f ),
- glyphOffset( 0.f ),
- lineHeight( 0.f ),
- primaryCursorHeight( 0.f ),
- secondaryCursorHeight( 0.f ),
- isSecondaryCursor( false )
- {}
+ lineOffset(0.f),
+ glyphOffset(0.f),
+ lineHeight(0.f),
+ primaryCursorHeight(0.f),
+ secondaryCursorHeight(0.f),
+ isSecondaryCursor(false)
+ {
+ }
~CursorInfo()
- {}
+ {
+ }
Vector2 primaryPosition; ///< The primary cursor's position (in text's coords).
Vector2 secondaryPosition; ///< The secondary cursor's position (in text's coords).
};
/**
+ * @brief Parameters passed to the GetCursorPosition() function.
+ */
+struct GetCursorPositionParameters
+{
+ VisualModelPtr visualModel; ///< The visual model.
+ LogicalModelPtr logicalModel; ///< The logical model.
+ MetricsPtr metrics; ///< A wrapper around FontClient used to get metrics.
+ CharacterIndex 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.
+ bool isMultiline; ///< Whether the text control is multi-line.
+};
+
+/**
* @brief Retrieves the closest line for a given touch point.
*
* It returns the first line if the touch point is above the text and the last line if the touch point is below.
*
* @return A line index.
*/
-LineIndex GetClosestLine( VisualModelPtr visualModel,
- float visualY,
- bool& matchedLine );
+LineIndex GetClosestLine(VisualModelPtr visualModel,
+ float visualY,
+ bool& matchedLine);
/**
* @brief Calculates the vertical line's offset for a given line.
*
* @return The vertical offset of the given line.
*/
-float CalculateLineOffset( const Vector<LineRun>& lines,
- LineIndex lineIndex );
+float CalculateLineOffset(const Vector<LineRun>& lines,
+ LineIndex lineIndex);
/**
* @brief Retrieves the cursor's logical position for a given touch point x,y
*
* @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.
*/
-CharacterIndex GetClosestCursorIndex( VisualModelPtr visualModel,
- LogicalModelPtr logicalModel,
- MetricsPtr metrics,
- float visualX,
- float visualY,
- CharacterHitTest::Mode mode,
- bool& matchedCharacter );
+CharacterIndex GetClosestCursorIndex(VisualModelPtr visualModel,
+ LogicalModelPtr logicalModel,
+ MetricsPtr metrics,
+ float visualX,
+ float visualY,
+ CharacterHitTest::Mode mode,
+ bool& matchedCharacter);
/**
* @brief Calculates the cursor's position for a given character index in the logical order.
* It retrieves as well the line's height and the cursor's height and
* if there is a valid alternative cursor, its position and height.
*
- * @param[in] visualModel The visual model.
- * @param[in] logicalModel The logical model.
- * @param[in] metrics A wrapper around FontClient used to get metrics.
- * @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.
+ * @param[in] parameters Parameters used to calculate the cursor's position.
+ * @param[in] defaultFontLineHeight The default font line height.
* @param[out] cursorInfo The line's height, the cursor's height, the cursor's position and whether there is an alternative cursor.
*/
-void GetCursorPosition( VisualModelPtr visualModel,
- LogicalModelPtr logicalModel,
- MetricsPtr metrics,
- CharacterIndex logical,
- CursorInfo& cursorInfo );
+void GetCursorPosition(GetCursorPositionParameters& parameters,
+ float defaultFontLineHeight,
+ CursorInfo& cursorInfo);
/**
* @brief Find the indices to the first and last characters of a word for the given touch point.
*
* @return @e true if the touch point hits a character.
*/
-bool FindSelectionIndices( VisualModelPtr visualModel,
- LogicalModelPtr logicalModel,
- MetricsPtr metrics,
- float visualX,
- float visualY,
- CharacterIndex& startIndex,
- CharacterIndex& endIndex,
- CharacterIndex& noTextHitIndex );
+bool FindSelectionIndices(VisualModelPtr visualModel,
+ LogicalModelPtr logicalModel,
+ MetricsPtr metrics,
+ float visualX,
+ float visualY,
+ CharacterIndex& startIndex,
+ CharacterIndex& endIndex,
+ CharacterIndex& noTextHitIndex);
} // namespace Text