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 "base/time.h" | 7 #include "base/time.h" |
8 #include "grit/ui_strings.h" | 8 #include "grit/ui_strings.h" |
9 #include "third_party/skia/include/effects/SkGradientShader.h" | 9 #include "third_party/skia/include/effects/SkGradientShader.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 gfx::Path path; | 74 gfx::Path path; |
75 gfx::Rect bounds(circle.center.x() - circle.radius, | 75 gfx::Rect bounds(circle.center.x() - circle.radius, |
76 circle.center.y() - circle.radius, | 76 circle.center.y() - circle.radius, |
77 circle.radius * 2, | 77 circle.radius * 2, |
78 circle.radius * 2); | 78 circle.radius * 2); |
79 SkRect rect; | 79 SkRect rect; |
80 rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()), | 80 rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()), |
81 SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom())); | 81 SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom())); |
82 SkScalar radius = SkIntToScalar(circle.radius); | 82 SkScalar radius = SkIntToScalar(circle.radius); |
83 path.addRoundRect(rect, radius, radius); | 83 path.addRoundRect(rect, radius, radius); |
84 canvas->AsCanvasSkia()->drawPath(path, paint); | 84 canvas->GetSkCanvas()->drawPath(path, paint); |
85 } | 85 } |
86 | 86 |
87 // The points may not match exactly, since the selection range computation may | 87 // The points may not match exactly, since the selection range computation may |
88 // introduce some floating point errors. So check for a minimum size to decide | 88 // introduce some floating point errors. So check for a minimum size to decide |
89 // whether or not there is any selection. | 89 // whether or not there is any selection. |
90 bool IsEmptySelection(const gfx::Point& p1, const gfx::Point& p2) { | 90 bool IsEmptySelection(const gfx::Point& p1, const gfx::Point& p2) { |
91 int delta_x = p2.x() - p1.x(); | 91 int delta_x = p2.x() - p1.x(); |
92 int delta_y = p2.y() - p1.y(); | 92 int delta_y = p2.y() - p1.y(); |
93 return (abs(delta_x) < kMinSelectionSize && abs(delta_y) < kMinSelectionSize); | 93 return (abs(delta_x) < kMinSelectionSize && abs(delta_y) < kMinSelectionSize); |
94 } | 94 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 SkPaint paint; | 271 SkPaint paint; |
272 paint.setShader(shader); | 272 paint.setShader(shader); |
273 shader->unref(); | 273 shader->unref(); |
274 | 274 |
275 paint.setStyle(SkPaint::kFill_Style); | 275 paint.setStyle(SkPaint::kFill_Style); |
276 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 276 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
277 | 277 |
278 canvas->DrawRectInt(0, 0, width(), height(), paint); | 278 canvas->DrawRectInt(0, 0, width(), height(), paint); |
279 #else | 279 #else |
280 // This is the same as COLOR_TOOLBAR. | 280 // This is the same as COLOR_TOOLBAR. |
281 canvas->AsCanvasSkia()->drawColor(SkColorSetRGB(210, 225, 246), | 281 canvas->GetSkCanvas()->drawColor(SkColorSetRGB(210, 225, 246), |
282 SkXfermode::kSrc_Mode); | 282 SkXfermode::kSrc_Mode); |
283 #endif | 283 #endif |
284 } | 284 } |
285 | 285 |
286 // ButtonListener | 286 // ButtonListener |
287 virtual void ButtonPressed(Button* sender, const views::Event& event) { | 287 virtual void ButtonPressed(Button* sender, const views::Event& event) { |
288 controller_->ExecuteCommand(sender->tag()); | 288 controller_->ExecuteCommand(sender->tag()); |
289 } | 289 } |
290 | 290 |
291 private: | 291 private: |
292 // Queries the client view for what elements to show in the menu and sizes | 292 // Queries the client view for what elements to show in the menu and sizes |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 bool TouchSelectionControllerImpl::IsSelectionHandle2Visible() { | 498 bool TouchSelectionControllerImpl::IsSelectionHandle2Visible() { |
499 return selection_handle_2_->IsVisible(); | 499 return selection_handle_2_->IsVisible(); |
500 } | 500 } |
501 | 501 |
502 TouchSelectionController* TouchSelectionController::create( | 502 TouchSelectionController* TouchSelectionController::create( |
503 TouchSelectionClientView* client_view) { | 503 TouchSelectionClientView* client_view) { |
504 return new TouchSelectionControllerImpl(client_view); | 504 return new TouchSelectionControllerImpl(client_view); |
505 } | 505 } |
506 | 506 |
507 } // namespace views | 507 } // namespace views |
OLD | NEW |