Chromium Code Reviews| Index: ui/native_theme/native_theme_mac.mm |
| diff --git a/ui/native_theme/native_theme_mac.mm b/ui/native_theme/native_theme_mac.mm |
| index f9627ff3cb75d417b719cf57873b6a7a6b481501..df2cd58549e4245817a3788ca1f0ca52774c9c8a 100644 |
| --- a/ui/native_theme/native_theme_mac.mm |
| +++ b/ui/native_theme/native_theme_mac.mm |
| @@ -12,6 +12,7 @@ |
| #include "base/mac/sdk_forward_declarations.h" |
| #include "base/macros.h" |
| #import "skia/ext/skia_utils_mac.h" |
| +#include "third_party/skia/include/core/SkRRect.h" |
| #include "third_party/skia/include/effects/SkGradientShader.h" |
| #include "ui/gfx/geometry/rect.h" |
| #include "ui/gfx/skia_util.h" |
| @@ -266,6 +267,60 @@ void NativeThemeMac::PaintMenuItemBackground( |
| } |
| } |
| +skia::RefPtr<SkShader> |
| +GetComboboxArrowBackgroundShader(NativeTheme::State state, int height) { |
| + SkPoint gradient_points[2]; |
| + gradient_points[0].iset(0, 0); |
| + gradient_points[1].iset(0, height); |
| + |
| + // TODO(ellyjones): These colors are not exactly right, and the gradient |
| + // probably needs more stops. |
| + SkScalar gradient_positions[] = { 0.0, 0.38, 1.0 }; |
| + |
| + SkColor light_blue = SkColorSetRGB(0x4e, 0x97, 0xfd); |
|
tapted
2016/03/21 07:09:04
Are there things we can pick from ui/gfx/color_pal
Elly Fong-Jones
2016/03/21 18:53:56
Done. kGoogleBlue300 and kGoogleBlue700 turn out t
|
| + SkColor dark_blue = SkColorSetRGB(0x3f, 0x68, 0xe5); |
| + |
| + // TODO(ellyjones): Does this need to handle states other than kHovered and |
| + // kNormal? |
|
tapted
2016/03/21 07:09:04
kDisabled. There's also "invalid"
Elly Fong-Jones
2016/03/21 18:53:56
Done.
|
| + SkColor hovered_colors[] = { light_blue, light_blue, dark_blue }; |
| + SkColor normal_colors[] = { SK_ColorWHITE, SK_ColorWHITE, SK_ColorWHITE }; |
| + SkColor* gradient_colors = state == NativeTheme::kHovered ? |
| + hovered_colors : |
| + normal_colors; |
| + |
| + skia::RefPtr<SkShader> gradient_shader = skia::AdoptRef( |
| + SkGradientShader::CreateLinear( |
| + gradient_points, gradient_colors, gradient_positions, 3, |
| + SkShader::kClamp_TileMode)); |
| + return gradient_shader; |
| +} |
| + |
| +void NativeThemeMac::PaintComboboxArrowBackground(SkCanvas* canvas, |
| + State state, |
| + const gfx::Rect& rect) const { |
| + // TODO(ellyjones): This constant is duplicated in FocusableRoundedBorder at |
| + // the moment. Maybe this function should take this as a parameter instead. |
| + const int kComboboxBorderRadius = 5; |
| + |
| + skia::RefPtr<SkShader> shader = |
| + GetComboboxArrowBackgroundShader(state, rect.height()); |
| + |
| + SkPaint paint; |
| + paint.setShader(shader.get()); |
| + paint.setStyle(SkPaint::kFill_Style); |
| + paint.setAntiAlias(true); |
| + |
| + SkPoint no_curve = SkPoint::Make(0, 0); |
| + SkPoint curve = SkPoint::Make(kComboboxBorderRadius, kComboboxBorderRadius); |
| + // Curve upper-right and lower-right corners of the background only. |
| + SkVector curves[4] = { no_curve, curve, curve, no_curve }; |
| + |
| + SkRRect fill_rect; |
| + fill_rect.setRectRadii(gfx::RectToSkRect(rect), curves); |
| + |
| + canvas->drawRRect(fill_rect, paint); |
| +} |
| + |
| NativeThemeMac::NativeThemeMac() { |
| } |