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 const int kSearchBoxWidth = kIconSize * 6 + kIconMargin * 7; |
oshima
2014/08/28 20:44:51
can you document this logic?
Jun Mukai
2014/08/28 21:55:36
Done.
| |
44 const int kSearchBoxHeight = 40; | 44 const int kSearchBoxHeight = 40; |
45 | 45 |
46 class PlaceHolderButton : public views::ImageButton, | 46 class PlaceHolderButton : public views::ImageButton, |
47 public views::ButtonListener { | 47 public views::ButtonListener { |
48 public: | 48 public: |
49 PlaceHolderButton() | 49 PlaceHolderButton() |
50 : ImageButton(this) { | 50 : ImageButton(this) { |
51 gfx::Canvas canvas(gfx::Size(kIconSize, kIconSize), 1.0f, true); | 51 gfx::Canvas canvas(gfx::Size(kIconSize, kIconSize), 1.0f, true); |
52 SkPaint paint; | 52 SkPaint paint; |
53 paint.setStyle(SkPaint::kFill_Style); | 53 paint.setStyle(SkPaint::kFill_Style); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 int width) { | 250 int width) { |
251 LayoutData state; | 251 LayoutData state; |
252 state.icons.set_size(app_icon_container_->size()); | 252 state.icons.set_size(app_icon_container_->size()); |
253 state.icons.set_x(kIconMargin); | 253 state.icons.set_x(kIconMargin); |
254 state.icons.set_y(kIconMargin); | 254 state.icons.set_y(kIconMargin); |
255 | 255 |
256 state.controls.set_size(control_icon_container_->size()); | 256 state.controls.set_size(control_icon_container_->size()); |
257 state.controls.set_x(width - kIconMargin - state.controls.width()); | 257 state.controls.set_x(width - kIconMargin - state.controls.width()); |
258 state.controls.set_y(kIconMargin); | 258 state.controls.set_y(kIconMargin); |
259 | 259 |
260 state.search_box.set_size(search_box_container_->size()); | 260 int search_box_max_width = |
261 state.controls.x() - state.icons.right() - kIconMargin * 2; | |
262 state.search_box.set_width(std::min(search_box_max_width, kSearchBoxWidth)); | |
263 state.search_box.set_height(search_box_container_->height()); | |
261 state.search_box.set_x((width - state.search_box.width()) / 2); | 264 state.search_box.set_x((width - state.search_box.width()) / 2); |
262 state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2); | 265 state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2); |
263 | 266 |
264 state.logo_opacity = 0.0f; | 267 state.logo_opacity = 0.0f; |
265 state.background_opacity = 0.9f; | 268 state.background_opacity = 0.9f; |
266 return state; | 269 return state; |
267 } | 270 } |
268 | 271 |
269 AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds( | 272 AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds( |
270 int width) { | 273 int width) { |
271 LayoutData state; | 274 LayoutData state; |
272 | 275 |
273 state.search_box.set_size(search_box_container_->size()); | 276 state.search_box.set_size(search_box_container_->GetPreferredSize()); |
274 state.search_box.set_x((width - state.search_box.width()) / 2); | 277 state.search_box.set_x((width - state.search_box.width()) / 2); |
275 state.search_box.set_y(logo_->bounds().bottom() + kInstantContainerSpacing); | 278 state.search_box.set_y(logo_->bounds().bottom() + kInstantContainerSpacing); |
276 | 279 |
277 state.icons.set_size(app_icon_container_->size()); | 280 state.icons.set_size(app_icon_container_->size()); |
278 state.icons.set_x(width / 2 - state.icons.width() - kIconMargin / 2); | 281 state.icons.set_x(width / 2 - state.icons.width() - kIconMargin / 2); |
279 state.icons.set_y(state.search_box.bottom() + kInstantContainerSpacing); | 282 state.icons.set_y(state.search_box.bottom() + kInstantContainerSpacing); |
280 | 283 |
281 state.controls.set_size(control_icon_container_->size()); | 284 state.controls.set_size(control_icon_container_->size()); |
282 state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2); | 285 state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2); |
283 state.controls.set_y(state.icons.y()); | 286 state.controls.set_y(state.icons.y()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 base::TrimWhitespace( | 398 base::TrimWhitespace( |
396 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); | 399 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); |
397 | 400 |
398 if (!query.empty()) | 401 if (!query.empty()) |
399 search_results_view_->SetSelectedIndex(0); | 402 search_results_view_->SetSelectedIndex(0); |
400 | 403 |
401 LayoutSearchResults(!query.empty()); | 404 LayoutSearchResults(!query.empty()); |
402 } | 405 } |
403 | 406 |
404 } // namespace athena | 407 } // namespace athena |
OLD | NEW |