| 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/athena_start_page_view.h" | 5 #include "athena/home/athena_start_page_view.h" |
| 6 | 6 |
| 7 #include "athena/home/home_card_constants.h" | 7 #include "athena/home/home_card_constants.h" |
| 8 #include "athena/system/public/system_ui.h" | 8 #include "athena/system/public/system_ui.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 canvas.DrawCircle( | 65 canvas.DrawCircle( |
| 66 gfx::Point(kIconSize / 2, kIconSize / 2), kIconSize / 2, paint); | 66 gfx::Point(kIconSize / 2, kIconSize / 2), kIconSize / 2, paint); |
| 67 | 67 |
| 68 scoped_ptr<gfx::ImageSkia> image( | 68 scoped_ptr<gfx::ImageSkia> image( |
| 69 new gfx::ImageSkia(canvas.ExtractImageRep())); | 69 new gfx::ImageSkia(canvas.ExtractImageRep())); |
| 70 SetImage(STATE_NORMAL, image.get()); | 70 SetImage(STATE_NORMAL, image.get()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 // views::ButtonListener: | 74 // views::ButtonListener: |
| 75 virtual void ButtonPressed(views::Button* sender, | 75 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 76 const ui::Event& event) override { | |
| 77 // Do nothing: remove these place holders. | 76 // Do nothing: remove these place holders. |
| 78 } | 77 } |
| 79 | 78 |
| 80 DISALLOW_COPY_AND_ASSIGN(PlaceHolderButton); | 79 DISALLOW_COPY_AND_ASSIGN(PlaceHolderButton); |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 class AppIconButton : public views::ImageButton, | 82 class AppIconButton : public views::ImageButton, |
| 84 public views::ButtonListener { | 83 public views::ButtonListener { |
| 85 public: | 84 public: |
| 86 explicit AppIconButton(app_list::AppListItem* item) | 85 explicit AppIconButton(app_list::AppListItem* item) |
| 87 : ImageButton(this), item_(nullptr) { | 86 : ImageButton(this), item_(nullptr) { |
| 88 SetItem(item); | 87 SetItem(item); |
| 89 } | 88 } |
| 90 | 89 |
| 91 void SetItem(app_list::AppListItem* item) { | 90 void SetItem(app_list::AppListItem* item) { |
| 92 item_ = item; | 91 item_ = item; |
| 93 // TODO(mukai): icon should be resized. | 92 // TODO(mukai): icon should be resized. |
| 94 SetImage(STATE_NORMAL, &item->icon()); | 93 SetImage(STATE_NORMAL, &item->icon()); |
| 95 } | 94 } |
| 96 | 95 |
| 97 private: | 96 private: |
| 98 // views::ButtonListener: | 97 // views::ButtonListener: |
| 99 virtual void ButtonPressed(views::Button* sender, | 98 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 100 const ui::Event& event) override { | |
| 101 DCHECK_EQ(sender, this); | 99 DCHECK_EQ(sender, this); |
| 102 item_->Activate(event.flags()); | 100 item_->Activate(event.flags()); |
| 103 } | 101 } |
| 104 | 102 |
| 105 app_list::AppListItem* item_; | 103 app_list::AppListItem* item_; |
| 106 | 104 |
| 107 DISALLOW_COPY_AND_ASSIGN(AppIconButton); | 105 DISALLOW_COPY_AND_ASSIGN(AppIconButton); |
| 108 }; | 106 }; |
| 109 | 107 |
| 110 // The background to paint the round rectangle of the view area. | 108 // The background to paint the round rectangle of the view area. |
| 111 class RoundRectBackground : public views::Background { | 109 class RoundRectBackground : public views::Background { |
| 112 public: | 110 public: |
| 113 RoundRectBackground(SkColor color, int corner_radius) | 111 RoundRectBackground(SkColor color, int corner_radius) |
| 114 : color_(color), | 112 : color_(color), |
| 115 corner_radius_(corner_radius) {} | 113 corner_radius_(corner_radius) {} |
| 116 virtual ~RoundRectBackground() {} | 114 ~RoundRectBackground() override {} |
| 117 | 115 |
| 118 private: | 116 private: |
| 119 // views::Background: | 117 // views::Background: |
| 120 virtual void Paint(gfx::Canvas* canvas, views::View* view) const override { | 118 void Paint(gfx::Canvas* canvas, views::View* view) const override { |
| 121 SkPaint paint; | 119 SkPaint paint; |
| 122 paint.setStyle(SkPaint::kFill_Style); | 120 paint.setStyle(SkPaint::kFill_Style); |
| 123 paint.setColor(color_); | 121 paint.setColor(color_); |
| 124 canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint); | 122 canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint); |
| 125 } | 123 } |
| 126 | 124 |
| 127 SkColor color_; | 125 SkColor color_; |
| 128 int corner_radius_; | 126 int corner_radius_; |
| 129 | 127 |
| 130 DISALLOW_COPY_AND_ASSIGN(RoundRectBackground); | 128 DISALLOW_COPY_AND_ASSIGN(RoundRectBackground); |
| 131 }; | 129 }; |
| 132 | 130 |
| 133 class SearchBoxContainer : public views::View { | 131 class SearchBoxContainer : public views::View { |
| 134 public: | 132 public: |
| 135 explicit SearchBoxContainer(app_list::SearchBoxView* search_box) | 133 explicit SearchBoxContainer(app_list::SearchBoxView* search_box) |
| 136 : search_box_(search_box) { | 134 : search_box_(search_box) { |
| 137 search_box->set_background( | 135 search_box->set_background( |
| 138 new RoundRectBackground(SK_ColorWHITE, kSearchBoxCornerRadius)); | 136 new RoundRectBackground(SK_ColorWHITE, kSearchBoxCornerRadius)); |
| 139 search_box->SetBorder(views::Border::CreateBorderPainter( | 137 search_box->SetBorder(views::Border::CreateBorderPainter( |
| 140 new views::RoundRectPainter(SK_ColorGRAY, kSearchBoxCornerRadius), | 138 new views::RoundRectPainter(SK_ColorGRAY, kSearchBoxCornerRadius), |
| 141 gfx::Insets(kSearchBoxBorderWidth, kSearchBoxBorderWidth, | 139 gfx::Insets(kSearchBoxBorderWidth, kSearchBoxBorderWidth, |
| 142 kSearchBoxBorderWidth, kSearchBoxBorderWidth))); | 140 kSearchBoxBorderWidth, kSearchBoxBorderWidth))); |
| 143 SetLayoutManager(new views::FillLayout()); | 141 SetLayoutManager(new views::FillLayout()); |
| 144 AddChildView(search_box_); | 142 AddChildView(search_box_); |
| 145 } | 143 } |
| 146 virtual ~SearchBoxContainer() {} | 144 ~SearchBoxContainer() override {} |
| 147 | 145 |
| 148 private: | 146 private: |
| 149 // views::View: | 147 // views::View: |
| 150 virtual gfx::Size GetPreferredSize() const override { | 148 gfx::Size GetPreferredSize() const override { |
| 151 return gfx::Size(kSearchBoxWidth, kSearchBoxHeight); | 149 return gfx::Size(kSearchBoxWidth, kSearchBoxHeight); |
| 152 } | 150 } |
| 153 | 151 |
| 154 // Owned by the views hierarchy. | 152 // Owned by the views hierarchy. |
| 155 app_list::SearchBoxView* search_box_; | 153 app_list::SearchBoxView* search_box_; |
| 156 | 154 |
| 157 DISALLOW_COPY_AND_ASSIGN(SearchBoxContainer); | 155 DISALLOW_COPY_AND_ASSIGN(SearchBoxContainer); |
| 158 }; | 156 }; |
| 159 | 157 |
| 160 } // namespace | 158 } // namespace |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 app_list::AppListItem* item) { | 484 app_list::AppListItem* item) { |
| 487 UpdateAppIcons(); | 485 UpdateAppIcons(); |
| 488 } | 486 } |
| 489 | 487 |
| 490 // static | 488 // static |
| 491 size_t AthenaStartPageView::GetMaxIconNumForTest() { | 489 size_t AthenaStartPageView::GetMaxIconNumForTest() { |
| 492 return kMaxIconNum; | 490 return kMaxIconNum; |
| 493 } | 491 } |
| 494 | 492 |
| 495 } // namespace athena | 493 } // namespace athena |
| OLD | NEW |