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

Side by Side Diff: ui/app_list/views/search_box_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.h ('k') | ui/app_list/views/search_result_page_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_box_view.h" 5 #include "ui/app_list/views/search_box_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/app_list/app_list_constants.h" 9 #include "ui/app_list/app_list_constants.h"
10 #include "ui/app_list/app_list_model.h" 10 #include "ui/app_list/app_list_model.h"
(...skipping 26 matching lines...) Expand all
37 const int kPreferredHeight = 48; 37 const int kPreferredHeight = 48;
38 38
39 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); 39 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0);
40 40
41 // Menu offset relative to the bottom-right corner of the menu button. 41 // Menu offset relative to the bottom-right corner of the menu button.
42 const int kMenuYOffsetFromButton = -4; 42 const int kMenuYOffsetFromButton = -4;
43 const int kMenuXOffsetFromButton = -7; 43 const int kMenuXOffsetFromButton = -7;
44 44
45 const int kBackgroundBorderCornerRadius = 2; 45 const int kBackgroundBorderCornerRadius = 2;
46 46
47 const int kShadowBlur = 4;
48 const int kShadowYOffset = 2;
49 const SkColor kShadowColor = SkColorSetARGB(0x33, 0, 0, 0);
50
51 // A background that paints a solid white rounded rect with a thin grey border. 47 // A background that paints a solid white rounded rect with a thin grey border.
52 class ExperimentalSearchBoxBackground : public views::Background { 48 class ExperimentalSearchBoxBackground : public views::Background {
53 public: 49 public:
54 ExperimentalSearchBoxBackground() {} 50 ExperimentalSearchBoxBackground() {}
55 ~ExperimentalSearchBoxBackground() override {} 51 ~ExperimentalSearchBoxBackground() override {}
56 52
57 private: 53 private:
58 // views::Background overrides: 54 // views::Background overrides:
59 void Paint(gfx::Canvas* canvas, views::View* view) const override { 55 void Paint(gfx::Canvas* canvas, views::View* view) const override {
60 gfx::Rect bounds = view->GetContentsBounds(); 56 gfx::Rect bounds = view->GetContentsBounds();
(...skipping 18 matching lines...) Expand all
79 icon_view_(NULL), 75 icon_view_(NULL),
80 back_button_(NULL), 76 back_button_(NULL),
81 speech_button_(NULL), 77 speech_button_(NULL),
82 menu_button_(NULL), 78 menu_button_(NULL),
83 search_box_(new views::Textfield), 79 search_box_(new views::Textfield),
84 contents_view_(NULL) { 80 contents_view_(NULL) {
85 SetLayoutManager(new views::FillLayout); 81 SetLayoutManager(new views::FillLayout);
86 AddChildView(content_container_); 82 AddChildView(content_container_);
87 83
88 if (switches::IsExperimentalAppListEnabled()) { 84 if (switches::IsExperimentalAppListEnabled()) {
89 SetBorder(make_scoped_ptr(new views::ShadowBorder(gfx::ShadowValue( 85 SetShadow(GetShadowForZHeight(1));
90 gfx::Point(0, kShadowYOffset), kShadowBlur, kShadowColor))));
91 back_button_ = new views::ImageButton(this); 86 back_button_ = new views::ImageButton(this);
92 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 87 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
93 back_button_->SetImage( 88 back_button_->SetImage(
94 views::ImageButton::STATE_NORMAL, 89 views::ImageButton::STATE_NORMAL,
95 rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL)); 90 rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL));
96 back_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, 91 back_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
97 views::ImageButton::ALIGN_MIDDLE); 92 views::ImageButton::ALIGN_MIDDLE);
98 content_container_->AddChildView(back_button_); 93 content_container_->AddChildView(back_button_);
99 94
100 content_container_->set_background(new ExperimentalSearchBoxBackground()); 95 content_container_->set_background(new ExperimentalSearchBoxBackground());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // Updates model and fires query changed manually because SetText() above 164 // Updates model and fires query changed manually because SetText() above
170 // does not generate ContentsChanged() notification. 165 // does not generate ContentsChanged() notification.
171 UpdateModel(); 166 UpdateModel();
172 NotifyQueryChanged(); 167 NotifyQueryChanged();
173 } 168 }
174 169
175 void SearchBoxView::InvalidateMenu() { 170 void SearchBoxView::InvalidateMenu() {
176 menu_.reset(); 171 menu_.reset();
177 } 172 }
178 173
174 void SearchBoxView::SetShadow(const gfx::ShadowValue& shadow) {
175 SetBorder(make_scoped_ptr(new views::ShadowBorder(shadow)));
176 Layout();
177 }
178
179 gfx::Rect SearchBoxView::GetViewBoundsForSearchBoxContentsBounds( 179 gfx::Rect SearchBoxView::GetViewBoundsForSearchBoxContentsBounds(
180 const gfx::Rect& rect) const { 180 const gfx::Rect& rect) const {
181 gfx::Rect view_bounds = rect; 181 gfx::Rect view_bounds = rect;
182 view_bounds.Inset(GetInsets().Scale(-1)); 182 view_bounds.Inset(-GetInsets());
183 return view_bounds; 183 return view_bounds;
184 } 184 }
185 185
186 gfx::Size SearchBoxView::GetPreferredSize() const { 186 gfx::Size SearchBoxView::GetPreferredSize() const {
187 return gfx::Size(kPreferredWidth, kPreferredHeight); 187 return gfx::Size(kPreferredWidth, kPreferredHeight);
188 } 188 }
189 189
190 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { 190 bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) {
191 if (contents_view_) 191 if (contents_view_)
192 return contents_view_->OnMouseWheel(event); 192 return contents_view_->OnMouseWheel(event);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 NotifyQueryChanged(); 305 NotifyQueryChanged();
306 } 306 }
307 307
308 void SearchBoxView::OnSpeechRecognitionStateChanged( 308 void SearchBoxView::OnSpeechRecognitionStateChanged(
309 SpeechRecognitionState new_state) { 309 SpeechRecognitionState new_state) {
310 SpeechRecognitionButtonPropChanged(); 310 SpeechRecognitionButtonPropChanged();
311 SchedulePaint(); 311 SchedulePaint();
312 } 312 }
313 313
314 } // namespace app_list 314 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/search_box_view.h ('k') | ui/app_list/views/search_result_page_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698