OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/detachable_toolbar_view.h" | 5 #include "chrome/browser/ui/views/detachable_toolbar_view.h" |
6 | 6 |
7 #include "chrome/browser/themes/theme_properties.h" | 7 #include "chrome/browser/themes/theme_properties.h" |
8 #include "grit/theme_resources.h" | 8 #include "grit/theme_resources.h" |
9 #include "third_party/skia/include/core/SkShader.h" | 9 #include "third_party/skia/include/core/SkShader.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/base/theme_provider.h" | 11 #include "ui/base/theme_provider.h" |
12 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
13 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
14 #include "ui/gfx/skia_util.h" | |
15 #include "ui/views/window/non_client_view.h" | 14 #include "ui/views/window/non_client_view.h" |
16 | 15 |
17 // static | 16 // static |
18 void DetachableToolbarView::PaintBackgroundAttachedMode( | 17 void DetachableToolbarView::PaintBackgroundAttachedMode( |
19 gfx::Canvas* canvas, | 18 gfx::Canvas* canvas, |
20 ui::ThemeProvider* theme_provider, | 19 ui::ThemeProvider* theme_provider, |
21 const gfx::Rect& bounds, | 20 const gfx::Rect& bounds, |
22 const gfx::Point& background_origin, | 21 const gfx::Point& background_origin, |
23 chrome::HostDesktopType host_desktop_type) { | 22 chrome::HostDesktopType host_desktop_type) { |
24 canvas->FillRect(bounds, | 23 canvas->FillRect(bounds, |
(...skipping 27 matching lines...) Expand all Loading... |
52 | 51 |
53 // static | 52 // static |
54 void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas, | 53 void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas, |
55 DetachableToolbarView* view, | 54 DetachableToolbarView* view, |
56 bool at_top, | 55 bool at_top, |
57 SkColor color) { | 56 SkColor color) { |
58 int thickness = views::NonClientFrameView::kClientEdgeThickness; | 57 int thickness = views::NonClientFrameView::kClientEdgeThickness; |
59 int y = at_top ? 0 : (view->height() - thickness); | 58 int y = at_top ? 0 : (view->height() - thickness); |
60 canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), color); | 59 canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), color); |
61 } | 60 } |
62 | |
63 // static | |
64 void DetachableToolbarView::PaintVerticalDivider(gfx::Canvas* canvas, | |
65 int x, | |
66 int height, | |
67 int vertical_padding, | |
68 SkColor top_color, | |
69 SkColor middle_color, | |
70 SkColor bottom_color) { | |
71 // Draw the upper half of the divider. | |
72 SkPaint paint; | |
73 skia::RefPtr<SkShader> shader = gfx::CreateGradientShader( | |
74 vertical_padding + 1, height / 2, top_color, middle_color); | |
75 paint.setShader(shader.get()); | |
76 SkRect rc = { SkIntToScalar(x), | |
77 SkIntToScalar(vertical_padding + 1), | |
78 SkIntToScalar(x + 1), | |
79 SkIntToScalar(height / 2) }; | |
80 canvas->sk_canvas()->drawRect(rc, paint); | |
81 | |
82 // Draw the lower half of the divider. | |
83 SkPaint paint_down; | |
84 shader = gfx::CreateGradientShader( | |
85 height / 2, height - vertical_padding, middle_color, bottom_color); | |
86 paint_down.setShader(shader.get()); | |
87 SkRect rc_down = { SkIntToScalar(x), | |
88 SkIntToScalar(height / 2), | |
89 SkIntToScalar(x + 1), | |
90 SkIntToScalar(height - vertical_padding) }; | |
91 canvas->sk_canvas()->drawRect(rc_down, paint_down); | |
92 } | |
OLD | NEW |