OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ash/touch_hud/touch_hud_renderer.h" | 5 #include "ash/touch_hud/touch_hud_renderer.h" |
6 | 6 |
7 #include "third_party/skia/include/effects/SkGradientShader.h" | 7 #include "third_party/skia/include/effects/SkGradientShader.h" |
8 #include "ui/compositor/layer.h" | 8 #include "ui/compositor/layer.h" |
9 #include "ui/compositor/layer_owner.h" | 9 #include "ui/compositor/layer_owner.h" |
| 10 #include "ui/compositor/layer_type.h" |
10 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
11 #include "ui/gfx/animation/animation_delegate.h" | 12 #include "ui/gfx/animation/animation_delegate.h" |
12 #include "ui/gfx/animation/linear_animation.h" | 13 #include "ui/gfx/animation/linear_animation.h" |
13 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
14 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
15 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
17 #include "ui/views/widget/widget_observer.h" | 18 #include "ui/views/widget/widget_observer.h" |
18 | 19 |
19 namespace ash { | 20 namespace ash { |
20 | 21 |
21 const int kPointRadius = 20; | 22 const int kPointRadius = 20; |
22 const SkColor kProjectionFillColor = SkColorSetRGB(0xF5, 0xF5, 0xDC); | 23 const SkColor kProjectionFillColor = SkColorSetRGB(0xF5, 0xF5, 0xDC); |
23 const SkColor kProjectionStrokeColor = SK_ColorGRAY; | 24 const SkColor kProjectionStrokeColor = SK_ColorGRAY; |
24 const int kProjectionAlpha = 0xB0; | 25 const int kProjectionAlpha = 0xB0; |
25 const int kFadeoutDurationInMs = 250; | 26 const int kFadeoutDurationInMs = 250; |
26 const int kFadeoutFrameRate = 60; | 27 const int kFadeoutFrameRate = 60; |
27 | 28 |
28 // TouchPointView draws a single touch point. This object manages its own | 29 // TouchPointView draws a single touch point. This object manages its own |
29 // lifetime and deletes itself upon fade-out completion or whenever |Destroy()| | 30 // lifetime and deletes itself upon fade-out completion or whenever |Destroy()| |
30 // is explicitly called. | 31 // is explicitly called. |
31 class TouchPointView : public views::View, | 32 class TouchPointView : public views::View, |
32 public gfx::AnimationDelegate, | 33 public gfx::AnimationDelegate, |
33 public views::WidgetObserver { | 34 public views::WidgetObserver { |
34 public: | 35 public: |
35 explicit TouchPointView(views::Widget* parent_widget) | 36 explicit TouchPointView(views::Widget* parent_widget) |
36 : circle_center_(kPointRadius + 1, kPointRadius + 1), | 37 : circle_center_(kPointRadius + 1, kPointRadius + 1), |
37 gradient_center_(SkPoint::Make(kPointRadius + 1, kPointRadius + 1)) { | 38 gradient_center_(SkPoint::Make(kPointRadius + 1, kPointRadius + 1)) { |
38 SetPaintToLayer(true); | 39 SetPaintToLayer(ui::LAYER_TEXTURED); |
39 layer()->SetFillsBoundsOpaquely(false); | 40 layer()->SetFillsBoundsOpaquely(false); |
40 | 41 |
41 SetSize(gfx::Size(2 * kPointRadius + 2, 2 * kPointRadius + 2)); | 42 SetSize(gfx::Size(2 * kPointRadius + 2, 2 * kPointRadius + 2)); |
42 | 43 |
43 stroke_paint_.setStyle(SkPaint::kStroke_Style); | 44 stroke_paint_.setStyle(SkPaint::kStroke_Style); |
44 stroke_paint_.setColor(kProjectionStrokeColor); | 45 stroke_paint_.setColor(kProjectionStrokeColor); |
45 | 46 |
46 gradient_colors_[0] = kProjectionFillColor; | 47 gradient_colors_[0] = kProjectionFillColor; |
47 gradient_colors_[1] = kProjectionStrokeColor; | 48 gradient_colors_[1] = kProjectionStrokeColor; |
48 | 49 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 if (event.type() == ui::ET_TOUCH_RELEASED || | 172 if (event.type() == ui::ET_TOUCH_RELEASED || |
172 event.type() == ui::ET_TOUCH_CANCELLED || | 173 event.type() == ui::ET_TOUCH_CANCELLED || |
173 event.type() == ui::ET_POINTER_UP || | 174 event.type() == ui::ET_POINTER_UP || |
174 event.type() == ui::ET_POINTER_CANCELLED) | 175 event.type() == ui::ET_POINTER_CANCELLED) |
175 points_.erase(iter); | 176 points_.erase(iter); |
176 } | 177 } |
177 } | 178 } |
178 } | 179 } |
179 | 180 |
180 } // namespace ash | 181 } // namespace ash |
OLD | NEW |