TextInput Adding new Handles class and matching API in Decorator
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-input / text-input-handles-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_HANDLES_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_HANDLES_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/dali.h>
22
23 namespace Dali
24 {
25
26 namespace Toolkit
27 {
28
29 namespace Internal
30 {
31 /**
32  * Class to create handles and alter their visualisation.
33  * Not responsible for positioning.
34  */
35
36 class TextInputHandles : public ConnectionTracker
37 {
38
39 public:
40
41   /**
42    * Default constructor
43    */
44   TextInputHandles();
45
46   /**
47    * Destructor
48    */
49   ~TextInputHandles();
50
51   /**
52    * Create the selection handles
53    */
54   void CreateSelectionHandles();
55
56   /**
57    * Un-parents the Selection Handles and resets their Image Actors
58    */
59   void DestorySelectionHandles();
60
61   /**
62    * Set the Actor visibility on Selection Handle One
63    * @param[in] visibility visibility flag
64    */
65   void SetSelectionHandleOneVisibility( bool visibility );
66
67   /**
68    * Set the Actor visibility on Selection Handle Two
69    * @param[in] visibility visibility flag
70    */
71   void SetSelectionHandleTwoVisibility( bool visibility );
72
73   /**
74    * Attach the two selection handles to the pan gesture detector
75    * @param[in] panGestureDetector the PanGestureDetector to attach to
76    */
77   void AttachSelectionHandlesToGivenPanGesture(PanGestureDetector& panGestureDetector );
78
79   /**
80    * Attach the two selection handles to the tap gesture detector
81    * @param[in] tapGestureDetector the TapGestureDetector to attach to
82    */
83   void AttachSelectionHandlesToGivenTapDetector(TapGestureDetector& tapGestureDetector );
84
85   /**
86    * Attach the grab handle to the pan gesture detector
87    * @param[in] panGestureDetector the PanGestureDetector to attach to
88    */
89   void AttachGrabHandleToGivenPanGesture( PanGestureDetector& panGestureDetector );
90
91   /**
92    * Get Selection handle one
93    * @return selection handle actor
94    */
95   Actor GetSelectionHandleOne();
96
97   /**
98    * Get Selection handle two
99    * @return selection handle actor
100    */
101   Actor GetSelectionHandleTwo();
102
103   /**
104    * Get the grab handle
105    * @return grab handle Actor
106    */
107   Actor GetGrabHandle();
108
109   /**
110    * Create the grab handle that positions the cursor
111    * @param[in] image the image to be used.
112    */
113   void CreateGrabHandle();
114
115   /**
116    * Removes and Resets GrabHandle
117    */
118   void DestoryGrabHandle();
119
120   /**
121    * Set the image to be used as the cursor grab hander
122    * @pre The text input actor has been initialised.
123    * @param[in] image The image to be used.
124    */
125   void SetGrabHandleImage( Dali::Image image );
126
127   /**
128    * Set the Actor visibility on the GrabHandle
129    * @param[in] visibility visibility flag
130    */
131   void SetGrabHandleVisibility( bool visibility );
132
133   /* Touch Event Callbacks */
134
135   /**
136    * Callback on selection handle touched.
137    * Sets the image depending if handle in pressed or normal state
138    * @param[in] actor touched
139    * @param[in] touch touch event, used to determine if down or up event
140    */
141   bool OnSelectionHandleTouched(Dali::Actor actor, const TouchEvent& touch);
142
143 private:
144
145   /**
146    * @brief Copy Constructor
147    * @param[in] handles
148    * Undefined/Hidden.
149    */
150   TextInputHandles(const TextInputHandles& handles);
151
152   /**
153    * @Assignment Constructor
154    * @param[in] rhs
155    * Undefined/Hidden.
156    */
157   TextInputHandles& operator=(const TextInputHandles& rhs);
158
159 private:
160
161   ImageActor mSelectionHandleOne;                 // First selection handle used for selecting text to cut&paste
162   ImageActor mSelectionHandleTwo;                 // Second selection handle used for selecting text to cut&paste
163   Actor mHandleOneGrabArea;                       // Invisible actor that receives pans events for the selection handle.
164   Actor mHandleTwoGrabArea;                       // Invisible actor that receives pans events for the selection handle.
165
166   Image mSelectionHandleOneImage;                 // image used for selection handle one
167   Image mSelectionHandleOneImagePressed;          // image used for selection handle one pressed state
168   Image mSelectionHandleTwoImage;                 // image used for selection handle two
169   Image mSelectionHandleTwoImagePressed;          // image used for selection handle two pressed state
170
171   Vector3 mSelectionHandleOneOffset;              // Handle One's Offset
172   Vector3 mSelectionHandleTwoOffset;              // Handle Two's Offset
173   Vector3 mSelectionHandleOneCoordinatePosition;  // Actual x y z position of handle
174   Vector3 mSelectionHandleTwoCoordinatePosition;  // Actual x y z position of handle
175   std::size_t mSelectionHandleOneStringPosition;  // Position of handle along the string of text
176   std::size_t mSelectionHandleTwoStringPosition;  // Position of handle along the string of text
177
178   Image mGrabHandleImage;                         // Image to be used for grab handle
179   ImageActor mGrabHandle;                         // Handle used to move cursor for editing
180   Actor mGrabHandleGrabArea;                      // invisible actor that receives pans events for the grab handle.
181
182   bool mIsSelectionHandleOneFlipped:1;            // Flag to know whether the handle one is flipped or not.
183   bool mIsSelectionHandleTwoFlipped:1;            // Flag to know whether the handle two is flipped or not.
184 };
185
186
187 } // namespace Internal
188
189
190 } // namespace Toolkit
191
192 } // namespace Dali
193
194 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_HANDLES_H__