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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual void ButtonPressed(views::Button* sender, |
76 const ui::Event& event) OVERRIDE { | 76 const ui::Event& event) override { |
77 // Do nothing: remove these place holders. | 77 // Do nothing: remove these place holders. |
78 } | 78 } |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(PlaceHolderButton); | 80 DISALLOW_COPY_AND_ASSIGN(PlaceHolderButton); |
81 }; | 81 }; |
82 | 82 |
83 class AppIconButton : public views::ImageButton, | 83 class AppIconButton : public views::ImageButton, |
84 public views::ButtonListener { | 84 public views::ButtonListener { |
85 public: | 85 public: |
86 explicit AppIconButton(app_list::AppListItem* item) | 86 explicit AppIconButton(app_list::AppListItem* item) |
87 : ImageButton(this), | 87 : ImageButton(this), |
88 item_(item) { | 88 item_(item) { |
89 // TODO(mukai): icon should be resized. | 89 // TODO(mukai): icon should be resized. |
90 SetImage(STATE_NORMAL, &item->icon()); | 90 SetImage(STATE_NORMAL, &item->icon()); |
91 } | 91 } |
92 | 92 |
93 private: | 93 private: |
94 // views::ButtonListener: | 94 // views::ButtonListener: |
95 virtual void ButtonPressed(views::Button* sender, | 95 virtual void ButtonPressed(views::Button* sender, |
96 const ui::Event& event) OVERRIDE { | 96 const ui::Event& event) override { |
97 DCHECK_EQ(sender, this); | 97 DCHECK_EQ(sender, this); |
98 item_->Activate(event.flags()); | 98 item_->Activate(event.flags()); |
99 } | 99 } |
100 | 100 |
101 app_list::AppListItem* item_; | 101 app_list::AppListItem* item_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(AppIconButton); | 103 DISALLOW_COPY_AND_ASSIGN(AppIconButton); |
104 }; | 104 }; |
105 | 105 |
106 // The background to paint the round rectangle of the view area. | 106 // The background to paint the round rectangle of the view area. |
107 class RoundRectBackground : public views::Background { | 107 class RoundRectBackground : public views::Background { |
108 public: | 108 public: |
109 RoundRectBackground(SkColor color, int corner_radius) | 109 RoundRectBackground(SkColor color, int corner_radius) |
110 : color_(color), | 110 : color_(color), |
111 corner_radius_(corner_radius) {} | 111 corner_radius_(corner_radius) {} |
112 virtual ~RoundRectBackground() {} | 112 virtual ~RoundRectBackground() {} |
113 | 113 |
114 private: | 114 private: |
115 // views::Background: | 115 // views::Background: |
116 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { | 116 virtual void Paint(gfx::Canvas* canvas, views::View* view) const override { |
117 SkPaint paint; | 117 SkPaint paint; |
118 paint.setStyle(SkPaint::kFill_Style); | 118 paint.setStyle(SkPaint::kFill_Style); |
119 paint.setColor(color_); | 119 paint.setColor(color_); |
120 canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint); | 120 canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint); |
121 } | 121 } |
122 | 122 |
123 SkColor color_; | 123 SkColor color_; |
124 int corner_radius_; | 124 int corner_radius_; |
125 | 125 |
126 DISALLOW_COPY_AND_ASSIGN(RoundRectBackground); | 126 DISALLOW_COPY_AND_ASSIGN(RoundRectBackground); |
127 }; | 127 }; |
128 | 128 |
129 class SearchBoxContainer : public views::View { | 129 class SearchBoxContainer : public views::View { |
130 public: | 130 public: |
131 explicit SearchBoxContainer(app_list::SearchBoxView* search_box) | 131 explicit SearchBoxContainer(app_list::SearchBoxView* search_box) |
132 : search_box_(search_box) { | 132 : search_box_(search_box) { |
133 search_box->set_background( | 133 search_box->set_background( |
134 new RoundRectBackground(SK_ColorWHITE, kSearchBoxCornerRadius)); | 134 new RoundRectBackground(SK_ColorWHITE, kSearchBoxCornerRadius)); |
135 search_box->SetBorder(views::Border::CreateBorderPainter( | 135 search_box->SetBorder(views::Border::CreateBorderPainter( |
136 new views::RoundRectPainter(SK_ColorGRAY, kSearchBoxCornerRadius), | 136 new views::RoundRectPainter(SK_ColorGRAY, kSearchBoxCornerRadius), |
137 gfx::Insets(kSearchBoxBorderWidth, kSearchBoxBorderWidth, | 137 gfx::Insets(kSearchBoxBorderWidth, kSearchBoxBorderWidth, |
138 kSearchBoxBorderWidth, kSearchBoxBorderWidth))); | 138 kSearchBoxBorderWidth, kSearchBoxBorderWidth))); |
139 SetLayoutManager(new views::FillLayout()); | 139 SetLayoutManager(new views::FillLayout()); |
140 AddChildView(search_box_); | 140 AddChildView(search_box_); |
141 } | 141 } |
142 virtual ~SearchBoxContainer() {} | 142 virtual ~SearchBoxContainer() {} |
143 | 143 |
144 private: | 144 private: |
145 // views::View: | 145 // views::View: |
146 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 146 virtual gfx::Size GetPreferredSize() const override { |
147 return gfx::Size(kSearchBoxWidth, kSearchBoxHeight); | 147 return gfx::Size(kSearchBoxWidth, kSearchBoxHeight); |
148 } | 148 } |
149 | 149 |
150 // Owned by the views hierarchy. | 150 // Owned by the views hierarchy. |
151 app_list::SearchBoxView* search_box_; | 151 app_list::SearchBoxView* search_box_; |
152 | 152 |
153 DISALLOW_COPY_AND_ASSIGN(SearchBoxContainer); | 153 DISALLOW_COPY_AND_ASSIGN(SearchBoxContainer); |
154 }; | 154 }; |
155 | 155 |
156 } // namespace | 156 } // namespace |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 base::TrimWhitespace( | 432 base::TrimWhitespace( |
433 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); | 433 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); |
434 | 434 |
435 if (!query.empty()) | 435 if (!query.empty()) |
436 search_results_view_->SetSelectedIndex(0); | 436 search_results_view_->SetSelectedIndex(0); |
437 | 437 |
438 LayoutSearchResults(!query.empty()); | 438 LayoutSearchResults(!query.empty()); |
439 } | 439 } |
440 | 440 |
441 } // namespace athena | 441 } // namespace athena |
OLD | NEW |