| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "athena/home/bottom_home_view.h" | |
| 6 | |
| 7 #include "ui/app_list/app_list_item_list.h" | |
| 8 #include "ui/app_list/app_list_model.h" | |
| 9 #include "ui/app_list/app_list_view_delegate.h" | |
| 10 #include "ui/app_list/views/search_box_view.h" | |
| 11 #include "ui/app_list/views/tile_item_view.h" | |
| 12 #include "ui/gfx/canvas.h" | |
| 13 #include "ui/views/background.h" | |
| 14 #include "ui/views/border.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 | |
| 51 | |
| 52 namespace athena { | |
| 53 | |
| 54 BottomHomeView::BottomHomeView(app_list::AppListViewDelegate* view_delegate) | |
| 55 : view_delegate_(view_delegate) { | |
| 56 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | |
| 57 | |
| 58 app_list::AppListModel* model = view_delegate->GetModel(); | |
| 59 app_list::AppListItemList* top_level = model->top_level_item_list(); | |
| 60 | |
| 61 views::View* items_container = new views::View(); | |
| 62 AddChildView(items_container); | |
| 63 | |
| 64 views::BoxLayout* items_layout = new views::BoxLayout( | |
| 65 views::BoxLayout::kHorizontal, 0, 0, 0); | |
| 66 items_layout->SetDefaultFlex(1); | |
| 67 items_container->SetLayoutManager(items_layout); | |
| 68 for (size_t i = 0; i < top_level->item_count(); ++i) { | |
| 69 app_list::TileItemView* tile_item_view = new app_list::TileItemView(); | |
| 70 tile_item_view->SetAppListItem(top_level->item_at(i)); | |
| 71 items_container->AddChildView(tile_item_view); | |
| 72 tile_item_view->set_background(NULL); | |
| 73 } | |
| 74 | |
| 75 app_list::SearchBoxView* search_box = new app_list::SearchBoxView( | |
| 76 this, view_delegate); | |
| 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)); | |
| 82 } | |
| 83 | |
| 84 BottomHomeView::~BottomHomeView() {} | |
| 85 | |
| 86 void BottomHomeView::QueryChanged(app_list::SearchBoxView* sender) { | |
| 87 // Nothing needs to be done. | |
| 88 } | |
| 89 | |
| 90 } // namespace athena | |
| OLD | NEW |