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 "base/bind.h" | 8 #include "base/bind.h" |
8 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
9 #include "third_party/skia/include/core/SkPaint.h" | 10 #include "third_party/skia/include/core/SkPaint.h" |
10 #include "third_party/skia/include/core/SkPath.h" | 11 #include "third_party/skia/include/core/SkPath.h" |
11 #include "ui/app_list/app_list_item.h" | 12 #include "ui/app_list/app_list_item.h" |
12 #include "ui/app_list/app_list_item_list.h" | 13 #include "ui/app_list/app_list_item_list.h" |
13 #include "ui/app_list/app_list_model.h" | 14 #include "ui/app_list/app_list_model.h" |
14 #include "ui/app_list/app_list_view_delegate.h" | 15 #include "ui/app_list/app_list_view_delegate.h" |
15 #include "ui/app_list/search_box_model.h" | 16 #include "ui/app_list/search_box_model.h" |
16 #include "ui/app_list/views/search_box_view.h" | 17 #include "ui/app_list/views/search_box_view.h" |
(...skipping 18 matching lines...) Expand all Loading... |
35 | 36 |
36 // Copied from ui/app_list/views/start_page_view.cc | 37 // Copied from ui/app_list/views/start_page_view.cc |
37 const int kInstantContainerSpacing = 20; | 38 const int kInstantContainerSpacing = 20; |
38 const int kWebViewWidth = 500; | 39 const int kWebViewWidth = 500; |
39 const int kWebViewHeight = 105; | 40 const int kWebViewHeight = 105; |
40 const int kSearchBoxBorderWidth = 1; | 41 const int kSearchBoxBorderWidth = 1; |
41 const int kSearchBoxCornerRadius = 2; | 42 const int kSearchBoxCornerRadius = 2; |
42 const int kSearchBoxWidth = 490; | 43 const int kSearchBoxWidth = 490; |
43 const int kSearchBoxHeight = 40; | 44 const int kSearchBoxHeight = 40; |
44 | 45 |
45 // The preferred height for VISIBLE_BOTTOM state. | |
46 const int kPreferredHeightBottom = 100; | |
47 | |
48 class PlaceHolderButton : public views::ImageButton, | 46 class PlaceHolderButton : public views::ImageButton, |
49 public views::ButtonListener { | 47 public views::ButtonListener { |
50 public: | 48 public: |
51 PlaceHolderButton() | 49 PlaceHolderButton() |
52 : ImageButton(this) { | 50 : ImageButton(this) { |
53 gfx::Canvas canvas(gfx::Size(kIconSize, kIconSize), 1.0f, true); | 51 gfx::Canvas canvas(gfx::Size(kIconSize, kIconSize), 1.0f, true); |
54 SkPaint paint; | 52 SkPaint paint; |
55 paint.setStyle(SkPaint::kFill_Style); | 53 paint.setStyle(SkPaint::kFill_Style); |
56 paint.setColor(SkColorSetRGB(86, 119, 252)); | 54 paint.setColor(SkColorSetRGB(86, 119, 252)); |
57 paint.setFlags(SkPaint::kAntiAlias_Flag); | 55 paint.setFlags(SkPaint::kAntiAlias_Flag); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 205 |
208 void AthenaStartPageView::RequestFocusOnSearchBox() { | 206 void AthenaStartPageView::RequestFocusOnSearchBox() { |
209 search_box_view_->search_box()->RequestFocus(); | 207 search_box_view_->search_box()->RequestFocus(); |
210 } | 208 } |
211 | 209 |
212 void AthenaStartPageView::LayoutSearchResults(bool should_show_search_results) { | 210 void AthenaStartPageView::LayoutSearchResults(bool should_show_search_results) { |
213 if (should_show_search_results == | 211 if (should_show_search_results == |
214 search_results_view_->layer()->GetTargetVisibility()) { | 212 search_results_view_->layer()->GetTargetVisibility()) { |
215 return; | 213 return; |
216 } | 214 } |
217 if (GetContentsBounds().height() <= kPreferredHeightBottom) { | 215 if (GetContentsBounds().height() <= kHomeCardHeight) { |
218 search_results_view_->SetVisible(false); | 216 search_results_view_->SetVisible(false); |
219 Layout(); | 217 Layout(); |
220 return; | 218 return; |
221 } | 219 } |
222 | 220 |
223 gfx::Rect search_box_bounds = search_box_container_->bounds(); | 221 gfx::Rect search_box_bounds = search_box_container_->bounds(); |
224 if (!search_results_view_->visible()) { | 222 if (!search_results_view_->visible()) { |
225 search_results_view_->SetVisible(true); | 223 search_results_view_->SetVisible(true); |
226 search_results_view_->SetBounds( | 224 search_results_view_->SetBounds( |
227 search_box_bounds.x(), search_box_bounds.bottom(), | 225 search_box_bounds.x(), search_box_bounds.bottom(), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 void AthenaStartPageView::OnSearchResultLayoutAnimationCompleted( | 272 void AthenaStartPageView::OnSearchResultLayoutAnimationCompleted( |
275 bool should_show_search_results) { | 273 bool should_show_search_results) { |
276 logo_->SetVisible(!should_show_search_results); | 274 logo_->SetVisible(!should_show_search_results); |
277 search_results_view_->SetVisible(should_show_search_results); | 275 search_results_view_->SetVisible(should_show_search_results); |
278 } | 276 } |
279 | 277 |
280 void AthenaStartPageView::Layout() { | 278 void AthenaStartPageView::Layout() { |
281 gfx::Rect bounds = GetContentsBounds(); | 279 gfx::Rect bounds = GetContentsBounds(); |
282 search_results_view_->SetVisible(false); | 280 search_results_view_->SetVisible(false); |
283 | 281 |
284 if (bounds.height() <= kPreferredHeightBottom) { | 282 if (bounds.height() <= kHomeCardHeight) { |
285 logo_->SetVisible(false); | 283 logo_->SetVisible(false); |
286 gfx::Rect icon_bounds(app_icon_container_->GetPreferredSize()); | 284 gfx::Rect icon_bounds(app_icon_container_->GetPreferredSize()); |
287 icon_bounds.set_x(bounds.x() + kIconMargin); | 285 icon_bounds.set_x(bounds.x() + kIconMargin); |
288 icon_bounds.set_y(bounds.x() + kIconMargin); | 286 icon_bounds.set_y(bounds.x() + kIconMargin); |
289 app_icon_container_->SetBoundsRect(icon_bounds); | 287 app_icon_container_->SetBoundsRect(icon_bounds); |
290 | 288 |
291 gfx::Rect control_bounds(control_icon_container_->GetPreferredSize()); | 289 gfx::Rect control_bounds(control_icon_container_->GetPreferredSize()); |
292 control_bounds.set_x( | 290 control_bounds.set_x( |
293 bounds.right() - kIconMargin - control_bounds.width()); | 291 bounds.right() - kIconMargin - control_bounds.width()); |
294 control_bounds.set_y(bounds.y() + kIconMargin); | 292 control_bounds.set_y(bounds.y() + kIconMargin); |
295 control_icon_container_->SetBoundsRect(control_bounds); | 293 control_icon_container_->SetBoundsRect(control_bounds); |
296 | 294 |
297 search_box_container_->SetBounds( | 295 search_box_container_->SetBounds( |
298 icon_bounds.right(), bounds.y(), | 296 icon_bounds.right(), bounds.y(), |
299 control_bounds.x() - icon_bounds.right(), kPreferredHeightBottom); | 297 control_bounds.x() - icon_bounds.right(), kHomeCardHeight); |
300 | 298 |
301 set_background(views::Background::CreateSolidBackground( | 299 set_background(views::Background::CreateSolidBackground( |
302 255, 255, 255, 255 * 0.9)); | 300 255, 255, 255, 255 * 0.9)); |
303 } else { | 301 } else { |
304 // TODO(mukai): set the intermediate state. | 302 // TODO(mukai): set the intermediate state. |
305 logo_->SetVisible(true); | 303 logo_->SetVisible(true); |
306 logo_->layer()->SetOpacity(1.0f); | 304 logo_->layer()->SetOpacity(1.0f); |
307 set_background(views::Background::CreateSolidBackground(SK_ColorWHITE)); | 305 set_background(views::Background::CreateSolidBackground(SK_ColorWHITE)); |
308 gfx::Rect logo_bounds(bounds.x() + bounds.width() / 2 - kWebViewWidth / 2, | 306 gfx::Rect logo_bounds(bounds.x() + bounds.width() / 2 - kWebViewWidth / 2, |
309 bounds.y() + kTopMargin, | 307 bounds.y() + kTopMargin, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 base::TrimWhitespace( | 341 base::TrimWhitespace( |
344 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); | 342 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); |
345 | 343 |
346 if (!query.empty()) | 344 if (!query.empty()) |
347 search_results_view_->SetSelectedIndex(0); | 345 search_results_view_->SetSelectedIndex(0); |
348 | 346 |
349 LayoutSearchResults(!query.empty()); | 347 LayoutSearchResults(!query.empty()); |
350 } | 348 } |
351 | 349 |
352 } // namespace athena | 350 } // namespace athena |
OLD | NEW |