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

Unified Diff: ui/touch_selection/touch_handle.h

Issue 481683003: Support for Adaptive Handle Orientation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed nits Created 5 years, 5 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: ui/touch_selection/touch_handle.h
diff --git a/ui/touch_selection/touch_handle.h b/ui/touch_selection/touch_handle.h
index 1a1995ea6f0747a1e27321ffb1675411090165dc..96696f240f52f7a81eb7c6eebaa174fd75d8220a 100644
--- a/ui/touch_selection/touch_handle.h
+++ b/ui/touch_selection/touch_handle.h
@@ -25,10 +25,13 @@ class UI_TOUCH_SELECTION_EXPORT TouchHandleDrawable {
public:
virtual ~TouchHandleDrawable() {}
virtual void SetEnabled(bool enabled) = 0;
- virtual void SetOrientation(TouchHandleOrientation orientation) = 0;
+ virtual void SetOrientation(ui::TouchHandleOrientation orientation,
+ bool mirror_vertical,
+ bool mirror_horizontal) = 0;
+ virtual void SetOrigin(const gfx::PointF& origin) = 0;
mfomitchev 2015/08/06 14:33:02 Could you please add some comments to SetOrigin, G
AviD 2015/08/09 13:55:41 Done.
virtual void SetAlpha(float alpha) = 0;
- virtual void SetFocus(const gfx::PointF& position) = 0;
virtual gfx::RectF GetVisibleBounds() const = 0;
+ virtual const float GetDrawableHorizontalPadding() const = 0;
};
// Interface through which |TouchHandle| communicates handle manipulation and
@@ -41,6 +44,7 @@ class UI_TOUCH_SELECTION_EXPORT TouchHandleClient
virtual void SetNeedsAnimate() = 0;
virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0;
virtual base::TimeDelta GetTapTimeout() const = 0;
+ virtual bool IsEnabledAdaptiveHandleOrientation() const = 0;
};
// Responsible for displaying a selection or insertion handle for text
@@ -48,7 +52,9 @@ class UI_TOUCH_SELECTION_EXPORT TouchHandleClient
class UI_TOUCH_SELECTION_EXPORT TouchHandle : public TouchSelectionDraggable {
public:
// The drawable will be enabled but invisible until otherwise specified.
- TouchHandle(TouchHandleClient* client, TouchHandleOrientation orientation);
+ TouchHandle(TouchHandleClient* client,
+ TouchHandleOrientation orientation,
+ const gfx::RectF viewport_rect);
~TouchHandle() override;
// TouchSelectionDraggable implementation.
@@ -67,10 +73,14 @@ class UI_TOUCH_SELECTION_EXPORT TouchHandle : public TouchSelectionDraggable {
// If an animation is in-progress, it will be overriden appropriately.
void SetVisible(bool visible, AnimationStyle animation_style);
- // Update the handle placement to |position|.
+ // Update the focus points for the handles. The Handle will be positioned
+ // either |top| or |bottom| based on the mirror parameters.
// Note: If a fade out animation is active or the handle is invisible, the
// handle position will not be updated until the handle regains visibility.
- void SetPosition(const gfx::PointF& position);
+ void SetFocus(const gfx::PointF& top, const gfx::PointF& bottom);
+
+ // Update the Viewport rect, based on which the handle decide its inversion
+ void SetViewportRect(const gfx::RectF viewport_rect);
// Update the handle visuals to |orientation|.
// Note: If the handle is being dragged, the orientation change will be
@@ -86,21 +96,30 @@ class UI_TOUCH_SELECTION_EXPORT TouchHandle : public TouchSelectionDraggable {
// the bounds will be empty.
gfx::RectF GetVisibleBounds() const;
- const gfx::PointF& position() const { return position_; }
+ // Updates the Handle layout if the is_handle_layout_update_required_ flag is
+ // set. Will be called once per frame update, avoids multiple updates for
+ // for the same frame update due to more than one parameter updates.
+ void UpdateHandleLayout();
+
+ const gfx::PointF& focus_bottom() const { return focus_bottom_; }
TouchHandleOrientation orientation() const { return orientation_; }
private:
+ gfx::PointF GetHandleOrigin() const;
void BeginDrag();
void EndDrag();
void BeginFade();
void EndFade();
void SetAlpha(float alpha);
+ void SetUpdateLayoutRequired() { is_handle_layout_update_required_ = true; }
scoped_ptr<TouchHandleDrawable> drawable_;
TouchHandleClient* const client_;
- gfx::PointF position_;
+ gfx::PointF focus_bottom_;
+ gfx::PointF focus_top_;
+ gfx::RectF viewport_rect_;
TouchHandleOrientation orientation_;
TouchHandleOrientation deferred_orientation_;
@@ -120,6 +139,12 @@ class UI_TOUCH_SELECTION_EXPORT TouchHandle : public TouchSelectionDraggable {
bool is_visible_;
bool is_dragging_;
bool is_drag_within_tap_region_;
+ bool is_handle_layout_update_required_;
+
+ // Mirror variables determine if the handles should be inverted or not.
+ bool mirror_vertical_;
+ bool mirror_horizontal_;
+ float handle_horizontal_padding_;
DISALLOW_COPY_AND_ASSIGN(TouchHandle);
};

Powered by Google App Engine
This is Rietveld 408576698