| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "views/touchui/touch_selection_controller_impl.h" | 5 #include "views/touchui/touch_selection_controller_impl.h" |
| 6 | 6 |
| 7 #include "ui/gfx/canvas.h" | 7 #include "ui/gfx/canvas.h" |
| 8 #include "ui/gfx/canvas_skia.h" | 8 #include "ui/gfx/canvas_skia.h" |
| 9 #include "ui/gfx/path.h" | 9 #include "ui/gfx/path.h" |
| 10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 void TouchSelectionControllerImpl::SelectionChanged(const gfx::Point& p1, | 155 void TouchSelectionControllerImpl::SelectionChanged(const gfx::Point& p1, |
| 156 const gfx::Point& p2) { | 156 const gfx::Point& p2) { |
| 157 gfx::Point screen_pos_1(p1); | 157 gfx::Point screen_pos_1(p1); |
| 158 View::ConvertPointToScreen(client_view_, &screen_pos_1); | 158 View::ConvertPointToScreen(client_view_, &screen_pos_1); |
| 159 gfx::Point screen_pos_2(p2); | 159 gfx::Point screen_pos_2(p2); |
| 160 View::ConvertPointToScreen(client_view_, &screen_pos_2); | 160 View::ConvertPointToScreen(client_view_, &screen_pos_2); |
| 161 | 161 |
| 162 if (dragging_handle_) { | 162 if (dragging_handle_) { |
| 163 // We need to reposition only the selection handle that is being dragged. | 163 // We need to reposition only the selection handle that is being dragged. |
| 164 // The other handle stays the same. | 164 // The other handle stays the same. Also, the selection handle being dragged |
| 165 SelectionHandleView* fixed_handle = selection_handle_1_.get(); | 165 // will always be at the end of selection, while the other handle will be at |
| 166 if (fixed_handle == dragging_handle_) | 166 // the start. |
| 167 fixed_handle = selection_handle_2_.get(); | 167 dragging_handle_->SetScreenPosition(screen_pos_2); |
| 168 | |
| 169 gfx::Point fixed_handle_pos = fixed_handle->GetScreenPosition(); | |
| 170 fixed_handle_pos.Offset(kSelectionHandleRadius, 0); | |
| 171 | |
| 172 if (fixed_handle_pos == screen_pos_1) | |
| 173 dragging_handle_->SetScreenPosition(screen_pos_2); | |
| 174 else | |
| 175 dragging_handle_->SetScreenPosition(screen_pos_1); | |
| 176 } else { | 168 } else { |
| 177 // Check if there is any selection at all. | 169 // Check if there is any selection at all. |
| 178 if (screen_pos_1 == screen_pos_2) { | 170 if (screen_pos_1 == screen_pos_2) { |
| 179 selection_handle_1_->SetVisible(false); | 171 selection_handle_1_->SetVisible(false); |
| 180 selection_handle_2_->SetVisible(false); | 172 selection_handle_2_->SetVisible(false); |
| 181 return; | 173 return; |
| 182 } | 174 } |
| 183 | 175 |
| 184 if (client_view_->bounds().Contains(p1)) { | 176 if (client_view_->bounds().Contains(p1)) { |
| 185 selection_handle_1_->SetScreenPosition(screen_pos_1); | 177 selection_handle_1_->SetScreenPosition(screen_pos_1); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 bool TouchSelectionControllerImpl::IsSelectionHandle2Visible() { | 240 bool TouchSelectionControllerImpl::IsSelectionHandle2Visible() { |
| 249 return selection_handle_2_->IsVisible(); | 241 return selection_handle_2_->IsVisible(); |
| 250 } | 242 } |
| 251 | 243 |
| 252 TouchSelectionController* TouchSelectionController::create( | 244 TouchSelectionController* TouchSelectionController::create( |
| 253 TouchSelectionClientView* client_view) { | 245 TouchSelectionClientView* client_view) { |
| 254 return new TouchSelectionControllerImpl(client_view); | 246 return new TouchSelectionControllerImpl(client_view); |
| 255 } | 247 } |
| 256 | 248 |
| 257 } // namespace views | 249 } // namespace views |
| OLD | NEW |