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

Unified Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 798283002: Cleanup: Move PaintVerticalDivider() into bookmark_bar_view.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/detachable_toolbar_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
index 84aa669a917e3e4c9660a67af805cd184872d9c4..34037c765f81e3229d932be16413d065dd11153f 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
@@ -420,13 +420,50 @@ struct BookmarkBarView::DropInfo {
// ButtonSeparatorView --------------------------------------------------------
+// Paints a themed gradient divider at location |x|. |height| is the full
+// height of the view you want to paint the divider into, not the height of
+// the divider. The height of the divider will become:
+// |height| - 2 * |vertical_padding|.
+// The color of the divider is a gradient starting with |top_color| at the
+// top, and changing into |middle_color| and then over to |bottom_color| as
+// you go further down.
+void PaintVerticalDivider(gfx::Canvas* canvas,
+ int x,
+ int height,
+ int vertical_padding,
+ SkColor top_color,
+ SkColor middle_color,
+ SkColor bottom_color) {
+ // Draw the upper half of the divider.
+ SkPaint paint;
+ skia::RefPtr<SkShader> shader = gfx::CreateGradientShader(
+ vertical_padding + 1, height / 2, top_color, middle_color);
+ paint.setShader(shader.get());
+ SkRect rc = { SkIntToScalar(x),
+ SkIntToScalar(vertical_padding + 1),
+ SkIntToScalar(x + 1),
+ SkIntToScalar(height / 2) };
+ canvas->sk_canvas()->drawRect(rc, paint);
+
+ // Draw the lower half of the divider.
+ SkPaint paint_down;
+ shader = gfx::CreateGradientShader(
+ height / 2, height - vertical_padding, middle_color, bottom_color);
+ paint_down.setShader(shader.get());
+ SkRect rc_down = { SkIntToScalar(x),
+ SkIntToScalar(height / 2),
+ SkIntToScalar(x + 1),
+ SkIntToScalar(height - vertical_padding) };
+ canvas->sk_canvas()->drawRect(rc_down, paint_down);
+}
+
class BookmarkBarView::ButtonSeparatorView : public views::View {
public:
ButtonSeparatorView() {}
~ButtonSeparatorView() override {}
void OnPaint(gfx::Canvas* canvas) override {
- DetachableToolbarView::PaintVerticalDivider(
+ PaintVerticalDivider(
canvas,
kSeparatorStartX,
height(),
« no previous file with comments | « no previous file | chrome/browser/ui/views/detachable_toolbar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698