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

Unified Diff: content/browser/renderer_host/input/touch_handle.h

Issue 335943002: [Android] Composited selection handle rendering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@input_native_handles_final
Patch Set: Test and comments Created 6 years, 6 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
Index: content/browser/renderer_host/input/touch_handle.h
diff --git a/content/browser/renderer_host/input/touch_handle.h b/content/browser/renderer_host/input/touch_handle.h
new file mode 100644
index 0000000000000000000000000000000000000000..59083b90bda74c38d70ec5f68f9061dc96d02424
--- /dev/null
+++ b/content/browser/renderer_host/input/touch_handle.h
@@ -0,0 +1,103 @@
+// Copyright 2014 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 CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_HANDLE_H_
+#define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_HANDLE_H_
+
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "content/common/content_export.h"
+#include "ui/events/gesture_detection/motion_event.h"
+#include "ui/gfx/geometry/point_f.h"
+#include "ui/gfx/geometry/vector2d_f.h"
+
+namespace content {
+
+class TouchHandle;
+
+enum TouchHandleOrientation {
+ TOUCH_HANDLE_LEFT,
+ TOUCH_HANDLE_CENTER,
+ TOUCH_HANDLE_RIGHT,
+ TOUCH_HANDLE_ORIENTATION_UNDEFINED,
+};
+
+// Interface through which |TouchHandle| delegates rendering-specific duties.
+class CONTENT_EXPORT TouchHandleDrawable {
+ public:
+ virtual ~TouchHandleDrawable() {}
+ virtual void SetOrientation(TouchHandleOrientation orientation) = 0;
+ virtual void SetAlpha(float alpha) = 0;
+ virtual void SetFocus(const gfx::PointF& position) = 0;
+ virtual void SetVisible(bool visible) = 0;
+ virtual bool ContainsPoint(const gfx::PointF& point) const = 0;
+};
+
+// Interface through which |TouchHandle| communicates handle manipulation and
+// requests concrete drawable instances.
+class CONTENT_EXPORT TouchHandleClient {
+ public:
+ virtual ~TouchHandleClient() {}
+ virtual void OnHandleDragBegin(const TouchHandle& handle) = 0;
+ virtual void OnHandleDragUpdate(const TouchHandle& handle,
+ const gfx::PointF& new_position) = 0;
+ virtual void OnHandleDragEnd(const TouchHandle& handle) = 0;
+ virtual void OnHandleTapped(const TouchHandle& handle) = 0;
+ virtual void SetNeedsAnimate() = 0;
+ virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0;
+};
+
+// Responsible for displaying a selection or insertion handle for text
+// interaction.
+class CONTENT_EXPORT TouchHandle {
+ public:
+ TouchHandle(TouchHandleClient* client, TouchHandleOrientation orientation);
+ ~TouchHandle();
+
+ void SetVisible(bool visible);
+ void SetVisibleAnimated(bool visible);
+ void SetPosition(const gfx::PointF& position);
+ void SetOrientation(TouchHandleOrientation orientation);
+ void Hide();
+
+ bool WillHandleTouchEvent(const ui::MotionEvent& event);
+ bool Animate(base::TimeTicks frame_time);
+
+ bool is_dragging() const { return is_dragging_; }
+ const gfx::PointF& position() const { return position_; }
+ TouchHandleOrientation orientation() const { return orientation_; }
+
+ private:
+ void BeginDrag();
+ void EndDrag();
+ void ScheduleFade();
+ void CancelFade();
+ void SetAlpha(float alpha);
+
+ scoped_ptr<TouchHandleDrawable> drawable_;
+
+ TouchHandleClient* const client_;
+
+ gfx::PointF position_;
+ TouchHandleOrientation orientation_;
+ TouchHandleOrientation deferred_orientation_;
cjhopman 2014/07/07 22:13:41 A comment somewhere that orientation changes while
jdduke (slow) 2014/07/08 00:54:44 Good call, added some basic documentation to each
+
+ gfx::PointF down_position_;
+ gfx::Vector2dF touch_to_focus_offset_;
+
+ base::TimeTicks touch_timer_;
cjhopman 2014/07/07 22:13:41 Maybe make a note about what things might get out
jdduke (slow) 2014/07/08 00:54:44 Done.
+ float alpha_;
+ base::TimeTicks fade_end_time_;
+ gfx::PointF fade_start_position_;
+
+ bool is_visible_;
+ bool is_dragging_;
+
+ DISALLOW_COPY_AND_ASSIGN(TouchHandle);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_HANDLE_H_

Powered by Google App Engine
This is Rietveld 408576698