OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/touch_selection/touch_handle.h" | 5 #include "ui/touch_selection/touch_handle.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 namespace ui { | 9 namespace ui { |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 gfx::PointF closest_point_in_rect(circle_center); | 37 gfx::PointF closest_point_in_rect(circle_center); |
38 closest_point_in_rect.SetToMax(rect.origin()); | 38 closest_point_in_rect.SetToMax(rect.origin()); |
39 closest_point_in_rect.SetToMin(rect.bottom_right()); | 39 closest_point_in_rect.SetToMin(rect.bottom_right()); |
40 | 40 |
41 gfx::Vector2dF distance = circle_center - closest_point_in_rect; | 41 gfx::Vector2dF distance = circle_center - closest_point_in_rect; |
42 return distance.LengthSquared() < (circle_radius * circle_radius); | 42 return distance.LengthSquared() < (circle_radius * circle_radius); |
43 } | 43 } |
44 | 44 |
45 } // namespace | 45 } // namespace |
46 | 46 |
47 // TODO(AviD): Remove this once logging(DCHECK) supports enum class. | |
48 static std::ostream& operator<<(std::ostream& os, | |
49 const TouchHandleOrientation& orientation) { | |
50 switch (orientation) { | |
51 case TouchHandleOrientation::LEFT: | |
52 return os << "LEFT"; | |
53 case TouchHandleOrientation::RIGHT: | |
54 return os << "RIGHT"; | |
55 case TouchHandleOrientation::CENTER: | |
56 return os << "CENTER"; | |
57 case TouchHandleOrientation::UNDEFINED: | |
58 return os << "UNDEFINED"; | |
59 default: | |
60 return os << "INVALID: " << static_cast<int>(orientation); | |
61 } | |
62 } | |
63 | |
64 // Responsible for rendering a selection or insertion handle for text editing. | 47 // Responsible for rendering a selection or insertion handle for text editing. |
65 TouchHandle::TouchHandle(TouchHandleClient* client, | 48 TouchHandle::TouchHandle(TouchHandleClient* client, |
66 TouchHandleOrientation orientation, | 49 TouchHandleOrientation orientation, |
67 const gfx::RectF& viewport_rect) | 50 const gfx::RectF& viewport_rect) |
68 : drawable_(client->CreateDrawable()), | 51 : drawable_(client->CreateDrawable()), |
69 client_(client), | 52 client_(client), |
70 viewport_rect_(viewport_rect), | 53 viewport_rect_(viewport_rect), |
71 orientation_(orientation), | 54 orientation_(orientation), |
72 deferred_orientation_(TouchHandleOrientation::UNDEFINED), | 55 deferred_orientation_(TouchHandleOrientation::UNDEFINED), |
73 alpha_(0.f), | 56 alpha_(0.f), |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 drawable_->SetAlpha(alpha); | 382 drawable_->SetAlpha(alpha); |
400 } | 383 } |
401 | 384 |
402 void TouchHandle::SetUpdateLayoutRequired() { | 385 void TouchHandle::SetUpdateLayoutRequired() { |
403 // TODO(AviD): Make the layout call explicit to the caller by adding this in | 386 // TODO(AviD): Make the layout call explicit to the caller by adding this in |
404 // TouchHandleClient. | 387 // TouchHandleClient. |
405 is_handle_layout_update_required_ = true; | 388 is_handle_layout_update_required_ = true; |
406 } | 389 } |
407 | 390 |
408 } // namespace ui | 391 } // namespace ui |
OLD | NEW |