36864661d374068e2da7a786e56aa36475696b35
[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   typedef SignalV2< bool () > HandlesReleasedSignal;
42
43   /**
44    * Signal emitted when a handle is released
45    */
46   HandlesReleasedSignal& ReleasedSignal(){ return mReleasedSignal; };
47
48   /**
49    * Default constructor
50    */
51   TextInputHandles() {}
52
53   /**
54    * Destructor
55    */
56   ~TextInputHandles() {};
57
58   /**
59    * Create the selection handles
60    */
61   void CreateSelectionHandles(){};
62
63   /**
64    * Un-parents the Selection Handles and resets their Image Actors
65    */
66   void DestorySelectionHandles(){};
67
68   /**
69    * Set the Actor visibility on Selection Handle One
70    * @param[in] visibility visibility flag
71    */
72   void SetSelectionHandleOneVisibility( bool visibility ){};
73
74   /**
75    * Set the Actor visibility on Selection Handle Two
76    * @param[in] visibility visibility flag
77    */
78   void SetSelectionHandleTwoVisibility( bool visibility ){};
79
80   /**
81    * Attach the two selection handles to the pan gesture detector
82    * @param[in] panGestureDetector the PanGestureDetector to attach to
83    */
84   void AttachSelectionHandlesToGivenPanGesture(PanGestureDetector& panGestureDetector ){};
85
86   /**
87    * Attach the two selection handles to the tap gesture detector
88    * @param[in] tapGestureDetector the TapGestureDetector to attach to
89    */
90   void AttachSelectionHandlesToGivenTapDetector(TapGestureDetector& tapGestureDetector ){};
91
92   /**
93    * Attach the grab handle to the pan gesture detector
94    * @param[in] panGestureDetector the PanGestureDetector to attach to
95    */
96   void AttachGrabHandleToGivenPanGesture( PanGestureDetector& panGestureDetector ){};
97
98   /**
99    * Get Selection handle one
100    * @return selection handle actor
101    */
102   Actor GetSelectionHandleOne() { return Actor(); };
103
104   /**
105    * Get Selection handle two
106    * @return selection handle actor
107    */
108   Actor GetSelectionHandleTwo() { return Actor(); };
109
110   /**
111    * Get the grab handle
112    * @return grab handle Actor
113    */
114   Actor GetGrabHandle()  { return Actor(); };
115
116   /**
117    * Create the grab handle that positions the cursor
118    * @param[in] image the image to be used.
119    */
120   void CreateGrabHandle(){};
121
122   /**
123    * Removes and Resets GrabHandle
124    */
125   void DestoryGrabHandle(){};
126
127   /**
128    * Set the image to be used as the cursor grab hander
129    * @pre The text input actor has been initialised.
130    * @param[in] image The image to be used.
131    */
132   void SetGrabHandleImage( Dali::Image image ){};
133
134   /**
135    * Set the Actor visibility on the GrabHandle
136    * @param[in] visibility visibility flag
137    */
138   void SetGrabHandleVisibility( bool visibility ){};
139
140   /* Touch Event Callbacks */
141
142   /**
143    * Callback on selection handle touched.
144    * Sets the image depending if handle in pressed or normal state
145    * @param[in] actor touched
146    * @param[in] touch touch event, used to determine if down or up event
147    */
148   bool OnSelectionHandleTouched(Dali::Actor actor, const TouchEvent& touch){ return true; };
149
150 private:
151
152   /**
153    * @brief Copy Constructor
154    * @param[in] handles
155    * Undefined/Hidden.
156    */
157   TextInputHandles(const TextInputHandles& handles);
158
159   /**
160    * @Assignment Constructor
161    * @param[in] rhs
162    * Undefined/Hidden.
163    */
164   TextInputHandles& operator=(const TextInputHandles& rhs);
165
166 private:
167
168   ImageActor mSelectionHandleOne;                 // First selection handle used for selecting text to cut&paste
169   ImageActor mSelectionHandleTwo;                 // Second selection handle used for selecting text to cut&paste
170   Actor mHandleOneGrabArea;                       // Invisible actor that receives pans events for the selection handle.
171   Actor mHandleTwoGrabArea;                       // Invisible actor that receives pans events for the selection handle.
172
173   Image mSelectionHandleOneImage;                 // image used for selection handle one
174   Image mSelectionHandleOneImagePressed;          // image used for selection handle one pressed state
175   Image mSelectionHandleTwoImage;                 // image used for selection handle two
176   Image mSelectionHandleTwoImagePressed;          // image used for selection handle two pressed state
177
178   Vector3 mSelectionHandleOneOffset;              // Handle One's Offset
179   Vector3 mSelectionHandleTwoOffset;              // Handle Two's Offset
180   Vector3 mSelectionHandleOneCoordinatePosition;  // Actual x y z position of handle
181   Vector3 mSelectionHandleTwoCoordinatePosition;  // Actual x y z position of handle
182   std::size_t mSelectionHandleOneStringPosition;  // Position of handle along the string of text
183   std::size_t mSelectionHandleTwoStringPosition;  // Position of handle along the string of text
184
185   Image mGrabHandleImage;                         // Image to be used for grab handle
186   ImageActor mGrabHandle;                         // Handle used to move cursor for editing
187   Actor mGrabHandleGrabArea;                      // invisible actor that receives pans events for the grab handle.
188
189   HandlesReleasedSignal mReleasedSignal;          // Signal emitted when a handle is released
190
191   bool mIsSelectionHandleOneFlipped:1;            // Flag to know whether the handle one is flipped or not.
192   bool mIsSelectionHandleTwoFlipped:1;            // Flag to know whether the handle two is flipped or not.
193 };
194
195
196 } // namespace Internal
197
198
199 } // namespace Toolkit
200
201 } // namespace Dali
202
203 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_HANDLES_H__