Chromium Code Reviews| 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..e794431a90f2afbd78f111546e07e5451510a28c 100644 |
| --- a/ui/touch_selection/touch_handle.h |
| +++ b/ui/touch_selection/touch_handle.h |
| @@ -24,11 +24,33 @@ class TouchHandle; |
| class UI_TOUCH_SELECTION_EXPORT TouchHandleDrawable { |
| public: |
| virtual ~TouchHandleDrawable() {} |
| + |
| + // Sets whether the handle is active, allowing resource cleanup if necessary. |
| virtual void SetEnabled(bool enabled) = 0; |
| - virtual void SetOrientation(TouchHandleOrientation orientation) = 0; |
| + |
| + // Update the handle visuals to |orientation|. |
| + // |mirror_vertical| and |mirror_horizontal| are used to invert the drawables |
| + // if required for Adaptive Handle Orientation. |
| + virtual void SetOrientation(ui::TouchHandleOrientation orientation, |
| + bool mirror_vertical, |
| + bool mirror_horizontal) = 0; |
| + |
| + // Sets the Origin position of the touch handle. |
| + // |origin| takes care of positioning the handle drawable based on the |
|
mfomitchev
2015/08/10 13:23:46
I think if you say that it's based on handle's vis
AviD
2015/08/10 14:16:10
Done.
|
| + // horizontal transparent padding and the orientation. |
| + virtual void SetOrigin(const gfx::PointF& origin) = 0; |
| + |
| + // Sets the transparency |alpha| for the handle drawable. |
| virtual void SetAlpha(float alpha) = 0; |
| - virtual void SetFocus(const gfx::PointF& position) = 0; |
| + |
| + // Returns the visible bounds of the handle drawable. |
| + // The bounds includes the transparent horizontal padding, which is |
|
mfomitchev
2015/08/10 13:23:45
Nit: I'd drop the "which is" part - IMO generally
AviD
2015/08/10 14:16:10
Done.
|
| + // present in case of Android handle drawables. |
| virtual gfx::RectF GetVisibleBounds() const = 0; |
| + |
| + // Returns the Transparent horizontal if present in the handle drawable. |
|
mfomitchev
2015/08/10 13:23:45
"padding" missing
AviD
2015/08/10 14:16:10
Done.
|
| + // The transparent padding is present in case of Android handle drawables. |
|
mfomitchev
2015/08/10 13:23:46
I'd drop the second sentence.
AviD
2015/08/10 14:16:10
Done.
|
| + virtual const float GetDrawableHorizontalPadding() const = 0; |
| }; |
| // Interface through which |TouchHandle| communicates handle manipulation and |
| @@ -41,6 +63,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 +71,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 +92,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 +115,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 +158,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); |
| }; |