Remove mesh from text input.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-input / text-input-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_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 // EXTERNAL INCLUDES
22 #include <dali/public-api/adaptor-framework/clipboard.h>
23 #include <dali/public-api/adaptor-framework/clipboard-event-notifier.h>
24 #include <dali/public-api/adaptor-framework/imf-manager.h>
25 #include <dali/public-api/adaptor-framework/timer.h>
26 #include <dali/public-api/common/dali-vector.h>
27
28 // INTERNAL INCLUDES
29 #include <dali-toolkit/public-api/controls/control-impl.h>
30 #include <dali-toolkit/public-api/controls/text-input/text-input.h>
31 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
32 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
33 #include <dali-toolkit/internal/controls/text-input/text-input-popup-impl.h>
34
35 namespace Dali
36 {
37
38 namespace Toolkit
39 {
40
41 namespace Internal
42 {
43
44 class TextInput;
45 class TextView;
46
47 typedef IntrusivePtr<TextInput> TextInputPtr;
48
49 class TextInput : public Control
50 {
51 public:
52
53   // Properties
54   enum
55   {
56     TEXTINPUT_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
57     TEXTINPUT_PROPERTY_END_INDEX = TEXTINPUT_PROPERTY_START_INDEX + 512 ///< Reserving property indices
58   };
59
60   /**
61    * Create a new TextInput
62    * @return instrusive ptr to a TextInput
63    */
64   static Dali::Toolkit::TextInput New();
65
66   /**
67    * @copydoc Toolkit::TextInput::GetText
68    */
69   std::string GetText() const;
70
71   /**
72    * @copydoc Toolkit::TextInput::GetMarkupText()
73    */
74   std::string GetMarkupText() const;
75
76   /**
77    * @copydoc Toolkit::TextInput::SetPlaceholderText
78    */
79   void SetPlaceholderText( const std::string& placeHolderText );
80
81   /**
82    * @copydoc Toolkit::TextInput::SetPlaceholderText
83    */
84   std::string GetPlaceholderText();
85
86   /**
87    * @copydoc Toolkit::TextInput::SetInitialText
88    */
89   void SetInitialText(const std::string& initialText);
90
91   /**
92    *  set the text to be displayed in text-input, will overwrite any existing text.
93    *  can be used to clear the text-input by passing an empty string.
94    *  @param [in] initialText text to be initially displayed
95    */
96   void SetText(const std::string& initialText);
97
98   /**
99    * @copydoc Toolkit::TextInput::SetMaxCharacterLength
100    */
101   void SetMaxCharacterLength(std::size_t maxChars);
102
103   /**
104    * @copydoc Toolkit::TextInput::SetNumberOfLinesLimit
105    */
106   void SetNumberOfLinesLimit(std::size_t maxLines);
107
108   /**
109    * @copydoc Toolkit::TextInput::GetNumberOfLinesLimit
110    */
111   std::size_t GetNumberOfLinesLimit() const;
112
113   /**
114    * @copydoc Toolkit::TextInput::GetFont
115    */
116   Font GetFont() const;
117
118   /**
119    * @copydoc Toolkit::TextInput::SetFont
120    */
121   void SetFont(Font font);
122
123   /**
124    * @copydoc Toolkit::TextInput::InputStartedSignal()
125    */
126   Toolkit::TextInput::InputSignalType& InputStartedSignal();
127
128   /**
129    * @copydoc Toolkit::TextInput::InputFinishedSignal()
130    */
131   Toolkit::TextInput::InputSignalType& InputFinishedSignal();
132
133   /**
134    * @copydoc Toolkit::TextInput::CutAndPasteToolBarDisplayedSignal()
135    */
136   Toolkit::TextInput::InputSignalType& CutAndPasteToolBarDisplayedSignal();
137
138   /**
139    * @copydoc Toolkit::TextInput::StyleChangedSignal()
140    */
141   Toolkit::TextInput::StyleChangedSignalType& StyleChangedSignal();
142
143   /**
144    * @copydoc Toolkit::TextInput::TextModifiedSignal()
145    */
146   Toolkit::TextInput::TextModifiedSignalType& TextModifiedSignal();
147
148   /**
149    * @copydoc Toolkit::TextInput::MaxInputCharactersReachedSignal()
150    */
151   Toolkit::TextInput::MaxInputCharactersReachedSignalType& MaxInputCharactersReachedSignal();
152
153   /**
154    * @copydoc Toolkit::TextInput::InputTextExceedBoundariesSignal()
155    */
156   Toolkit::TextInput::InputTextExceedBoundariesSignalType& InputTextExceedBoundariesSignal();
157
158   /**
159    * Connects a callback function with the object's signals.
160    * @param[in] object The object providing the signal.
161    * @param[in] tracker Used to disconnect the signal.
162    * @param[in] signalName The signal to connect to.
163    * @param[in] functor A newly allocated FunctorDelegate.
164    * @return True if the signal was connected.
165    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
166    */
167   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
168
169   /**
170    * @see Toolkit::TextInput::SetEditMode(bool editMode)
171    * @see Toolkit::TextInput::SetEditMode(bool editMode, const Vector2& touchPoint)
172    *
173    * @param[in] editMode true or false to indicate editMode on or off.
174    * @param[in] setCursorOnTouchPoint Whether to use the touch point to set the cursor position.
175    * @param[in] touchPoint A position in actor coordinates within the text-input.
176    */
177   void SetEditable(bool editMode, bool setCursorOnTouchPoint, const Vector2& touchPoint = Vector2::ZERO);
178
179   /**
180    * @copydoc Toolkit::TextInput::GetEditMode
181    */
182   bool IsEditable() const;
183
184   /**
185    * @copydoc Toolkit::TextInput::SetTextSelectable
186    */
187   void SetTextSelectable(bool textSelectable = true);
188
189   /**
190    * @copydoc Toolkit::TextInput::IsTextSelectable
191    */
192   bool IsTextSelectable() const;
193
194   /**
195    * @copydoc Toolkit::TextInput::IsTextSelected
196    */
197   bool IsTextSelected() const;
198
199   /**
200    * @copydoc Toolkit::TextInput::DeSelectText
201    */
202   void DeSelectText();
203
204   /**
205    * @copydoc Toolkit::TextInput::SetEditOnTouch
206    */
207   void SetEditOnTouch(bool editOnTouch);
208
209   /**
210    * @copydoc Toolkit::TextInput::IsEditOnTouch
211    */
212   bool IsEditOnTouch() const;
213
214   /**
215    * @copydoc Toolkit::TextInput::SetGrabHandleImage
216    */
217   void SetGrabHandleImage(Dali::Image image);
218
219   /**
220    * @copydoc Toolkit::TextInput::SetCursorImage
221    */
222   void SetCursorImage(Dali::Image image, const Vector4& border );
223
224   /**
225    * @copydoc Toolkit::TextInput::GetSelectionHandleSize
226    */
227   Vector3 GetSelectionHandleSize();
228
229   /**
230    * @copydoc Toolkit::TextInput::SetRTLCursorImage
231    */
232   void SetRTLCursorImage(Dali::Image image, const Vector4& border );
233
234   /**
235    * @copydoc Toolkit::TextInput::EnableGrabHandle
236    */
237   void EnableGrabHandle(bool toggle);
238
239   /**
240    * @copydoc Toolkit::TextInput::IsGrabHandleEnabled
241    */
242   bool IsGrabHandleEnabled();
243
244   /**
245    * @copydoc Toolkit::TextInput::EnableSelectionHandleFlip
246    */
247   void EnableSelectionHandleFlip( bool toggle );
248
249   /**
250    * @copydoc Toolkit::TextInput::IsSelectionHandleFlipEnabled
251    */
252   bool IsSelectionHandleFlipEnabled();
253
254   /**
255    * @copydoc Toolkit::TextInput::SetSelectionHandleFlipMargin
256    */
257   void SetSelectionHandleFlipMargin( const Vector4& margin );
258
259   /**
260    * @copydoc Toolkit::TextInput::SetBoundingRectangle
261    */
262   void SetBoundingRectangle( const Rect<float>& boundingRectangle );
263
264   /**
265    * @copydoc Toolkit::TextInput::GetBoundingRectangle
266    */
267   const Rect<float> GetBoundingRectangle() const;
268
269   /**
270    * @copydoc Toolkit::TextInput::GetSelectionHandleFlipMargin
271    */
272   const Vector4& GetSelectionHandleFlipMargin();
273
274   /**
275    * @copydoc Toolkit::TextInput::SetTextColor
276    */
277   void SetTextColor( const Vector4& color );
278
279   /**
280    * @copydoc Toolkit::TextInput::SetActiveStyle
281    */
282   void SetActiveStyle( const TextStyle& style, const TextStyle::Mask mask );
283
284   /**
285    * @copydoc Toolkit::TextInput::ApplyStyle
286    */
287   void ApplyStyle( const TextStyle& style, const TextStyle::Mask mask );
288
289   /**
290    * @copydoc Toolkit::TextInput::ApplyStyleToAll
291    */
292   void ApplyStyleToAll( const TextStyle& style, const TextStyle::Mask mask );
293
294   /**
295    * @copydoc Toolkit::TextInput::GetStyleAtCursor
296    */
297   TextStyle GetStyleAtCursor() const;
298
299   /**
300    * Retrieves the character style for the given position.
301    * @param[in] position The character position which style is required.
302    * @return The style for the given position.
303    */
304   TextStyle GetStyleAt( std::size_t position ) const;
305
306   /**
307    * @copydoc Toolkit::TextInput::SetTextAlignment()
308    */
309   void SetTextAlignment( Toolkit::Alignment::Type align );
310
311   /**
312    * @copydoc Toolkit::TextInput::SetTextLineJustification()
313    */
314   void SetTextLineJustification( Toolkit::TextView::LineJustification justification );
315
316   /**
317    * @copydoc Toolkit::TextInput::SetFadeBoundary()
318    */
319   void SetFadeBoundary( const Toolkit::TextView::FadeBoundary& fadeBoundary );
320
321   /**
322    * @copydoc Toolkit::TextInput::GetFadeBoundary()
323    */
324   const Toolkit::TextView::FadeBoundary& GetFadeBoundary() const;
325
326   /**
327    * @copydoc Toolkit::TextInput::GetTextAlignment()
328    */
329   Toolkit::Alignment::Type GetTextAlignment() const;
330
331   /**
332    * @copydoc Toolkit::TextInput::SetMultilinePolicy()
333    */
334   void SetMultilinePolicy( Toolkit::TextView::MultilinePolicy policy );
335
336   /**
337    * @copydoc Toolkit::TextInput::GetMultilinePolicy()
338    */
339   Toolkit::TextView::MultilinePolicy GetMultilinePolicy() const;
340
341   /**
342    * @copydoc Toolkit::TextInput::SetWidthExceedPolicy()
343    */
344   void SetWidthExceedPolicy( Toolkit::TextView::ExceedPolicy policy );
345
346   /**
347    * @copydoc Toolkit::TextInput::GetWidthExceedPolicy()
348    */
349   Toolkit::TextView::ExceedPolicy GetWidthExceedPolicy() const;
350
351   /**
352    * @copydoc Toolkit::TextInput::SetHeightExceedPolicy()
353    */
354   void SetHeightExceedPolicy( Toolkit::TextView::ExceedPolicy policy );
355
356   /**
357    * @copydoc Toolkit::TextInput::GetHeightExceedPolicy()
358    */
359   Toolkit::TextView::ExceedPolicy GetHeightExceedPolicy() const;
360
361   /**
362    * @copydoc Toolkit::TextInput::SetExceedEnabled()
363    */
364   void SetExceedEnabled( bool enable );
365
366   /**
367    * @copydoc Toolkit::TextInput::GetExceedEnabled()
368    */
369   bool GetExceedEnabled() const;
370
371   /**
372    * @copydoc Toolkit::TextInput::SetBackground
373    */
374   void SetBackground(Dali::Image image );
375
376   /**
377    * @copydoc Toolkit::TextInput::SetNumberOfLines
378    */
379   void SetNumberOfLines(std::size_t lines);
380
381   /**
382    * @copydoc Toolkit::TextInput::GetNumberOfLines
383    */
384   std::size_t GetNumberOfLines();
385
386   /**
387    * @copydoc Toolkit::TextInput::GetNumberOfCharacters
388    */
389   std::size_t GetNumberOfCharacters() const;
390
391   /**
392    * Styling
393    */
394
395   /**
396    * Set the diffuse color for the highlight
397    * @param[in] color color to use
398    */
399   void SetMaterialDiffuseColor( const Vector4& color );
400
401   /**
402    * Get the diffuse color used by the highlight
403    * @return color
404    */
405   const Vector4& GetMaterialDiffuseColor() const;
406
407 private:
408
409   /**
410    * structure to hold each highlight box needed for text selection
411    */
412   struct HighlightBox
413   {
414     Vector3 size;                         ///< size of the highlight box
415     Vector3 position;                     ///< position of highlight box
416     ImageActor highlightBoxActor;         ///< as actor that is the highlight box
417   };
418
419   /**
420    * structure to hold each character in displayed string and its position from the left
421    */
422   struct CharPositions
423   {
424     char character;   ///< todo change to UTF to aid multi-language support
425     Vector3 position;
426     Vector2 size;
427   };
428
429   /**
430    * structure to hold coordinates of each quad, which will make up the mesh.
431    */
432   struct QuadCoordinates
433   {
434     /**
435      * Default constructor
436      */
437     QuadCoordinates()
438     {
439     }
440
441     /**
442      * Constructor
443      * @param[in] x1 left co-ordinate
444      * @param[in] y1 top co-ordinate
445      * @param[in] x2 right co-ordinate
446      * @param[in] y2 bottom co-ordinate
447      */
448     QuadCoordinates(float x1, float y1, float x2, float y2)
449     : min(x1, y1),
450       max(x2, y2)
451     {
452     }
453
454     Vector2 min;                          ///< top-left (minimum) position of quad
455     Vector2 max;                          ///< bottom-right (maximum) position of quad
456   };
457
458   typedef std::vector<QuadCoordinates> QuadContainer;
459
460   /**
461    * structure for information required to build the highlight mesh
462    */
463   struct HighlightInfo
464   {
465     /**
466      * Adds a Quad (2D rectangular sub-selection)
467      * @param[in] x1 left co-ordinate
468      * @param[in] y1 top co-ordinate
469      * @param[in] x2 right co-ordinate
470      * @param[in] y2 bottom co-ordinate
471      */
472     void AddQuad( float x1, float y1, float x2, float y2 );
473
474     /**
475      * Clamps all quads to fit within a min -> max 2D boundary.
476      */
477     void Clamp2D(const Vector2& min, const Vector2& max);
478
479     QuadContainer mQuadList;                                 ///< List of quads (sub-selections that form to create complete selection)
480   };
481
482   /**
483    * Holds requested selection start and end points for highlighted text.
484    */
485   struct SelectionParameters
486   {
487     SelectionParameters( size_t start, size_t end )
488     : mStartOfSelection( start ), mEndOfSelection( end )
489     {
490
491     }
492
493     size_t mStartOfSelection;
494     size_t mEndOfSelection;
495   };
496
497   enum State
498   {
499     StateEdit,
500     StateDraggingHandle
501   };
502
503   enum SelectionHandleId
504   {
505     HandleOne,   ///< Selection handle one which is on the left
506     HandleTwo    ///< Selection handle two which is on the right
507   };
508
509   /**
510    * Two different behaviours are needed to convert a touch point into a character index.
511    * When a tap is received and the touch point doesn't hit any character, the final character selected might
512    * be different than the one selected if the event is a pan.
513    * i.e. If a tap is received and the touch point doesn't hit any character the expected position of the cursor
514    * would be the end or the beginning of a line. However, this behaviour would be weird while panning.
515    */
516   enum TouchToIndex
517   {
518     TapMode,  ///< Touch point to character index conversion mode used for Tap events.
519     DragMode  ///< Touch point to character index conversion mode used for Pan events.
520   };
521
522   /**
523    * Used to set the direction when find the next visible character.
524    */
525   enum FindVisibleCharacterDirection
526   {
527     Left,  ///< Find visible characters on the left.
528     Right, ///< Find visible characters on the right.
529     ByEnd  ///< Start finding visible characters by the end.
530   };
531
532   /**
533    *
534    */
535   virtual bool OnTouchEvent(const TouchEvent& event);
536
537   /**
538    * From CustomActorImpl; called after the Text Input actor is touched
539    * @param[in] event The KeyEvent event.
540    * @return True if the event should be consumed.
541    */
542   virtual bool OnKeyEvent(const KeyEvent& event);
543
544   /**
545    * From CustomActorImpl; called when this actor gains keyboard focus.
546    */
547   virtual void OnKeyInputFocusGained();
548
549   /**
550    * From CustomActorImpl; called when this actor loses keyboard focus.
551    */
552   virtual void OnKeyInputFocusLost();
553
554   /**
555    * From Control; called whenever the control is added to the stage.
556    */
557   virtual void OnControlStageConnection();
558
559 private: // From Control
560
561   /**
562    * Creation of the layer that is used by top level active parts of the TextInput like handles
563    */
564   void CreateActiveLayer();
565
566   /**
567    * @copydoc Control::OnInitialize()
568    */
569   virtual void OnInitialize();
570
571   /**
572    * @copydoc Control::OnControlSizeSet()
573    */
574   virtual void OnControlSizeSet(const Vector3& targetSize);
575
576   /**
577    * @copydoc Control::OnRelayout()
578    */
579   virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
580
581   /**
582    * Retrieves the text-input's natural size by calling TextView::GetNaturalSize().
583    *
584    * @return The natural size.
585    */
586   virtual Vector3 GetNaturalSize();
587
588   /**
589    * Retrieves the text-input's \e height for a given \e width by calling TextView::GetHeightForWidth().
590    *
591    * @param[in] width The given \e width.
592    *
593    * @return The \e height for the given \e width.
594    */
595   virtual float GetHeightForWidth( float width );
596
597 protected:
598
599   /**
600    * Construct a new TextInput.
601    */
602   TextInput();
603
604   /**
605    * A reference counted object may only be deleted by calling Unreference()
606    */
607   virtual ~TextInput();
608
609 private:
610
611   // Undefined
612   TextInput(const TextInput&);
613
614   // Undefined
615   TextInput& operator=(const TextInput& rhs);
616
617   /**
618     * Callback when a handle is panned/moved, either selection handles or grab handle
619     * @param actor Handle of the selection or grab handle.
620     * @param gesture Data structure with the parameters of the gesture.
621     */
622    void OnHandlePan(Actor actor, const PanGesture& gesture);
623
624    /**
625     * Callback for touch down on Grab handle
626     * @param[in] actor touched
627     * @param[in] touch touch event
628     */
629    bool OnPressDown(Dali::Actor actor, const TouchEvent& touch);
630
631    /**
632     * Callback for touch down on Selection handle one
633     * @param[in] actor touched
634     * @param[in] touch touch event, used to determine if down or up event
635     */
636    bool OnHandleOneTouched(Dali::Actor actor, const TouchEvent& touch);
637
638    /**
639     * Callback for touch down on Selection handle two
640     * @param[in] actor touched
641     * @param[in] touch touch event, used to determine if down or up event
642     */
643    bool OnHandleTwoTouched(Dali::Actor actor, const TouchEvent& touch);
644
645    /**
646     * Callback for tap on TextInput
647     * @param[in] actor
648     * @param[in] tap touch event
649     */
650    void OnTextTap(Dali::Actor actor, const Dali::TapGesture& tap);
651
652    /**
653     * Callback for double tap on TextInput
654     * @param[in] actor
655     * @param[in] tap touch event
656     */
657    void OnDoubleTap(Dali::Actor actor, const Dali::TapGesture& tap);
658
659     /**
660      * Callback for long press on TextInput
661      * @param[in] actor
662      * @param[in] longPress long press event
663      */
664    void OnLongPress(Dali::Actor actor, const Dali::LongPressGesture& longPress);
665
666    /**
667     * Callback for the ClipboardEventNotifier when text is selected in the clipboard window.
668     * @param[in] notifier The Clipboard Event Notifier.
669     */
670    void OnClipboardTextSelected( ClipboardEventNotifier& notifier );
671
672    /**
673     * Callback for when a button is pressed in popup panel
674     * @param[in] button handle to the button pressed.
675     */
676    bool OnPopupButtonPressed( Toolkit::Button button );
677
678    /**
679     * Callback when handle timer ticks.
680     *
681     * Cursor should become visible/invisible to simulate blinking.
682     *
683     * @return True if the timer should be keep running.
684     */
685    bool OnCursorBlinkTimerTick();
686
687    /**
688     * Invoked upon popup Hide animation completing.
689     * @note Only called for animating hide, not called for instantaneous (animate = false)
690     * @param[in] popup The popup which was hidden.
691     */
692    void OnPopupHideFinished(TextInputPopup& popup);
693
694    /**
695     * Called in OnKeyEvent to handle key down events.
696     * @param[in] event The KeyEvent event.
697     * @return True if the event should be consumed.
698     */
699    bool OnKeyDownEvent(const KeyEvent& event);
700
701    /**
702     * Called in OnKeyEvent to handle key up events.
703     * @param[in] event The KeyEvent event.
704     * @return True if the event should be consumed.
705     */
706    bool OnKeyUpEvent(const KeyEvent& event);
707
708    /**
709     * Chooses from all handle position and alternative handle positions where to set the position of the two selection handles.
710     *
711     * @param[in] cursorPositionOne The initial position of the first selection handle.
712     * @param[in] cursorPositionTwo The initial position of the second selection handle.
713     * @param[in] altPositionValidOne Whether there is an alternative position for the first selection handle.
714     * @param[in] altPositionValidTwo Whether there is an alternative position for the second selection handle.
715     * @param[in] altPositionOne The alternative position of the first selection handle.
716     * @param[in] altPositionTwo The alternative position of the second selection handle.
717     */
718    void ChooseRtlSelectionHandlePosition( const Vector3& cursorPositionOne,
719                                           const Vector3& cursorPositionTwo,
720                                           bool altPositionValidOne,
721                                           bool altPositionValidTwo,
722                                           const Vector3& altPositionOne,
723                                           const Vector3& altPositionTwo );
724    /**
725     * Callback called when the text-view is scrolled.
726     *
727     * Updates the selection and grab handles, and the highlighted text.
728     *
729     * @param[in] textView Handle of the text-view.
730     * @param[in] scrollPosition The difference with the previous scroll position.
731     */
732    void OnTextViewScrolled( Toolkit::TextView textView, Vector2 scrollPosition );
733
734    /**
735     * Scrolls the text-view to make the cursor visible.
736     *
737     * @param[in] cursorPosition The actual cursor position in actor coordinates.
738     */
739    void ScrollTextViewToMakeCursorVisible( const Vector3& cursorPosition );
740
741    /**
742     * Creates and starts a timer to scroll the text when handles are close to the edges of the text-input.
743     *
744     * It only starts the timer if it's already created.
745     */
746    void StartScrollTimer();
747
748    /**
749     * Stops the timer used to scroll the text.
750     */
751    void StopScrollTimer();
752
753    /**
754     * Callback called by the timer used to scroll the text.
755     *
756     * It calculates and sets a new scroll position.
757     */
758    bool OnScrollTimerTick();
759
760 public:  // Public to allow internal testing.
761
762   /**
763    * Register for touch events
764    */
765   void SetUpTouchEvents();
766
767   /**
768    * Sets up TextView Actor
769    */
770   void CreateTextViewActor();
771
772   /**
773    * Set Styled Text for text input.
774    * @param[in] styleText The new styled text for the text input.
775    */
776   void SetText( const MarkupProcessor::StyledTextArray& styleText );
777
778   /**
779    * Start a timer to signal cursor to blink.
780    */
781   void StartCursorBlinkTimer();
782
783   /**
784    * Stop the timer signalling the cursor to blink.
785    */
786   void StopCursorBlinkTimer();
787
788   /**
789    * Starts input, setting focus and showing keyboard..
790    */
791   void StartEditMode();
792
793   /**
794    * Called when End of input and focus no longer required, keyboard is hidden.
795    */
796   void EndEditMode();
797
798   /**
799    * Applies a style to the current pre-edit / predicted word to show it is being edited.
800    * @param[in] preEditStartPosition position in text array that the predicted word starts at
801    * @param[in] preEditStringLength used to calculate how many characters need their style changed.
802    */
803   void ApplyPreEditStyle( std::size_t preEditStartPosition, std::size_t preEditStringLength );
804
805   /**
806    * Restores style to value before applying Pre-Edit style.
807    */
808   void RemovePreEditStyle();
809
810   /**
811    * Event received from IMF manager
812    * @return ImfCallbackData data struture undicating if update is needed, cursor position and current text
813    */
814   ImfManager::ImfCallbackData ImfEventReceived( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& test );
815
816   /**
817    * Called when the OnKey event is a Pre-edit string
818    * @param[in] keyString String received in Pre-edit
819    * @param[in] cursorOffset the cursor offset from where the pre-edit word starts
820    * @return bool true if preedit reset is required.
821    */
822   bool PreEditReceived( const std::string& keyString, std::size_t cursorOffset  );
823
824  /**
825   * Called when the OnKey event is a Commit string
826   * @param[in] keyString String received in Comment
827   * @return update flag to trigger cursor update of TextInput only when needed.
828   */
829   bool CommitReceived( const std::string& keyString );
830
831   /**
832    * Deletes Pre-edit string
833    * By default it doesn't update the character's size and position table, which is a costly
834    * operation. As in many cases deletion and insertion (InsertAt) of text
835    * occurs in the same action i.e. preedit/commit. It makes sense to
836    * delete without updating, and then insert with updating.
837    *
838    * @return The number of characters to be deleted.
839    */
840   std::size_t DeletePreEdit();
841
842   /**
843    * Reset all pre-edit flag and signal IMF keyboard that the current pre-edit word has been comitted.
844    * This may be due to the cursor being moved by user or reached the max character limit.
845    * @param[in] preserveCursorPosition Set true to keep cursor in current position, eg. touch event caused cursor to move.
846    */
847   void PreEditReset( bool preserveCursorPosition );
848
849   /**
850    * Called after cursor position needs updating.
851    * Redraws cursor and notifies VirtualKeyboard
852    */
853   void CursorUpdate();
854
855   /**
856    * Delete highlighted characters
857    * @param[in] inheritStyle Whether style from previous character in the string should be inherited.
858    */
859   void DeleteHighlightedText( bool inheritStyle );
860
861   /*
862    * Delete range of characters
863    * @param[in] start position of characters to delete
864    * @param[in] ncharacters number of characters to delete
865    */
866   void DeleteRange(std::size_t start, std::size_t ncharacters);
867
868   /**
869    * Delete character at current cursor position and redisplay
870    * @param[in] positionToDelete position of character to delete
871    */
872   void DeleteCharacter( std::size_t positionToDelete );
873
874   /**
875    * Add or replaces characters to currently displayed string at cursor position
876    * By default it doesn't update the character's size and position table, which is a costly
877    * operation. As in many cases deletion and insertion (InsertAt) of text
878    * occurs in the same action i.e. preedit/commit. It makes sense to
879    * delete without updating, and then insert with updating.
880    * @param[in] newText string to add to TextInput display string.
881    * @param[in] insertionPosition position to insert at.
882    * @param[in] numberOfCharactersToReplace The number of characters to replace.
883    * @return number of characters to offset the cursor by.
884    */
885   std::size_t InsertAt( const Text& newText, const std::size_t insertionPosition, const std::size_t numberOfCharactersToReplace );
886
887   /**
888   * Creates a cursor.
889   * @param[in] color the cursor color.
890   * @return the image actor to be used as the cursor.
891   */
892   ImageActor CreateCursor( const Vector4 &color );
893
894   /**
895    * Moves cursor to the right
896    * param[in] reverse if true then cursor moves in the reverse direction (to the left)
897    * param[in] places number of character cursor should move.
898    */
899   void AdvanceCursor(bool reverse = false, std::size_t places = 1);
900
901   /**
902    * Draw a cursor / caret at position where new text should appear
903    */
904   void DrawCursor();
905
906   /**
907    * Sets cursor visibility
908    * This sets visibility of the cursor. Which is comprised of 2
909    * cursors. The conventional cursor, and the alternate (RTL) cursor,
910    * which only appears when the cursor is at a character that can have
911    * a character appended to different visual positions depending on whether that
912    * character to be appended is RTL or LTR.
913    * @param[in] visible true - enable visibility for cursor, false - disable visiblity for cursor
914    */
915   void SetCursorVisibility( bool visible );
916
917   /**
918    * Sets alternate cursor enable state
919    * @see SetCursorVisibility
920    * alternate cursor will only be visible if both SetCursorVisiblity
921    * and cursor enabled have been set to true.
922    */
923   void SetAltCursorEnabled( bool enabled );
924
925   /**
926    * Create the grab handle that positions the cursor
927    * @param[in] image to be used for grab handle
928    *
929    */
930   void CreateGrabHandle(Image image=Image());
931
932   /**
933    * Create Grab area to be used by Grab Handle
934    */
935   void CreateGrabArea( Actor& parent);
936
937   /**
938    * Move grab handle to the required character position
939    *
940    * @param[in] displacement Displacement of the grab handle in actor coordinates.
941    *
942    * @return The new actual position the handle has been set to.
943    */
944   Vector3 MoveGrabHandle( const Vector2& displacement );
945
946   /**
947    * Show or hide the grab handle without baking the visibility flag.
948    * Used when the Grab handle needs to be invisible due to text-view scrolling making it out of view
949    *
950    * @param[in] visible bool flag to set as true is grab handle should be shown, else false to hide.
951    */
952   void ShowGrabHandle( bool visible );
953
954   /**
955    * Show or hide the grab handle and bake the visibility flag.
956    * Used when the state of text-input changes to a state which the grabhandle is not required. E.g. Selection mode starts or edit mode ends.
957    * Calls ShowGrabHandle.
958    *
959    * @param[in] visible bool flag to set as true is grab handle should be shown, else false to hide.
960    */
961   void ShowGrabHandleAndSetVisibility( bool visible );
962
963   /* Boundary Property Notifications when handle exceed bounding box*/
964
965   /**
966    * PropertyNotification Callback when left boundary exceeded so handle can be flipped.
967    * @param[in] source PropertyNotification
968    */
969   void OnLeftBoundaryExceeded( PropertyNotification& source );
970   /**
971    * PropertyNotification Callback when within left boundary so handle can be flipped back.
972    * @param[in] source PropertyNotification
973    */
974   void OnReturnToLeftBoundary( PropertyNotification& source );
975   /**
976    * PropertyNotification Callback when right boundary exceeded so handle can be flipped.
977    * @param[in] source PropertyNotification
978    */
979   void OnRightBoundaryExceeded( PropertyNotification& source );
980   /**
981    * * PropertyNotification Callback when within right boundary so handle can be flipped back.
982    * @param[in] source PropertyNotification
983    */
984   void OnReturnToRightBoundary( PropertyNotification& source );
985
986   /**
987    * PropertyNotification Callbacks for hiding handle one when it exceeds boundary.
988    * @param[in] source PropertyNotification
989    */
990   void OnHandleOneLeavesBoundary( PropertyNotification& source );
991   /**
992    * PropertyNotification Callbacks for showing hidden handle one when returns within boundary
993    * @param[in] source PropertyNotification
994    */
995   void OnHandleOneWithinBoundary( PropertyNotification& source );
996   /**
997    * PropertyNotification Callbacks for hiding handle two it  when exceeds boundary.
998    * @param[in] source PropertyNotification
999    */
1000   void OnHandleTwoLeavesBoundary( PropertyNotification& source );
1001   /**
1002    * PropertyNotification Callbacks for showing hidden handle two when returns within boundary
1003    * * @param[in] source PropertyNotification
1004    */
1005   void OnHandleTwoWithinBoundary( PropertyNotification& source );
1006
1007   /**
1008    * Set up property notifications on the position of the handles to facilitate flipping and hiding when at screen boundary.
1009    */
1010   void SetUpHandlePropertyNotifications();
1011
1012   /**
1013    * Create the selection handles that bound text to be selected for copy/cut.
1014    * @param[in] start initial position of start selection handle.
1015    * @param[in] end initial position of end selection handle.
1016    * @param[in] handleOneImage (optional) to be used for selection handle
1017    * @param[in] handleTwoImage (optional) to be used for selection handle
1018    */
1019   void CreateSelectionHandles( std::size_t start = 0, std::size_t end = std::numeric_limits<std::size_t>::max(), Dali::Image handleOneImage = Dali::Image(),  Dali::Image handleTwoImage = Dali::Image() );
1020
1021   /**
1022    * Move the selection handles to required positions in text.
1023    *
1024    * @param[in] handleId the handle to position
1025    * @param[in] displacement Displacement of the selection handle in actor coordinates.
1026    *
1027    * @return The new actual position the handle has been set to.
1028    */
1029   Vector3 MoveSelectionHandle(SelectionHandleId handleId, const Vector2& displacement);
1030
1031   /**
1032    * Calculate and position the specified selection handle the given index position
1033    *
1034    * @param[in] handleId the handle to position
1035    */
1036   void SetSelectionHandlePosition(SelectionHandleId handleId);
1037
1038   /**
1039    * Gets a table of the visual text positions which has a flag
1040    * for each Character. The flag is either true (character selected)
1041    * or false (character deselected)
1042    * @note startSelection can be greater or less than endSelection
1043    *
1044    * @param[in,out] selectedVisualText The vector to be resized and populated with the selected flags
1045    * @param[in] startSelection The start selection point for the text
1046    * @param[in] endSelection The end selection point for the text
1047    */
1048   void GetVisualTextSelection(std::vector<bool>& selectedVisualText, std::size_t startSelection, std::size_t endSelection);
1049
1050   /**
1051    *  Iterates between selection handles and computes the info required to build the highlight mesh
1052    */
1053   HighlightInfo CalculateHighlightInfo();
1054
1055   /**
1056    * This method was added to fix a PLM. it creates one quad per character so the mesh can show different selection boxes when a mix of right to left and left to right text is selected.
1057    */
1058   HighlightInfo CalculateHighlightInfoRtl();
1059
1060   /**
1061    * Calculates new Mesh data so highlight moves with selection handles.
1062    */
1063   void UpdateHighlight();
1064
1065   /**
1066    * Removes popup, and its options.
1067    */
1068   void ClearPopup();
1069
1070   /**
1071    * Adds Popup options which have been enabled.
1072    */
1073   void AddPopupOptions();
1074
1075   /**
1076    * Sets popup position
1077    * @param[in] position The actual position for this popup.
1078    * @param[in] alternativePosition Alternative popup position if no space in upper area.
1079    */
1080   void SetPopupPosition(const Vector3& position, const Vector2& alternativePosition );
1081
1082   /**
1083    * Hides the popup
1084    * @param[in] animate (optional) whether to animate popup to hide state over time (i.e. tween).
1085    * @param[in] signalFinished (optional) whether to perform an animation finish operation after the hide animation completes. Requires animate to be true.
1086    */
1087   void HidePopup( bool animate = true, bool signalFinished = true );
1088
1089   /**
1090    * Shows the popup
1091    * @param[in] animate (optional) whether to animate popup to show state over time (i.e. tween).
1092    */
1093   void ShowPopup(bool animate = true);
1094
1095   /**
1096    * Shows the cut-copy-paste popup
1097    */
1098   void ShowPopupCutCopyPaste();
1099
1100   /**
1101    * Setup the selection popup and clipboard if relevant so the correct options are shown when ShowPopup is called.
1102    * @param[in] showCutButton Flag to show or hide cut button, in some cases like whitespace we do not want to cut just select.
1103    * default is true.
1104    */
1105   void SetUpPopupSelection( bool showCutButton = true );
1106
1107   /**
1108    * Return the logical index containing the character position closest to the source.
1109    * Used for positioning the grab handle at characters when dragged along.
1110    * Two different behaviours are needed in case the source point doesn't actually touch a
1111    * character. @see TouchToIndex.
1112    * @param[in] source float to match against
1113    * @param[out] closestIndex index to the vector of character's size and position.
1114    * @return \e true if the source point is actually inside the geometry provided by TextView.
1115    */
1116   bool ReturnClosestIndex(const Vector2& source, std::size_t& closestIndex );
1117
1118   /**
1119    * Returns the X-position of the current line justification
1120    * (relative to left of text-view container)
1121    * @return X position for line justification
1122    */
1123   float GetLineJustificationPosition() const;
1124
1125   /**
1126    * Currently the cursor is positioned at the previous characters position plus it's width.
1127    * If the previous character is on a different line then this function returns the correct position.
1128    * @param[in] characterPosition the character position index that the cursor should be at
1129    * @return position of cursor/handle
1130    */
1131   Vector3 PositionCursorAfterWordWrap( std::size_t characterPosition ) const;
1132
1133
1134   /**
1135    * Return a vector which is the actual position for the given character position
1136    * The character position is where a cursor would be position for that character.
1137    * @param[in] characterPosition the logical (input) position in the 'string' of characters.
1138    *
1139    * @return Vector3 the actual x,y,z position
1140    */
1141   Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition ) const;
1142
1143   /**
1144    * Return a vector which is the actual position for the given character position
1145    * The character position is where a cursor would be positioned for that character to be inserted.
1146    * An additional alternatePosition is also set in circumstances where the possible writing
1147    * of characters would be in the opposite direction.
1148    * e.g. "HelloشقشلاهؤEnglish"
1149    *            |     |
1150    *            *     +
1151    * [*] - Primary actual position for cursor i.e. continuing writing LTR (English)
1152    * [+] - Alternate actual position for cursor i.e. writing RTL (Arabic)
1153    *
1154    * @param[in] characterPosition the logical (input) position in the 'string' of characters.
1155    * @param[out] directionRTL Whether the actual x,y,z position is after LTR (false) or RTL (true) text.
1156    * @param[out] alternatePosition the actual x,y,z position of the cursor if user types
1157    * in alternate direction to current flow of text.
1158    * @param[out] alternatePositionValid whether this alternate position is valid.
1159    * @return Vector3 the actual x,y,z position
1160    */
1161   Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition, bool& directionRTL, Vector3& alternatePosition, bool& alternatePositionValid ) const;
1162
1163   /**
1164    * Retrieve the character position of the first character on the row of text
1165    * that this character resides on.
1166    * @param[in] logicalPosition the position in the 'string' of characters.
1167    * @return logical character position of start of row.
1168    */
1169   std::size_t GetRowStartFromCharacterPosition(std::size_t logicalPosition) const;
1170
1171   /**
1172    * Retrieves the first character of a group of characters with the same direction.
1173    *
1174    * @param[in] logicalPosition Index to a character.
1175    *
1176    * @return Index to the character.
1177    */
1178   std::size_t GetFirstCharacterWithSameDirection( std::size_t logicalPosition ) const;
1179
1180   /**
1181    * Retrieve the dimensions of this row of text that the character resides on.
1182    * @param[in] characterPosition the position in the 'string' of characters.
1183    * @return The size of the rectangle representing this row
1184    */
1185   Size GetRowRectFromCharacterPosition(std::size_t characterPosition) const;
1186
1187   /**
1188    * Retrieve the dimensions (and min-max) of this row of text that the character resides on.
1189    * @param[in] characterPosition the position in the 'string' of characters.
1190    * @param[out] min the top-left position of the rectangle representing this row
1191    * @param[out] max the bottom-right position of the rectangle representing this row
1192    * @return The size of the rectangle representing this row (max - min)
1193    */
1194   Size GetRowRectFromCharacterPosition(std::size_t characterPosition, Vector2& min, Vector2& max) const;
1195
1196   /**
1197    * Checks if the provided touchedActor was this text-input
1198    * @param[in] touchedActor the touched actor that will be checked against this text-input
1199    * @return true if the touchActor was the text-input or one of its children
1200    */
1201   bool WasTouchedCheck( const Actor& touchedActor ) const;
1202
1203   /**
1204    * Connect to the stage touch event
1205    */
1206   void StartMonitoringStageForTouch();
1207
1208   /**
1209    * Disconnect from the stage touch event
1210    */
1211   void EndMonitoringStageForTouch();
1212
1213   /**
1214    * Callback for when the screen is touched, this will be connected when selection starts and disconnected when it ends.
1215    * @param[in] event The touch event
1216    */
1217   void OnStageTouched(const TouchEvent& event);
1218
1219
1220   /**
1221    * Select the text between the given values
1222    * @param[in] start position within array to start selection
1223    * @param[in] end position within array to end selection
1224    */
1225   void SelectText(std::size_t start, std::size_t end);
1226
1227   /**
1228    * Gets selected text and returns it as a StyleText vector
1229    * @return StyledText vector that is selected.
1230    */
1231   MarkupProcessor::StyledTextArray GetSelectedText();
1232
1233   /**
1234    * Applies the given style to all text, selected or not selected.
1235    * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
1236    */
1237   void ApplyStyleToRange(const TextStyle& style, const TextStyle::Mask mask, const std::size_t begin, const std::size_t end);
1238
1239   /**
1240    * Callback for when the keyboard status changes
1241    * @param[in]  keyboardShown  Whether the keyboard has just been shown or not.
1242    */
1243   void KeyboardStatusChanged(bool keyboardShown);
1244
1245   /**
1246    * Hide highlight shown between selection handles.
1247    * @param[in] hidePopup flag to hide the popup too, default is to hide popup.
1248    */
1249   void RemoveHighlight( bool hidePopup = true );
1250
1251   /**
1252    * Highlights text that has been selected
1253    */
1254   void CreateHighlight();
1255
1256   /**
1257    * Copies selected text to clipboard
1258    * @return bool true if copy was successful.
1259    */
1260   bool CopySelectedTextToClipboard();
1261
1262   /**
1263    * Pastes the given text to currently displayed string at the current cursor position
1264    * @param[in] text Text to be pasted
1265    */
1266   void PasteText( const Text& text );
1267
1268   /**
1269    * Sets the direction of the text if it is empty.
1270    */
1271   void SetTextDirection();
1272
1273   /**
1274    * Updates the line height accordingly with the current text input style.
1275    */
1276   void UpdateLineHeight();
1277
1278   /**
1279    * Finds a visible character.
1280    *
1281    * The \e direction parameters specifies from where to start to look for a visible character. \e Left means start by characters in lower
1282    * positions than \e cursorPosition, \e Right means start by characters in greater positions than \e cursorPosition and \e ByEnd starts
1283    * by the last characters.
1284    *
1285    * If \e Left or \e Right is provided and any character is found, then looks in the other direction.
1286    *
1287    * @param[in] direction Direction used to find a visible character.
1288    * @param[in] cursorPosition Starting position.
1289    *
1290    * @return The found visible character.
1291    */
1292   std::size_t FindVisibleCharacter( const FindVisibleCharacterDirection direction , const std::size_t cursorPosition ) const;
1293
1294   /**
1295    * @copydoc SetSortModifier()
1296    */
1297   void SetSortModifier( float depthOffset );
1298
1299   /**
1300    * @copydoc SetSnapshotModeEnabled()
1301    */
1302   void SetSnapshotModeEnabled( bool enable );
1303
1304   /**
1305    * @copydoc IsSnapshotModeEnabled()
1306    */
1307   bool IsSnapshotModeEnabled() const;
1308
1309   /**
1310    * @copydoc SetScrollEnabled()
1311    */
1312   void SetScrollEnabled( bool enable );
1313
1314   /**
1315    * @copydoc IsScrollEnabled()
1316    */
1317   bool IsScrollEnabled() const;
1318
1319   /**
1320    * @copydoc SetScrollPosition()
1321    */
1322   void SetScrollPosition( const Vector2& position );
1323
1324   /**
1325    * @copydoc GetScrollPosition()
1326    */
1327   Vector2 GetScrollPosition() const;
1328
1329   /**
1330    * @brief Sets whether markup processing should be carried out.
1331    *
1332    * @param[in] enable whether markup processing is carried out or not.
1333    */
1334   void SetMarkupProcessingEnabled( bool enable );
1335
1336   /**
1337    * @brief Returns whether markup processing is enabled or not
1338    *
1339    * @return true is markup processing is enabled
1340    */
1341   bool IsMarkupProcessingEnabled() const;
1342
1343   /**
1344    * Insert or replaces the given text in the given position. It checks if the text exceeds the maximum allowed number of characters
1345    * and if it fits in the text-input's boundaries.
1346    *
1347    * @param[in] text Text to be inserted.
1348    * @param[in] position Position where the text is inserted.
1349    * @param[in] numberOfCharactersToReplace The number of characters to replace.
1350    * @param[out] textExceedsMaximunNumberOfCharacters The number of characters that have been inserted.
1351    * @param[out] textExceedsBoundary Whether the inserted text has exceeded the boundaries of the text-input.
1352    *
1353    * @return The number of characters that have been inserted.
1354    */
1355   std::size_t DoInsertAt( const Text& text, std::size_t position, std::size_t numberOfCharactersToReplace, bool& textExceedsMaximunNumberOfCharacters, bool& textExceedsBoundary );
1356
1357   /**
1358    *  Retrieve Text-view's layout info.
1359    */
1360   void GetTextLayoutInfo();
1361
1362   /**
1363    * Set the offset for positioning Popup from the TextInput
1364    * @param[in] offset in the order, left, top, right, bottom
1365    */
1366   void SetOffsetFromText( const Vector4& offset );
1367
1368   /**
1369    * Get the offset of the Popup from the TextInput
1370    * @return Vector4 with the offset in the order, left, top, right, bottom
1371    */
1372   const Vector4& GetOffsetFromText() const;
1373
1374   /**
1375    * Show the Placeholder text with an already created StyleTextArray
1376    * @param[in] stylePlaceHolderText Required placeholder text to be used
1377    */
1378   void ShowPlaceholderText( const MarkupProcessor::StyledTextArray& stylePlaceHolderText );
1379
1380   // Properties
1381
1382   /**
1383    * Called when a property of an object of this type is set.
1384    * @param[in] object The object whose property is set.
1385    * @param[in] index The property index.
1386    * @param[in] value The new property value.
1387    */
1388   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
1389
1390   /**
1391    * Called to retrieve a property of an object of this type.
1392    * @param[in] object The object whose property is to be retrieved.
1393    * @param[in] index The property index.
1394    * @return The current value of the property.
1395    */
1396   static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
1397
1398   /**
1399    * Emits the style changed signal.
1400    */
1401   void EmitStyleChangedSignal();
1402
1403   /**
1404    * Emit signal when text is modified.
1405    */
1406   void EmitTextModified();
1407
1408   /**
1409    * Emits max input characters reached signal.
1410    */
1411   void EmitMaxInputCharactersReachedSignal();
1412
1413   /**
1414    * Emits a signal when the input text exceeds the boundaries of the text-input.
1415    */
1416   void EmitInputTextExceedsBoundariesSignal();
1417
1418 private:
1419
1420   State mState;                                 ///< Current State of Text input.
1421   MarkupProcessor::StyledTextArray mStyledText; ///< String currently displayed by TextView with style info.
1422   TextStyle mInputStyle;                        ///< Stores the current input style.
1423   float     mLineHeight;                        ///< Stores the current line height accordingly with the input style.
1424   Toolkit::TextView mDisplayedTextView;         ///< Actor which actually display text
1425
1426   MarkupProcessor::StyledTextArray mStyledPlaceHolderText; ///< Text used as place holder with style info.
1427
1428   std::size_t mMaxStringLength;                 ///< Max number of characters for string
1429   std::size_t mNumberOflinesLimit;              ///< Limit on the number of lines this TextInput will display.
1430
1431   ImageActor mCursor;                           ///< Cursor overlayed on Text to show where new text will be inserted
1432   ImageActor mCursorRTL;                        ///< Right To Left Cursor overlayed on Text (where new RTL text would be inserted)
1433   Animation mCursorAnimation;                   ///< animator for cursor blinking.
1434   std::size_t mCursorPosition;                  ///< position along string cursor is at.
1435   Timer mCursorBlinkTimer;                      ///< Timer to signal cursor to blink
1436
1437   Layer mActiveLayer;                           ///< Layer for active handles and alike that ensures they are above all else.
1438
1439   Image mGrabHandleImage;                       ///< image to be used for grab handle
1440   ImageActor mGrabHandle;                       ///< Handle used to move cursor for editing
1441
1442   Actor mGrabArea;                              ///< invisible actor that receives pans events for the grab handle.
1443   PanGestureDetector  mPanGestureDetector;      ///< Pan gesture for handles
1444   TapGestureDetector mTapDetector;              ///< used to start editing
1445   TapGestureDetector mDoubleTapDetector;        ///< double tap detector
1446
1447   Vector3 mActualGrabHandlePosition;            ///< actual position of grab handle, this might not be snapped to a character
1448
1449   LongPressGestureDetector mLongPressDetector;  ///< Gesture to start selection
1450
1451   /*Selection handles*/
1452   Image mSelectionHandleOneImage;               ///< image used for selection handle one
1453   Image mSelectionHandleOneImagePressed;        ///< image used for selection handle one pressed state
1454   Image mSelectionHandleTwoImage;               ///< image used for selection handle two
1455   Image mSelectionHandleTwoImagePressed;        ///< image used for selection handle two pressed state
1456
1457   bool mIsSelectionHandleOneFlipped:1;          ///< Flag to know whether the handle one is flipped or not.
1458   bool mIsSelectionHandleTwoFlipped:1;          ///< Flag to know whether the handle two is flipped or not.
1459   Vector3 mSelectionHandleOneOffset;            ///< Handle One's Offset
1460   Vector3 mSelectionHandleTwoOffset;            ///< Handle Two's Offset
1461   Vector3 mSelectionHandleOneActualPosition;    ///< Actual x y position of handle
1462   Vector3 mSelectionHandleTwoActualPosition;    ///< Actual x y position of handle
1463   std::size_t mSelectionHandleOnePosition;      ///< Position of handle along the string of text
1464   std::size_t mSelectionHandleTwoPosition;      ///< Position of handle along the string of text
1465   ImageActor mSelectionHandleOne;               ///< First selection handle used for selecting text to cut&paste
1466   ImageActor mSelectionHandleTwo;               ///< Second selection handle used for selecting text to cut&paste
1467   Actor mHandleOneGrabArea;                     ///< invisible actor that receives pans events for the selection handle.
1468   Actor mHandleTwoGrabArea;                     ///< invisible actor that receives pans events for the selection handle.
1469
1470   HighlightInfo     mNewHighlightInfo;          ///< Geometry info to create highlight.
1471
1472   Text mPreEditString;                          ///< Holds current input string prior to it being committed.
1473   std::size_t mPreEditStartPosition;            ///< Cursor position for start of pre-edit string
1474   std::size_t mPreEditLength;                   ///< Cursor position for length of current pre-edit string after purging characters that do not fit.
1475   std::size_t mNumberOfSurroundingCharactersDeleted; ///< Stores the number of surrounding characters deleted.
1476   unsigned long mTouchStartTime;                ///< Touch Start time (time in ms when down press began)
1477
1478   Toolkit::TextView::TextLayoutInfo                                 mTextLayoutInfo; ///< It contains a table layout info per character sorted by the character's visual index (retrieved from TextView),
1479                                                                                      ///< a reorder map that stores each character's visual (output) index according to its logical (input) index,
1480                                                                                      ///< a reorder map that stores each character's logical (input) index according to its visual (output) index,
1481                                                                                      ///< the text size after layout and the scroll offset.
1482
1483   MarkupProcessor::StyledTextArray mCurrentCopySelecton;                                              ///< Array to store copied text.
1484   TextInputPopup mPopupPanel;                                                                         ///< Panel to house cut and paste, select all buttons.
1485
1486   Timer mScrollTimer;
1487   Vector2 mScrollDisplacement;
1488   Vector3 mCurrentHandlePosition;
1489   SelectionHandleId mCurrentSelectionId;
1490   Vector3 mCurrentSelectionHandlePosition;
1491   SelectionParameters mRequestedSelection;
1492   Vector4 mSelectionHandleFlipMargin;
1493   Vector4 mBoundingRectangleWorldCoordinates;
1494
1495   Clipboard mClipboard;                   ///< Handle to clipboard
1496
1497   // Styling
1498   Vector4           mMaterialColor;       // Color of the highlight
1499   Vector4           mPopupOffsetFromText; // Offset of Popup from the TextInput.
1500
1501   bool mOverrideAutomaticAlignment:1;    ///< Whether to override the alignment automatically set by the text content (e.g. european LTR or arabic RTL)
1502   bool mCursorRTLEnabled:1;              ///< Enable state of Alternate RTL Cursor (need to keep track of this as it's not always enabled)
1503   bool mClosestCursorPositionEOL:1;      ///< closest cursor position is end of line.
1504   bool mCursorBlinkStatus:1;             ///< \e true shows the cursor, \e false hiddes it.
1505
1506   bool mCursorVisibility:1;              ///< Visibility status of Cursor
1507   bool mGrabHandleVisibility:1;          ///< Visibility status of the grab handle.
1508
1509   bool mIsCursorInScrollArea:1;          ///< Whether the cursor is inside the boundaries of the text-input.
1510   bool mIsGrabHandleInScrollArea:1;      ///< Whether the grab handle is inside the boundaries of the text-input.
1511
1512   bool mEditModeActive:1;                ///< true to indicate TextInput is in edit mode.
1513   bool mEditOnTouch:1;                   ///< true indicates edit mode starts by touching/tapping the TextInput
1514   bool mTextSelection:1;                 ///< true indicates text selection is enabled.
1515   bool mExceedEnabled:1;                 ///< Whether text-input editing text beyond its boundary is enabled or not. By default is enabled.
1516   bool mGrabHandleEnabled:1;             ///< Flag to enable the grab handle instead of the default magnifier.
1517   bool mIsSelectionHandleFlipEnabled:1;  ///< Flag to enable the selection handle flip
1518
1519   bool mPreEditFlag:1;                   ///< Flag to indicate if key string received is still in pre-edit mode (Ecore IMF keyboard)
1520   bool mIgnoreCommitFlag:1;              ///< Flag to indicate if the commit string should be ignored, maybe due to a keyboard reset.
1521   bool mIgnoreFirstCommitFlag:1;         ///< Whether to ignore the first commit.
1522   bool mSelectingText:1;                 ///< Ignore surrounding text as selecting text
1523
1524   bool mPreserveCursorPosition:1;        ///< Indicates that the commit message is from a reset and does not require the cursor to be moved
1525
1526   bool mSelectTextOnCommit:1;
1527
1528   bool mUnderlinedPriorToPreEdit:1;      ///< As predictive text adds underline style this flag enables us to revert back or keep underline.
1529
1530   bool mCommitByKeyInput:1;              ///< Set if a commit is done by key input rather than automatically (usually when a space bar or enter is pressed).
1531
1532   bool mPlaceHolderSet:1;                ///< Whether the place holder text is set.
1533   bool mMarkUpEnabled:1;                 ///< enable to scan for mark-up
1534
1535   Toolkit::TextInput::InputSignalType                      mInputStartedSignal;              ///< Signal emitted when input starts
1536   Toolkit::TextInput::InputSignalType                      mInputFinishedSignal;             ///< Signal emitted when input ends
1537   Toolkit::TextInput::StyleChangedSignalType               mStyleChangedSignal;              ///< Signal emitted when style changes.
1538   Toolkit::TextInput::TextModifiedSignalType             mTextModifiedSignal;                ///< Signal emitted when text modified.
1539   Toolkit::TextInput::MaxInputCharactersReachedSignalType  mMaxInputCharactersReachedSignal; ///< Signal emitted when max input characters is reached.
1540   Toolkit::TextInput::InputSignalType                      mCutAndPasteToolBarDisplayed;       ///< Signal emitted when toolbar displayed
1541   Toolkit::TextInput::InputTextExceedBoundariesSignalType  mInputTextExceedBoundariesSignal; ///< Signal emitted when input text exceeds the boundaries of the text-input.
1542 };
1543
1544 } // namespace Internal
1545
1546 // Helpers for public-api forwarding methods
1547
1548 inline Toolkit::Internal::TextInput& GetImpl(Toolkit::TextInput& textInput)
1549 {
1550   DALI_ASSERT_ALWAYS(textInput);
1551
1552   Dali::RefObject& handle = textInput.GetImplementation();
1553
1554   return static_cast<Toolkit::Internal::TextInput&>(handle);
1555 }
1556
1557 inline const Toolkit::Internal::TextInput& GetImpl(const Toolkit::TextInput& textInput)
1558 {
1559   DALI_ASSERT_ALWAYS(textInput);
1560
1561   const Dali::RefObject& handle = textInput.GetImplementation();
1562
1563   return static_cast<const Toolkit::Internal::TextInput&>(handle);
1564 }
1565
1566 } // namespace Toolkit
1567
1568 } // namespace Dali
1569
1570 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_H__