OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/home/bottom_home_view.h" | 5 #include "athena/home/bottom_home_view.h" |
6 | 6 |
7 #include "ui/app_list/app_list_item_list.h" | 7 #include "ui/app_list/app_list_item_list.h" |
8 #include "ui/app_list/app_list_model.h" | 8 #include "ui/app_list/app_list_model.h" |
9 #include "ui/app_list/app_list_view_delegate.h" | 9 #include "ui/app_list/app_list_view_delegate.h" |
10 #include "ui/app_list/views/search_box_view.h" | 10 #include "ui/app_list/views/search_box_view.h" |
11 #include "ui/app_list/views/tile_item_view.h" | 11 #include "ui/app_list/views/tile_item_view.h" |
| 12 #include "ui/gfx/canvas.h" |
12 #include "ui/views/background.h" | 13 #include "ui/views/background.h" |
13 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
14 #include "ui/views/layout/box_layout.h" | 15 #include "ui/views/layout/box_layout.h" |
| 16 #include "ui/views/painter.h" |
| 17 #include "ui/views/shadow_border.h" |
| 18 |
| 19 namespace { |
| 20 |
| 21 class BottomHomeBackground : public views::Background { |
| 22 public: |
| 23 explicit BottomHomeBackground(views::View* search_box) |
| 24 : search_box_(search_box), |
| 25 painter_(views::Painter::CreateVerticalGradient( |
| 26 SkColorSetA(SK_ColorWHITE, 0x7f), |
| 27 SK_ColorWHITE)) {} |
| 28 virtual ~BottomHomeBackground() {} |
| 29 |
| 30 private: |
| 31 // views::Background: |
| 32 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { |
| 33 CHECK_EQ(view, search_box_->parent()); |
| 34 views::Painter::PaintPainterAt( |
| 35 canvas, |
| 36 painter_.get(), |
| 37 gfx::Rect(0, 0, view->width(), search_box_->y())); |
| 38 canvas->FillRect(gfx::Rect(0, |
| 39 search_box_->y(), |
| 40 view->width(), |
| 41 view->height() - search_box_->y()), |
| 42 SK_ColorWHITE); |
| 43 } |
| 44 |
| 45 views::View* search_box_; |
| 46 scoped_ptr<views::Painter> painter_; |
| 47 DISALLOW_COPY_AND_ASSIGN(BottomHomeBackground); |
| 48 }; |
| 49 |
| 50 } // namespace |
15 | 51 |
16 namespace athena { | 52 namespace athena { |
17 | 53 |
18 BottomHomeView::BottomHomeView(app_list::AppListViewDelegate* view_delegate) | 54 BottomHomeView::BottomHomeView(app_list::AppListViewDelegate* view_delegate) |
19 : view_delegate_(view_delegate) { | 55 : view_delegate_(view_delegate) { |
20 set_background(views::Background::CreateSolidBackground(SK_ColorWHITE)); | 56 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
21 SetBorder(views::Border::CreateSolidBorder(1, SK_ColorBLACK)); | |
22 SetLayoutManager(new views::BoxLayout( | |
23 views::BoxLayout::kVertical, 0, 0, 0)); | |
24 | 57 |
25 app_list::AppListModel* model = view_delegate->GetModel(); | 58 app_list::AppListModel* model = view_delegate->GetModel(); |
26 app_list::AppListItemList* top_level = model->top_level_item_list(); | 59 app_list::AppListItemList* top_level = model->top_level_item_list(); |
27 | 60 |
28 views::View* items_container = new views::View(); | 61 views::View* items_container = new views::View(); |
29 AddChildView(items_container); | 62 AddChildView(items_container); |
30 | 63 |
31 views::BoxLayout* items_layout = new views::BoxLayout( | 64 views::BoxLayout* items_layout = new views::BoxLayout( |
32 views::BoxLayout::kHorizontal, 0, 0, 0); | 65 views::BoxLayout::kHorizontal, 0, 0, 0); |
33 items_layout->SetDefaultFlex(1); | 66 items_layout->SetDefaultFlex(1); |
34 items_container->SetLayoutManager(items_layout); | 67 items_container->SetLayoutManager(items_layout); |
35 for (size_t i = 0; i < top_level->item_count(); ++i) { | 68 for (size_t i = 0; i < top_level->item_count(); ++i) { |
36 app_list::TileItemView* tile_item_view = new app_list::TileItemView(); | 69 app_list::TileItemView* tile_item_view = new app_list::TileItemView(); |
37 tile_item_view->SetAppListItem(top_level->item_at(i)); | 70 tile_item_view->SetAppListItem(top_level->item_at(i)); |
38 items_container->AddChildView(tile_item_view); | 71 items_container->AddChildView(tile_item_view); |
| 72 tile_item_view->set_background(NULL); |
39 } | 73 } |
40 | 74 |
41 app_list::SearchBoxView* search_box = new app_list::SearchBoxView( | 75 app_list::SearchBoxView* search_box = new app_list::SearchBoxView( |
42 this, view_delegate); | 76 this, view_delegate); |
43 AddChildView(search_box); | 77 AddChildView(search_box); |
| 78 search_box->SetBorder( |
| 79 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, SK_ColorGRAY)); |
| 80 |
| 81 set_background(new BottomHomeBackground(search_box)); |
44 } | 82 } |
45 | 83 |
46 BottomHomeView::~BottomHomeView() {} | 84 BottomHomeView::~BottomHomeView() {} |
47 | 85 |
48 void BottomHomeView::QueryChanged(app_list::SearchBoxView* sender) { | 86 void BottomHomeView::QueryChanged(app_list::SearchBoxView* sender) { |
49 // Nothing needs to be done. | 87 // Nothing needs to be done. |
50 } | 88 } |
51 | 89 |
52 } // namespace athena | 90 } // namespace athena |
OLD | NEW |