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

Side by Side Diff: ui/app_list/app_list_background.cc

Issue 10905311: Consolidate bubble border code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove USE_AURA ifdef for kBigShadowImages and kSmalleShadowImages Created 8 years, 3 months 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
« no previous file with comments | « ui/app_list/app_list_background.h ('k') | ui/app_list/app_list_bubble_border.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/app_list/app_list_bubble_border.h" 5 #include "ui/app_list/app_list_background.h"
6 6
7 #include "third_party/skia/include/core/SkPaint.h"
7 #include "third_party/skia/include/core/SkPath.h" 8 #include "third_party/skia/include/core/SkPath.h"
8 #include "third_party/skia/include/core/SkPaint.h"
9 #include "third_party/skia/include/effects/SkGradientShader.h"
10 #include "ui/app_list/app_list_constants.h" 9 #include "ui/app_list/app_list_constants.h"
11 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/path.h" 11 #include "ui/gfx/rect.h"
13 #include "ui/gfx/skia_util.h" 12 #include "ui/gfx/skia_util.h"
13 #include "ui/views/view.h"
14 14
15 namespace { 15 namespace {
16 16
17 const SkColor kSearchBoxBackground = SK_ColorWHITE; 17 const SkColor kSearchBoxBackground = SK_ColorWHITE;
18 18
19 // Colors and sizes of top separator between searchbox and grid view. 19 // Colors and sizes of top separator between searchbox and grid view.
20 const SkColor kTopSeparatorColor = SkColorSetRGB(0xE5, 0xE5, 0xE5); 20 const SkColor kTopSeparatorColor = SkColorSetRGB(0xE5, 0xE5, 0xE5);
21 const int kTopSeparatorSize = 1; 21 const int kTopSeparatorSize = 1;
22 22
23 } // namespace 23 } // namespace
24 24
25 namespace app_list { 25 namespace app_list {
26 26
27 AppListBubbleBorder::AppListBubbleBorder(views::View* app_list_view, 27 AppListBackground::AppListBackground(int corner_radius,
28 views::View* search_box_view) 28 views::View* search_box_view)
29 : views::BubbleBorder2(views::BubbleBorder::BOTTOM_RIGHT), 29 : corner_radius_(corner_radius),
30 app_list_view_(app_list_view),
31 search_box_view_(search_box_view) { 30 search_box_view_(search_box_view) {
32 } 31 }
33 32
34 AppListBubbleBorder::~AppListBubbleBorder() { 33 AppListBackground::~AppListBackground() {
35 } 34 }
36 35
37 void AppListBubbleBorder::PaintBackground(gfx::Canvas* canvas, 36 void AppListBackground::Paint(gfx::Canvas* canvas,
38 const gfx::Rect& bounds) const { 37 views::View* view) const {
38 gfx::Rect bounds = view->GetContentsBounds();
39
40 canvas->Save();
41 SkPath path;
42 // Contents corner radius is 1px smaller than border corner radius.
43 SkScalar radius = SkIntToScalar(corner_radius_ - 1);
44 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius);
45 canvas->ClipPath(path);
46
39 SkPaint paint; 47 SkPaint paint;
40 paint.setStyle(SkPaint::kFill_Style); 48 paint.setStyle(SkPaint::kFill_Style);
41 49
42 // TODO(benwells): Get these details painting on Windows. 50 // TODO(benwells): Get these details painting on Windows.
43 #if !defined(OS_WIN) 51 #if !defined(OS_WIN)
44 const gfx::Rect search_box_view_bounds = 52 const gfx::Rect search_box_view_bounds =
45 app_list_view_->ConvertRectToWidget(search_box_view_->bounds()); 53 search_box_view_->ConvertRectToWidget(search_box_view_->GetLocalBounds());
46 gfx::Rect search_box_rect(bounds.x(), 54 gfx::Rect search_box_rect(bounds.x(),
47 bounds.y(), 55 bounds.y(),
48 bounds.width(), 56 bounds.width(),
49 search_box_view_bounds.bottom() - bounds.y()); 57 search_box_view_bounds.bottom() - bounds.y());
50 58
51 paint.setColor(kSearchBoxBackground); 59 paint.setColor(kSearchBoxBackground);
52 canvas->DrawRect(search_box_rect, paint); 60 canvas->DrawRect(search_box_rect, paint);
53 61
54 gfx::Rect seperator_rect(search_box_rect); 62 gfx::Rect seperator_rect(search_box_rect);
55 seperator_rect.set_y(seperator_rect.bottom()); 63 seperator_rect.set_y(seperator_rect.bottom());
56 seperator_rect.set_height(kTopSeparatorSize); 64 seperator_rect.set_height(kTopSeparatorSize);
57 canvas->FillRect(seperator_rect, kTopSeparatorColor); 65 canvas->FillRect(seperator_rect, kTopSeparatorColor);
58 66
59 gfx::Rect contents_rect(bounds.x(), 67 gfx::Rect contents_rect(bounds.x(),
60 seperator_rect.bottom(), 68 seperator_rect.bottom(),
61 bounds.width(), 69 bounds.width(),
62 bounds.bottom() - seperator_rect.bottom()); 70 bounds.bottom() - seperator_rect.bottom());
63 #else 71 #else
64 gfx::Rect contents_rect(bounds); 72 gfx::Rect contents_rect(bounds);
65 #endif 73 #endif
66 74
67 paint.setColor(kContentsBackgroundColor); 75 paint.setColor(kContentsBackgroundColor);
68 canvas->DrawRect(contents_rect, paint); 76 canvas->DrawRect(contents_rect, paint);
77 canvas->Restore();
69 } 78 }
70 79
71 } // namespace app_list 80 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/app_list_background.h ('k') | ui/app_list/app_list_bubble_border.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698