/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #pragma once #include "Gesture.hpp" #include "TouchInfo.hpp" #include "GestureInfos.hpp" #include "Base/Event.hpp" namespace OpenVulkano::Input { class GesturePinch final : public Gesture { PinchInfo m_pinchInfo; std::vector m_pendingTouches; float m_initialDistance = 0, m_lastDistance; bool m_paused = false; void TryStart(); static float LinearLength(std::vector const &points) ; float CalculateDistance() const; Math::Vector2f CalculateCenter() const; public: GesturePinch() : Gesture(TYPE_PINCH) {} void Cancel() override; void Reset() override { if (IsActive()) Cancel(); m_pendingTouches.clear(); m_initialDistance = 0; } void TouchDown(const Touch& touch) override; void TouchUp(const Touch& touch) override; void TouchMoved(const Touch& touch) override; Event OnPinchStarted, OnPinchMoved, OnPinchEnded; }; }