Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: ui/views/controls/scrollbar/overlay_scroll_bar.cc

Issue 2680943002: ui: Clean up naming of paint-related identifiers (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "cc/paint/paint_flags.h"
9 #include "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/compositor/scoped_layer_animation_settings.h" 10 #include "ui/compositor/scoped_layer_animation_settings.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 gfx::Size OverlayScrollBar::Thumb::GetPreferredSize() const { 45 gfx::Size OverlayScrollBar::Thumb::GetPreferredSize() const {
46 // 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
47 // forth by kThumbHoverOffset. To make event targetting work well, expand the 47 // forth by kThumbHoverOffset. To make event targetting work well, expand the
48 // 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
49 // track regardless of the offset. 49 // track regardless of the offset.
50 return gfx::Size(kThumbThickness + kThumbHoverOffset, 50 return gfx::Size(kThumbThickness + kThumbHoverOffset,
51 kThumbThickness + kThumbHoverOffset); 51 kThumbThickness + kThumbHoverOffset);
52 } 52 }
53 53
54 void OverlayScrollBar::Thumb::OnPaint(gfx::Canvas* canvas) { 54 void OverlayScrollBar::Thumb::OnPaint(gfx::Canvas* canvas) {
55 cc::PaintFlags fill_paint; 55 cc::PaintFlags fill_flags;
56 fill_paint.setStyle(cc::PaintFlags::kFill_Style); 56 fill_flags.setStyle(cc::PaintFlags::kFill_Style);
57 fill_paint.setColor(SK_ColorBLACK); 57 fill_flags.setColor(SK_ColorBLACK);
58 gfx::RectF fill_bounds(GetLocalBounds()); 58 gfx::RectF fill_bounds(GetLocalBounds());
59 fill_bounds.Inset(gfx::InsetsF(IsHorizontal() ? kThumbHoverOffset : 0, 59 fill_bounds.Inset(gfx::InsetsF(IsHorizontal() ? kThumbHoverOffset : 0,
60 IsHorizontal() ? 0 : kThumbHoverOffset, 0, 0)); 60 IsHorizontal() ? 0 : kThumbHoverOffset, 0, 0));
61 fill_bounds.Inset(gfx::InsetsF(kThumbStroke, kThumbStroke, 61 fill_bounds.Inset(gfx::InsetsF(kThumbStroke, kThumbStroke,
62 IsHorizontal() ? 0 : kThumbStroke, 62 IsHorizontal() ? 0 : kThumbStroke,
63 IsHorizontal() ? kThumbStroke : 0)); 63 IsHorizontal() ? kThumbStroke : 0));
64 canvas->DrawRect(fill_bounds, fill_paint); 64 canvas->DrawRect(fill_bounds, fill_flags);
65 65
66 cc::PaintFlags stroke_paint; 66 cc::PaintFlags stroke_flags;
67 stroke_paint.setStyle(cc::PaintFlags::kStroke_Style); 67 stroke_flags.setStyle(cc::PaintFlags::kStroke_Style);
68 stroke_paint.setColor(SK_ColorWHITE); 68 stroke_flags.setColor(SK_ColorWHITE);
69 stroke_paint.setStrokeWidth(kThumbStroke); 69 stroke_flags.setStrokeWidth(kThumbStroke);
70 gfx::RectF stroke_bounds(fill_bounds); 70 gfx::RectF stroke_bounds(fill_bounds);
71 stroke_bounds.Inset(gfx::InsetsF(kThumbStroke / 2.f)); 71 stroke_bounds.Inset(gfx::InsetsF(kThumbStroke / 2.f));
72 // 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.
73 SkPath path; 73 SkPath path;
74 path.moveTo(gfx::PointFToSkPoint(stroke_bounds.top_right())); 74 path.moveTo(gfx::PointFToSkPoint(stroke_bounds.top_right()));
75 path.lineTo(gfx::PointFToSkPoint(stroke_bounds.origin())); 75 path.lineTo(gfx::PointFToSkPoint(stroke_bounds.origin()));
76 path.lineTo(gfx::PointFToSkPoint(stroke_bounds.bottom_left())); 76 path.lineTo(gfx::PointFToSkPoint(stroke_bounds.bottom_left()));
77 if (IsHorizontal()) { 77 if (IsHorizontal()) {
78 path.moveTo(gfx::PointFToSkPoint(stroke_bounds.bottom_right())); 78 path.moveTo(gfx::PointFToSkPoint(stroke_bounds.bottom_right()));
79 path.close(); 79 path.close();
80 } else { 80 } else {
81 path.lineTo(gfx::PointFToSkPoint(stroke_bounds.bottom_right())); 81 path.lineTo(gfx::PointFToSkPoint(stroke_bounds.bottom_right()));
82 } 82 }
83 canvas->DrawPath(path, stroke_paint); 83 canvas->DrawPath(path, stroke_flags);
84 } 84 }
85 85
86 void OverlayScrollBar::Thumb::OnBoundsChanged( 86 void OverlayScrollBar::Thumb::OnBoundsChanged(
87 const gfx::Rect& previous_bounds) { 87 const gfx::Rect& previous_bounds) {
88 scroll_bar_->Show(); 88 scroll_bar_->Show();
89 // Don't start the hide countdown if the thumb is still hovered or pressed. 89 // Don't start the hide countdown if the thumb is still hovered or pressed.
90 if (GetState() == CustomButton::STATE_NORMAL) 90 if (GetState() == CustomButton::STATE_NORMAL)
91 scroll_bar_->StartHideCountdown(); 91 scroll_bar_->StartHideCountdown();
92 } 92 }
93 93
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 void OverlayScrollBar::StartHideCountdown() { 172 void OverlayScrollBar::StartHideCountdown() {
173 if (IsMouseHovered()) 173 if (IsMouseHovered())
174 return; 174 return;
175 hide_timer_.Start( 175 hide_timer_.Start(
176 FROM_HERE, base::TimeDelta::FromSeconds(1), 176 FROM_HERE, base::TimeDelta::FromSeconds(1),
177 base::Bind(&OverlayScrollBar::Hide, base::Unretained(this))); 177 base::Bind(&OverlayScrollBar::Hide, base::Unretained(this)));
178 } 178 }
179 179
180 } // namespace views 180 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scrollbar/cocoa_scroll_bar.mm ('k') | ui/views/controls/tabbed_pane/tabbed_pane.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698