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 "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "third_party/skia/include/core/SkPaint.h" | 10 #include "third_party/skia/include/core/SkPaint.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 const int kIconMargin = 25; | 33 const int kIconMargin = 25; |
34 | 34 |
35 const int kTopMargin = 100; | 35 const int kTopMargin = 100; |
36 | 36 |
37 // Copied from ui/app_list/views/start_page_view.cc | 37 // Copied from ui/app_list/views/start_page_view.cc |
38 const int kInstantContainerSpacing = 20; | 38 const int kInstantContainerSpacing = 20; |
39 const int kWebViewWidth = 500; | 39 const int kWebViewWidth = 500; |
40 const int kWebViewHeight = 105; | 40 const int kWebViewHeight = 105; |
41 const int kSearchBoxBorderWidth = 1; | 41 const int kSearchBoxBorderWidth = 1; |
42 const int kSearchBoxCornerRadius = 2; | 42 const int kSearchBoxCornerRadius = 2; |
43 const int kSearchBoxWidth = 490; | 43 |
| 44 // Taken from the mock. The width is not specified by pixel but the search box |
| 45 // covers 6 icons with margin. |
| 46 const int kSearchBoxWidth = kIconSize * 6 + kIconMargin * 7; |
44 const int kSearchBoxHeight = 40; | 47 const int kSearchBoxHeight = 40; |
45 | 48 |
46 class PlaceHolderButton : public views::ImageButton, | 49 class PlaceHolderButton : public views::ImageButton, |
47 public views::ButtonListener { | 50 public views::ButtonListener { |
48 public: | 51 public: |
49 PlaceHolderButton() | 52 PlaceHolderButton() |
50 : ImageButton(this) { | 53 : ImageButton(this) { |
51 gfx::Canvas canvas(gfx::Size(kIconSize, kIconSize), 1.0f, true); | 54 gfx::Canvas canvas(gfx::Size(kIconSize, kIconSize), 1.0f, true); |
52 SkPaint paint; | 55 SkPaint paint; |
53 paint.setStyle(SkPaint::kFill_Style); | 56 paint.setStyle(SkPaint::kFill_Style); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 int width) { | 254 int width) { |
252 LayoutData state; | 255 LayoutData state; |
253 state.icons.set_size(app_icon_container_->size()); | 256 state.icons.set_size(app_icon_container_->size()); |
254 state.icons.set_x(kIconMargin); | 257 state.icons.set_x(kIconMargin); |
255 state.icons.set_y(kIconMargin); | 258 state.icons.set_y(kIconMargin); |
256 | 259 |
257 state.controls.set_size(control_icon_container_->size()); | 260 state.controls.set_size(control_icon_container_->size()); |
258 state.controls.set_x(width - kIconMargin - state.controls.width()); | 261 state.controls.set_x(width - kIconMargin - state.controls.width()); |
259 state.controls.set_y(kIconMargin); | 262 state.controls.set_y(kIconMargin); |
260 | 263 |
261 state.search_box.set_size(search_box_container_->size()); | 264 int search_box_max_width = |
| 265 state.controls.x() - state.icons.right() - kIconMargin * 2; |
| 266 state.search_box.set_width(std::min(search_box_max_width, kSearchBoxWidth)); |
| 267 state.search_box.set_height(search_box_container_->height()); |
262 state.search_box.set_x((width - state.search_box.width()) / 2); | 268 state.search_box.set_x((width - state.search_box.width()) / 2); |
263 state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2); | 269 state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2); |
264 | 270 |
265 state.logo_opacity = 0.0f; | 271 state.logo_opacity = 0.0f; |
266 state.background_opacity = 0.9f; | 272 state.background_opacity = 0.9f; |
267 return state; | 273 return state; |
268 } | 274 } |
269 | 275 |
270 AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds( | 276 AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds( |
271 int width) { | 277 int width) { |
272 LayoutData state; | 278 LayoutData state; |
273 | 279 |
274 state.search_box.set_size(search_box_container_->size()); | 280 state.search_box.set_size(search_box_container_->GetPreferredSize()); |
275 state.search_box.set_x((width - state.search_box.width()) / 2); | 281 state.search_box.set_x((width - state.search_box.width()) / 2); |
276 state.search_box.set_y(logo_->bounds().bottom() + kInstantContainerSpacing); | 282 state.search_box.set_y(logo_->bounds().bottom() + kInstantContainerSpacing); |
277 | 283 |
278 state.icons.set_size(app_icon_container_->size()); | 284 state.icons.set_size(app_icon_container_->size()); |
279 state.icons.set_x(width / 2 - state.icons.width() - kIconMargin / 2); | 285 state.icons.set_x(width / 2 - state.icons.width() - kIconMargin / 2); |
280 state.icons.set_y(state.search_box.bottom() + kInstantContainerSpacing); | 286 state.icons.set_y(state.search_box.bottom() + kInstantContainerSpacing); |
281 | 287 |
282 state.controls.set_size(control_icon_container_->size()); | 288 state.controls.set_size(control_icon_container_->size()); |
283 state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2); | 289 state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2); |
284 state.controls.set_y(state.icons.y()); | 290 state.controls.set_y(state.icons.y()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 base::TrimWhitespace( | 402 base::TrimWhitespace( |
397 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); | 403 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); |
398 | 404 |
399 if (!query.empty()) | 405 if (!query.empty()) |
400 search_results_view_->SetSelectedIndex(0); | 406 search_results_view_->SetSelectedIndex(0); |
401 | 407 |
402 LayoutSearchResults(!query.empty()); | 408 LayoutSearchResults(!query.empty()); |
403 } | 409 } |
404 | 410 |
405 } // namespace athena | 411 } // namespace athena |
OLD | NEW |