1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_HANDLES_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_HANDLES_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/actors/image-actor.h>
23 #include <dali/public-api/events/pan-gesture-detector.h>
24 #include <dali/public-api/events/tap-gesture-detector.h>
25 #include <dali/public-api/events/touch-event.h>
26 #include <dali/public-api/images/image.h>
27 #include <dali/public-api/signals/connection-tracker.h>
38 * Class to create handles and alter their visualisation.
39 * Not responsible for positioning.
42 class TextInputHandles : public ConnectionTracker
58 * Create the selection handles
60 void CreateSelectionHandles();
63 * Un-parents the Selection Handles and resets their Image Actors
65 void DestorySelectionHandles();
68 * Set the Actor visibility on Selection Handle One
69 * @param[in] visibility visibility flag
71 void SetSelectionHandleOneVisibility( bool visibility );
74 * Set the Actor visibility on Selection Handle Two
75 * @param[in] visibility visibility flag
77 void SetSelectionHandleTwoVisibility( bool visibility );
80 * Attach the two selection handles to the pan gesture detector
81 * @param[in] panGestureDetector the PanGestureDetector to attach to
83 void AttachSelectionHandlesToGivenPanGesture(PanGestureDetector& panGestureDetector );
86 * Attach the two selection handles to the tap gesture detector
87 * @param[in] tapGestureDetector the TapGestureDetector to attach to
89 void AttachSelectionHandlesToGivenTapDetector(TapGestureDetector& tapGestureDetector );
92 * Attach the grab handle to the pan gesture detector
93 * @param[in] panGestureDetector the PanGestureDetector to attach to
95 void AttachGrabHandleToGivenPanGesture( PanGestureDetector& panGestureDetector );
98 * Get Selection handle one
99 * @return selection handle actor
101 Actor GetSelectionHandleOne();
104 * Get Selection handle two
105 * @return selection handle actor
107 Actor GetSelectionHandleTwo();
110 * Get the grab handle
111 * @return grab handle Actor
113 Actor GetGrabHandle();
116 * Create the grab handle that positions the cursor
117 * @param[in] image the image to be used.
119 void CreateGrabHandle();
122 * Removes and Resets GrabHandle
124 void DestoryGrabHandle();
127 * Set the image to be used as the cursor grab hander
128 * @pre The text input actor has been initialised.
129 * @param[in] image The image to be used.
131 void SetGrabHandleImage( Dali::Image image );
134 * Set the Actor visibility on the GrabHandle
135 * @param[in] visibility visibility flag
137 void SetGrabHandleVisibility( bool visibility );
139 /* Touch Event Callbacks */
142 * Callback on selection handle touched.
143 * Sets the image depending if handle in pressed or normal state
144 * @param[in] actor touched
145 * @param[in] touch touch event, used to determine if down or up event
147 bool OnSelectionHandleTouched(Dali::Actor actor, const TouchEvent& touch);
152 * @brief Copy Constructor
156 TextInputHandles(const TextInputHandles& handles);
159 * @Assignment Constructor
163 TextInputHandles& operator=(const TextInputHandles& rhs);
167 ImageActor mSelectionHandleOne; // First selection handle used for selecting text to cut&paste
168 ImageActor mSelectionHandleTwo; // Second selection handle used for selecting text to cut&paste
169 Actor mHandleOneGrabArea; // Invisible actor that receives pans events for the selection handle.
170 Actor mHandleTwoGrabArea; // Invisible actor that receives pans events for the selection handle.
172 Image mSelectionHandleOneImage; // image used for selection handle one
173 Image mSelectionHandleOneImagePressed; // image used for selection handle one pressed state
174 Image mSelectionHandleTwoImage; // image used for selection handle two
175 Image mSelectionHandleTwoImagePressed; // image used for selection handle two pressed state
177 Vector3 mSelectionHandleOneOffset; // Handle One's Offset
178 Vector3 mSelectionHandleTwoOffset; // Handle Two's Offset
179 Vector3 mSelectionHandleOneCoordinatePosition; // Actual x y z position of handle
180 Vector3 mSelectionHandleTwoCoordinatePosition; // Actual x y z position of handle
181 std::size_t mSelectionHandleOneStringPosition; // Position of handle along the string of text
182 std::size_t mSelectionHandleTwoStringPosition; // Position of handle along the string of text
184 Image mGrabHandleImage; // Image to be used for grab handle
185 ImageActor mGrabHandle; // Handle used to move cursor for editing
186 Actor mGrabHandleGrabArea; // invisible actor that receives pans events for the grab handle.
188 bool mIsSelectionHandleOneFlipped:1; // Flag to know whether the handle one is flipped or not.
189 bool mIsSelectionHandleTwoFlipped:1; // Flag to know whether the handle two is flipped or not.
193 } // namespace Internal
196 } // namespace Toolkit
200 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_HANDLES_H__