1 #ifndef DALI_INTERNAL_PINCH_GESTURE_EVENT_PROCESSOR_H
2 #define DALI_INTERNAL_PINCH_GESTURE_EVENT_PROCESSOR_H
5 * Copyright (c) 2019 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/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.h>
23 #include <dali/internal/event/events/gesture-processor.h>
24 #include <dali/internal/event/render-tasks/render-task-impl.h>
35 struct PinchGestureEvent;
38 * Pinch Gesture Event Processing:
40 * When we receive a pinch gesture event, we do the following:
41 * - Find the hit actor that requires a pinch underneath the center-point of the pinch.
42 * - Emit the gesture if the event satisfies the detector conditions.
44 * The above is only checked when our gesture starts. We continue sending the pinch gesture to this
45 * detector until the pinch ends or is cancelled.
47 class PinchGestureProcessor : public GestureProcessor, public RecognizerObserver<PinchGestureEvent>
52 * Create a pinch gesture processor.
54 PinchGestureProcessor();
57 * Non-virtual destructor; PinchGestureProcessor is not a base class
59 ~PinchGestureProcessor() override;
61 public: // To be called by GestureEventProcessor
64 * This method sets the minimum distance to start a pinch
65 * @param[in] value The distance in pixels
67 void SetMinimumPinchDistance( float value );
70 * Sets the minimum touch events required before a pinch can be started
71 * @param[in] value The number of touch events
73 void SetMinimumTouchEvents( uint32_t value );
76 * Sets the minimum touch events required after a pinch started
77 * @param[in] value The number of touch events
79 void SetMinimumTouchEventsAfterStart( uint32_t value );
82 * This method is called whenever a pinch gesture event occurs.
83 * @param[in] scene The scene the pinch gesture event occurs in.
84 * @param[in] pinchEvent The event that has occurred.
86 void Process( Scene& scene, const PinchGestureEvent& pinchEvent ) override;
89 * Adds a gesture detector to this gesture processor.
90 * If this is the first gesture detector being added, then this method registers the required
91 * gesture with the adaptor.
92 * @param[in] gestureDetector The gesture detector being added.
94 void AddGestureDetector(PinchGestureDetector* gestureDetector, Scene& scene);
97 * Removes the specified gesture detector from this gesture processor. If, after removing this
98 * gesture detector, there are no more gesture detectors registered, then this method unregisters
99 * the gesture from the adaptor.
100 * @param[in] gestureDetector The gesture detector being removed.
102 void RemoveGestureDetector(PinchGestureDetector* gestureDetector);
105 * This method updates the gesture detection parameters.
106 * @param[in] gestureDetector The gesture detector that has been updated.
108 void GestureDetectorUpdated(PinchGestureDetector* gestureDetector);
113 PinchGestureProcessor(const PinchGestureProcessor&);
114 PinchGestureProcessor& operator=(const PinchGestureProcessor& rhs);
118 // GestureProcessor overrides
121 * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
123 void OnGesturedActorStageDisconnection() override;
126 * @copydoc GestureProcessor::CheckGestureDetector()
128 bool CheckGestureDetector( GestureDetector* detector, Actor* actor ) override;
131 * @copydoc GestureProcessor::EmitGestureSignal()
133 void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) override;
137 PinchGestureDetectorContainer mPinchGestureDetectors;
138 GestureDetectorContainer mCurrentPinchEmitters;
139 RenderTaskPtr mCurrentRenderTask;
141 const PinchGestureEvent* mCurrentPinchEvent; ///< Pointer to current PinchEvent, used when calling ProcessAndEmit()
143 float mMinimumPinchDistance;
144 uint32_t mMinimumTouchEvents;
145 uint32_t mMinimumTouchEventsAfterStart;
148 } // namespace Internal
152 #endif // DALI_INTERNAL_PINCH_GESTURE_EVENT_PROCESSOR_H