Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Side by Side Diff: ui/app_list/views/search_result_page_view.cc

Issue 889593003: Animate the app list search box shadow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_animations
Patch Set: move GetShadowForZHeight to app_list_constants.cc Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/app_list/views/search_box_view.cc ('k') | ui/app_list/views/speech_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_page_view.h" 5 #include "ui/app_list/views/search_result_page_view.h"
6 6
7 #include "ui/app_list/app_list_constants.h" 7 #include "ui/app_list/app_list_constants.h"
8 #include "ui/app_list/app_list_switches.h" 8 #include "ui/app_list/app_list_switches.h"
9 #include "ui/app_list/app_list_view_delegate.h" 9 #include "ui/app_list/app_list_view_delegate.h"
10 #include "ui/app_list/views/app_list_main_view.h" 10 #include "ui/app_list/views/app_list_main_view.h"
11 #include "ui/app_list/views/search_box_view.h"
11 #include "ui/app_list/views/search_result_list_view.h" 12 #include "ui/app_list/views/search_result_list_view.h"
12 #include "ui/app_list/views/search_result_tile_item_list_view.h" 13 #include "ui/app_list/views/search_result_tile_item_list_view.h"
13 #include "ui/gfx/shadow_value.h" 14 #include "ui/gfx/shadow_value.h"
14 #include "ui/views/background.h" 15 #include "ui/views/background.h"
15 #include "ui/views/layout/box_layout.h" 16 #include "ui/views/layout/box_layout.h"
16 #include "ui/views/layout/fill_layout.h" 17 #include "ui/views/layout/fill_layout.h"
17 #include "ui/views/shadow_border.h" 18 #include "ui/views/shadow_border.h"
18 19
19 namespace app_list { 20 namespace app_list {
20 21
21 namespace { 22 namespace {
22 23
23 const int kGroupSpacing = 20; 24 const int kGroupSpacing = 20;
24 const int kTopPadding = 5; 25 const int kTopPadding = 5;
25 26
26 // A container view that ensures the card background and the shadow are painted 27 // A container view that ensures the card background and the shadow are painted
27 // in the correct order. 28 // in the correct order.
28 class SearchCardView : public views::View { 29 class SearchCardView : public views::View {
29 public: 30 public:
30 explicit SearchCardView(views::View* content_view) { 31 explicit SearchCardView(views::View* content_view) {
31 SetBorder(make_scoped_ptr(new views::ShadowBorder( 32 SetBorder(make_scoped_ptr(new views::ShadowBorder(GetShadowForZHeight(1))));
32 gfx::ShadowValue(gfx::Point(0, kCardShadowYOffset), kCardShadowBlur,
33 kCardShadowColor))));
34 SetLayoutManager(new views::FillLayout()); 33 SetLayoutManager(new views::FillLayout());
35 content_view->set_background( 34 content_view->set_background(
36 views::Background::CreateSolidBackground(kCardBackgroundColor)); 35 views::Background::CreateSolidBackground(kCardBackgroundColor));
37 AddChildView(content_view); 36 AddChildView(content_view);
38 } 37 }
39 38
40 ~SearchCardView() override {} 39 ~SearchCardView() override {}
41 40
42 void ChildPreferredSizeChanged(views::View* child) override { 41 void ChildPreferredSizeChanged(views::View* child) override {
43 Layout(); 42 Layout();
44 PreferredSizeChanged(); 43 PreferredSizeChanged();
45 } 44 }
46 }; 45 };
47 46
48 } // namespace 47 } // namespace
49 48
50 SearchResultPageView::SearchResultPageView() : selected_index_(0) { 49 SearchResultPageView::SearchResultPageView() : selected_index_(0) {
51 if (switches::IsExperimentalAppListEnabled()) { 50 if (switches::IsExperimentalAppListEnabled()) {
52 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 51 gfx::ShadowValue shadow = GetShadowForZHeight(1);
53 kExperimentalWindowPadding, 52 scoped_ptr<views::Border> border(new views::ShadowBorder(shadow));
54 kTopPadding, kGroupSpacing)); 53
54 gfx::Insets insets = gfx::Insets(kTopPadding, kExperimentalWindowPadding, 0,
55 kExperimentalWindowPadding);
56 insets += -border->GetInsets();
57
58 views::BoxLayout* layout =
59 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, kGroupSpacing);
60 layout->set_inside_border_insets(insets);
61
62 SetLayoutManager(layout);
55 } else { 63 } else {
56 SetLayoutManager(new views::FillLayout); 64 SetLayoutManager(new views::FillLayout);
57 } 65 }
58 } 66 }
59 67
60 SearchResultPageView::~SearchResultPageView() { 68 SearchResultPageView::~SearchResultPageView() {
61 } 69 }
62 70
63 void SearchResultPageView::AddSearchResultContainerView( 71 void SearchResultPageView::AddSearchResultContainerView(
64 AppListModel::SearchResults* results_model, 72 AppListModel::SearchResults* results_model,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return index >= 0 && index < static_cast<int>(result_container_views_.size()); 129 return index >= 0 && index < static_cast<int>(result_container_views_.size());
122 } 130 }
123 131
124 void SearchResultPageView::ChildPreferredSizeChanged(views::View* child) { 132 void SearchResultPageView::ChildPreferredSizeChanged(views::View* child) {
125 DCHECK(!result_container_views_.empty()); 133 DCHECK(!result_container_views_.empty());
126 Layout(); 134 Layout();
127 SetSelectedIndex(0); 135 SetSelectedIndex(0);
128 } 136 }
129 137
130 } // namespace app_list 138 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/search_box_view.cc ('k') | ui/app_list/views/speech_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698