Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Unified Diff: ui/views/painter.cc

Issue 10823229: (Views only) Add a gradient background to the tabstrip of the view tabbed pane implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/views/painter.h ('K') | « ui/views/painter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/painter.cc
diff --git a/ui/views/painter.cc b/ui/views/painter.cc
index 96d063d8134c8ac7b69db90078c8ea37b2464740..fc29db5c7acbc8c29a5760e2954e7a788713c5b3 100644
--- a/ui/views/painter.cc
+++ b/ui/views/painter.cc
@@ -20,8 +20,11 @@ namespace {
class GradientPainter : public Painter {
public:
- GradientPainter(bool horizontal, SkColor top, SkColor bottom)
- : horizontal_(horizontal) {
+ GradientPainter(bool horizontal, SkColor top, SkColor bottom, double start,
msw 2012/08/08 17:12:20 nit: one param per line
markusheintz_ 2012/08/08 21:53:55 Done.
+ double end)
+ : horizontal_(horizontal),
+ start_(start),
+ end_(end) {
colors_[0] = top;
colors_[1] = bottom;
}
@@ -33,11 +36,13 @@ class GradientPainter : public Painter {
virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE {
SkPaint paint;
SkPoint p[2];
- p[0].iset(0, 0);
- if (horizontal_)
- p[1].iset(size.width(), 0);
- else
- p[1].iset(0, size.height());
+ if (horizontal_) {
+ p[0].iset(size.width() * start_, 0);
+ p[1].iset(size.width() * end_, 0);
+ } else {
+ p[0].iset(0, size.height() * start_);
+ p[1].iset(0, size.height() * end_);
+ }
SkShader* s = SkGradientShader::CreateLinear(p, colors_, NULL, 2,
SkShader::kClamp_TileMode, NULL);
@@ -52,8 +57,16 @@ class GradientPainter : public Painter {
}
private:
+ // If |horizontal_| is true then the gradiant is painted horizontally.
bool horizontal_;
+ // The start and the end color of the gradient.
SkColor colors_[2];
+ // The start of the gradient specified as percentage of the total size of the
msw 2012/08/08 17:12:20 nit: s/percentage/ratio/, ditto below
markusheintz_ 2012/08/08 21:53:55 obsolete
+ // background.
+ double start_;
msw 2012/08/08 17:12:20 Consider using SkScalar/floats here, instead of do
markusheintz_ 2012/08/08 21:53:55 Done.
+ // The end of the gradient specified as percentage of the total size of the
+ // background.
+ double end_;
DISALLOW_COPY_AND_ASSIGN(GradientPainter);
};
@@ -163,12 +176,18 @@ void Painter::PaintPainterAt(gfx::Canvas* canvas,
// static
Painter* Painter::CreateHorizontalGradient(SkColor c1, SkColor c2) {
- return new GradientPainter(true, c1, c2);
+ return new GradientPainter(true, c1, c2, 0.0f, 1.0f);
}
// static
Painter* Painter::CreateVerticalGradient(SkColor c1, SkColor c2) {
- return new GradientPainter(false, c1, c2);
+ return new GradientPainter(false, c1, c2, 0.0f, 1.0f);
+}
+
+// static
+Painter* Painter::CreateVerticalGradientRange(
+ SkColor c1, SkColor c2, float start, float end) {
msw 2012/08/08 17:12:20 nit: one param per line
markusheintz_ 2012/08/08 21:53:55 Done.
+ return new GradientPainter(false, c1, c2, start, end);
}
// static
« ui/views/painter.h ('K') | « ui/views/painter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698