Commit 39f40c22 authored by tfarina's avatar tfarina Committed by Commit bot

Cleanup: Move PaintVerticalDivider() into bookmark_bar_view.cc.

Actually it does not have to do much with DetachableToolbarView.

It is used by BookmarkBarView to draw a button separator in the left
side of "Other bookmarks" folder. The "Other bookmarks" only appears
when you actually have bookmarks on it. So to separate it from the rest
of the Bookmarks bar nodes, a separator is drawn.

Screenshot: http://imgur.com/nW38lEy

BUG=None
TEST=open chrome, bookmark something in the "Other bookmarks" folder,
make sure you have "Bookmarks bar" shown, then make sure the separator
is there. No regressions observed.
R=sky@chromium.org

Review URL: https://codereview.chromium.org/798283002

Cr-Commit-Position: refs/heads/master@{#308371}
parent 7d52139c
......@@ -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(),
......
......@@ -11,7 +11,6 @@
#include "ui/base/theme_provider.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/skia_util.h"
#include "ui/views/window/non_client_view.h"
// static
......@@ -59,34 +58,3 @@ void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas,
int y = at_top ? 0 : (view->height() - thickness);
canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), color);
}
// static
void DetachableToolbarView::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);
}
......@@ -8,8 +8,6 @@
#include "chrome/browser/ui/host_desktop.h"
#include "ui/views/accessible_pane_view.h"
struct SkRect;
// DetachableToolbarView contains functionality common to views that can detach
// from the Chrome frame, such as the BookmarkBarView and the Extension shelf.
class DetachableToolbarView : public views::AccessiblePaneView {
......@@ -43,21 +41,6 @@ class DetachableToolbarView : public views::AccessiblePaneView {
bool at_top,
SkColor color);
// Paint 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.
static void PaintVerticalDivider(gfx::Canvas* canvas,
int x,
int height,
int vertical_padding,
SkColor top_color,
SkColor middle_color,
SkColor bottom_color);
private:
DISALLOW_COPY_AND_ASSIGN(DetachableToolbarView);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment