OLD | NEW |
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/views/app_list_background.h" | 5 #include "ui/app_list/views/app_list_background.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "third_party/skia/include/core/SkPaint.h" | 8 #include "third_party/skia/include/core/SkPaint.h" |
9 #include "third_party/skia/include/core/SkPath.h" | 9 #include "third_party/skia/include/core/SkPath.h" |
10 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
11 #include "ui/app_list/app_list_switches.h" | 11 #include "ui/app_list/app_list_switches.h" |
12 #include "ui/app_list/views/app_list_main_view.h" | 12 #include "ui/app_list/views/app_list_main_view.h" |
13 #include "ui/app_list/views/contents_view.h" | 13 #include "ui/app_list/views/contents_view.h" |
14 #include "ui/app_list/views/search_box_view.h" | 14 #include "ui/app_list/views/search_box_view.h" |
15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
17 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
18 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // Size of top separator between searchbox and grid view. | |
23 const int kTopSeparatorSize = 1; | |
24 | |
25 // Size of bottom separator between contents view and contents switcher. | 22 // Size of bottom separator between contents view and contents switcher. |
26 const int kBottomSeparatorSize = 1; | 23 const int kBottomSeparatorSize = 1; |
27 | 24 |
28 } // namespace | 25 } // namespace |
29 | 26 |
30 namespace app_list { | 27 namespace app_list { |
31 | 28 |
32 AppListBackground::AppListBackground(int corner_radius, | 29 AppListBackground::AppListBackground(int corner_radius, |
33 AppListMainView* main_view) | 30 AppListMainView* main_view) |
34 : corner_radius_(corner_radius), | 31 : corner_radius_(corner_radius), |
(...skipping 11 matching lines...) Expand all Loading... |
46 SkPath path; | 43 SkPath path; |
47 // Contents corner radius is 1px smaller than border corner radius. | 44 // Contents corner radius is 1px smaller than border corner radius. |
48 SkScalar radius = SkIntToScalar(corner_radius_ - 1); | 45 SkScalar radius = SkIntToScalar(corner_radius_ - 1); |
49 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); | 46 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); |
50 canvas->ClipPath(path, false); | 47 canvas->ClipPath(path, false); |
51 | 48 |
52 SkPaint paint; | 49 SkPaint paint; |
53 paint.setStyle(SkPaint::kFill_Style); | 50 paint.setStyle(SkPaint::kFill_Style); |
54 | 51 |
55 int contents_top = bounds.y(); | 52 int contents_top = bounds.y(); |
56 views::View* search_box_view = main_view_->search_box_view(); | |
57 if (main_view_->visible() && search_box_view->visible() && | |
58 !app_list::switches::IsExperimentalAppListEnabled()) { | |
59 const gfx::Rect search_box_view_bounds = | |
60 search_box_view->ConvertRectToWidget(search_box_view->GetLocalBounds()); | |
61 gfx::Rect search_box_rect(bounds.x(), | |
62 bounds.y(), | |
63 bounds.width(), | |
64 search_box_view_bounds.bottom() - bounds.y()); | |
65 | |
66 paint.setColor(kSearchBoxBackground); | |
67 canvas->DrawRect(search_box_rect, paint); | |
68 | |
69 gfx::Rect separator_rect(search_box_rect); | |
70 separator_rect.set_y(separator_rect.bottom()); | |
71 separator_rect.set_height(kTopSeparatorSize); | |
72 canvas->FillRect(separator_rect, kTopSeparatorColor); | |
73 contents_top = separator_rect.bottom(); | |
74 } | |
75 | |
76 gfx::Rect contents_rect(bounds.x(), | 53 gfx::Rect contents_rect(bounds.x(), |
77 contents_top, | 54 contents_top, |
78 bounds.width(), | 55 bounds.width(), |
79 bounds.bottom() - contents_top); | 56 bounds.bottom() - contents_top); |
80 | 57 |
81 paint.setColor(kContentsBackgroundColor); | 58 paint.setColor(kContentsBackgroundColor); |
82 canvas->DrawRect(contents_rect, paint); | 59 canvas->DrawRect(contents_rect, paint); |
83 | 60 |
84 if (app_list::switches::IsExperimentalAppListEnabled()) { | 61 if (app_list::switches::IsExperimentalAppListEnabled()) { |
85 if (main_view_->visible()) { | 62 if (main_view_->visible()) { |
86 views::View* contents_view = main_view_->contents_view(); | 63 views::View* contents_view = main_view_->contents_view(); |
87 const gfx::Rect contents_view_view_bounds = | 64 const gfx::Rect contents_view_view_bounds = |
88 contents_view->ConvertRectToWidget(contents_view->GetLocalBounds()); | 65 contents_view->ConvertRectToWidget(contents_view->GetLocalBounds()); |
89 gfx::Rect separator_rect(contents_rect); | 66 gfx::Rect separator_rect(contents_rect); |
90 separator_rect.Inset( | 67 separator_rect.Inset( |
91 kExperimentalWindowPadding + main_view_->GetInsets().left(), 0); | 68 kExperimentalWindowPadding + main_view_->GetInsets().left(), 0); |
92 separator_rect.set_y(contents_view_view_bounds.bottom() - 1); | 69 separator_rect.set_y(contents_view_view_bounds.bottom() - 1); |
93 separator_rect.set_height(kBottomSeparatorSize); | 70 separator_rect.set_height(kBottomSeparatorSize); |
94 canvas->FillRect(separator_rect, kBottomSeparatorColor); | 71 canvas->FillRect(separator_rect, kBottomSeparatorColor); |
95 } | 72 } |
96 } | 73 } |
97 | 74 |
98 canvas->Restore(); | 75 canvas->Restore(); |
99 } | 76 } |
100 | 77 |
101 } // namespace app_list | 78 } // namespace app_list |
OLD | NEW |