OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/app_list/views/app_list_main_view.h" | 5 #include "ui/app_list/views/app_list_main_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "ui/app_list/app_list_constants.h" | 14 #include "ui/app_list/app_list_constants.h" |
15 #include "ui/app_list/app_list_folder_item.h" | 15 #include "ui/app_list/app_list_folder_item.h" |
16 #include "ui/app_list/app_list_item.h" | 16 #include "ui/app_list/app_list_item.h" |
17 #include "ui/app_list/app_list_model.h" | 17 #include "ui/app_list/app_list_model.h" |
18 #include "ui/app_list/app_list_switches.h" | 18 #include "ui/app_list/app_list_switches.h" |
19 #include "ui/app_list/app_list_view_delegate.h" | 19 #include "ui/app_list/app_list_view_delegate.h" |
20 #include "ui/app_list/pagination_model.h" | 20 #include "ui/app_list/pagination_model.h" |
21 #include "ui/app_list/search_box_model.h" | 21 #include "ui/app_list/search_box_model.h" |
22 #include "ui/app_list/views/app_list_folder_view.h" | 22 #include "ui/app_list/views/app_list_folder_view.h" |
23 #include "ui/app_list/views/app_list_item_view.h" | 23 #include "ui/app_list/views/app_list_item_view.h" |
24 #include "ui/app_list/views/apps_container_view.h" | 24 #include "ui/app_list/views/apps_container_view.h" |
25 #include "ui/app_list/views/apps_grid_view.h" | 25 #include "ui/app_list/views/apps_grid_view.h" |
26 #include "ui/app_list/views/contents_switcher_view.h" | 26 #include "ui/app_list/views/contents_switcher_view.h" |
27 #include "ui/app_list/views/contents_view.h" | 27 #include "ui/app_list/views/contents_view.h" |
28 #include "ui/app_list/views/search_box_view.h" | 28 #include "ui/app_list/views/search_box_view.h" |
| 29 #include "ui/views/border.h" |
29 #include "ui/views/controls/textfield/textfield.h" | 30 #include "ui/views/controls/textfield/textfield.h" |
30 #include "ui/views/layout/box_layout.h" | 31 #include "ui/views/layout/box_layout.h" |
31 #include "ui/views/layout/fill_layout.h" | 32 #include "ui/views/layout/fill_layout.h" |
32 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
33 | 34 |
34 namespace app_list { | 35 namespace app_list { |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 // Inner padding space in pixels of bubble contents. | 39 // Inner padding space in pixels of bubble contents. |
39 const int kInnerPadding = 1; | 40 const int kInnerPadding = 1; |
40 | 41 |
41 // The maximum allowed time to wait for icon loading in milliseconds. | 42 // The maximum allowed time to wait for icon loading in milliseconds. |
42 const int kMaxIconLoadingWaitTimeInMs = 50; | 43 const int kMaxIconLoadingWaitTimeInMs = 50; |
43 | 44 |
| 45 // The padding around the search box in the experimental app list. |
| 46 const int kSearchBoxViewPadding = 24; |
| 47 const int kSearchBoxViewPaddingBottom = 12; |
| 48 |
44 // A view that holds another view and takes its preferred size. This is used for | 49 // A view that holds another view and takes its preferred size. This is used for |
45 // wrapping the search box view so it still gets laid out while hidden. This is | 50 // wrapping the search box view so it still gets laid out while hidden. This is |
46 // a separate class so it can notify the main view on search box visibility | 51 // a separate class so it can notify the main view on search box visibility |
47 // change. | 52 // change. |
48 class SearchBoxContainerView : public views::View { | 53 class SearchBoxContainerView : public views::View { |
49 public: | 54 public: |
50 SearchBoxContainerView(AppListMainView* host, SearchBoxView* search_box) | 55 SearchBoxContainerView(AppListMainView* host, SearchBoxView* search_box) |
51 : host_(host), search_box_(search_box) { | 56 : host_(host), search_box_(search_box) { |
52 SetLayoutManager(new views::FillLayout()); | 57 SetLayoutManager(new views::FillLayout()); |
53 AddChildView(search_box); | 58 AddChildView(search_box); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 search_box_view_(NULL), | 122 search_box_view_(NULL), |
118 contents_view_(NULL), | 123 contents_view_(NULL), |
119 contents_switcher_view_(NULL), | 124 contents_switcher_view_(NULL), |
120 weak_ptr_factory_(this) { | 125 weak_ptr_factory_(this) { |
121 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, | 126 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, |
122 kInnerPadding, | 127 kInnerPadding, |
123 kInnerPadding, | 128 kInnerPadding, |
124 kInnerPadding)); | 129 kInnerPadding)); |
125 | 130 |
126 search_box_view_ = new SearchBoxView(this, delegate); | 131 search_box_view_ = new SearchBoxView(this, delegate); |
127 AddChildView(new SearchBoxContainerView(this, search_box_view_)); | 132 views::View* container = new SearchBoxContainerView(this, search_box_view_); |
| 133 if (switches::IsExperimentalAppListEnabled()) { |
| 134 container->SetBorder( |
| 135 views::Border::CreateEmptyBorder(kSearchBoxViewPadding, |
| 136 kSearchBoxViewPadding, |
| 137 kSearchBoxViewPaddingBottom, |
| 138 kSearchBoxViewPadding)); |
| 139 } |
| 140 AddChildView(container); |
128 AddContentsViews(); | 141 AddContentsViews(); |
129 | 142 |
130 // Switch the apps grid view to the specified page. | 143 // Switch the apps grid view to the specified page. |
131 app_list::PaginationModel* pagination_model = GetAppsPaginationModel(); | 144 app_list::PaginationModel* pagination_model = GetAppsPaginationModel(); |
132 if (pagination_model->is_valid_page(initial_apps_page)) | 145 if (pagination_model->is_valid_page(initial_apps_page)) |
133 pagination_model->SelectPage(initial_apps_page, false); | 146 pagination_model->SelectPage(initial_apps_page, false); |
134 | 147 |
135 // Starts icon loading early. | 148 // Starts icon loading early. |
136 PreloadIcons(parent); | 149 PreloadIcons(parent); |
137 } | 150 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 // Resubmit the query via a posted task so that all observers for the | 345 // Resubmit the query via a posted task so that all observers for the |
333 // uninstall notification are notified. | 346 // uninstall notification are notified. |
334 base::MessageLoop::current()->PostTask( | 347 base::MessageLoop::current()->PostTask( |
335 FROM_HERE, | 348 FROM_HERE, |
336 base::Bind(&AppListMainView::QueryChanged, | 349 base::Bind(&AppListMainView::QueryChanged, |
337 weak_ptr_factory_.GetWeakPtr(), | 350 weak_ptr_factory_.GetWeakPtr(), |
338 search_box_view_)); | 351 search_box_view_)); |
339 } | 352 } |
340 | 353 |
341 } // namespace app_list | 354 } // namespace app_list |
OLD | NEW |