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 "ui/views/controls/scrollbar/overlay_scroll_bar.h" | 5 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "cc/paint/paint_flags.h" |
8 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
9 #include "ui/compositor/scoped_layer_animation_settings.h" | 10 #include "ui/compositor/scoped_layer_animation_settings.h" |
10 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
11 #include "ui/views/background.h" | 12 #include "ui/views/background.h" |
12 #include "ui/views/border.h" | 13 #include "ui/views/border.h" |
13 | 14 |
14 namespace views { | 15 namespace views { |
15 namespace { | 16 namespace { |
16 | 17 |
17 // Total thickness of the thumb (matches visuals when hovered). | 18 // Total thickness of the thumb (matches visuals when hovered). |
(...skipping 26 matching lines...) Expand all Loading... |
44 gfx::Size OverlayScrollBar::Thumb::GetPreferredSize() const { | 45 gfx::Size OverlayScrollBar::Thumb::GetPreferredSize() const { |
45 // The visual size of the thumb is kThumbThickness, but it slides back and | 46 // The visual size of the thumb is kThumbThickness, but it slides back and |
46 // forth by kThumbHoverOffset. To make event targetting work well, expand the | 47 // forth by kThumbHoverOffset. To make event targetting work well, expand the |
47 // width of the thumb such that it's always taking up the full width of the | 48 // width of the thumb such that it's always taking up the full width of the |
48 // track regardless of the offset. | 49 // track regardless of the offset. |
49 return gfx::Size(kThumbThickness + kThumbHoverOffset, | 50 return gfx::Size(kThumbThickness + kThumbHoverOffset, |
50 kThumbThickness + kThumbHoverOffset); | 51 kThumbThickness + kThumbHoverOffset); |
51 } | 52 } |
52 | 53 |
53 void OverlayScrollBar::Thumb::OnPaint(gfx::Canvas* canvas) { | 54 void OverlayScrollBar::Thumb::OnPaint(gfx::Canvas* canvas) { |
54 SkPaint fill_paint; | 55 cc::PaintFlags fill_paint; |
55 fill_paint.setStyle(SkPaint::kFill_Style); | 56 fill_paint.setStyle(cc::PaintFlags::kFill_Style); |
56 fill_paint.setColor(SK_ColorBLACK); | 57 fill_paint.setColor(SK_ColorBLACK); |
57 gfx::RectF fill_bounds(GetLocalBounds()); | 58 gfx::RectF fill_bounds(GetLocalBounds()); |
58 fill_bounds.Inset(gfx::InsetsF(IsHorizontal() ? kThumbHoverOffset : 0, | 59 fill_bounds.Inset(gfx::InsetsF(IsHorizontal() ? kThumbHoverOffset : 0, |
59 IsHorizontal() ? 0 : kThumbHoverOffset, 0, 0)); | 60 IsHorizontal() ? 0 : kThumbHoverOffset, 0, 0)); |
60 fill_bounds.Inset(gfx::InsetsF(kThumbStroke, kThumbStroke, | 61 fill_bounds.Inset(gfx::InsetsF(kThumbStroke, kThumbStroke, |
61 IsHorizontal() ? 0 : kThumbStroke, | 62 IsHorizontal() ? 0 : kThumbStroke, |
62 IsHorizontal() ? kThumbStroke : 0)); | 63 IsHorizontal() ? kThumbStroke : 0)); |
63 canvas->DrawRect(fill_bounds, fill_paint); | 64 canvas->DrawRect(fill_bounds, fill_paint); |
64 | 65 |
65 SkPaint stroke_paint; | 66 cc::PaintFlags stroke_paint; |
66 stroke_paint.setStyle(SkPaint::kStroke_Style); | 67 stroke_paint.setStyle(cc::PaintFlags::kStroke_Style); |
67 stroke_paint.setColor(SK_ColorWHITE); | 68 stroke_paint.setColor(SK_ColorWHITE); |
68 stroke_paint.setStrokeWidth(kThumbStroke); | 69 stroke_paint.setStrokeWidth(kThumbStroke); |
69 gfx::RectF stroke_bounds(fill_bounds); | 70 gfx::RectF stroke_bounds(fill_bounds); |
70 stroke_bounds.Inset(gfx::InsetsF(kThumbStroke / 2.f)); | 71 stroke_bounds.Inset(gfx::InsetsF(kThumbStroke / 2.f)); |
71 // The stroke doesn't apply to the far edge of the thumb. | 72 // The stroke doesn't apply to the far edge of the thumb. |
72 SkPath path; | 73 SkPath path; |
73 path.moveTo(gfx::PointFToSkPoint(stroke_bounds.top_right())); | 74 path.moveTo(gfx::PointFToSkPoint(stroke_bounds.top_right())); |
74 path.lineTo(gfx::PointFToSkPoint(stroke_bounds.origin())); | 75 path.lineTo(gfx::PointFToSkPoint(stroke_bounds.origin())); |
75 path.lineTo(gfx::PointFToSkPoint(stroke_bounds.bottom_left())); | 76 path.lineTo(gfx::PointFToSkPoint(stroke_bounds.bottom_left())); |
76 if (IsHorizontal()) { | 77 if (IsHorizontal()) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 171 |
171 void OverlayScrollBar::StartHideCountdown() { | 172 void OverlayScrollBar::StartHideCountdown() { |
172 if (IsMouseHovered()) | 173 if (IsMouseHovered()) |
173 return; | 174 return; |
174 hide_timer_.Start( | 175 hide_timer_.Start( |
175 FROM_HERE, base::TimeDelta::FromSeconds(1), | 176 FROM_HERE, base::TimeDelta::FromSeconds(1), |
176 base::Bind(&OverlayScrollBar::Hide, base::Unretained(this))); | 177 base::Bind(&OverlayScrollBar::Hide, base::Unretained(this))); |
177 } | 178 } |
178 | 179 |
179 } // namespace views | 180 } // namespace views |
OLD | NEW |