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