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 // The search box spans horizontally over the 6 icons (3 apps icon and 3 control | |
45 // icons) with margins. | |
oshima
2014/08/29 17:47:18
can you update the comment as discussed offline?
Jun Mukai
2014/08/29 18:36:29
Done.
| |
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 int width) { | 253 int width) { |
251 LayoutData state; | 254 LayoutData state; |
252 state.icons.set_size(app_icon_container_->size()); | 255 state.icons.set_size(app_icon_container_->size()); |
253 state.icons.set_x(kIconMargin); | 256 state.icons.set_x(kIconMargin); |
254 state.icons.set_y(kIconMargin); | 257 state.icons.set_y(kIconMargin); |
255 | 258 |
256 state.controls.set_size(control_icon_container_->size()); | 259 state.controls.set_size(control_icon_container_->size()); |
257 state.controls.set_x(width - kIconMargin - state.controls.width()); | 260 state.controls.set_x(width - kIconMargin - state.controls.width()); |
258 state.controls.set_y(kIconMargin); | 261 state.controls.set_y(kIconMargin); |
259 | 262 |
260 state.search_box.set_size(search_box_container_->size()); | 263 int search_box_max_width = |
264 state.controls.x() - state.icons.right() - kIconMargin * 2; | |
265 state.search_box.set_width(std::min(search_box_max_width, kSearchBoxWidth)); | |
266 state.search_box.set_height(search_box_container_->height()); | |
261 state.search_box.set_x((width - state.search_box.width()) / 2); | 267 state.search_box.set_x((width - state.search_box.width()) / 2); |
262 state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2); | 268 state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2); |
263 | 269 |
264 state.logo_opacity = 0.0f; | 270 state.logo_opacity = 0.0f; |
265 state.background_opacity = 0.9f; | 271 state.background_opacity = 0.9f; |
266 return state; | 272 return state; |
267 } | 273 } |
268 | 274 |
269 AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds( | 275 AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds( |
270 int width) { | 276 int width) { |
271 LayoutData state; | 277 LayoutData state; |
272 | 278 |
273 state.search_box.set_size(search_box_container_->size()); | 279 state.search_box.set_size(search_box_container_->GetPreferredSize()); |
274 state.search_box.set_x((width - state.search_box.width()) / 2); | 280 state.search_box.set_x((width - state.search_box.width()) / 2); |
275 state.search_box.set_y(logo_->bounds().bottom() + kInstantContainerSpacing); | 281 state.search_box.set_y(logo_->bounds().bottom() + kInstantContainerSpacing); |
276 | 282 |
277 state.icons.set_size(app_icon_container_->size()); | 283 state.icons.set_size(app_icon_container_->size()); |
278 state.icons.set_x(width / 2 - state.icons.width() - kIconMargin / 2); | 284 state.icons.set_x(width / 2 - state.icons.width() - kIconMargin / 2); |
279 state.icons.set_y(state.search_box.bottom() + kInstantContainerSpacing); | 285 state.icons.set_y(state.search_box.bottom() + kInstantContainerSpacing); |
280 | 286 |
281 state.controls.set_size(control_icon_container_->size()); | 287 state.controls.set_size(control_icon_container_->size()); |
282 state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2); | 288 state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2); |
283 state.controls.set_y(state.icons.y()); | 289 state.controls.set_y(state.icons.y()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 base::TrimWhitespace( | 401 base::TrimWhitespace( |
396 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); | 402 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); |
397 | 403 |
398 if (!query.empty()) | 404 if (!query.empty()) |
399 search_results_view_->SetSelectedIndex(0); | 405 search_results_view_->SetSelectedIndex(0); |
400 | 406 |
401 LayoutSearchResults(!query.empty()); | 407 LayoutSearchResults(!query.empty()); |
402 } | 408 } |
403 | 409 |
404 } // namespace athena | 410 } // namespace athena |
OLD | NEW |