1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_HIGHLIGHT_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_HIGHLIGHT_H__
5 * Copyright (c) 2014 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/controls/text-input/textview-character-positions-impl.h>
23 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
35 * @brief TextHighlight is a decoration which highlights selected text.
37 * The class creates a highlight mesh used to show selected text between handles.
38 * Not responsible for positioning.
43 * structure to hold coordinates of each quad, which will make up the mesh.
45 struct QuadCoordinates
56 * @param[in] x1 left co-ordinate
57 * @param[in] y1 top co-ordinate
58 * @param[in] x2 right co-ordinate
59 * @param[in] y2 bottom co-ordinate
61 QuadCoordinates(float x1, float y1, float x2, float y2)
67 Vector2 min; ///< top-left (minimum) position of quad
68 Vector2 max; ///< bottom-right (maximum) position of quad
71 typedef std::vector<QuadCoordinates> QuadContainer;
76 * structure for information required to build the highlight mesh
81 * Adds a Quad (2D rectangular sub-selection)
82 * @param[in] x1 left co-ordinate
83 * @param[in] y1 top co-ordinate
84 * @param[in] x2 right co-ordinate
85 * @param[in] y2 bottom co-ordinate
87 void AddQuad( float x1, float y1, float x2, float y2 );
90 * Clamps all quads to fit within a min -> max 2D boundary.
92 void Clamp2D(const Vector2& min, const Vector2& max);
94 QuadContainer mQuadList; ///< List of quads (sub-selections that form to create complete selection)
99 * @param[in] textViewCharacterPositioning TextViewCharacterPositioning to be used for positioning information.
101 TextHighlight( TextViewCharacterPositioning& textViewCharacterPositioning );
109 * Gets the table of the visual text positions which has a flag
110 * for each Character. The flag is either true (character selected)
111 * or false (character de-selected)
112 * @note startSelection can be greater or less than endSelection
114 * @param[in,out] selectedVisualText The vector to be resized and populated with the selected flags
115 * @param[in] startSelection The start selection point for the text
116 * @param[in] endSelection The end selection point for the text
117 * @param[in] endSelection The end selection point for the text
118 * @param[in] textLayoutInfo TextView character layout information
120 void GetVisualTextSelection(std::vector<bool>& selectedVisualText, std::size_t startSelection, std::size_t endSelection,
121 Toolkit::TextView::TextLayoutInfo& textLayoutInfo);
124 * Iterates between selection handles and computes the info required to build the highlight mesh
125 * @param[in] handlePositionStart starting handle position
126 * @param[in] handlePositionEnd ending handle position
127 * @return textHighlight target TextHighlight
129 TextHighlight::HighlightInfo CalculateHighlightInfo( std::size_t handlePositionStart, std::size_t handlePositionEnd, Toolkit::TextView::TextLayoutInfo& textLayoutInfo );
132 * Calculates new Mesh data so highlight moves with selection handles.
133 * @param[in] newHighlightInfo HighlightInfo calculated by CalculateHighlightInfo
135 void UpdateHighlight( TextHighlight::HighlightInfo& newHighlightInfo );
138 * Creates the Mesh data needed by the Mesh Actor
140 void CreateHighLightMesh();
145 * @brief Copy Constructor
146 * @param[in] textHight
149 TextHighlight(const TextHighlight& textHight );
152 * @Assignment Constructor
156 TextHighlight& operator=(const TextHighlight& rhs);
160 TextViewCharacterPositioning& mTextViewCharacterPositioning;
162 HighlightInfo mNewHighlightInfo; ///< Geometry info to create highlight.
167 } // namespace Internal
170 } // namespace Toolkit
174 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_HIGHLIGHT_H__