#ifndef UI_TOUCH_SELECTION_LONGPRESS_DRAG_SELECTOR_H_
#define UI_TOUCH_SELECTION_LONGPRESS_DRAG_SELECTOR_H_
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/vector2d_f.h"
#include "ui/touch_selection/touch_selection_draggable.h"
#include "ui/touch_selection/ui_touch_selection_export.h"
#if BUILDFLAG(ARKWEB_MENU)
#include "arkweb/build/features/features.h"
#include "arkweb/chromium_ext/ui/touch_selection/longpress_drag_selector_util.h"
#endif
namespace ui {
class MotionEvent;
class UI_TOUCH_SELECTION_EXPORT LongPressDragSelectorClient
: public TouchSelectionDraggableClient {
public:
~LongPressDragSelectorClient() override {}
virtual void OnLongPressDragActiveStateChanged() = 0;
virtual gfx::PointF GetSelectionStart() const = 0;
virtual gfx::PointF GetSelectionEnd() const = 0;
#if BUILDFLAG(ARKWEB_MENU)
virtual gfx::PointF GetSelectionTop() const = 0;
#endif
};
class UI_TOUCH_SELECTION_EXPORT LongPressDragSelector
: public TouchSelectionDraggable {
public:
explicit LongPressDragSelector(LongPressDragSelectorClient* client);
~LongPressDragSelector() override;
bool WillHandleTouchEvent(const MotionEvent& event) override;
bool IsActive() const override;
#if BUILDFLAG(ARKWEB_MENU)
bool IsDragging() const override { return state_ == DRAGGING; }
#endif
void OnLongPressEvent(base::TimeTicks event_time,
const gfx::PointF& position);
void OnDoublePressEvent(base::TimeTicks event_time,
const gfx::PointF& position);
void OnScrollBeginEvent();
void OnSelectionActivated();
void OnSelectionDeactivated();
private:
enum SelectionState {
INACTIVE,
INITIATING_GESTURE_PENDING,
SELECTION_PENDING,
DRAG_PENDING,
DRAGGING
};
void SetState(SelectionState state);
const raw_ptr<LongPressDragSelectorClient> client_;
SelectionState state_;
base::TimeTicks touch_down_time_;
gfx::PointF touch_down_position_;
gfx::Vector2dF longpress_drag_selection_offset_;
gfx::PointF longpress_drag_start_anchor_;
bool has_longpress_drag_start_anchor_;
#if BUILDFLAG(IS_ARKWEB)
std::unique_ptr<LongPressDragSelectorUtils> utils_;
#endif
};
}
#endif