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

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

Issue 2898743002: Draggable peeking/fullscreen launcher with transparent background. (Closed)
Patch Set: manually resolve merge conflict. Created 3 years, 6 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/app_list_view.h ('k') | ui/app_list/views/contents_view.h » ('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/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/macros.h" 10 #include "base/macros.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "ui/wm/core/masked_window_targeter.h" 49 #include "ui/wm/core/masked_window_targeter.h"
50 #include "ui/wm/core/shadow_types.h" 50 #include "ui/wm/core/shadow_types.h"
51 51
52 namespace app_list { 52 namespace app_list {
53 53
54 namespace { 54 namespace {
55 55
56 // The margin from the edge to the speech UI. 56 // The margin from the edge to the speech UI.
57 const int kSpeechUIMargin = 12; 57 const int kSpeechUIMargin = 12;
58 58
59 // The height/width of the shelf.
60 const int kShelfSize = 48;
61
62 // The height of the peeking launcher.
63 const int kPeekingLauncherHeight = 320;
64 // The fraction of launcher height that the launcher must be released at in
65 // order to transition to the next state.
66 const int kLauncherThresholdDenominator = 3;
67 // The velocity the launcher must be dragged in order to transition to the next
68 // state, measured in DIPs/event.
69 const int kLauncherDragVelocityThreshold = 25;
70
71 const float kLauncherOpacity = 0.8;
72
59 // The vertical position for the appearing animation of the speech UI. 73 // The vertical position for the appearing animation of the speech UI.
60 const float kSpeechUIAppearingPosition = 12; 74 const float kSpeechUIAppearingPosition = 12;
61 75
62 // This view forwards the focus to the search box widget by providing it as a 76 // This view forwards the focus to the search box widget by providing it as a
63 // FocusTraversable when a focus search is provided. 77 // FocusTraversable when a focus search is provided.
64 class SearchBoxFocusHost : public views::View { 78 class SearchBoxFocusHost : public views::View {
65 public: 79 public:
66 explicit SearchBoxFocusHost(views::Widget* search_box_widget) 80 explicit SearchBoxFocusHost(views::Widget* search_box_widget)
67 : search_box_widget_(search_box_widget) {} 81 : search_box_widget_(search_box_widget) {}
68 82
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 //////////////////////////////////////////////////////////////////////////////// 182 ////////////////////////////////////////////////////////////////////////////////
169 // AppListView: 183 // AppListView:
170 184
171 AppListView::AppListView(AppListViewDelegate* delegate) 185 AppListView::AppListView(AppListViewDelegate* delegate)
172 : delegate_(delegate), 186 : delegate_(delegate),
173 app_list_main_view_(nullptr), 187 app_list_main_view_(nullptr),
174 speech_view_(nullptr), 188 speech_view_(nullptr),
175 search_box_focus_host_(nullptr), 189 search_box_focus_host_(nullptr),
176 search_box_widget_(nullptr), 190 search_box_widget_(nullptr),
177 search_box_view_(nullptr), 191 search_box_view_(nullptr),
192 display_observer_(this),
178 overlay_view_(nullptr), 193 overlay_view_(nullptr),
179 animation_observer_(new HideViewAnimationObserver()) { 194 animation_observer_(new HideViewAnimationObserver()) {
180 CHECK(delegate); 195 CHECK(delegate);
181 196
182 delegate_->GetSpeechUI()->AddObserver(this); 197 delegate_->GetSpeechUI()->AddObserver(this);
198
199 if (features::IsFullscreenAppListEnabled())
200 display_observer_.Add(display::Screen::GetScreen());
183 } 201 }
184 202
185 AppListView::~AppListView() { 203 AppListView::~AppListView() {
204 // Remove this instance from the DisplayManager's list of observers.
205 if (features::IsFullscreenAppListEnabled())
206 display_observer_.Remove(display::Screen::GetScreen());
207
186 delegate_->GetSpeechUI()->RemoveObserver(this); 208 delegate_->GetSpeechUI()->RemoveObserver(this);
187 animation_observer_.reset(); 209 animation_observer_.reset();
188 // Remove child views first to ensure no remaining dependencies on delegate_. 210 // Remove child views first to ensure no remaining dependencies on delegate_.
189 RemoveAllChildViews(true); 211 RemoveAllChildViews(true);
190 } 212 }
191 213
192 void AppListView::Initialize(gfx::NativeView parent, int initial_apps_page) { 214 void AppListView::Initialize(gfx::NativeView parent, int initial_apps_page) {
193 base::Time start_time = base::Time::Now(); 215 base::Time start_time = base::Time::Now();
194 InitContents(parent, initial_apps_page); 216 InitContents(parent, initial_apps_page);
195 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); 217 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
196 set_color(kContentsBackgroundColor); 218 set_color(kContentsBackgroundColor);
197 set_parent_window(parent); 219 set_parent_window(parent);
198 220
199 if (features::IsFullscreenAppListEnabled()) 221 if (features::IsFullscreenAppListEnabled())
200 InitializeFullscreen(parent, initial_apps_page); 222 InitializeFullscreen(parent, initial_apps_page);
201 else 223 else
202 InitializeBubble(parent, initial_apps_page); 224 InitializeBubble(parent, initial_apps_page);
203 225
204 InitChildWidgets(); 226 InitChildWidgets();
205 AddChildView(overlay_view_); 227 AddChildView(overlay_view_);
228
206 if (delegate_) 229 if (delegate_)
207 delegate_->ViewInitialized(); 230 delegate_->ViewInitialized();
231
208 UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime", 232 UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime",
209 base::Time::Now() - start_time); 233 base::Time::Now() - start_time);
210 } 234 }
211 235
212 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { 236 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) {
213 GetBubbleFrameView()->bubble_border()->set_arrow(arrow); 237 GetBubbleFrameView()->bubble_border()->set_arrow(arrow);
214 SizeToContents(); // Recalcuates with new border. 238 SizeToContents(); // Recalcuates with new border.
215 GetBubbleFrameView()->SchedulePaint(); 239 GetBubbleFrameView()->SchedulePaint();
216 } 240 }
217 241
(...skipping 12 matching lines...) Expand all
230 app_list_main_view_->ShowAppListWhenReady(); 254 app_list_main_view_->ShowAppListWhenReady();
231 } 255 }
232 256
233 void AppListView::CloseAppList() { 257 void AppListView::CloseAppList() {
234 app_list_main_view_->Close(); 258 app_list_main_view_->Close();
235 delegate_->Dismiss(); 259 delegate_->Dismiss();
236 } 260 }
237 261
238 void AppListView::UpdateBounds() { 262 void AppListView::UpdateBounds() {
239 // if the AppListView is a bubble 263 // if the AppListView is a bubble
240 if (!features::IsFullscreenAppListEnabled()) 264 if (!launcher_background_shield_)
241 SizeToContents(); 265 SizeToContents();
242 } 266 }
243 267
268 void AppListView::UpdateDimensions() {
269 display_work_area_bounds_ = display::Screen::GetScreen()
270 ->GetDisplayNearestView(parent_window())
271 .work_area();
272 default_peeking_launcher_y_ =
273 display_work_area_bounds_.height() + kShelfSize - kPeekingLauncherHeight;
274 }
275
244 void AppListView::SetAppListOverlayVisible(bool visible) { 276 void AppListView::SetAppListOverlayVisible(bool visible) {
245 DCHECK(overlay_view_); 277 DCHECK(overlay_view_);
246 278
247 // Display the overlay immediately so we can begin the animation. 279 // Display the overlay immediately so we can begin the animation.
248 overlay_view_->SetVisible(true); 280 overlay_view_->SetVisible(true);
249 281
250 ui::ScopedLayerAnimationSettings settings( 282 ui::ScopedLayerAnimationSettings settings(
251 overlay_view_->layer()->GetAnimator()); 283 overlay_view_->layer()->GetAnimator());
252 settings.SetTweenType(gfx::Tween::LINEAR); 284 settings.SetTweenType(gfx::Tween::LINEAR);
253 285
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 ->pagination_model(); 355 ->pagination_model();
324 } 356 }
325 357
326 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) { 358 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) {
327 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and 359 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and
328 // crbug.com/441028 are fixed. 360 // crbug.com/441028 are fixed.
329 tracked_objects::ScopedTracker tracking_profile( 361 tracked_objects::ScopedTracker tracking_profile(
330 FROM_HERE_WITH_EXPLICIT_FUNCTION( 362 FROM_HERE_WITH_EXPLICIT_FUNCTION(
331 "440224, 441028 AppListView::InitContents")); 363 "440224, 441028 AppListView::InitContents"));
332 364
333 app_list_main_view_ = new AppListMainView(delegate_); 365 if (features::IsFullscreenAppListEnabled()) {
366 // The shield view that colors the background of the launcher and makes it
367 // transparent.
368 launcher_background_shield_ = new views::View;
369 launcher_background_shield_->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
370 launcher_background_shield_->layer()->SetColor(SK_ColorBLACK);
371 launcher_background_shield_->layer()->SetOpacity(kLauncherOpacity);
372 AddChildView(launcher_background_shield_);
373 }
374 app_list_main_view_ = new AppListMainView(delegate_, this);
334 AddChildView(app_list_main_view_); 375 AddChildView(app_list_main_view_);
335 app_list_main_view_->SetPaintToLayer(); 376 app_list_main_view_->SetPaintToLayer();
336 app_list_main_view_->layer()->SetFillsBoundsOpaquely(false); 377 app_list_main_view_->layer()->SetFillsBoundsOpaquely(false);
337 app_list_main_view_->layer()->SetMasksToBounds(true); 378 app_list_main_view_->layer()->SetMasksToBounds(true);
338 // This will be added to the |search_box_widget_| after the app list widget is 379 // This will be added to the |search_box_widget_| after the app list widget is
339 // initialized. 380 // initialized.
340 search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_); 381 search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_);
382 search_box_view_->SetAppListView(this);
vadimt 2017/05/26 17:58:55 Constructor parameter, const field.
newcomer 2017/05/26 23:20:22 Done.
341 search_box_view_->SetPaintToLayer(); 383 search_box_view_->SetPaintToLayer();
342 search_box_view_->layer()->SetFillsBoundsOpaquely(false); 384 search_box_view_->layer()->SetFillsBoundsOpaquely(false);
343 search_box_view_->layer()->SetMasksToBounds(true); 385 search_box_view_->layer()->SetMasksToBounds(true);
344 386
345 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and 387 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and
346 // crbug.com/441028 are fixed. 388 // crbug.com/441028 are fixed.
347 tracked_objects::ScopedTracker tracking_profile1( 389 tracked_objects::ScopedTracker tracking_profile1(
348 FROM_HERE_WITH_EXPLICIT_FUNCTION( 390 FROM_HERE_WITH_EXPLICIT_FUNCTION(
349 "440224, 441028 AppListView::InitContents1")); 391 "440224, 441028 AppListView::InitContents1"));
350 392
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // Mouse events on the search box shadow should not be captured. 439 // Mouse events on the search box shadow should not be captured.
398 aura::Window* window = search_box_widget_->GetNativeWindow(); 440 aura::Window* window = search_box_widget_->GetNativeWindow();
399 window->SetEventTargeter( 441 window->SetEventTargeter(
400 base::MakeUnique<SearchBoxWindowTargeter>(search_box_view_)); 442 base::MakeUnique<SearchBoxWindowTargeter>(search_box_view_));
401 443
402 app_list_main_view_->contents_view()->Layout(); 444 app_list_main_view_->contents_view()->Layout();
403 } 445 }
404 446
405 void AppListView::InitializeFullscreen(gfx::NativeView parent, 447 void AppListView::InitializeFullscreen(gfx::NativeView parent,
406 int initial_apps_page) { 448 int initial_apps_page) {
407 views::Widget* widget = new views::Widget; 449 UpdateDimensions();
450
451 gfx::Rect app_list_overlay_view_bounds(
452 display_work_area_bounds_.x(), default_peeking_launcher_y_,
453 display_work_area_bounds_.width(),
454 display_work_area_bounds_.height() + kShelfSize);
455
456 fullscreen_widget_ = new views::Widget;
408 views::Widget::InitParams app_list_overlay_view_params( 457 views::Widget::InitParams app_list_overlay_view_params(
409 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 458 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
410 459
460 app_list_overlay_view_params.name = "AppList";
411 app_list_overlay_view_params.parent = parent; 461 app_list_overlay_view_params.parent = parent;
412 app_list_overlay_view_params.delegate = this; 462 app_list_overlay_view_params.delegate = this;
413 app_list_overlay_view_params.opacity = 463 app_list_overlay_view_params.opacity =
414 views::Widget::InitParams::TRANSLUCENT_WINDOW; 464 views::Widget::InitParams::TRANSLUCENT_WINDOW;
415 app_list_overlay_view_params.bounds = 465 app_list_overlay_view_params.bounds = app_list_overlay_view_bounds;
416 display::Screen::GetScreen()-> 466 app_list_overlay_view_params.layer_type = ui::LAYER_SOLID_COLOR;
417 GetDisplayNearestView(parent).work_area(); 467 fullscreen_widget_->Init(app_list_overlay_view_params);
418 widget->Init(app_list_overlay_view_params);
419 widget->GetLayer()->SetBackgroundBlur(10);
420 468
469 fullscreen_widget_bounds_ = fullscreen_widget_->GetWindowBoundsInScreen();
421 overlay_view_ = new AppListOverlayView(0 /* no corners */); 470 overlay_view_ = new AppListOverlayView(0 /* no corners */);
471
472 // Launcher + shelf height, used in HandleDrag.
473 launcher_threshold_ =
474 (default_peeking_launcher_y_ + fullscreen_widget_bounds_.height() -
475 fullscreen_widget_bounds_.y()) /
476 kLauncherThresholdDenominator;
422 } 477 }
423 478
424 void AppListView::InitializeBubble(gfx::NativeView parent, 479 void AppListView::InitializeBubble(gfx::NativeView parent,
425 int initial_apps_page) { 480 int initial_apps_page) {
426 set_margins(gfx::Insets()); 481 set_margins(gfx::Insets());
427 set_close_on_deactivate(false); 482 set_close_on_deactivate(false);
428 set_shadow(views::BubbleBorder::NO_ASSETS); 483 set_shadow(views::BubbleBorder::NO_ASSETS);
429 484
430 // This creates the app list widget. (Before this, child widgets cannot be 485 // This creates the app list widget. (Before this, child widgets cannot be
431 // created.) 486 // created.
432 views::BubbleDialogDelegateView::CreateBubble(this); 487 views::BubbleDialogDelegateView::CreateBubble(this);
433 488
434 SetBubbleArrow(views::BubbleBorder::FLOAT); 489 SetBubbleArrow(views::BubbleBorder::FLOAT);
435 // We can now create the internal widgets. 490 // We can now create the internal widgets.
436 491
437 aura::Window* window = GetWidget()->GetNativeWindow(); 492 aura::Window* window = GetWidget()->GetNativeWindow();
438 window->SetEventTargeter(base::MakeUnique<views::BubbleWindowTargeter>(this)); 493 window->SetEventTargeter(base::MakeUnique<views::BubbleWindowTargeter>(this));
439 494
440 const int kOverlayCornerRadius = 495 const int kOverlayCornerRadius =
441 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); 496 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius();
442 overlay_view_ = new AppListOverlayView(kOverlayCornerRadius); 497 overlay_view_ = new AppListOverlayView(kOverlayCornerRadius);
443 overlay_view_->SetBoundsRect(GetContentsBounds()); 498 overlay_view_->SetBoundsRect(GetContentsBounds());
444 } 499 }
445 500
501 void AppListView::HandleDrag(gfx::Point location, ui::EventType type) {
502 switch (type) {
503 case ui::ET_GESTURE_SCROLL_BEGIN:
504 case ui::ET_MOUSE_PRESSED: {
505 // Drag start, grab the initial_drag_separation_ to maintain the relative
506 // position of the top of the widget and the mouse/gesture.
507 initial_drag_separation_ = location.y();
508 fullscreen_widget_bounds_ = fullscreen_widget_->GetWindowBoundsInScreen();
509 break;
510 }
511 case ui::ET_GESTURE_SCROLL_UPDATE:
512 case ui::ET_MOUSE_DRAGGED: {
513 // Drag update, update the bounds of the widget while maintaining the
514 // relative position of the top of the widget and the mouse/gesture.
515 // Block drags north of 0 and recalculate the initial_drag_separation_.
516 int new_y_position = location.y() - initial_drag_separation_ +
517 fullscreen_widget_bounds_.y();
518 if (new_y_position < 0) {
519 fullscreen_widget_bounds_.set_y(0);
520 initial_drag_separation_ = location.y();
521 } else {
522 fullscreen_widget_bounds_.set_y(new_y_position);
523 }
524 fullscreen_widget_->SetBounds(fullscreen_widget_bounds_);
525 break;
526 }
527
528 case ui::ET_GESTURE_END:
529 case ui::ET_MOUSE_RELEASED: {
530 // Drag completion, either snap to fullscreen or close the App List based
531 // on where the drag ended. If fling velocity was over the threshold, snap
532 // to the next state in the direction of the fling.
533 int new_y_position = location.y() - initial_drag_separation_ +
534 fullscreen_widget_bounds_.y();
535 if (std::abs(last_fling_velocity_) > kLauncherDragVelocityThreshold) {
536 // If the user releases drag with velocity over the threshold, snap to
537 // the next state, ignoring the drag release position.
538 if (is_fullscreen_launcher_) {
539 if (last_fling_velocity_ > 0) {
540 ToPeeking();
541 }
542 } else {
543 if (last_fling_velocity_ > 0) {
544 CloseAppList();
545 } else if (last_fling_velocity_ < 0) {
546 ToFullscreen();
547 }
548 }
549 last_fling_velocity_ = 0;
550 } else {
551 // The drag release velocity was too low, so use the release point.
552 int launcher_snap_y =
553 is_fullscreen_launcher_ ? 0 : default_peeking_launcher_y_;
554 // If the user releases +/- 1/3 of launcher_threshold_ , snap to the
555 // next state.
556 if (std::abs(launcher_snap_y - new_y_position) <
557 (launcher_threshold_)) {
558 // If the drag released to the state above.
559 if (is_fullscreen_launcher_) {
560 ToFullscreen();
561 } else {
562 ToPeeking();
563 }
564 } else if ((launcher_snap_y + (launcher_threshold_)) < new_y_position) {
565 // If the user released to the state below.
566 if (is_fullscreen_launcher_) {
567 ToPeeking();
568 } else {
569 CloseAppList();
570 }
571 } else {
572 // if the user released to the state above, go to the state above.
573 ToFullscreen();
574 }
575 }
576 break;
577 }
578 default:
579 NOTREACHED();
580 break;
581 }
582 }
583
446 void AppListView::OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, 584 void AppListView::OnBeforeBubbleWidgetInit(views::Widget::InitParams* params,
447 views::Widget* widget) const { 585 views::Widget* widget) const {
448 if (!params->native_widget) { 586 if (!params->native_widget) {
449 views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance(); 587 views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance();
450 if (views_delegate && !views_delegate->native_widget_factory().is_null()) { 588 if (views_delegate && !views_delegate->native_widget_factory().is_null()) {
451 params->native_widget = 589 params->native_widget =
452 views_delegate->native_widget_factory().Run(*params, widget); 590 views_delegate->native_widget_factory().Run(*params, widget);
453 } 591 }
454 } 592 }
455 // Apply a WM-provided shadow (see ui/wm/core/). 593 // Apply a WM-provided shadow (see ui/wm/core/).
(...skipping 13 matching lines...) Expand all
469 return GetBubbleFrameView() != nullptr; 607 return GetBubbleFrameView() != nullptr;
470 } 608 }
471 609
472 void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const { 610 void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const {
473 DCHECK(mask); 611 DCHECK(mask);
474 DCHECK(GetBubbleFrameView()); 612 DCHECK(GetBubbleFrameView());
475 613
476 mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds())); 614 mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds()));
477 } 615 }
478 616
617 void AppListView::OnMouseEvent(ui::MouseEvent* event) {
618 if (!launcher_background_shield_)
619 return;
620
621 switch (event->type()) {
622 case ui::ET_MOUSE_PRESSED:
623 case ui::ET_MOUSE_DRAGGED:
624 case ui::ET_MOUSE_RELEASED:
625 HandleDrag(event->location(), event->type());
626 event->SetHandled();
627 break;
628 default:
629 break;
630 }
631 }
632
633 void AppListView::OnGestureEvent(ui::GestureEvent* event) {
634 if (!launcher_background_shield_)
635 return;
636
637 switch (event->type()) {
638 case ui::ET_GESTURE_SCROLL_UPDATE:
639 last_fling_velocity_ = event->details().velocity_y();
640 HandleDrag(event->location(), event->type());
641 event->SetHandled();
642 break;
643 case ui::ET_GESTURE_SCROLL_BEGIN:
644 case ui::ET_GESTURE_END:
645 HandleDrag(event->location(), event->type());
646 event->SetHandled();
647 break;
648 default:
649 break;
650 }
651 }
652
479 bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) { 653 bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) {
480 DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code()); 654 DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code());
481 655
482 // If the ContentsView does not handle the back action, then this is the 656 // If the ContentsView does not handle the back action, then this is the
483 // top level, so we close the app list. 657 // top level, so we close the app list.
484 if (!app_list_main_view_->contents_view()->Back()) { 658 if (!app_list_main_view_->contents_view()->Back()) {
485 GetWidget()->Deactivate(); 659 GetWidget()->Deactivate();
486 CloseAppList(); 660 CloseAppList();
487 } 661 }
488 662
489 // Don't let DialogClientView handle the accelerator. 663 // Don't let DialogClientView handle the accelerator.
490 return true; 664 return true;
491 } 665 }
492 666
493 void AppListView::Layout() { 667 void AppListView::Layout() {
668 // If the fullscreen feature has been enabled.
669 if (launcher_background_shield_) {
670 UpdateDimensions();
671
672 gfx::Rect recomputed_fullscreen_widget_bounds(
673 display_work_area_bounds_.x(), default_peeking_launcher_y_,
674 display_work_area_bounds_.width(),
675 display_work_area_bounds_.height() + kShelfSize);
676
677 fullscreen_widget_bounds_ = recomputed_fullscreen_widget_bounds;
678
679 if (is_fullscreen_launcher_) {
680 ToFullscreen();
681 } else {
682 ToPeeking();
683 }
684 }
494 const gfx::Rect contents_bounds = GetContentsBounds(); 685 const gfx::Rect contents_bounds = GetContentsBounds();
495 686
496 // Make sure to layout |app_list_main_view_| and |speech_view_| at the center 687 // Make sure to layout |app_list_main_view_| and |speech_view_| at the center
497 // of the widget. 688 // of the widget.
498 gfx::Rect centered_bounds = contents_bounds; 689 gfx::Rect centered_bounds = contents_bounds;
499 centered_bounds.ClampToCenteredSize(gfx::Size( 690 centered_bounds.ClampToCenteredSize(gfx::Size(
500 app_list_main_view_->contents_view()->GetDefaultContentsBounds().width(), 691 app_list_main_view_->contents_view()->GetDefaultContentsBounds().width(),
501 contents_bounds.height())); 692 contents_bounds.height()));
502 693
503 app_list_main_view_->SetBoundsRect(centered_bounds); 694 app_list_main_view_->SetBoundsRect(centered_bounds);
504 695
505 if (speech_view_) { 696 if (speech_view_) {
506 gfx::Rect speech_bounds = centered_bounds; 697 gfx::Rect speech_bounds = centered_bounds;
507 int preferred_height = speech_view_->GetPreferredSize().height(); 698 int preferred_height = speech_view_->GetPreferredSize().height();
508 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin); 699 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin);
509 speech_bounds.set_height( 700 speech_bounds.set_height(
510 std::min(speech_bounds.height(), preferred_height)); 701 std::min(speech_bounds.height(), preferred_height));
511 speech_bounds.Inset(-speech_view_->GetInsets()); 702 speech_bounds.Inset(-speech_view_->GetInsets());
512 speech_view_->SetBoundsRect(speech_bounds); 703 speech_view_->SetBoundsRect(speech_bounds);
513 } 704 }
705 // If the fullscreen feature has been enabled.
706 if (launcher_background_shield_) {
707 app_list_main_view_->contents_view()->Layout();
708 launcher_background_shield_->SetBoundsRect(contents_bounds);
709 }
514 } 710 }
515 711
516 void AppListView::SchedulePaintInRect(const gfx::Rect& rect) { 712 void AppListView::SchedulePaintInRect(const gfx::Rect& rect) {
517 BubbleDialogDelegateView::SchedulePaintInRect(rect); 713 BubbleDialogDelegateView::SchedulePaintInRect(rect);
518 if (GetBubbleFrameView()) 714 if (GetBubbleFrameView())
519 GetBubbleFrameView()->SchedulePaint(); 715 GetBubbleFrameView()->SchedulePaint();
520 } 716 }
521 717
718 void AppListView::ToFullscreen() {
719 fullscreen_widget_bounds_.set_y(0);
720 fullscreen_widget_->SetBounds(fullscreen_widget_bounds_);
721 is_fullscreen_launcher_ = true;
722 launcher_threshold_ = (fullscreen_widget_bounds_.height() + kShelfSize) /
723 kLauncherThresholdDenominator;
724 }
725
726 void AppListView::ToPeeking() {
727 fullscreen_widget_bounds_.set_y(default_peeking_launcher_y_);
728 fullscreen_widget_->SetBounds(fullscreen_widget_bounds_);
729 is_fullscreen_launcher_ = false;
730 launcher_threshold_ = (fullscreen_widget_bounds_.height() + kShelfSize -
731 kPeekingLauncherHeight) /
732 kLauncherThresholdDenominator;
733 }
734
735 bool AppListView::IsFullscreen() const {
736 return is_fullscreen_launcher_;
737 }
738
522 void AppListView::OnWidgetDestroying(views::Widget* widget) { 739 void AppListView::OnWidgetDestroying(views::Widget* widget) {
523 BubbleDialogDelegateView::OnWidgetDestroying(widget); 740 BubbleDialogDelegateView::OnWidgetDestroying(widget);
524 if (delegate_ && widget == GetWidget()) 741 if (delegate_ && widget == GetWidget())
525 delegate_->ViewClosing(); 742 delegate_->ViewClosing();
526 } 743 }
527 744
528 void AppListView::OnWidgetVisibilityChanged(views::Widget* widget, 745 void AppListView::OnWidgetVisibilityChanged(views::Widget* widget,
529 bool visible) { 746 bool visible) {
530 BubbleDialogDelegateView::OnWidgetVisibilityChanged(widget, visible); 747 BubbleDialogDelegateView::OnWidgetVisibilityChanged(widget, visible);
531 748
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 } else { 813 } else {
597 app_list_main_view_->SetVisible(true); 814 app_list_main_view_->SetVisible(true);
598 // Refocus the search box. However, if the app list widget does not have 815 // Refocus the search box. However, if the app list widget does not have
599 // focus, it means another window has already taken focus, and we *must not* 816 // focus, it means another window has already taken focus, and we *must not*
600 // focus the search box (or we would steal focus back into the app list). 817 // focus the search box (or we would steal focus back into the app list).
601 if (GetWidget()->IsActive()) 818 if (GetWidget()->IsActive())
602 search_box_view_->search_box()->RequestFocus(); 819 search_box_view_->search_box()->RequestFocus();
603 } 820 }
604 } 821 }
605 822
823 void AppListView::OnDisplayMetricsChanged(const display::Display& display,
824 uint32_t changed_metrics) {
825 Layout();
826 }
827
606 } // namespace app_list 828 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_view.h ('k') | ui/app_list/views/contents_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698