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

Unified Diff: ui/native_theme/native_theme_aura.cc

Issue 2426793002: Aura overlay scrollbars adjust color for dark backgrounds (Closed)
Patch Set: add test and remove dead code Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/native_theme/native_theme_aura.h ('k') | ui/native_theme/native_theme_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/native_theme/native_theme_aura.cc
diff --git a/ui/native_theme/native_theme_aura.cc b/ui/native_theme/native_theme_aura.cc
index d03a0d3211edc0f216a157fa5ff93b7ce22cab68..bd2d9df1e5359e60c1636f9cea77359ebc723d24 100644
--- a/ui/native_theme/native_theme_aura.cc
+++ b/ui/native_theme/native_theme_aura.cc
@@ -35,8 +35,11 @@ constexpr int kOverlayScrollbarMinimumLength = 12;
constexpr SkAlpha kOverlayScrollbarAlphaNormal = 0x4D;
constexpr SkAlpha kOverlayScrollbarAlphaHovered = 0x80;
constexpr SkAlpha kOverlayScrollbarAlphaPressed = 0x80;
-constexpr SkColor kOverlayScrollbarThumbColor = SK_ColorBLACK;
-constexpr SkColor kOverlayScrollbarStrokeColor = SK_ColorWHITE;
+constexpr SkColor kOverlayScrollbarThumbDarkColor = SK_ColorBLACK;
+constexpr SkColor kOverlayScrollbarThumbLightColor = SK_ColorWHITE;
+constexpr SkColor kOverlayScrollbarStrokeDarkColor = SK_ColorWHITE;
+constexpr SkColor kOverlayScrollbarStrokeLightColor = SK_ColorBLACK;
+
SkAlpha ThumbAlphaForState(NativeTheme::State state) {
bool overlay = IsOverlayScrollbarEnabled();
@@ -177,35 +180,40 @@ void NativeThemeAura::PaintScrollbarTrack(
canvas->drawIRect(gfx::RectToSkIRect(rect), paint);
}
-void NativeThemeAura::PaintScrollbarThumb(SkCanvas* canvas,
- Part part,
- State state,
- const gfx::Rect& rect) const {
+void NativeThemeAura::PaintScrollbarThumb(
+ SkCanvas* canvas,
+ Part part,
+ State state,
+ const gfx::Rect& rect,
+ ScrollbarOverlayColorTheme theme) const {
// Do not paint if state is disabled.
if (state == kDisabled)
return;
- PaintScrollbarThumbStateTransition(canvas, part, state, state, 1.0, rect);
-}
+ TRACE_EVENT0("blink", "NativeThemeAura::PaintScrollbarThumb");
-void NativeThemeAura::PaintScrollbarThumbStateTransition(
- SkCanvas* canvas,
- Part part,
- State start_state,
- State end_state,
- double progress,
- const gfx::Rect& rect) const {
- TRACE_EVENT0("blink", "NativeThemeAura::PaintScrollbarThumbStateTransition");
gfx::Rect thumb_rect(rect);
SkColor thumb_color;
+ double progress = 1.0;
bokan 2016/10/27 18:29:53 Remove this and the IntValueBetween calls since th
+
if (IsOverlayScrollbarEnabled()) {
+ SkColor stroke_color;
+ if (theme == ScrollbarOverlayColorThemeLight) {
+ thumb_color = kOverlayScrollbarThumbLightColor;
+ stroke_color = kOverlayScrollbarStrokeLightColor;
+ } else {
+ thumb_color = kOverlayScrollbarThumbDarkColor;
+ stroke_color = kOverlayScrollbarStrokeDarkColor;
+ }
+
// In overlay mode, draw a stroke (border).
constexpr int kStrokeWidth = kOverlayScrollbarStrokeWidth;
SkAlpha stroke_alpha = gfx::Tween::IntValueBetween(
- progress, ThumbAlphaForState(start_state),
- ThumbAlphaForState(end_state));
+ progress, ThumbAlphaForState(state),
+ ThumbAlphaForState(state));
+
SkPaint paint;
- paint.setColor(SkColorSetA(kOverlayScrollbarStrokeColor, stroke_alpha));
+ paint.setColor(SkColorSetA(stroke_color, stroke_alpha));
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(kStrokeWidth);
@@ -216,7 +224,7 @@ void NativeThemeAura::PaintScrollbarThumbStateTransition(
// Inset the all the edges edges so we fill-in the stroke below.
thumb_rect.Inset(kStrokeWidth, kStrokeWidth);
- thumb_color = kOverlayScrollbarThumbColor;
+
} else {
// If there are no scrollbuttons then provide some padding so that the thumb
// doesn't touch the top of the track.
@@ -233,7 +241,7 @@ void NativeThemeAura::PaintScrollbarThumbStateTransition(
SkPaint paint;
SkAlpha alpha = gfx::Tween::IntValueBetween(
- progress, ThumbAlphaForState(start_state), ThumbAlphaForState(end_state));
+ progress, ThumbAlphaForState(state), ThumbAlphaForState(state));
paint.setColor(SkColorSetA(thumb_color, alpha));
canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), paint);
}
« no previous file with comments | « ui/native_theme/native_theme_aura.h ('k') | ui/native_theme/native_theme_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698