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

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

Issue 11784034: Skeleton for app_list on OSX, and refactoring for enable_app_list=1 on OS=="mac". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase for 175876 and 175961 Created 7 years, 11 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
« no previous file with comments | « ui/app_list/app_list_background.h ('k') | ui/app_list/app_list_item_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/app_list/app_list_background.h"
6
7 #include "third_party/skia/include/core/SkPaint.h"
8 #include "third_party/skia/include/core/SkPath.h"
9 #include "ui/app_list/app_list_constants.h"
10 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/rect.h"
12 #include "ui/gfx/skia_util.h"
13 #include "ui/views/view.h"
14
15 namespace {
16
17 const SkColor kSearchBoxBackground = SK_ColorWHITE;
18
19 // Colors and sizes of top separator between searchbox and grid view.
20 const SkColor kTopSeparatorColor = SkColorSetRGB(0xE5, 0xE5, 0xE5);
21 const int kTopSeparatorSize = 1;
22
23 } // namespace
24
25 namespace app_list {
26
27 AppListBackground::AppListBackground(int corner_radius,
28 views::View* search_box_view)
29 : corner_radius_(corner_radius),
30 search_box_view_(search_box_view) {
31 }
32
33 AppListBackground::~AppListBackground() {
34 }
35
36 void AppListBackground::Paint(gfx::Canvas* canvas,
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
47 SkPaint paint;
48 paint.setStyle(SkPaint::kFill_Style);
49
50 const gfx::Rect search_box_view_bounds =
51 search_box_view_->ConvertRectToWidget(search_box_view_->GetLocalBounds());
52 gfx::Rect search_box_rect(bounds.x(),
53 bounds.y(),
54 bounds.width(),
55 search_box_view_bounds.bottom() - bounds.y());
56
57 paint.setColor(kSearchBoxBackground);
58 canvas->DrawRect(search_box_rect, paint);
59
60 gfx::Rect seperator_rect(search_box_rect);
61 seperator_rect.set_y(seperator_rect.bottom());
62 seperator_rect.set_height(kTopSeparatorSize);
63 canvas->FillRect(seperator_rect, kTopSeparatorColor);
64
65 gfx::Rect contents_rect(bounds.x(),
66 seperator_rect.bottom(),
67 bounds.width(),
68 bounds.bottom() - seperator_rect.bottom());
69
70 paint.setColor(kContentsBackgroundColor);
71 canvas->DrawRect(contents_rect, paint);
72 canvas->Restore();
73 }
74
75 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/app_list_background.h ('k') | ui/app_list/app_list_item_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698