Files
OpenVulkano/openVulkanoCpp/Input/Touch/GestureProcessor.hpp
2023-10-15 13:39:22 +02:00

63 lines
1.4 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 "GesturePan.hpp"
#include "GesturePinch.hpp"
#include "GestureTap.hpp"
#include <functional>
#include <memory>
#include <vector>
namespace OpenVulkano::Input
{
class GestureProcessor final
{
friend class InputDeviceTouch;
GesturePan m_gesturePan;
GesturePan m_gesturePanTwoFingers;
GesturePinch m_gesturePinch;
GestureTap m_gestureTap;
GestureTap m_gestureTapTwoFingers; // TODO
std::vector<Gesture*> m_gestures;
public:
GestureProcessor();
~GestureProcessor();
void Init();
void Close();
void AddGesture(Gesture* gesture);
void RemoveGesture(Gesture* gesture);
bool ResolveConflicts(Gesture* gesture);
void Reset();
void TouchDown(const Touch& touch);
void TouchUp(const Touch& touch);
void TouchMoved(const Touch& touch);
//region conflict resolution
enum class ConflictResult
{
NeitherGesture,
ExistingGesture,
NewGesture,
BothGestures
};
using ConflictResolutionDelegate = std::function<ConflictResult(const Gesture*, const Gesture*)>;
void SetConflictResolutionDelegate(const ConflictResolutionDelegate& delegate) { m_conflictResolutionDelegate = delegate; }
private:
ConflictResolutionDelegate m_conflictResolutionDelegate;
//endregion
};
}