47 lines
1.0 KiB
C++
47 lines
1.0 KiB
C++
/*
|
|
* 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 GesturePan final : public Gesture
|
|
{
|
|
PanInfo m_panInfo;
|
|
std::vector<TouchInfo> m_pendingTouches;
|
|
uint32_t m_requiredTouchInputs;
|
|
bool m_paused = false;
|
|
|
|
void TryStart(const Touch& touch);
|
|
|
|
Math::Vector2f CalculatePosition() const;
|
|
|
|
public:
|
|
GesturePan(uint32_t requiredTouchInputs)
|
|
: Gesture(TYPE_PAN), m_requiredTouchInputs(requiredTouchInputs)
|
|
{}
|
|
|
|
void Cancel() override;
|
|
|
|
void Reset() override
|
|
{
|
|
if (IsActive()) Cancel();
|
|
m_pendingTouches.clear();
|
|
}
|
|
|
|
void TouchDown(const Touch& touch) override;
|
|
void TouchUp(const Touch& touch) override;
|
|
void TouchMoved(const Touch& touch) override;
|
|
|
|
Event<GesturePan*, PanInfo&> OnPanStarted, OnPanMoved, OnPanEnded;
|
|
};
|
|
} |