| 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 6587ec1060157f7d69f0ee2227e92754c2046ace..51f81da8115be2f9d563aaa6551d67adaac3bb30 100644
|
| --- a/ui/native_theme/native_theme_aura.cc
|
| +++ b/ui/native_theme/native_theme_aura.cc
|
| @@ -20,6 +20,7 @@
|
| #include "ui/gfx/path.h"
|
| #include "ui/gfx/skia_util.h"
|
| #include "ui/native_theme/common_theme.h"
|
| +#include "ui/native_theme/material_design_constants.h"
|
| #include "ui/native_theme/native_theme_switches.h"
|
|
|
| namespace ui {
|
| @@ -32,11 +33,11 @@ SkAlpha ThumbAlphaForState(NativeTheme::State state) {
|
| case NativeTheme::kDisabled:
|
| return 0x00;
|
| case NativeTheme::kHovered:
|
| - return overlay ? 0xB2 : 0x4D;
|
| + return overlay ? kMDScrollbarAlphaHovered : 0x4D;
|
| case NativeTheme::kNormal:
|
| - return overlay ? 0x8C : 0x33;
|
| + return overlay ? kMDScrollbarAlphaNormal : 0x33;
|
| case NativeTheme::kPressed:
|
| - return overlay ? 0xB2 : 0x80;
|
| + return overlay ? kMDScrollbarAlphaPressed : 0x80;
|
| case NativeTheme::kNumStates:
|
| break;
|
| }
|
| @@ -51,10 +52,11 @@ SkAlpha ThumbStrokeAlphaForState(NativeTheme::State state) {
|
| case NativeTheme::kDisabled:
|
| return 0x00;
|
| case NativeTheme::kHovered:
|
| + return kMDScrollbarAlphaHovered;
|
| case NativeTheme::kPressed:
|
| - return 0x33;
|
| + return kMDScrollbarAlphaPressed;
|
| case NativeTheme::kNormal:
|
| - return 0x26;
|
| + return kMDScrollbarAlphaNormal;
|
| case NativeTheme::kNumStates:
|
| break;
|
| }
|
| @@ -84,6 +86,11 @@ NativeThemeAura::NativeThemeAura() {
|
| set_scrollbar_button_length(0);
|
| #endif
|
|
|
| + if (IsOverlayScrollbarEnabled()) {
|
| + scrollbar_width_ =
|
| + kMDScrollbarThumbWidthPressed + kMDScrollbarStrokeWidth * 2;
|
| + }
|
| +
|
| // Images and alphas declarations assume the following order.
|
| static_assert(kDisabled == 0, "states unexpectedly changed");
|
| static_assert(kHovered == 1, "states unexpectedly changed");
|
| @@ -181,12 +188,14 @@ void NativeThemeAura::PaintScrollbarTrack(
|
| void NativeThemeAura::PaintScrollbarThumb(SkCanvas* canvas,
|
| Part part,
|
| State state,
|
| - const gfx::Rect& rect) const {
|
| + const gfx::Rect& rect,
|
| + ScrollbarOverlayStyle style) const {
|
| // Do not paint if state is disabled.
|
| if (state == kDisabled)
|
| return;
|
|
|
| - PaintScrollbarThumbStateTransition(canvas, part, state, state, 1.0, rect);
|
| + PaintScrollbarThumbStateTransition(canvas, part, state, state, 1.0, rect,
|
| + style);
|
| }
|
|
|
| void NativeThemeAura::PaintScrollbarThumbStateTransition(
|
| @@ -195,21 +204,35 @@ void NativeThemeAura::PaintScrollbarThumbStateTransition(
|
| State start_state,
|
| State end_state,
|
| double progress,
|
| - const gfx::Rect& rect) const {
|
| + const gfx::Rect& rect,
|
| + ScrollbarOverlayStyle style) const {
|
| gfx::Rect thumb_rect(rect);
|
| + SkColor thumb_color;
|
| if (IsOverlayScrollbarEnabled()) {
|
| // In overlay mode, draw a stroke (border).
|
| - const int kStrokeWidth = 1;
|
| + const int kStrokeWidth = kMDScrollbarStrokeWidth;
|
| SkAlpha stroke_alpha = gfx::Tween::IntValueBetween(
|
| progress, ThumbStrokeAlphaForState(start_state),
|
| ThumbStrokeAlphaForState(end_state));
|
| SkPaint paint;
|
| - paint.setColor(SkColorSetA(SK_ColorWHITE, stroke_alpha));
|
| + paint.setColor(SkColorSetA(kMDScrollbarStrokeColor, stroke_alpha));
|
| paint.setStyle(SkPaint::kStroke_Style);
|
| paint.setStrokeWidth(kStrokeWidth);
|
| +
|
| + // When stroking in skia, there's some surprising behavior so we need to
|
| + // inset the right and bottom edges first. See the discussion here:
|
| + // https://groups.google.com/forum/#!topic/skia-discuss/HGZcc3Z7w1Q
|
| + thumb_rect.Inset(0, 0, kStrokeWidth, kStrokeWidth);
|
| canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), paint);
|
|
|
| - thumb_rect.Inset(kStrokeWidth, kStrokeWidth, kStrokeWidth, kStrokeWidth);
|
| + // Inset the top and left edges for filling in the stroke below.
|
| + thumb_rect.Inset(kStrokeWidth, kStrokeWidth, 0, 0);
|
| +
|
| + // thumb_color = kMDScrollbarThumbColor;
|
| + if (style == ScrollbarOverlayStyleLight)
|
| + thumb_color = SK_ColorWHITE;
|
| + else
|
| + thumb_color = SK_ColorBLACK;
|
| } else {
|
| // If there are no scrollbuttons then provide some padding so that the thumb
|
| // doesn't touch the top of the track.
|
| @@ -220,12 +243,14 @@ void NativeThemeAura::PaintScrollbarThumbStateTransition(
|
| thumb_rect.Inset(kThumbPadding, extra_padding);
|
| else
|
| thumb_rect.Inset(extra_padding, kThumbPadding);
|
| +
|
| + thumb_color = SK_ColorBLACK;
|
| }
|
|
|
| SkPaint paint;
|
| SkAlpha alpha = gfx::Tween::IntValueBetween(
|
| progress, ThumbAlphaForState(start_state), ThumbAlphaForState(end_state));
|
| - paint.setColor(SkColorSetA(SK_ColorBLACK, alpha));
|
| + paint.setColor(SkColorSetA(thumb_color, alpha));
|
| canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), paint);
|
| }
|
|
|
|
|