Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Unified Diff: ui/touch_selection/longpress_drag_selector.h

Issue 1087893003: Support longpress drag selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/touch_selection/BUILD.gn ('k') | ui/touch_selection/longpress_drag_selector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/touch_selection/longpress_drag_selector.h
diff --git a/ui/touch_selection/longpress_drag_selector.h b/ui/touch_selection/longpress_drag_selector.h
new file mode 100644
index 0000000000000000000000000000000000000000..08e7e2a27f79024cfcbc666f06c4a03f1f420cbc
--- /dev/null
+++ b/ui/touch_selection/longpress_drag_selector.h
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_TOUCH_SELECTION_LONGPRESS_DRAG_SELECTOR_H_
+#define UI_TOUCH_SELECTION_LONGPRESS_DRAG_SELECTOR_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"
+
+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;
+};
+
+// Supports text selection via touch dragging after a longpress-initiated
+// selection.
+class UI_TOUCH_SELECTION_EXPORT LongPressDragSelector
+ : public TouchSelectionDraggable {
+ public:
+ explicit LongPressDragSelector(LongPressDragSelectorClient* client);
+ ~LongPressDragSelector() override;
+
+ // TouchSelectionDraggable implementation.
+ bool WillHandleTouchEvent(const MotionEvent& event) override;
+ bool IsActive() const override;
+
+ // Called just prior to a longpress event being handled.
+ void OnLongPressEvent(base::TimeTicks event_time,
+ const gfx::PointF& position);
+
+ // Called when the active selection changes.
+ void OnSelectionActivated();
+ void OnSelectionDeactivated();
+
+ // Whether drag detection following a longpress-triggered selection is active.
+ // This includes both the actual drag motion, and the time when the touch
+ // sequence is still active after the longpress triggers a selection.
+ bool IsDetectingDrag() const;
mfomitchev 2015/04/29 00:34:28 This should be removed
jdduke (slow) 2015/04/29 16:39:15 Done.
+
+ private:
+ enum SelectionState {
+ INACTIVE,
+ LONGPRESS_PENDING,
+ SELECTION_PENDING,
+ DRAG_PENDING,
+ DRAGGING
+ };
+
+ void SetState(SelectionState state);
+
+ LongPressDragSelectorClient* const client_;
+
+ SelectionState state_;
+
+ gfx::PointF longpress_drag_start_position_;
+ gfx::Vector2dF longpress_drag_selection_offset_;
+
+ base::TimeTicks touch_down_time_;
+ gfx::PointF touch_down_position_;
+};
+
+} // namespace ui
+
+#endif // UI_TOUCH_SELECTION_LONGPRESS_DRAG_SELECTOR_H_
« no previous file with comments | « ui/touch_selection/BUILD.gn ('k') | ui/touch_selection/longpress_drag_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698