Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/native_theme/native_theme_aura.h" | 5 #include "ui/native_theme/native_theme_aura.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 return NativeThemeAura::instance(); | 73 return NativeThemeAura::instance(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // static | 76 // static |
| 77 NativeThemeAura* NativeThemeAura::instance() { | 77 NativeThemeAura* NativeThemeAura::instance() { |
| 78 CR_DEFINE_STATIC_LOCAL(NativeThemeAura, s_native_theme, ()); | 78 CR_DEFINE_STATIC_LOCAL(NativeThemeAura, s_native_theme, ()); |
| 79 return &s_native_theme; | 79 return &s_native_theme; |
| 80 } | 80 } |
| 81 #endif | 81 #endif |
| 82 | 82 |
| 83 bool NativeThemeAura::HasScrollbarButtons() const { | |
| 84 #if defined(OS_CHROMEOS) | |
| 85 // We don't draw scrollbar buttons. | |
| 86 return false; | |
| 87 #else | |
| 88 return NativeTheme::HasScrollbarButtons(); | |
| 89 #endif | |
| 90 } | |
| 91 | |
| 83 NativeThemeAura::NativeThemeAura() { | 92 NativeThemeAura::NativeThemeAura() { |
| 84 // We don't draw scrollbar buttons. | |
| 85 #if defined(OS_CHROMEOS) | |
| 86 set_scrollbar_button_length(0); | |
|
Evan Stade
2016/05/24 22:03:54
I still don't understand why you're changing this
| |
| 87 #endif | |
| 88 | |
| 89 // Images and alphas declarations assume the following order. | 93 // Images and alphas declarations assume the following order. |
| 90 static_assert(kDisabled == 0, "states unexpectedly changed"); | 94 static_assert(kDisabled == 0, "states unexpectedly changed"); |
| 91 static_assert(kHovered == 1, "states unexpectedly changed"); | 95 static_assert(kHovered == 1, "states unexpectedly changed"); |
| 92 static_assert(kNormal == 2, "states unexpectedly changed"); | 96 static_assert(kNormal == 2, "states unexpectedly changed"); |
| 93 static_assert(kPressed == 3, "states unexpectedly changed"); | 97 static_assert(kPressed == 3, "states unexpectedly changed"); |
| 94 } | 98 } |
| 95 | 99 |
| 96 NativeThemeAura::~NativeThemeAura() { | 100 NativeThemeAura::~NativeThemeAura() { |
| 97 } | 101 } |
| 98 | 102 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 paint.setColor(SkColorSetA(SK_ColorWHITE, stroke_alpha)); | 213 paint.setColor(SkColorSetA(SK_ColorWHITE, stroke_alpha)); |
| 210 paint.setStyle(SkPaint::kStroke_Style); | 214 paint.setStyle(SkPaint::kStroke_Style); |
| 211 paint.setStrokeWidth(kStrokeWidth); | 215 paint.setStrokeWidth(kStrokeWidth); |
| 212 canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), paint); | 216 canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), paint); |
| 213 | 217 |
| 214 thumb_rect.Inset(kStrokeWidth, kStrokeWidth, kStrokeWidth, kStrokeWidth); | 218 thumb_rect.Inset(kStrokeWidth, kStrokeWidth, kStrokeWidth, kStrokeWidth); |
| 215 } else { | 219 } else { |
| 216 // If there are no scrollbuttons then provide some padding so that the thumb | 220 // If there are no scrollbuttons then provide some padding so that the thumb |
| 217 // doesn't touch the top of the track. | 221 // doesn't touch the top of the track. |
| 218 const int kThumbPadding = 2; | 222 const int kThumbPadding = 2; |
| 219 const int extra_padding = | 223 const int extra_padding = HasScrollbarButtons() ? 0 : kThumbPadding; |
| 220 (scrollbar_button_length() == 0) ? kThumbPadding : 0; | |
| 221 if (part == NativeTheme::kScrollbarVerticalThumb) | 224 if (part == NativeTheme::kScrollbarVerticalThumb) |
| 222 thumb_rect.Inset(kThumbPadding, extra_padding); | 225 thumb_rect.Inset(kThumbPadding, extra_padding); |
| 223 else | 226 else |
| 224 thumb_rect.Inset(extra_padding, kThumbPadding); | 227 thumb_rect.Inset(extra_padding, kThumbPadding); |
| 225 } | 228 } |
| 226 | 229 |
| 227 SkPaint paint; | 230 SkPaint paint; |
| 228 SkAlpha alpha = gfx::Tween::IntValueBetween( | 231 SkAlpha alpha = gfx::Tween::IntValueBetween( |
| 229 progress, ThumbAlphaForState(start_state), ThumbAlphaForState(end_state)); | 232 progress, ThumbAlphaForState(start_state), ThumbAlphaForState(end_state)); |
| 230 paint.setColor(SkColorSetA(SK_ColorBLACK, alpha)); | 233 paint.setColor(SkColorSetA(SK_ColorBLACK, alpha)); |
| 231 canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), paint); | 234 canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), paint); |
| 232 } | 235 } |
| 233 | 236 |
| 234 void NativeThemeAura::PaintScrollbarCorner(SkCanvas* canvas, | 237 void NativeThemeAura::PaintScrollbarCorner(SkCanvas* canvas, |
| 235 State state, | 238 State state, |
| 236 const gfx::Rect& rect) const { | 239 const gfx::Rect& rect) const { |
| 237 // Overlay Scrollbar should never paint a scrollbar corner. | 240 // Overlay Scrollbar should never paint a scrollbar corner. |
| 238 DCHECK(!IsOverlayScrollbarEnabled()); | 241 DCHECK(!IsOverlayScrollbarEnabled()); |
| 239 SkPaint paint; | 242 SkPaint paint; |
| 240 paint.setColor(SkColorSetRGB(0xDC, 0xDC, 0xDC)); | 243 paint.setColor(SkColorSetRGB(0xDC, 0xDC, 0xDC)); |
| 241 canvas->drawIRect(RectToSkIRect(rect), paint); | 244 canvas->drawIRect(RectToSkIRect(rect), paint); |
| 242 } | 245 } |
| 243 | 246 |
| 244 } // namespace ui | 247 } // namespace ui |
| OLD | NEW |