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