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 17 matching lines...) Expand all Loading... | |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // Constants for painting overlay scrollbars. Other properties needed outside | 31 // Constants for painting overlay scrollbars. Other properties needed outside |
32 // this painting code are defined in overlay_scrollbar_constants_aura.h. | 32 // this painting code are defined in overlay_scrollbar_constants_aura.h. |
33 constexpr int kOverlayScrollbarStrokeWidth = 1; | 33 constexpr int kOverlayScrollbarStrokeWidth = 1; |
34 constexpr int kOverlayScrollbarMinimumLength = 12; | 34 constexpr int kOverlayScrollbarMinimumLength = 12; |
35 constexpr SkAlpha kOverlayScrollbarAlphaNormal = 0x4D; | 35 constexpr SkAlpha kOverlayScrollbarAlphaNormal = 0x4D; |
36 constexpr SkAlpha kOverlayScrollbarAlphaHovered = 0x80; | 36 constexpr SkAlpha kOverlayScrollbarAlphaHovered = 0x80; |
37 constexpr SkAlpha kOverlayScrollbarAlphaPressed = 0x80; | 37 constexpr SkAlpha kOverlayScrollbarAlphaPressed = 0x80; |
38 constexpr SkAlpha kOverlayStrokeAlphaHovered = 0x58; | |
38 | 39 |
39 // Indexed by ScrollbarOverlayColorTheme. | 40 // Indexed by ScrollbarOverlayColorTheme. |
40 constexpr SkColor kOverlayScrollbarThumbColor[] = {SK_ColorBLACK, | 41 constexpr SkColor kOverlayScrollbarThumbColor[] = {SK_ColorBLACK, |
41 SK_ColorWHITE}; | 42 SK_ColorWHITE}; |
42 constexpr SkColor kOverlayScrollbarStrokeColor[] = {SK_ColorWHITE, | 43 constexpr SkColor kOverlayScrollbarStrokeColor[] = {SK_ColorWHITE, |
43 SK_ColorBLACK}; | 44 SK_ColorBLACK}; |
44 | 45 |
45 const SkColor kTrackColor = SkColorSetRGB(0xF1, 0xF1, 0xF1); | 46 const SkColor kTrackColor = SkColorSetRGB(0xF1, 0xF1, 0xF1); |
46 | 47 |
47 } // namespace | 48 } // namespace |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 } | 216 } |
216 | 217 |
217 gfx::Rect thumb_rect(rect); | 218 gfx::Rect thumb_rect(rect); |
218 SkColor thumb_color; | 219 SkColor thumb_color; |
219 if (overlay) { | 220 if (overlay) { |
220 thumb_color = kOverlayScrollbarThumbColor[theme]; | 221 thumb_color = kOverlayScrollbarThumbColor[theme]; |
221 | 222 |
222 // In overlay mode, draw a stroke (border). | 223 // In overlay mode, draw a stroke (border). |
223 constexpr int kStrokeWidth = kOverlayScrollbarStrokeWidth; | 224 constexpr int kStrokeWidth = kOverlayScrollbarStrokeWidth; |
224 SkPaint paint; | 225 SkPaint paint; |
226 | |
227 SkAlpha stroke_alpha = state == NativeTheme::kHovered | |
228 ? kOverlayStrokeAlphaHovered | |
229 : thumb_alpha; | |
bokan
2016/12/15 17:59:28
for consistency, replace thumb_alpha here with a n
| |
225 paint.setColor( | 230 paint.setColor( |
226 SkColorSetA(kOverlayScrollbarStrokeColor[theme], thumb_alpha)); | 231 SkColorSetA(kOverlayScrollbarStrokeColor[theme], stroke_alpha)); |
227 paint.setStyle(SkPaint::kStroke_Style); | 232 paint.setStyle(SkPaint::kStroke_Style); |
228 paint.setStrokeWidth(kStrokeWidth); | 233 paint.setStrokeWidth(kStrokeWidth); |
229 | 234 |
230 gfx::RectF stroke_rect(thumb_rect); | 235 gfx::RectF stroke_rect(thumb_rect); |
231 constexpr float kHalfStrokeWidth = kStrokeWidth / 2.f; | 236 constexpr float kHalfStrokeWidth = kStrokeWidth / 2.f; |
232 stroke_rect.Inset(kHalfStrokeWidth, kHalfStrokeWidth); | 237 stroke_rect.Inset(kHalfStrokeWidth, kHalfStrokeWidth); |
233 canvas->drawRect(gfx::RectFToSkRect(stroke_rect), paint); | 238 canvas->drawRect(gfx::RectFToSkRect(stroke_rect), paint); |
234 | 239 |
235 // Inset the all the edges edges so we fill-in the stroke below. | 240 // Inset the all the edges edges so we fill-in the stroke below. |
236 thumb_rect.Inset(kStrokeWidth, kStrokeWidth); | 241 thumb_rect.Inset(kStrokeWidth, kStrokeWidth); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 // scrollbars isn't asking for part sizes that don't exist. | 287 // scrollbars isn't asking for part sizes that don't exist. |
283 // crbug.com/657159. | 288 // crbug.com/657159. |
284 break; | 289 break; |
285 } | 290 } |
286 } | 291 } |
287 | 292 |
288 return NativeThemeBase::GetPartSize(part, state, extra); | 293 return NativeThemeBase::GetPartSize(part, state, extra); |
289 } | 294 } |
290 | 295 |
291 } // namespace ui | 296 } // namespace ui |
OLD | NEW |