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

Side by Side Diff: chrome/browser/ui/views/detachable_toolbar_view.cc

Issue 8405002: ui/gfx: Convert Canvas::FillRectInt() to use gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: save some vertical space, interactive_ui_tests are fixed by Peter's fix Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 = 31 SkColor theme_toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR);
32 tp->GetColor(ThemeService::COLOR_TOOLBAR); 32 canvas->FillRect(theme_toolbar_color, view->GetLocalBounds());
33 canvas->FillRectInt(theme_toolbar_color, 0, 0,
34 view->width(), view->height());
35 canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), 33 canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR),
36 background_origin.x(), background_origin.y(), 0, 0, 34 background_origin.x(), background_origin.y(), 0, 0,
37 view->width(), view->height()); 35 view->width(), view->height());
38 } 36 }
39 37
40 // static 38 // static
41 void DetachableToolbarView::CalculateContentArea( 39 void DetachableToolbarView::CalculateContentArea(
42 double animation_state, double horizontal_padding, 40 double animation_state, double horizontal_padding,
43 double vertical_padding, SkRect* rect, 41 double vertical_padding, SkRect* rect,
44 double* roundness, views::View* view) { 42 double* roundness, views::View* view) {
45 // 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.
46 rect->set(SkDoubleToScalar(horizontal_padding - 0.5), 44 rect->set(SkDoubleToScalar(horizontal_padding - 0.5),
47 SkDoubleToScalar(vertical_padding - 0.5), 45 SkDoubleToScalar(vertical_padding - 0.5),
48 SkDoubleToScalar(view->width() - horizontal_padding - 0.5), 46 SkDoubleToScalar(view->width() - horizontal_padding - 0.5),
49 SkDoubleToScalar(view->height() - vertical_padding - 0.5)); 47 SkDoubleToScalar(view->height() - vertical_padding - 0.5));
50 48
51 *roundness = static_cast<double>(kNewtabBarRoundness) * animation_state; 49 *roundness = static_cast<double>(kNewtabBarRoundness) * animation_state;
52 } 50 }
53 51
54 // static 52 // static
55 void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas, 53 void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas,
56 DetachableToolbarView* view) { 54 DetachableToolbarView* view) {
57 // 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
58 // the view (bar/shelf) is attached or detached. 56 // the view (bar/shelf) is attached or detached.
59 int thickness = views::NonClientFrameView::kClientEdgeThickness; 57 int thickness = views::NonClientFrameView::kClientEdgeThickness;
60 int y = view->IsDetached() ? 0 : (view->height() - thickness); 58 int y = view->IsDetached() ? 0 : (view->height() - thickness);
61 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, 59 canvas->FillRect(ResourceBundle::toolbar_separator_color,
62 0, y, view->width(), thickness); 60 gfx::Rect(0, y, view->width(), thickness));
63 } 61 }
64 62
65 // static 63 // static
66 void DetachableToolbarView::PaintContentAreaBackground( 64 void DetachableToolbarView::PaintContentAreaBackground(
67 gfx::Canvas* canvas, ui::ThemeProvider* theme_provider, 65 gfx::Canvas* canvas,
68 const SkRect& rect, double roundness) { 66 ui::ThemeProvider* theme_provider,
67 const SkRect& rect,
68 double roundness) {
69 SkPaint paint; 69 SkPaint paint;
70 paint.setAntiAlias(true); 70 paint.setAntiAlias(true);
71 paint.setColor(theme_provider->GetColor(ThemeService::COLOR_TOOLBAR)); 71 paint.setColor(theme_provider->GetColor(ThemeService::COLOR_TOOLBAR));
72 72
73 canvas->GetSkCanvas()->drawRoundRect( 73 canvas->GetSkCanvas()->drawRoundRect(
74 rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), paint); 74 rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), paint);
75 } 75 }
76 76
77 // static 77 // static
78 void DetachableToolbarView::PaintContentAreaBorder( 78 void DetachableToolbarView::PaintContentAreaBorder(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/default_search_view.cc ('k') | chrome/browser/ui/views/download/download_shelf_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698