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