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

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

Issue 2588103004: Apply new WM shadows to app list. (Closed)
Patch Set: stop building app list on other platforms Created 3 years, 12 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
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/views/app_list_background.h"
6
7 #include "base/command_line.h"
8 #include "third_party/skia/include/core/SkPaint.h"
9 #include "third_party/skia/include/core/SkPath.h"
10 #include "ui/app_list/app_list_constants.h"
11 #include "ui/app_list/app_list_switches.h"
12 #include "ui/app_list/views/contents_view.h"
13 #include "ui/app_list/views/search_box_view.h"
14 #include "ui/gfx/canvas.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/skia_util.h"
17 #include "ui/views/view.h"
18
19 namespace app_list {
20
21 AppListBackground::AppListBackground(int corner_radius)
22 : corner_radius_(corner_radius) {
23 }
24
25 AppListBackground::~AppListBackground() {
26 }
27
28 void AppListBackground::Paint(gfx::Canvas* canvas,
29 views::View* view) const {
30 gfx::Rect bounds = view->GetContentsBounds();
31
32 if (corner_radius_ > 0) {
33 canvas->Save();
34 SkPath path;
35 // Contents corner radius is 1px smaller than border corner radius.
36 SkScalar radius = SkIntToScalar(corner_radius_ - 1);
37 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius);
38 canvas->ClipPath(path, false);
39 }
40
41 SkPaint paint;
42 paint.setStyle(SkPaint::kFill_Style);
43
44 int contents_top = bounds.y();
45 gfx::Rect contents_rect(bounds.x(),
46 contents_top,
47 bounds.width(),
48 bounds.bottom() - contents_top);
49
50 paint.setColor(kContentsBackgroundColor);
51 canvas->DrawRect(contents_rect, paint);
52
53 if (corner_radius_ > 0)
54 canvas->Restore();
55 }
56
57 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698