#ifndef REMOTING_CLIENT_GESTURE_INTERPRETER_H_
#define REMOTING_CLIENT_GESTURE_INTERPRETER_H_
#include <memory>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "remoting/client/input/touch_input_strategy.h"
#include "remoting/client/ui/desktop_viewport.h"
#include "remoting/client/ui/fling_animation.h"
#include "remoting/proto/event.pb.h"
namespace remoting {
class ChromotingSession;
class RendererProxy;
class GestureInterpreter {
public:
enum GestureState { GESTURE_BEGAN, GESTURE_CHANGED, GESTURE_ENDED };
enum InputMode {
UNDEFINED_INPUT_MODE,
DIRECT_INPUT_MODE,
TRACKPAD_INPUT_MODE
};
GestureInterpreter();
GestureInterpreter(const GestureInterpreter&) = delete;
GestureInterpreter& operator=(const GestureInterpreter&) = delete;
~GestureInterpreter();
void SetContext(RendererProxy* renderer, ChromotingSession* input_stub);
void SetInputMode(InputMode mode);
InputMode GetInputMode() const;
void Zoom(float pivot_x, float pivot_y, float scale, GestureState state);
void Pan(float translation_x, float translation_y);
void Tap(float x, float y);
void TwoFingerTap(float x, float y);
void ThreeFingerTap(float x, float y);
void Drag(float x, float y, GestureState state);
void OneFingerFling(float velocity_x, float velocity_y);
void Scroll(float x, float y, float dx, float dy);
void ScrollWithVelocity(float velocity_x, float velocity_y);
void ProcessAnimations();
void OnSurfaceSizeChanged(int width, int height);
void OnDesktopSizeChanged(int width, int height);
void OnSafeInsetsChanged(int left, int top, int right, int bottom);
base::WeakPtr<GestureInterpreter> GetWeakPtr();
private:
void PanWithoutAbortAnimations(float translation_x, float translation_y);
void ScrollWithoutAbortAnimations(float dx, float dy);
void AbortAnimations();
void InjectMouseClick(float touch_x,
float touch_y,
protocol::MouseEvent_MouseButton button);
void InjectCursorPosition(float x, float y);
void SetGestureInProgress(TouchInputStrategy::Gesture gesture,
bool is_in_progress);
void StartInputFeedback(float cursor_x,
float cursor_y,
TouchInputStrategy::TouchFeedbackType feedback_type);
InputMode input_mode_ = UNDEFINED_INPUT_MODE;
std::unique_ptr<TouchInputStrategy> input_strategy_;
DesktopViewport viewport_;
raw_ptr<RendererProxy> renderer_ = nullptr;
raw_ptr<ChromotingSession> input_stub_ = nullptr;
TouchInputStrategy::Gesture gesture_in_progress_;
FlingAnimation pan_animation_;
FlingAnimation scroll_animation_;
base::WeakPtrFactory<GestureInterpreter> weak_factory_{this};
};
}
#endif