OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/views/touchui/touch_selection_controller_impl.h" | 5 #include "ui/views/touchui/touch_selection_controller_impl.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "ui/aura/client/cursor_client.h" | 9 #include "ui/aura/client/cursor_client.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // Note that this is not quite correct because it does not take into account | 175 // Note that this is not quite correct because it does not take into account |
176 // transforms such as rotation and scaling. This should be in TouchEditable. | 176 // transforms such as rotation and scaling. This should be in TouchEditable. |
177 // TODO(varunjain): Fix this. | 177 // TODO(varunjain): Fix this. |
178 ui::SelectionBound ConvertFromScreen(ui::TouchEditable* client, | 178 ui::SelectionBound ConvertFromScreen(ui::TouchEditable* client, |
179 const ui::SelectionBound& bound) { | 179 const ui::SelectionBound& bound) { |
180 ui::SelectionBound result = bound; | 180 ui::SelectionBound result = bound; |
181 gfx::Point edge_bottom = bound.edge_bottom_rounded(); | 181 gfx::Point edge_bottom = bound.edge_bottom_rounded(); |
182 gfx::Point edge_top = bound.edge_top_rounded(); | 182 gfx::Point edge_top = bound.edge_top_rounded(); |
183 client->ConvertPointFromScreen(&edge_bottom); | 183 client->ConvertPointFromScreen(&edge_bottom); |
184 client->ConvertPointFromScreen(&edge_top); | 184 client->ConvertPointFromScreen(&edge_top); |
185 result.SetEdge(edge_top, edge_bottom); | 185 result.SetEdge(gfx::PointF(edge_top), gfx::PointF(edge_bottom)); |
186 return result; | 186 return result; |
187 } | 187 } |
188 | 188 |
189 ui::SelectionBound ConvertToScreen(ui::TouchEditable* client, | 189 ui::SelectionBound ConvertToScreen(ui::TouchEditable* client, |
190 const ui::SelectionBound& bound) { | 190 const ui::SelectionBound& bound) { |
191 ui::SelectionBound result = bound; | 191 ui::SelectionBound result = bound; |
192 gfx::Point edge_bottom = bound.edge_bottom_rounded(); | 192 gfx::Point edge_bottom = bound.edge_bottom_rounded(); |
193 gfx::Point edge_top = bound.edge_top_rounded(); | 193 gfx::Point edge_top = bound.edge_top_rounded(); |
194 client->ConvertPointToScreen(&edge_bottom); | 194 client->ConvertPointToScreen(&edge_bottom); |
195 client->ConvertPointToScreen(&edge_top); | 195 client->ConvertPointToScreen(&edge_top); |
196 result.SetEdge(edge_top, edge_bottom); | 196 result.SetEdge(gfx::PointF(edge_top), gfx::PointF(edge_bottom)); |
197 return result; | 197 return result; |
198 } | 198 } |
199 | 199 |
200 gfx::Rect BoundToRect(const ui::SelectionBound& bound) { | 200 gfx::Rect BoundToRect(const ui::SelectionBound& bound) { |
201 return gfx::BoundingRect(bound.edge_top_rounded(), | 201 return gfx::BoundingRect(bound.edge_top_rounded(), |
202 bound.edge_bottom_rounded()); | 202 bound.edge_bottom_rounded()); |
203 } | 203 } |
204 | 204 |
205 } // namespace | 205 } // namespace |
206 | 206 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 } | 357 } |
358 selection_bound_.SetEdge(bound.edge_top(), bound.edge_bottom()); | 358 selection_bound_.SetEdge(bound.edge_top(), bound.edge_bottom()); |
359 | 359 |
360 widget_->SetBounds(GetSelectionWidgetBounds(selection_bound_)); | 360 widget_->SetBounds(GetSelectionWidgetBounds(selection_bound_)); |
361 | 361 |
362 aura::Window* window = widget_->GetNativeView(); | 362 aura::Window* window = widget_->GetNativeView(); |
363 gfx::Point edge_top = selection_bound_.edge_top_rounded(); | 363 gfx::Point edge_top = selection_bound_.edge_top_rounded(); |
364 gfx::Point edge_bottom = selection_bound_.edge_bottom_rounded(); | 364 gfx::Point edge_bottom = selection_bound_.edge_bottom_rounded(); |
365 wm::ConvertPointFromScreen(window, &edge_top); | 365 wm::ConvertPointFromScreen(window, &edge_top); |
366 wm::ConvertPointFromScreen(window, &edge_bottom); | 366 wm::ConvertPointFromScreen(window, &edge_bottom); |
367 selection_bound_.SetEdge(edge_top, edge_bottom); | 367 selection_bound_.SetEdge(gfx::PointF(edge_top), gfx::PointF(edge_bottom)); |
368 } | 368 } |
369 | 369 |
370 void SetDrawInvisible(bool draw_invisible) { | 370 void SetDrawInvisible(bool draw_invisible) { |
371 if (draw_invisible_ == draw_invisible) | 371 if (draw_invisible_ == draw_invisible) |
372 return; | 372 return; |
373 draw_invisible_ = draw_invisible; | 373 draw_invisible_ = draw_invisible; |
374 SchedulePaint(); | 374 SchedulePaint(); |
375 } | 375 } |
376 | 376 |
377 private: | 377 private: |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 } | 450 } |
451 | 451 |
452 void TouchSelectionControllerImpl::SelectionChanged() { | 452 void TouchSelectionControllerImpl::SelectionChanged() { |
453 ui::SelectionBound anchor, focus; | 453 ui::SelectionBound anchor, focus; |
454 client_view_->GetSelectionEndPoints(&anchor, &focus); | 454 client_view_->GetSelectionEndPoints(&anchor, &focus); |
455 ui::SelectionBound screen_bound_anchor = | 455 ui::SelectionBound screen_bound_anchor = |
456 ConvertToScreen(client_view_, anchor); | 456 ConvertToScreen(client_view_, anchor); |
457 ui::SelectionBound screen_bound_focus = ConvertToScreen(client_view_, focus); | 457 ui::SelectionBound screen_bound_focus = ConvertToScreen(client_view_, focus); |
458 gfx::Rect client_bounds = client_view_->GetBounds(); | 458 gfx::Rect client_bounds = client_view_->GetBounds(); |
459 if (anchor.edge_top().y() < client_bounds.y()) { | 459 if (anchor.edge_top().y() < client_bounds.y()) { |
460 gfx::Point anchor_edge_top = anchor.edge_top_rounded(); | 460 auto anchor_edge_top = gfx::PointF(anchor.edge_top_rounded()); |
461 anchor_edge_top.set_y(client_bounds.y()); | 461 anchor_edge_top.set_y(client_bounds.y()); |
462 anchor.SetEdgeTop(anchor_edge_top); | 462 anchor.SetEdgeTop(anchor_edge_top); |
463 } | 463 } |
464 if (focus.edge_top().y() < client_bounds.y()) { | 464 if (focus.edge_top().y() < client_bounds.y()) { |
465 gfx::Point focus_edge_top = focus.edge_top_rounded(); | 465 auto focus_edge_top = gfx::PointF(focus.edge_top_rounded()); |
466 focus_edge_top.set_y(client_bounds.y()); | 466 focus_edge_top.set_y(client_bounds.y()); |
467 focus.SetEdgeTop(focus_edge_top); | 467 focus.SetEdgeTop(focus_edge_top); |
468 } | 468 } |
469 ui::SelectionBound screen_bound_anchor_clipped = | 469 ui::SelectionBound screen_bound_anchor_clipped = |
470 ConvertToScreen(client_view_, anchor); | 470 ConvertToScreen(client_view_, anchor); |
471 ui::SelectionBound screen_bound_focus_clipped = | 471 ui::SelectionBound screen_bound_focus_clipped = |
472 ConvertToScreen(client_view_, focus); | 472 ConvertToScreen(client_view_, focus); |
473 if (screen_bound_anchor_clipped == selection_bound_1_clipped_ && | 473 if (screen_bound_anchor_clipped == selection_bound_1_clipped_ && |
474 screen_bound_focus_clipped == selection_bound_2_clipped_) | 474 screen_bound_focus_clipped == selection_bound_2_clipped_) |
475 return; | 475 return; |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 | 770 |
771 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { | 771 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { |
772 return selection_handle_1_.get(); | 772 return selection_handle_1_.get(); |
773 } | 773 } |
774 | 774 |
775 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { | 775 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { |
776 return selection_handle_2_.get(); | 776 return selection_handle_2_.get(); |
777 } | 777 } |
778 | 778 |
779 } // namespace views | 779 } // namespace views |
OLD | NEW |