Remove redundant orientation settings as default camera already looks at stage
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-input / textview-character-positions-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_TEXTVIEW_CHARACTER_POSITIONS_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_TEXTVIEW_CHARACTER_POSITIONS_H__
3
4 /*
5  * Copyright (c) 2014 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/internal/controls/text-input/text-input-text-style-impl.h>
23 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal
32 {
33
34 class TextInputTextStyle;
35
36 /**
37  * Class which contains functions related to the TextView.
38  * Functions which are needed by various parts of the TextInput to determine the position of characters.
39  * Functions to Set the TextView so text justification, alignment and wrapping behaviour in the desired manner for text input.
40  * The functionality of this class may be divided in future.
41  */
42 class TextViewCharacterPositioning
43 {
44
45 public:
46
47   /**
48    * @brief Constructor
49    *
50    * @param[in] displayedTextView TextView to be used with this class.
51    * @param[in] textStyle TextInputTextStyle to be used
52    */
53   TextViewCharacterPositioning( Toolkit::TextView displayedTextView, TextInputTextStyle& textStyle ):mTextStyle( textStyle ){};
54
55   /**
56    * Destructor
57    */
58   ~TextViewCharacterPositioning(){};
59
60   /**
61    * @brief Creates the TextView to be used within this class.
62    */
63   void CreateTextView(){};
64
65   /*
66    * @brief Get a handle to the current text view object
67    * If one does not exist then it's create.
68    * @return TextView
69    */
70   Toolkit::TextView GetTextView() const{return Toolkit::TextView();};
71
72   /**
73    * @brief Get the TextLayoutInfo from the TextView so know the updated positions of characters.
74    */
75   void UpdateTextLayoutInfo(){};
76
77
78   /**
79    *  @brief Get the TextLayoutInfo structure for the TextView
80    *  @return the TextLayoutInfo structure
81    */
82   const Toolkit::TextView::TextLayoutInfo& GetLayoutInfo() const{return mTextLayoutInfo;};
83
84
85   /**
86    * @brief Get the number of characters visually represented in the text
87    * @return the number of characters
88    */
89   std::size_t GetNumberOfCharactersInText() const{return 0;};
90
91   /**
92    * @brief Check if any text exists in TextView's character layout table
93    * @return bool true if empty
94    */
95   bool IsTextEmpty() const{return false;};
96
97   /**
98    * @brief Get the height of the line at the given cursor position
99    * @param[in] position
100    * @return float the height of the line
101    */
102   float GetLineHeight( std::size_t position ) const{return 0.0f;};
103
104   /**
105    * @brief Sets if the inputed text can exceed the text-input boundary.
106    * By default is enabled.
107    * @param[in] enable Whether the inputed text can exceed its boundary.
108    */
109   void SetTextExceedEnabled( bool enable ) {};
110
111   /**
112    * @brief Retrieves whether inputed text can exceed the text-input boundary.
113    * @return \e true if text inputed can exceed the boundary, otherwise \e false.
114    */
115   bool IsTextExceedEnabled() const{ return false;};
116
117   /**
118    * @brief From the given x and y vector the closest character position is returned
119    * @param[in] source the x and y position
120    * @return the position in the string of the character closest to the source.
121    */
122   std::size_t ReturnClosestIndex( const Vector2& source ){return 0;};
123
124   /**
125    * @brief If no text exists then this function uses the text alignment to position cursor.
126    * @param[in] cursorPosition
127    */
128   void GetActualPositionFromCharacterPositionWhenNoText( Vector3& cursorPosition ) const{};
129
130   /**
131    * @brief Function to position cursor when a word is wrapped to another line
132    * @param[in] characterPosition that actual position is required for
133    * @return the actual position of the cursor.
134    */
135   Vector3 PositionCursorAfterWordWrap( std::size_t characterPosition ) const{return Vector3::ZERO;};
136
137   /**
138    * @brief Returns the x-position of the current line justification
139    * (relative to left of text-view container)
140    * @return x position for line justification
141    */
142   float GetLineJustificationPosition() const{return 0.0f;};
143
144   /**
145    * @brief Retrieve the dimensions (and min-max) of this row of text that the character resides on.
146    * @param[in] characterPosition the position in the 'string' of characters.
147    * @param[out] min the top-left position of the rectangle representing this row
148    * @param[out] max the bottom-right position of the rectangle representing this row
149    * @return The size of the rectangle representing this row (max - min)
150    */
151   Size GetRowRectFromCharacterPosition(std::size_t characterPosition, Vector2& min, Vector2& max) const{return Vector2::ZERO;};
152
153   /**
154    * @brief Retrieve the character position of the first character on the row of text
155    * that this character resides on.
156    * @param[in] logicalPosition the position in the 'string' of characters.
157    * @return logical character position of start of row.
158    */
159   std::size_t GetRowStartFromCharacterPosition(std::size_t logicalPosition) const{return 0;};
160
161   /**
162    * @brief Gets the visual position of a logical position.
163    * @note This is preferred over directly accessing the Map, as it resolves visual
164    * positions outside of the character map range.
165    * @param[in] logicalPosition The logical position
166    * @return Visual position is returned.
167    */
168   std::size_t GetVisualPosition(std::size_t logicalPosition) const{return 0;};
169
170   /**
171    * @brief Return a vector which is the actual position for the given character position
172    * The character position is where a cursor would be position for that character.
173    * @param[in] characterPosition the logical (input) position in the 'string' of characters.
174    *
175    * @return Vector3 the actual x,y,z position
176    */
177   Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition ) const{return Vector3::ZERO;};
178
179   /**
180    * @brief Return a vector which is the actual position for the given character position
181    * The character position is where a cursor would be positioned for that character to be inserted.
182    * An additional alternatePosition is also set in circumstances where the possible writing
183    * of characters would be in the opposite direction.
184    * e.g. "HelloشقشلاهؤEnglish"
185    *            |     |
186    *            *     +
187    * [*] - Primary actual position for cursor i.e. continuing writing LTR (English)
188    * [+] - Alternate actual position for cursor i.e. writing RTL (Arabic)
189    *
190    * @param[in] characterPosition the logical (input) position in the 'string' of characters.
191    * @param[out] directionRTL Whether the actual x,y,z position is after LTR (false) or RTL (true) text.
192    * @param[out] alternatePosition the actual x,y,z position of the cursor if user types
193    * in alternate direction to current flow of text.
194    * @param[out] alternatePositionValid whether this alternate position is valid.
195    * @return Vector3 the actual x,y,z position
196    */
197   Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition, bool& directionRTL, Vector3& alternatePosition, bool& alternatePositionValid ) const{return Vector3::ZERO;};
198
199   /**
200    * @brief Get the currently displayed text.
201    * @return The currently displayed text.
202    */
203   std::string GetText() const{return std::string();};
204
205   /**
206    * @brief Get the text currently being displayed together with mark-up tags.
207    * @return string, the currently displayed string with mark-up.
208    */
209   std::string GetMarkupText() const{return std::string();};
210
211   /**
212    * @brief Sets whether markup processing should be carried out.
213    *
214    * @param[in] enable whether markup processing is carried out or not.
215    */
216   void SetMarkupProcessingEnabled( bool enable ){};
217
218   /**
219    * @brief Returns whether markup processing is enabled or not
220    *
221    * @return true is markup processing is enabled
222    */
223   bool IsMarkupProcessingEnabled() const{ return false;};
224
225   // Styled Text
226
227   /**
228    * @brief Check if styled text is empty
229    * @return bool returns true if styled text is empty
230    */
231   bool IsStyledTextEmpty() const{ return false;};
232
233   /**
234    * @brief The size of the style text
235    * @return std::size_t returns number of characters in styled text
236    */
237   std::size_t StyledTextSize() const{return 0;};
238
239   /**
240    * @brief Get the styled text array
241    * @return reference to MarkupProcessor::StyledTextArray
242    */
243   MarkupProcessor::StyledTextArray& GetStyledTextArray(){return mStyledText;};
244
245   /**
246    * @brief Get the style for the character at the given position
247    * @param[in] position of character style is required for
248    * @return a copy of the style structure for the character at the given position
249    */
250   TextStyle GetStyleAt( std::size_t position ) const{return TextStyle();};
251
252 /**
253    * @briefApplies the given style to all text, selected or not selected.
254    * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
255    * @param[in] style style to apply
256    * @param[in] mask mask style should be applied to
257    * @param[in] begin start position of range to apply style
258    * @param[in] end end position of range to apply style
259    */
260   void ApplyStyleToRange( const TextStyle& style, const TextStyle::Mask mask, const std::size_t begin, const std::size_t end ){};
261
262   // Snapshot
263   /**
264    * @copydoc TextView::SetSnapshotModeEnabled()
265    */
266   void SetSnapshotModeEnabled( bool enable ){};
267
268   /**
269    * @copydoc TextView::IsSnapshotModeEnabled()
270    */
271   bool IsSnapshotModeEnabled() const{ return false;};
272
273   // Scrolling
274   /**
275    * @copydoc TextView::SetScrollEnabled()
276    */
277   void SetScrollEnabled( bool enable ){};
278
279   /**
280    * @copydoc TextView::SetScrollPosition()
281    */
282   void SetScrollPosition( const Vector2& position ){};
283
284   /**
285    * @copydoc TextView::IsScrollEnabled()
286    */
287   bool IsScrollEnabled() const{ return false;};
288
289   /**
290    * @copydoc TextView::GetScrollPosition()
291    */
292   Vector2 GetScrollPosition() const{return Vector2::ZERO;};
293
294   /**
295    * @copydoc TextView::GetScrollPosition()
296    */
297   bool IsScrollPositionTrimmed() const{ return false;};
298
299 private:
300
301   /**
302    * @brief Copy Constructor
303    * @param[in] characterPositioning
304    * Undefined.
305    */
306   TextViewCharacterPositioning(const TextViewCharacterPositioning& characterPositioning );
307
308   /**
309    * @Assignment Constructor
310    * @param[in] rhs
311    * Undefined.
312    */
313   TextViewCharacterPositioning& operator=(const TextViewCharacterPositioning& rhs);
314
315 private:
316
317   Toolkit::TextView mDisplayedTextView;         // A text view object used to display the text.
318   TextInputTextStyle& mTextStyle;               // Holds the style object related to input style
319
320   MarkupProcessor::StyledTextArray mStyledText; // String currently displayed by TextView with style info.
321
322   Toolkit::TextView::TextLayoutInfo      mTextLayoutInfo; // It contains a table layout info per character sorted by the character's visual index (retrieved from TextView),
323                                                           // a reorder map that stores each character's visual (output) index according to its logical (input) index,
324                                                           // a reorder map that stores each character's logical (input) index according to its visual (output) index
325
326   bool mExceedEnabled:1; // flag set by user to determine if text can exceed the control's size
327   bool mMarkUpEnabled:1; // If Markup is being passed with the text
328 };
329
330
331 } // namespace Internal
332
333
334 } // namespace Toolkit
335
336 } // namespace Dali
337
338 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_TEXTVIEW_CHARACTER_POSITIONS_H__