OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "grit/theme_resources_standard.h" | 9 #include "grit/theme_resources_standard.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 SkColorSetRGB(222, 234, 248); | 21 SkColorSetRGB(222, 234, 248); |
22 const SkColor DetachableToolbarView::kMiddleDividerColor = | 22 const SkColor DetachableToolbarView::kMiddleDividerColor = |
23 SkColorSetRGB(194, 205, 212); | 23 SkColorSetRGB(194, 205, 212); |
24 | 24 |
25 // static | 25 // static |
26 void DetachableToolbarView::PaintBackgroundAttachedMode( | 26 void DetachableToolbarView::PaintBackgroundAttachedMode( |
27 gfx::Canvas* canvas, | 27 gfx::Canvas* canvas, |
28 views::View* view, | 28 views::View* view, |
29 const gfx::Point& background_origin) { | 29 const gfx::Point& background_origin) { |
30 ui::ThemeProvider* tp = view->GetThemeProvider(); | 30 ui::ThemeProvider* tp = view->GetThemeProvider(); |
31 SkColor theme_toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); | 31 canvas->FillRect(view->GetLocalBounds(), |
32 canvas->FillRect(theme_toolbar_color, view->GetLocalBounds()); | 32 tp->GetColor(ThemeService::COLOR_TOOLBAR)); |
33 canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), | 33 canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), |
34 background_origin.x(), background_origin.y(), 0, 0, | 34 background_origin.x(), background_origin.y(), 0, 0, |
35 view->width(), view->height()); | 35 view->width(), view->height()); |
36 } | 36 } |
37 | 37 |
38 // static | 38 // static |
39 void DetachableToolbarView::CalculateContentArea( | 39 void DetachableToolbarView::CalculateContentArea( |
40 double animation_state, double horizontal_padding, | 40 double animation_state, double horizontal_padding, |
41 double vertical_padding, SkRect* rect, | 41 double vertical_padding, SkRect* rect, |
42 double* roundness, views::View* view) { | 42 double* roundness, views::View* view) { |
43 // The 0.5 is to correct for Skia's "draw on pixel boundaries"ness. | 43 // The 0.5 is to correct for Skia's "draw on pixel boundaries"ness. |
44 rect->set(SkDoubleToScalar(horizontal_padding - 0.5), | 44 rect->set(SkDoubleToScalar(horizontal_padding - 0.5), |
45 SkDoubleToScalar(vertical_padding - 0.5), | 45 SkDoubleToScalar(vertical_padding - 0.5), |
46 SkDoubleToScalar(view->width() - horizontal_padding - 0.5), | 46 SkDoubleToScalar(view->width() - horizontal_padding - 0.5), |
47 SkDoubleToScalar(view->height() - vertical_padding - 0.5)); | 47 SkDoubleToScalar(view->height() - vertical_padding - 0.5)); |
48 | 48 |
49 *roundness = static_cast<double>(kNewtabBarRoundness) * animation_state; | 49 *roundness = static_cast<double>(kNewtabBarRoundness) * animation_state; |
50 } | 50 } |
51 | 51 |
52 // static | 52 // static |
53 void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas, | 53 void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas, |
54 DetachableToolbarView* view) { | 54 DetachableToolbarView* view) { |
55 // Border can be at the top or at the bottom of the view depending on whether | 55 // Border can be at the top or at the bottom of the view depending on whether |
56 // the view (bar/shelf) is attached or detached. | 56 // the view (bar/shelf) is attached or detached. |
57 int thickness = views::NonClientFrameView::kClientEdgeThickness; | 57 int thickness = views::NonClientFrameView::kClientEdgeThickness; |
58 int y = view->IsDetached() ? 0 : (view->height() - thickness); | 58 int y = view->IsDetached() ? 0 : (view->height() - thickness); |
59 canvas->FillRect(ResourceBundle::toolbar_separator_color, | 59 canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), |
60 gfx::Rect(0, y, view->width(), thickness)); | 60 ResourceBundle::toolbar_separator_color); |
61 } | 61 } |
62 | 62 |
63 // static | 63 // static |
64 void DetachableToolbarView::PaintContentAreaBackground( | 64 void DetachableToolbarView::PaintContentAreaBackground( |
65 gfx::Canvas* canvas, | 65 gfx::Canvas* canvas, |
66 ui::ThemeProvider* theme_provider, | 66 ui::ThemeProvider* theme_provider, |
67 const SkRect& rect, | 67 const SkRect& rect, |
68 double roundness) { | 68 double roundness) { |
69 SkPaint paint; | 69 SkPaint paint; |
70 paint.setAntiAlias(true); | 70 paint.setAntiAlias(true); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Draw the lower half of the divider. | 111 // Draw the lower half of the divider. |
112 SkPaint paint_down; | 112 SkPaint paint_down; |
113 SkSafeUnref(paint_down.setShader(gfx::CreateGradientShader( | 113 SkSafeUnref(paint_down.setShader(gfx::CreateGradientShader( |
114 height / 2, height - vertical_padding, middle_color, bottom_color))); | 114 height / 2, height - vertical_padding, middle_color, bottom_color))); |
115 SkRect rc_down = { SkIntToScalar(x), | 115 SkRect rc_down = { SkIntToScalar(x), |
116 SkIntToScalar(height / 2), | 116 SkIntToScalar(height / 2), |
117 SkIntToScalar(x + 1), | 117 SkIntToScalar(x + 1), |
118 SkIntToScalar(height - vertical_padding) }; | 118 SkIntToScalar(height - vertical_padding) }; |
119 canvas->GetSkCanvas()->drawRect(rc_down, paint_down); | 119 canvas->GetSkCanvas()->drawRect(rc_down, paint_down); |
120 } | 120 } |
OLD | NEW |