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

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

Issue 2898743002: Draggable peeking/fullscreen launcher with transparent background. (Closed)
Patch Set: Created 3 years, 7 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
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 int kShelfSize = 48;
vadimt 2017/05/22 23:36:58 Comment pls.
newcomer 2017/05/25 23:10:51 Done.
60
61 // The y position of the peeking launcher, used in ComputeLauncherConstants().
62 int kPeekingLauncherHeight = 320;
vadimt 2017/05/22 23:36:57 Remove 'used in'. Leave the meaning.
newcomer 2017/05/25 23:10:52 Done.
63
64 // todo(newcomer): Support half launcher mode.
65 // The y position of the half launcher, used in ComputeLauncherConstants().
66 // int kHalfLauncherHeight = 561;
vadimt 2017/05/22 23:36:58 I see. Please don't leave commented blocks like th
newcomer 2017/05/25 23:10:52 Done.
67
59 // The vertical position for the appearing animation of the speech UI. 68 // The vertical position for the appearing animation of the speech UI.
60 const float kSpeechUIAppearingPosition = 12; 69 const float kSpeechUIAppearingPosition = 12;
61 70
62 // This view forwards the focus to the search box widget by providing it as a 71 // This view forwards the focus to the search box widget by providing it as a
63 // FocusTraversable when a focus search is provided. 72 // FocusTraversable when a focus search is provided.
64 class SearchBoxFocusHost : public views::View { 73 class SearchBoxFocusHost : public views::View {
65 public: 74 public:
66 explicit SearchBoxFocusHost(views::Widget* search_box_widget) 75 explicit SearchBoxFocusHost(views::Widget* search_box_widget)
67 : search_box_widget_(search_box_widget) {} 76 : search_box_widget_(search_box_widget) {}
68 77
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 //////////////////////////////////////////////////////////////////////////////// 177 ////////////////////////////////////////////////////////////////////////////////
169 // AppListView: 178 // AppListView:
170 179
171 AppListView::AppListView(AppListViewDelegate* delegate) 180 AppListView::AppListView(AppListViewDelegate* delegate)
172 : delegate_(delegate), 181 : delegate_(delegate),
173 app_list_main_view_(nullptr), 182 app_list_main_view_(nullptr),
174 speech_view_(nullptr), 183 speech_view_(nullptr),
175 search_box_focus_host_(nullptr), 184 search_box_focus_host_(nullptr),
176 search_box_widget_(nullptr), 185 search_box_widget_(nullptr),
177 search_box_view_(nullptr), 186 search_box_view_(nullptr),
187 initial_drag_separation_(0),
vadimt 2017/05/22 23:36:57 Use initialization in header. type var = val;
newcomer 2017/05/25 23:10:51 Done.
188 last_fling_velocity_(0),
189 default_peeking_launcher_y_(0),
190 is_fullscreen_launcher_(false),
191 fullscreen_widget_bounds_(),
178 overlay_view_(nullptr), 192 overlay_view_(nullptr),
179 animation_observer_(new HideViewAnimationObserver()) { 193 animation_observer_(new HideViewAnimationObserver()) {
180 CHECK(delegate); 194 CHECK(delegate);
181 195
182 delegate_->GetSpeechUI()->AddObserver(this); 196 delegate_->GetSpeechUI()->AddObserver(this);
183 } 197 }
184 198
185 AppListView::~AppListView() { 199 AppListView::~AppListView() {
200 // Remove this instance from the DisplayManager's list of observers.
201 if (features::IsFullscreenAppListEnabled())
202 display::Screen::GetScreen()->RemoveObserver(this);
xiyuan 2017/05/24 18:28:18 Suggest to use ScopedObserver so that this happens
newcomer 2017/05/25 23:10:52 Cool! and done.
203
186 delegate_->GetSpeechUI()->RemoveObserver(this); 204 delegate_->GetSpeechUI()->RemoveObserver(this);
187 animation_observer_.reset(); 205 animation_observer_.reset();
188 // Remove child views first to ensure no remaining dependencies on delegate_. 206 // Remove child views first to ensure no remaining dependencies on delegate_.
189 RemoveAllChildViews(true); 207 RemoveAllChildViews(true);
190 } 208 }
191 209
192 void AppListView::Initialize(gfx::NativeView parent, int initial_apps_page) { 210 void AppListView::Initialize(gfx::NativeView parent, int initial_apps_page) {
193 base::Time start_time = base::Time::Now(); 211 base::Time start_time = base::Time::Now();
194 InitContents(parent, initial_apps_page); 212 InitContents(parent, initial_apps_page);
195 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); 213 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
196 set_color(kContentsBackgroundColor); 214 set_color(kContentsBackgroundColor);
197 set_parent_window(parent); 215 set_parent_window(parent);
198 216
199 if (features::IsFullscreenAppListEnabled()) 217 if (features::IsFullscreenAppListEnabled())
200 InitializeFullscreen(parent, initial_apps_page); 218 InitializeFullscreen(parent, initial_apps_page);
201 else 219 else
202 InitializeBubble(parent, initial_apps_page); 220 InitializeBubble(parent, initial_apps_page);
203 221
204 InitChildWidgets(); 222 InitChildWidgets();
205 AddChildView(overlay_view_); 223 AddChildView(overlay_view_);
224
206 if (delegate_) 225 if (delegate_)
207 delegate_->ViewInitialized(); 226 delegate_->ViewInitialized();
227
208 UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime", 228 UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime",
209 base::Time::Now() - start_time); 229 base::Time::Now() - start_time);
210 } 230 }
211 231
212 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { 232 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) {
213 GetBubbleFrameView()->bubble_border()->set_arrow(arrow); 233 GetBubbleFrameView()->bubble_border()->set_arrow(arrow);
214 SizeToContents(); // Recalcuates with new border. 234 SizeToContents(); // Recalcuates with new border.
215 GetBubbleFrameView()->SchedulePaint(); 235 GetBubbleFrameView()->SchedulePaint();
216 } 236 }
217 237
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 ->pagination_model(); 343 ->pagination_model();
324 } 344 }
325 345
326 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) { 346 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) {
327 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and 347 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and
328 // crbug.com/441028 are fixed. 348 // crbug.com/441028 are fixed.
329 tracked_objects::ScopedTracker tracking_profile( 349 tracked_objects::ScopedTracker tracking_profile(
330 FROM_HERE_WITH_EXPLICIT_FUNCTION( 350 FROM_HERE_WITH_EXPLICIT_FUNCTION(
331 "440224, 441028 AppListView::InitContents")); 351 "440224, 441028 AppListView::InitContents"));
332 352
353 if (features::IsFullscreenAppListEnabled()) {
354 // The shield view that colors the background of the launcher and makes it
355 // transparent.
356 launcher_background_shield_ = new views::View;
357 launcher_background_shield_->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
358 launcher_background_shield_->layer()->SetColor(SK_ColorBLACK);
359 launcher_background_shield_->layer()->SetOpacity(0.8f);
360 AddChildView(launcher_background_shield_);
361 }
333 app_list_main_view_ = new AppListMainView(delegate_); 362 app_list_main_view_ = new AppListMainView(delegate_);
334 AddChildView(app_list_main_view_); 363 AddChildView(app_list_main_view_);
335 app_list_main_view_->SetPaintToLayer(); 364 app_list_main_view_->SetPaintToLayer();
336 app_list_main_view_->layer()->SetFillsBoundsOpaquely(false); 365 app_list_main_view_->layer()->SetFillsBoundsOpaquely(false);
337 app_list_main_view_->layer()->SetMasksToBounds(true); 366 app_list_main_view_->layer()->SetMasksToBounds(true);
338 // This will be added to the |search_box_widget_| after the app list widget is 367 // This will be added to the |search_box_widget_| after the app list widget is
339 // initialized. 368 // initialized.
340 search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_); 369 search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_);
370 search_box_view_->SetAppListView(this);
341 search_box_view_->SetPaintToLayer(); 371 search_box_view_->SetPaintToLayer();
342 search_box_view_->layer()->SetFillsBoundsOpaquely(false); 372 search_box_view_->layer()->SetFillsBoundsOpaquely(false);
343 search_box_view_->layer()->SetMasksToBounds(true); 373 search_box_view_->layer()->SetMasksToBounds(true);
344 374
345 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and 375 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and
346 // crbug.com/441028 are fixed. 376 // crbug.com/441028 are fixed.
347 tracked_objects::ScopedTracker tracking_profile1( 377 tracked_objects::ScopedTracker tracking_profile1(
348 FROM_HERE_WITH_EXPLICIT_FUNCTION( 378 FROM_HERE_WITH_EXPLICIT_FUNCTION(
349 "440224, 441028 AppListView::InitContents1")); 379 "440224, 441028 AppListView::InitContents1"));
350 380
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // Mouse events on the search box shadow should not be captured. 427 // Mouse events on the search box shadow should not be captured.
398 aura::Window* window = search_box_widget_->GetNativeWindow(); 428 aura::Window* window = search_box_widget_->GetNativeWindow();
399 window->SetEventTargeter( 429 window->SetEventTargeter(
400 base::MakeUnique<SearchBoxWindowTargeter>(search_box_view_)); 430 base::MakeUnique<SearchBoxWindowTargeter>(search_box_view_));
401 431
402 app_list_main_view_->contents_view()->Layout(); 432 app_list_main_view_->contents_view()->Layout();
403 } 433 }
404 434
405 void AppListView::InitializeFullscreen(gfx::NativeView parent, 435 void AppListView::InitializeFullscreen(gfx::NativeView parent,
406 int initial_apps_page) { 436 int initial_apps_page) {
407 views::Widget* widget = new views::Widget; 437 ComputeConstants();
vadimt 2017/05/22 23:36:57 Sounds strange... UpdateDimensions?
newcomer 2017/05/25 23:10:53 Done.
438
439 gfx::Rect app_list_overlay_view_bounds(
440 display_work_area_bounds_.x(), default_peeking_launcher_y_,
441 display_work_area_bounds_.width(),
442 display_work_area_bounds_.height() + kShelfSize);
443
444 fullscreen_widget_ = new views::Widget;
408 views::Widget::InitParams app_list_overlay_view_params( 445 views::Widget::InitParams app_list_overlay_view_params(
409 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 446 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
410 447
448 app_list_overlay_view_params.name = "AppList";
411 app_list_overlay_view_params.parent = parent; 449 app_list_overlay_view_params.parent = parent;
412 app_list_overlay_view_params.delegate = this; 450 app_list_overlay_view_params.delegate = this;
413 app_list_overlay_view_params.opacity = 451 app_list_overlay_view_params.opacity =
414 views::Widget::InitParams::TRANSLUCENT_WINDOW; 452 views::Widget::InitParams::TRANSLUCENT_WINDOW;
415 app_list_overlay_view_params.bounds = 453 app_list_overlay_view_params.bounds = app_list_overlay_view_bounds;
416 display::Screen::GetScreen()-> 454 app_list_overlay_view_params.layer_type = ui::LAYER_SOLID_COLOR;
417 GetDisplayNearestView(parent).work_area(); 455 fullscreen_widget_->Init(app_list_overlay_view_params);
418 widget->Init(app_list_overlay_view_params);
419 widget->GetLayer()->SetBackgroundBlur(10);
420 456
457 fullscreen_widget_bounds_ = fullscreen_widget_->GetWindowBoundsInScreen();
421 overlay_view_ = new AppListOverlayView(0 /* no corners */); 458 overlay_view_ = new AppListOverlayView(0 /* no corners */);
459
460 // Launcher + shelf height, used in HandleDrag.
461 launcher_threshold_ =
462 (default_peeking_launcher_y_ + fullscreen_widget_bounds_.height() -
463 fullscreen_widget_bounds_.y()) /
464 3;
vadimt 2017/05/22 23:36:57 Should have a constant for '3'?
newcomer 2017/05/25 23:10:51 Done.
465
466 display::Screen::GetScreen()->AddObserver(this);
vadimt 2017/05/22 23:36:57 This line is paired with removing observer in dest
newcomer 2017/05/25 23:10:52 Done.
422 } 467 }
423 468
424 void AppListView::InitializeBubble(gfx::NativeView parent, 469 void AppListView::InitializeBubble(gfx::NativeView parent,
425 int initial_apps_page) { 470 int initial_apps_page) {
426 set_margins(gfx::Insets()); 471 set_margins(gfx::Insets());
427 set_close_on_deactivate(false); 472 set_close_on_deactivate(false);
428 set_shadow(views::BubbleBorder::NO_ASSETS); 473 set_shadow(views::BubbleBorder::NO_ASSETS);
429 474
430 // This creates the app list widget. (Before this, child widgets cannot be 475 // This creates the app list widget. (Before this, child widgets cannot be
431 // created.) 476 // created.
432 views::BubbleDialogDelegateView::CreateBubble(this); 477 views::BubbleDialogDelegateView::CreateBubble(this);
433 478
434 SetBubbleArrow(views::BubbleBorder::FLOAT); 479 SetBubbleArrow(views::BubbleBorder::FLOAT);
435 // We can now create the internal widgets. 480 // We can now create the internal widgets.
436 481
437 aura::Window* window = GetWidget()->GetNativeWindow(); 482 aura::Window* window = GetWidget()->GetNativeWindow();
438 window->SetEventTargeter(base::MakeUnique<views::BubbleWindowTargeter>(this)); 483 window->SetEventTargeter(base::MakeUnique<views::BubbleWindowTargeter>(this));
439 484
440 const int kOverlayCornerRadius = 485 const int kOverlayCornerRadius =
441 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); 486 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius();
(...skipping 27 matching lines...) Expand all
469 return GetBubbleFrameView() != nullptr; 514 return GetBubbleFrameView() != nullptr;
470 } 515 }
471 516
472 void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const { 517 void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const {
473 DCHECK(mask); 518 DCHECK(mask);
474 DCHECK(GetBubbleFrameView()); 519 DCHECK(GetBubbleFrameView());
475 520
476 mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds())); 521 mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds()));
477 } 522 }
478 523
524 void AppListView::OnMouseEvent(ui::MouseEvent* event) {
525 if (features::IsFullscreenAppListEnabled()) {
xiyuan 2017/05/24 18:28:18 nit: reverse condition and bail out early. i.e.
newcomer 2017/05/25 23:10:51 Done, also swapped if(features::IsFullscreenAppLis
526 if (event->type() == ui::ET_MOUSE_PRESSED ||
vadimt 2017/05/22 23:36:57 I'd prefer switch statement.
newcomer 2017/05/25 23:10:52 Done.
527 event->type() == ui::ET_MOUSE_DRAGGED ||
528 event->type() == ui::ET_MOUSE_RELEASED) {
529 HandleDrag(event->location(), event->type());
530 event->SetHandled();
531 }
532 }
533 }
534
535 void AppListView::OnGestureEvent(ui::GestureEvent* event) {
536 if (features::IsFullscreenAppListEnabled()) {
xiyuan 2017/05/24 18:28:18 ditto
newcomer 2017/05/25 23:10:52 Done.
537 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN ||
538 event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
539 event->type() == ui::ET_GESTURE_END) {
540 HandleDrag(event->location(), event->type());
541 event->SetHandled();
542 // Record the velocity so we can process it when the touch is released in
543 // HandleDrag.
544 last_fling_velocity_ = event->details().velocity_y();
545 }
546 }
547 }
548
549 void AppListView::HandleDrag(gfx::Point location, ui::EventType type) {
550 int new_y_position;
551 if (type != ui::ET_GESTURE_SCROLL_BEGIN && type != ui::ET_MOUSE_PRESSED)
552 // Calculate the new position of the launcher which may or may not be used.
vadimt 2017/05/22 23:36:57 Use {}, as the statement in 'if' takes more than 1
newcomer 2017/05/25 23:10:52 Done.
553 new_y_position =
vadimt 2017/05/22 23:36:57 'else' it will be uninitialized?
newcomer 2017/05/25 23:10:52 Moved the initialization into the switch statement
554 location.y() - initial_drag_separation_ + fullscreen_widget_bounds_.y();
555
556 switch (type) {
557 case ui::ET_GESTURE_SCROLL_BEGIN:
558 case ui::ET_MOUSE_PRESSED: {
559 // Drag start, grab the initial_drag_separation_ to maintain the relative
560 // position of the top of the widget and the mouse/gesture.
561 initial_drag_separation_ = location.y();
562 fullscreen_widget_bounds_ = fullscreen_widget_->GetWindowBoundsInScreen();
563 return;
564 }
565 case ui::ET_GESTURE_SCROLL_UPDATE:
566 case ui::ET_MOUSE_DRAGGED: {
567 // Drag update, update the bounds of the widget while maintaining the
568 // relative position of the top of the widget and the mouse/gesture.
569 // Block drags north of 0 and recalculate the initial_drag_separation_.
570 if (new_y_position < 0) {
571 fullscreen_widget_bounds_.set_y(0);
572 initial_drag_separation_ = location.y();
573 } else
574 fullscreen_widget_bounds_.set_y(new_y_position);
vadimt 2017/05/22 23:36:57 I assume you manually reproed cases when you need
newcomer 2017/05/25 23:10:52 Correct! The next CL will have full test coverage
575
576 fullscreen_widget_->SetBounds(fullscreen_widget_bounds_);
577 return;
vadimt 2017/05/22 23:36:57 Please use break as you don't use return as in ear
newcomer 2017/05/25 23:10:52 Done.
578 }
579
580 case ui::ET_GESTURE_END:
581 case ui::ET_MOUSE_RELEASED: {
582 // Drag completion, either snap to fullscreen or close the App List based
583 // on where the drag ended. If fling velocity was over the threshold, snap
584 // to the next state in the direction of the fling.
585
586 if (std::abs(last_fling_velocity_) > 25) {
vadimt 2017/05/22 23:36:57 Constant for 25?
newcomer 2017/05/25 23:10:52 Done.
587 // If the user releases drag with velocity over the threshold, snap to
588 // the next state, ignoring the drag release position.
589
vadimt 2017/05/22 23:36:57 Remove empty line.
newcomer 2017/05/25 23:10:51 Done.
590 if (is_fullscreen_launcher_) {
591 if (last_fling_velocity_ > 0)
592 ToPeeking();
593 } else if (!is_fullscreen_launcher_) {
vadimt 2017/05/22 23:36:57 No need to check !is_fullscreen_launcher_
newcomer 2017/05/25 23:10:52 Done.
594 if (last_fling_velocity_ > 0) {
595 CloseAppList();
596 } else if (last_fling_velocity_ < 0) {
597 ToFullscreen();
598 }
599 }
600 last_fling_velocity_ = 0;
601 return;
602 } else {
603 // The drag release velocity was too low, so use the release point.
604 int launcher_snap_y =
605 is_fullscreen_launcher_ ? 0 : default_peeking_launcher_y_;
606 // If the user releases +/- 1/3 of launcher_threshold_ , snap to the
607 // next state.
608 if (std::abs(launcher_snap_y - new_y_position) <
609 (launcher_threshold_)) {
610 // If the drag released to the state above.
611 if (is_fullscreen_launcher_) {
612 ToFullscreen();
613 } else {
614 ToPeeking();
615 }
616 } else if ((launcher_snap_y + (launcher_threshold_)) < new_y_position) {
617 // If the user released to the state below.
618 if (is_fullscreen_launcher_) {
619 ToPeeking();
620 } else {
621 CloseAppList();
622 }
623
624 } else {
625 // if the user released to the state above, go to the state above.
626 ToFullscreen();
627 }
628
629 return;
630 }
631 }
632 default:
633 NOTREACHED();
634 return;
635 }
636 }
637
vadimt 2017/05/22 23:36:57 This method is over 100 lines; please split.
newcomer 2017/05/25 23:10:52 It is now 81 lines.
479 bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) { 638 bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) {
480 DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code()); 639 DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code());
481 640
482 // If the ContentsView does not handle the back action, then this is the 641 // If the ContentsView does not handle the back action, then this is the
483 // top level, so we close the app list. 642 // top level, so we close the app list.
484 if (!app_list_main_view_->contents_view()->Back()) { 643 if (!app_list_main_view_->contents_view()->Back()) {
485 GetWidget()->Deactivate(); 644 GetWidget()->Deactivate();
486 CloseAppList(); 645 CloseAppList();
487 } 646 }
488 647
489 // Don't let DialogClientView handle the accelerator. 648 // Don't let DialogClientView handle the accelerator.
490 return true; 649 return true;
491 } 650 }
492 651
652 void AppListView::ComputeConstants() {
653 display_work_area_bounds_ = display::Screen::GetScreen()
654 ->GetDisplayNearestView(parent_window())
655 .work_area();
656 default_peeking_launcher_y_ =
657 display_work_area_bounds_.height() + kShelfSize - kPeekingLauncherHeight;
658 }
659
493 void AppListView::Layout() { 660 void AppListView::Layout() {
661 if (features::IsFullscreenAppListEnabled()) {
662 ComputeConstants();
663
664 gfx::Rect recomputed_fullscreen_widget_bounds(
665 display_work_area_bounds_.x(), default_peeking_launcher_y_,
666 display_work_area_bounds_.width(),
667 display_work_area_bounds_.height() + kShelfSize);
668
669 fullscreen_widget_bounds_ = recomputed_fullscreen_widget_bounds;
670 // todo(newcomer): Support half launcher and all start_page_view states.
671 if (is_fullscreen_launcher_) {
672 ToFullscreen();
673 } else {
674 ToPeeking();
675 }
676 }
494 const gfx::Rect contents_bounds = GetContentsBounds(); 677 const gfx::Rect contents_bounds = GetContentsBounds();
495 678
496 // Make sure to layout |app_list_main_view_| and |speech_view_| at the center 679 // Make sure to layout |app_list_main_view_| and |speech_view_| at the center
497 // of the widget. 680 // of the widget.
498 gfx::Rect centered_bounds = contents_bounds; 681 gfx::Rect centered_bounds = contents_bounds;
499 centered_bounds.ClampToCenteredSize(gfx::Size( 682 centered_bounds.ClampToCenteredSize(gfx::Size(
500 app_list_main_view_->contents_view()->GetDefaultContentsBounds().width(), 683 app_list_main_view_->contents_view()->GetDefaultContentsBounds().width(),
501 contents_bounds.height())); 684 contents_bounds.height()));
502 685
503 app_list_main_view_->SetBoundsRect(centered_bounds); 686 app_list_main_view_->SetBoundsRect(centered_bounds);
504 687
505 if (speech_view_) { 688 if (speech_view_) {
506 gfx::Rect speech_bounds = centered_bounds; 689 gfx::Rect speech_bounds = centered_bounds;
507 int preferred_height = speech_view_->GetPreferredSize().height(); 690 int preferred_height = speech_view_->GetPreferredSize().height();
508 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin); 691 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin);
509 speech_bounds.set_height( 692 speech_bounds.set_height(
510 std::min(speech_bounds.height(), preferred_height)); 693 std::min(speech_bounds.height(), preferred_height));
511 speech_bounds.Inset(-speech_view_->GetInsets()); 694 speech_bounds.Inset(-speech_view_->GetInsets());
512 speech_view_->SetBoundsRect(speech_bounds); 695 speech_view_->SetBoundsRect(speech_bounds);
513 } 696 }
697 if (features::IsFullscreenAppListEnabled()) {
698 app_list_main_view_->contents_view()->start_page_view()->parent()->Layout();
vadimt 2017/05/22 23:36:57 I'd explicitly plumb that view to here. Hierarchy
newcomer 2017/05/25 23:10:53 Done.
699 launcher_background_shield_->SetBoundsRect(contents_bounds);
700 }
514 } 701 }
515 702
516 void AppListView::SchedulePaintInRect(const gfx::Rect& rect) { 703 void AppListView::SchedulePaintInRect(const gfx::Rect& rect) {
517 BubbleDialogDelegateView::SchedulePaintInRect(rect); 704 BubbleDialogDelegateView::SchedulePaintInRect(rect);
518 if (GetBubbleFrameView()) 705 if (GetBubbleFrameView())
519 GetBubbleFrameView()->SchedulePaint(); 706 GetBubbleFrameView()->SchedulePaint();
520 } 707 }
521 708
709 void AppListView::ToFullscreen() {
710 fullscreen_widget_bounds_.set_y(0);
711 fullscreen_widget_->SetBounds(fullscreen_widget_bounds_);
712 is_fullscreen_launcher_ = true;
713 launcher_threshold_ = (fullscreen_widget_bounds_.height() + kShelfSize) / 3;
vadimt 2017/05/22 23:36:57 3 again
newcomer 2017/05/25 23:10:52 Done.
714 }
715
716 void AppListView::ToPeeking() {
717 fullscreen_widget_bounds_.set_y(default_peeking_launcher_y_);
718 fullscreen_widget_->SetBounds(fullscreen_widget_bounds_);
719 is_fullscreen_launcher_ = false;
720 // height is wrong
vadimt 2017/05/22 23:36:57 Need a better comment.
newcomer 2017/05/25 23:10:51 That was a prototyping comment. Removed!
721 launcher_threshold_ = (fullscreen_widget_bounds_.height() + kShelfSize -
722 kPeekingLauncherHeight) /
723 3;
724 }
725
726 bool AppListView::IsFullscreen() {
vadimt 2017/05/22 23:36:57 Should be const method
newcomer 2017/05/25 23:10:52 Done.
727 return is_fullscreen_launcher_;
728 }
729
522 void AppListView::OnWidgetDestroying(views::Widget* widget) { 730 void AppListView::OnWidgetDestroying(views::Widget* widget) {
523 BubbleDialogDelegateView::OnWidgetDestroying(widget); 731 BubbleDialogDelegateView::OnWidgetDestroying(widget);
524 if (delegate_ && widget == GetWidget()) 732 if (delegate_ && widget == GetWidget())
525 delegate_->ViewClosing(); 733 delegate_->ViewClosing();
526 } 734 }
527 735
528 void AppListView::OnWidgetVisibilityChanged(views::Widget* widget, 736 void AppListView::OnWidgetVisibilityChanged(views::Widget* widget,
529 bool visible) { 737 bool visible) {
530 BubbleDialogDelegateView::OnWidgetVisibilityChanged(widget, visible); 738 BubbleDialogDelegateView::OnWidgetVisibilityChanged(widget, visible);
531 739
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 } else { 804 } else {
597 app_list_main_view_->SetVisible(true); 805 app_list_main_view_->SetVisible(true);
598 // Refocus the search box. However, if the app list widget does not have 806 // 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* 807 // 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). 808 // focus the search box (or we would steal focus back into the app list).
601 if (GetWidget()->IsActive()) 809 if (GetWidget()->IsActive())
602 search_box_view_->search_box()->RequestFocus(); 810 search_box_view_->search_box()->RequestFocus();
603 } 811 }
604 } 812 }
605 813
814 void AppListView::OnDisplayMetricsChanged(const display::Display& display,
815 uint32_t changed_metrics) {
816 Layout();
817 }
818
606 } // namespace app_list 819 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698