diff options
author | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-19 08:49:21 +0000 |
---|---|---|
committer | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-19 08:49:21 +0000 |
commit | 7b17bd00c3b044e9e01d01c8bfb589a5e99e99e5 (patch) | |
tree | 1c67e27e3cb1150ad80315ef6cf385e28da28d39 /ui/views/touchui | |
parent | d936677a24d0a18fc35935a999b066496f9a6ec7 (diff) | |
download | chromium_src-7b17bd00c3b044e9e01d01c8bfb589a5e99e99e5.zip chromium_src-7b17bd00c3b044e9e01d01c8bfb589a5e99e99e5.tar.gz chromium_src-7b17bd00c3b044e9e01d01c8bfb589a5e99e99e5.tar.bz2 |
Add method to TouchSelectionController to check if a handle is currently being
dragged. Also fixes some handle positioning bugs.
BUG=none
Review URL: https://chromiumcodereview.appspot.com/13817012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/touchui')
-rw-r--r-- | ui/views/touchui/touch_selection_controller_impl.cc | 17 | ||||
-rw-r--r-- | ui/views/touchui/touch_selection_controller_impl.h | 1 | ||||
-rw-r--r-- | ui/views/touchui/touch_selection_controller_impl_unittest.cc | 3 |
3 files changed, 14 insertions, 7 deletions
diff --git a/ui/views/touchui/touch_selection_controller_impl.cc b/ui/views/touchui/touch_selection_controller_impl.cc index 6f78c96..c6bb087 100644 --- a/ui/views/touchui/touch_selection_controller_impl.cc +++ b/ui/views/touchui/touch_selection_controller_impl.cc @@ -245,6 +245,10 @@ void TouchSelectionControllerImpl::SelectionChanged() { } } +bool TouchSelectionControllerImpl::IsHandleDragInProgress() { + return !!dragging_handle_; +} + void TouchSelectionControllerImpl::SetDraggingHandle( EditingHandleView* handle) { dragging_handle_ = handle; @@ -261,10 +265,12 @@ void TouchSelectionControllerImpl::SelectionHandleDragged( DCHECK(dragging_handle_); + gfx::Point offset_drag_pos(drag_pos.x(), + drag_pos.y() - dragging_handle_->cursor_height() / 2 - + 2 * kSelectionHandleRadius); + ConvertPointToClientView(dragging_handle_, &offset_drag_pos); if (dragging_handle_ == cursor_handle_.get()) { - gfx::Point p(drag_pos.x() + kSelectionHandleRadius, drag_pos.y()); - ConvertPointToClientView(dragging_handle_, &p); - client_view_->MoveCaretTo(p); + client_view_->MoveCaretTo(offset_drag_pos); return; } @@ -274,16 +280,13 @@ void TouchSelectionControllerImpl::SelectionHandleDragged( fixed_handle = selection_handle_2_.get(); // Find selection end points in client_view's coordinate system. - gfx::Point p1(drag_pos.x() + kSelectionHandleRadius, drag_pos.y()); - ConvertPointToClientView(dragging_handle_, &p1); - gfx::Point p2(kSelectionHandleRadius, fixed_handle->cursor_height() / 2); ConvertPointToClientView(fixed_handle, &p2); // Instruct client_view to select the region between p1 and p2. The position // of |fixed_handle| is the start and that of |dragging_handle| is the end // of selection. - client_view_->SelectRect(p2, p1); + client_view_->SelectRect(p2, offset_drag_pos); } void TouchSelectionControllerImpl::ConvertPointToClientView( diff --git a/ui/views/touchui/touch_selection_controller_impl.h b/ui/views/touchui/touch_selection_controller_impl.h index 5d1f771..c42f778 100644 --- a/ui/views/touchui/touch_selection_controller_impl.h +++ b/ui/views/touchui/touch_selection_controller_impl.h @@ -29,6 +29,7 @@ class VIEWS_EXPORT TouchSelectionControllerImpl // TextSelectionController. virtual void SelectionChanged() OVERRIDE; + virtual bool IsHandleDragInProgress() OVERRIDE; private: friend class TouchSelectionControllerImplTest; diff --git a/ui/views/touchui/touch_selection_controller_impl_unittest.cc b/ui/views/touchui/touch_selection_controller_impl_unittest.cc index 15163a2..78a8236 100644 --- a/ui/views/touchui/touch_selection_controller_impl_unittest.cc +++ b/ui/views/touchui/touch_selection_controller_impl_unittest.cc @@ -78,6 +78,9 @@ class TouchSelectionControllerImplTest : public ViewsTestBase { else controller->SetDraggingHandle(controller->selection_handle_2_.get()); + // Offset the drag position by the selection handle radius since it is + // supposed to be in the coordinate system of the handle. + p.Offset(10, 0); controller->SelectionHandleDragged(p); // Do the work of OnMouseReleased(). |