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_service.h" | 7 #include "chrome/browser/themes/theme_service.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" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 SkDoubleToScalar(vertical_padding - 0.5), | 58 SkDoubleToScalar(vertical_padding - 0.5), |
59 SkDoubleToScalar(view->width() - horizontal_padding - 0.5), | 59 SkDoubleToScalar(view->width() - horizontal_padding - 0.5), |
60 SkDoubleToScalar(view->height() - vertical_padding - 0.5)); | 60 SkDoubleToScalar(view->height() - vertical_padding - 0.5)); |
61 | 61 |
62 *roundness = static_cast<double>(kNewtabBarRoundness) * animation_state; | 62 *roundness = static_cast<double>(kNewtabBarRoundness) * animation_state; |
63 } | 63 } |
64 | 64 |
65 // static | 65 // static |
66 void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas, | 66 void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas, |
67 DetachableToolbarView* view) { | 67 DetachableToolbarView* view) { |
68 PaintHorizontalBorderWithColor(canvas, view, | 68 // Border can be at the top or at the bottom of the view depending on whether |
| 69 // the view (bar/shelf) is attached or detached. |
| 70 int thickness = views::NonClientFrameView::kClientEdgeThickness; |
| 71 int y = view->IsDetached() ? 0 : (view->height() - thickness); |
| 72 canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), |
69 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); | 73 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); |
70 } | 74 } |
71 | 75 |
72 // static | 76 // static |
73 void DetachableToolbarView::PaintHorizontalBorderWithColor( | |
74 gfx::Canvas* canvas, | |
75 DetachableToolbarView* view, | |
76 SkColor border_color) { | |
77 // Border can be at the top or at the bottom of the view depending on whether | |
78 // the view (bar/shelf) is attached or detached. | |
79 int thickness = views::NonClientFrameView::kClientEdgeThickness; | |
80 int y = view->IsDetached() ? 0 : (view->height() - thickness); | |
81 canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), border_color); | |
82 } | |
83 | |
84 // static | |
85 void DetachableToolbarView::PaintContentAreaBackground( | 77 void DetachableToolbarView::PaintContentAreaBackground( |
86 gfx::Canvas* canvas, | 78 gfx::Canvas* canvas, |
87 ui::ThemeProvider* theme_provider, | 79 ui::ThemeProvider* theme_provider, |
88 const SkRect& rect, | 80 const SkRect& rect, |
89 double roundness) { | 81 double roundness) { |
90 SkPaint paint; | 82 SkPaint paint; |
91 paint.setAntiAlias(true); | 83 paint.setAntiAlias(true); |
92 paint.setColor(theme_provider->GetColor(ThemeService::COLOR_TOOLBAR)); | 84 paint.setColor(theme_provider->GetColor(ThemeService::COLOR_TOOLBAR)); |
93 | 85 |
94 canvas->sk_canvas()->drawRoundRect( | 86 canvas->sk_canvas()->drawRoundRect( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 SkPaint paint_down; | 126 SkPaint paint_down; |
135 shader = gfx::CreateGradientShader( | 127 shader = gfx::CreateGradientShader( |
136 height / 2, height - vertical_padding, middle_color, bottom_color); | 128 height / 2, height - vertical_padding, middle_color, bottom_color); |
137 paint_down.setShader(shader.get()); | 129 paint_down.setShader(shader.get()); |
138 SkRect rc_down = { SkIntToScalar(x), | 130 SkRect rc_down = { SkIntToScalar(x), |
139 SkIntToScalar(height / 2), | 131 SkIntToScalar(height / 2), |
140 SkIntToScalar(x + 1), | 132 SkIntToScalar(x + 1), |
141 SkIntToScalar(height - vertical_padding) }; | 133 SkIntToScalar(height - vertical_padding) }; |
142 canvas->sk_canvas()->drawRect(rc_down, paint_down); | 134 canvas->sk_canvas()->drawRect(rc_down, paint_down); |
143 } | 135 } |
OLD | NEW |