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

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

Issue 657653002: Move app list search box into AppListView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month 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
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/app_list_view.h" 5 #include "ui/app_list/views/app_list_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/win/windows_version.h" 12 #include "base/win/windows_version.h"
13 #include "ui/app_list/app_list_constants.h" 13 #include "ui/app_list/app_list_constants.h"
14 #include "ui/app_list/app_list_model.h" 14 #include "ui/app_list/app_list_model.h"
15 #include "ui/app_list/app_list_switches.h" 15 #include "ui/app_list/app_list_switches.h"
16 #include "ui/app_list/app_list_view_delegate.h" 16 #include "ui/app_list/app_list_view_delegate.h"
17 #include "ui/app_list/speech_ui_model.h" 17 #include "ui/app_list/speech_ui_model.h"
18 #include "ui/app_list/views/app_list_background.h" 18 #include "ui/app_list/views/app_list_background.h"
19 #include "ui/app_list/views/app_list_folder_view.h" 19 #include "ui/app_list/views/app_list_folder_view.h"
20 #include "ui/app_list/views/app_list_main_view.h" 20 #include "ui/app_list/views/app_list_main_view.h"
21 #include "ui/app_list/views/app_list_view_observer.h" 21 #include "ui/app_list/views/app_list_view_observer.h"
22 #include "ui/app_list/views/apps_container_view.h" 22 #include "ui/app_list/views/apps_container_view.h"
23 #include "ui/app_list/views/contents_view.h" 23 #include "ui/app_list/views/contents_view.h"
24 #include "ui/app_list/views/search_box_view.h"
25 #include "ui/app_list/views/speech_view.h" 24 #include "ui/app_list/views/speech_view.h"
26 #include "ui/app_list/views/start_page_view.h" 25 #include "ui/app_list/views/start_page_view.h"
27 #include "ui/base/ui_base_switches.h" 26 #include "ui/base/ui_base_switches.h"
28 #include "ui/compositor/layer.h" 27 #include "ui/compositor/layer.h"
29 #include "ui/compositor/layer_animation_observer.h" 28 #include "ui/compositor/layer_animation_observer.h"
30 #include "ui/compositor/scoped_layer_animation_settings.h" 29 #include "ui/compositor/scoped_layer_animation_settings.h"
31 #include "ui/gfx/canvas.h" 30 #include "ui/gfx/canvas.h"
32 #include "ui/gfx/image/image_skia.h" 31 #include "ui/gfx/image/image_skia.h"
33 #include "ui/gfx/insets.h" 32 #include "ui/gfx/insets.h"
34 #include "ui/gfx/path.h" 33 #include "ui/gfx/path.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 143
145 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); 144 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver);
146 }; 145 };
147 146
148 //////////////////////////////////////////////////////////////////////////////// 147 ////////////////////////////////////////////////////////////////////////////////
149 // AppListView: 148 // AppListView:
150 149
151 AppListView::AppListView(AppListViewDelegate* delegate) 150 AppListView::AppListView(AppListViewDelegate* delegate)
152 : delegate_(delegate), 151 : delegate_(delegate),
153 app_list_main_view_(NULL), 152 app_list_main_view_(NULL),
153 search_box_view_(NULL),
154 speech_view_(NULL), 154 speech_view_(NULL),
155 experimental_banner_view_(NULL), 155 experimental_banner_view_(NULL),
156 overlay_view_(NULL), 156 overlay_view_(NULL),
157 animation_observer_(new HideViewAnimationObserver()) { 157 animation_observer_(new HideViewAnimationObserver()) {
158 CHECK(delegate); 158 CHECK(delegate);
159 159
160 delegate_->AddObserver(this); 160 delegate_->AddObserver(this);
161 delegate_->GetSpeechUI()->AddObserver(this); 161 delegate_->GetSpeechUI()->AddObserver(this);
162 } 162 }
163 163
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 views::BubbleBorder::Arrow arrow, 325 views::BubbleBorder::Arrow arrow,
326 bool border_accepts_events, 326 bool border_accepts_events,
327 const gfx::Vector2d& anchor_offset) { 327 const gfx::Vector2d& anchor_offset) {
328 base::Time start_time = base::Time::Now(); 328 base::Time start_time = base::Time::Now();
329 329
330 app_list_main_view_ = new AppListMainView(delegate_); 330 app_list_main_view_ = new AppListMainView(delegate_);
331 AddChildView(app_list_main_view_); 331 AddChildView(app_list_main_view_);
332 app_list_main_view_->SetPaintToLayer(true); 332 app_list_main_view_->SetPaintToLayer(true);
333 app_list_main_view_->SetFillsBoundsOpaquely(false); 333 app_list_main_view_->SetFillsBoundsOpaquely(false);
334 app_list_main_view_->layer()->SetMasksToBounds(true); 334 app_list_main_view_->layer()->SetMasksToBounds(true);
335 app_list_main_view_->Init(parent, initial_apps_page); 335
336 search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_);
337 search_box_view_->SetPaintToLayer(true);
338 search_box_view_->SetFillsBoundsOpaquely(false);
339 search_box_view_->layer()->SetMasksToBounds(true);
340 AddChildView(search_box_view_);
341
342 app_list_main_view_->Init(parent, initial_apps_page, search_box_view_);
336 343
337 // Speech recognition is available only when the start page exists. 344 // Speech recognition is available only when the start page exists.
338 if (delegate_ && delegate_->IsSpeechRecognitionEnabled()) { 345 if (delegate_ && delegate_->IsSpeechRecognitionEnabled()) {
339 speech_view_ = new SpeechView(delegate_); 346 speech_view_ = new SpeechView(delegate_);
340 speech_view_->SetVisible(false); 347 speech_view_->SetVisible(false);
341 speech_view_->SetPaintToLayer(true); 348 speech_view_->SetPaintToLayer(true);
342 speech_view_->SetFillsBoundsOpaquely(false); 349 speech_view_->SetFillsBoundsOpaquely(false);
343 speech_view_->layer()->SetOpacity(0.0f); 350 speech_view_->layer()->SetOpacity(0.0f);
344 AddChildView(speech_view_); 351 AddChildView(speech_view_);
345 } 352 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 GetWidget()->Deactivate(); 493 GetWidget()->Deactivate();
487 Close(); 494 Close();
488 } 495 }
489 return true; 496 return true;
490 } 497 }
491 498
492 return false; 499 return false;
493 } 500 }
494 501
495 void AppListView::Layout() { 502 void AppListView::Layout() {
503 search_box_view_->SetBoundsRect(
504 app_list_main_view_->contents_view()->GetDefaultSearchBoxBounds());
505
496 const gfx::Rect contents_bounds = GetContentsBounds(); 506 const gfx::Rect contents_bounds = GetContentsBounds();
497 app_list_main_view_->SetBoundsRect(contents_bounds); 507 app_list_main_view_->SetBoundsRect(contents_bounds);
498 508
499 if (speech_view_) { 509 if (speech_view_) {
500 gfx::Rect speech_bounds = contents_bounds; 510 gfx::Rect speech_bounds = contents_bounds;
501 int preferred_height = speech_view_->GetPreferredSize().height(); 511 int preferred_height = speech_view_->GetPreferredSize().height();
502 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin); 512 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin);
503 speech_bounds.set_height(std::min(speech_bounds.height(), 513 speech_bounds.set_height(std::min(speech_bounds.height(),
504 preferred_height)); 514 preferred_height));
505 speech_bounds.Inset(-speech_view_->GetInsets()); 515 speech_bounds.Inset(-speech_view_->GetInsets());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 speech_view_->layer()->SetTransform(speech_transform); 605 speech_view_->layer()->SetTransform(speech_transform);
596 } 606 }
597 607
598 if (will_appear) 608 if (will_appear)
599 speech_view_->SetVisible(true); 609 speech_view_->SetVisible(true);
600 else 610 else
601 app_list_main_view_->SetVisible(true); 611 app_list_main_view_->SetVisible(true);
602 } 612 }
603 613
604 } // namespace app_list 614 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698