Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/omnibox/extension_action_util.h" | |
| 6 | |
| 7 #include "chrome/browser/themes/theme_service.h" | |
| 8 #include "chrome/common/extensions/extension_action.h" | |
| 9 #include "third_party/skia/include/core/SkPaint.h" | |
| 10 #include "third_party/skia/include/effects/SkGradientShader.h" | |
| 11 #include "ui/gfx/canvas.h" | |
| 12 #include "ui/gfx/color_utils.h" | |
| 13 #include "ui/gfx/rect.h" | |
| 14 | |
| 15 namespace extensions { | |
| 16 | |
| 17 void PaintExtensionActionBackground(const ExtensionAction& action, | |
| 18 int tab_id, | |
| 19 gfx::Canvas* canvas, | |
| 20 const gfx::Rect& bounds, | |
| 21 SkColor text_color, | |
| 22 SkColor background_color) { | |
| 23 if (action.WantsAttention(tab_id)) { | |
|
Peter Kasting
2012/09/11 22:27:47
Nit: Or early return so you can unindent rest of f
Jeffrey Yasskin
2012/09/12 20:29:34
Done.
| |
| 24 SkPoint gradient_bounds[2] = { {SkIntToScalar(bounds.x()), | |
| 25 SkIntToScalar(bounds.y())}, | |
| 26 {SkIntToScalar(bounds.x()), | |
| 27 SkIntToScalar(bounds.bottom())} }; | |
| 28 SkColor gradient_colors[2] = { | |
| 29 color_utils::AlphaBlend(text_color, background_color, 0x13), | |
| 30 color_utils::AlphaBlend(text_color, background_color, 0x1d) | |
| 31 }; | |
| 32 SkShader* gradient = SkGradientShader::CreateLinear( | |
| 33 gradient_bounds, gradient_colors, NULL, 2, SkShader::kClamp_TileMode); | |
| 34 SkPaint paint; | |
| 35 paint.setShader(gradient); | |
| 36 gradient->unref(); | |
| 37 canvas->DrawRect(bounds, paint); | |
| 38 | |
| 39 SkColor border_color = | |
| 40 color_utils::AlphaBlend(text_color, background_color, 0x55); | |
| 41 canvas->DrawLine(gfx::Point(bounds.x(), bounds.y()), | |
|
Peter Kasting
2012/09/11 22:27:47
Nit: First arg can be "bounds.origin()"
Jeffrey Yasskin
2012/09/11 23:05:28
I don't mind making this change, but it seemed mor
Peter Kasting
2012/09/11 23:25:41
That's OK. I'd prefer to keep the code more simpl
Jeffrey Yasskin
2012/09/12 20:29:34
Done.
| |
| 42 gfx::Point(bounds.x(), bounds.bottom()), | |
| 43 border_color); | |
| 44 // "-1" because gfx::Rects are half-open, not including their right or | |
| 45 // bottom edges. | |
|
Peter Kasting
2012/09/11 22:27:47
So two adjacent badges that request attention get
Jeffrey Yasskin
2012/09/11 23:05:28
No, they get a single-thickness line between them.
| |
| 46 canvas->DrawLine(gfx::Point(bounds.right() - 1, bounds.y()), | |
| 47 gfx::Point(bounds.right() - 1, bounds.bottom()), | |
| 48 border_color); | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 } // namespace extensions | |
| OLD | NEW |