| 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 "ui/app_list/views/search_result_tile_item_list_view.h" | 5 #include "ui/app_list/views/search_result_tile_item_list_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
| 11 #include "ui/app_list/app_list_features.h" | |
| 12 #include "ui/app_list/app_list_view_delegate.h" | 11 #include "ui/app_list/app_list_view_delegate.h" |
| 13 #include "ui/app_list/search_result.h" | 12 #include "ui/app_list/search_result.h" |
| 14 #include "ui/app_list/views/search_result_tile_item_view.h" | 13 #include "ui/app_list/views/search_result_tile_item_view.h" |
| 15 #include "ui/gfx/geometry/insets.h" | 14 #include "ui/gfx/geometry/insets.h" |
| 16 #include "ui/views/background.h" | 15 #include "ui/views/background.h" |
| 17 #include "ui/views/border.h" | 16 #include "ui/views/border.h" |
| 18 #include "ui/views/controls/textfield/textfield.h" | 17 #include "ui/views/controls/textfield/textfield.h" |
| 19 #include "ui/views/layout/box_layout.h" | 18 #include "ui/views/layout/box_layout.h" |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| 23 // Layout constants. | 22 // Layout constants. |
| 24 constexpr size_t kNumSearchResultTiles = 8; | 23 const size_t kNumSearchResultTiles = 8; |
| 25 constexpr int kHorizontalBorderSpacing = 1; | 24 const int kHorizontalBorderSpacing = 1; |
| 26 constexpr int kBetweenTileSpacing = 2; | 25 const int kBetweenTileSpacing = 2; |
| 27 constexpr int kTopBottomPadding = 8; | 26 const int kTopBottomPadding = 8; |
| 28 | |
| 29 // Layout constants used when fullscreen app list feature is enabled. | |
| 30 constexpr int kItemListVerticalSpacing = 16; | |
| 31 constexpr int kItemListHorizontalSpacing = 12; | |
| 32 constexpr int kBetweenItemSpacing = 8; | |
| 33 | 27 |
| 34 } // namespace | 28 } // namespace |
| 35 | 29 |
| 36 namespace app_list { | 30 namespace app_list { |
| 37 | 31 |
| 38 SearchResultTileItemListView::SearchResultTileItemListView( | 32 SearchResultTileItemListView::SearchResultTileItemListView( |
| 39 views::Textfield* search_box, | 33 views::Textfield* search_box, |
| 40 AppListViewDelegate* view_delegate) | 34 AppListViewDelegate* view_delegate) |
| 41 : search_box_(search_box), | 35 : search_box_(search_box) { |
| 42 is_fullscreen_app_list_enabled_(features::IsFullscreenAppListEnabled()) { | 36 SetLayoutManager(new views::BoxLayout( |
| 43 if (is_fullscreen_app_list_enabled_) { | 37 views::BoxLayout::kHorizontal, gfx::Insets(0, kHorizontalBorderSpacing), |
| 44 SetLayoutManager(new views::BoxLayout( | 38 kBetweenTileSpacing)); |
| 45 views::BoxLayout::kHorizontal, | |
| 46 gfx::Insets(kItemListVerticalSpacing, kItemListHorizontalSpacing), | |
| 47 kBetweenItemSpacing)); | |
| 48 } else { | |
| 49 SetLayoutManager(new views::BoxLayout( | |
| 50 views::BoxLayout::kHorizontal, gfx::Insets(0, kHorizontalBorderSpacing), | |
| 51 kBetweenTileSpacing)); | |
| 52 } | |
| 53 | 39 |
| 54 for (size_t i = 0; i < kNumSearchResultTiles; ++i) { | 40 for (size_t i = 0; i < kNumSearchResultTiles; ++i) { |
| 55 SearchResultTileItemView* tile_item = | 41 SearchResultTileItemView* tile_item = |
| 56 new SearchResultTileItemView(this, view_delegate); | 42 new SearchResultTileItemView(this, view_delegate); |
| 57 tile_item->SetParentBackgroundColor(kCardBackgroundColor); | 43 tile_item->SetParentBackgroundColor(kCardBackgroundColor); |
| 58 if (!is_fullscreen_app_list_enabled_) { | 44 tile_item->SetBorder( |
| 59 tile_item->SetBorder( | 45 views::CreateEmptyBorder(kTopBottomPadding, 0, kTopBottomPadding, 0)); |
| 60 views::CreateEmptyBorder(kTopBottomPadding, 0, kTopBottomPadding, 0)); | |
| 61 } | |
| 62 tile_views_.push_back(tile_item); | 46 tile_views_.push_back(tile_item); |
| 63 AddChildView(tile_item); | 47 AddChildView(tile_item); |
| 64 } | 48 } |
| 65 } | 49 } |
| 66 | 50 |
| 67 SearchResultTileItemListView::~SearchResultTileItemListView() { | 51 SearchResultTileItemListView::~SearchResultTileItemListView() { |
| 68 } | 52 } |
| 69 | 53 |
| 70 void SearchResultTileItemListView::OnContainerSelected( | 54 void SearchResultTileItemListView::OnContainerSelected( |
| 71 bool from_bottom, | 55 bool from_bottom, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 int selection_index = selected_index() + dir; | 139 int selection_index = selected_index() + dir; |
| 156 if (IsValidSelectionIndex(selection_index)) { | 140 if (IsValidSelectionIndex(selection_index)) { |
| 157 SetSelectedIndex(selection_index); | 141 SetSelectedIndex(selection_index); |
| 158 return true; | 142 return true; |
| 159 } | 143 } |
| 160 | 144 |
| 161 return false; | 145 return false; |
| 162 } | 146 } |
| 163 | 147 |
| 164 } // namespace app_list | 148 } // namespace app_list |
| OLD | NEW |