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

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

Issue 2939693004: Added HALF, FULLSCREEN_ALL_APPS, and FULLSCREEN_SEARCH. (Closed)
Patch Set: Addressed comments. 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
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // The margin from the edge to the speech UI. 55 // The margin from the edge to the speech UI.
56 constexpr int kSpeechUIMargin = 12; 56 constexpr int kSpeechUIMargin = 12;
57 57
58 // The height/width of the shelf. 58 // The height/width of the shelf.
59 constexpr int kShelfSize = 48; 59 constexpr int kShelfSize = 48;
60 60
61 // The height of the peeking app list. 61 // The height of the peeking app list.
62 constexpr int kPeekingAppListHeight = 320; 62 constexpr int kPeekingAppListHeight = 320;
63 63
64 // The height of the half app list.
oshima 2017/06/15 17:51:45 .. from the bottom of the screen, not workarea.
newcomer 2017/06/15 18:20:26 Done.
65 constexpr int kHalfAppListHeight = 561;
66
64 // The fraction of app list height that the app list must be released at in 67 // The fraction of app list height that the app list must be released at in
65 // order to transition to the next state. 68 // order to transition to the next state.
66 constexpr int kAppListThresholdDenominator = 3; 69 constexpr int kAppListThresholdDenominator = 3;
67 70
68 // The velocity the app list must be dragged in order to transition to the next 71 // The velocity the app list must be dragged in order to transition to the next
69 // state, measured in DIPs/event. 72 // state, measured in DIPs/event.
70 constexpr int kAppListDragVelocityThreshold = 25; 73 constexpr int kAppListDragVelocityThreshold = 25;
71 74
75 // The DIP distance from the bezel that a drag event must end within to transfer
76 // the |app_list_state_|.
77 constexpr int kAppListBezelMargin = 50;
78
72 // The opacity of the app list background. 79 // The opacity of the app list background.
73 constexpr float kAppListOpacity = 0.8; 80 constexpr float kAppListOpacity = 0.8;
74 81
75 // The vertical position for the appearing animation of the speech UI. 82 // The vertical position for the appearing animation of the speech UI.
76 constexpr float kSpeechUIAppearingPosition = 12; 83 constexpr float kSpeechUIAppearingPosition = 12;
77 84
78 bool IsFullscreenAppListEnabled() {
79 // Cache this value to avoid repeated lookup.
80 static bool cached_value = features::IsFullscreenAppListEnabled();
81 return cached_value;
82 }
83
84 // This view forwards the focus to the search box widget by providing it as a 85 // This view forwards the focus to the search box widget by providing it as a
85 // FocusTraversable when a focus search is provided. 86 // FocusTraversable when a focus search is provided.
86 class SearchBoxFocusHost : public views::View { 87 class SearchBoxFocusHost : public views::View {
87 public: 88 public:
88 explicit SearchBoxFocusHost(views::Widget* search_box_widget) 89 explicit SearchBoxFocusHost(views::Widget* search_box_widget)
89 : search_box_widget_(search_box_widget) {} 90 : search_box_widget_(search_box_widget) {}
90 91
91 ~SearchBoxFocusHost() override {} 92 ~SearchBoxFocusHost() override {}
92 93
93 views::FocusTraversable* GetFocusTraversable() override { 94 views::FocusTraversable* GetFocusTraversable() override {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 //////////////////////////////////////////////////////////////////////////////// 191 ////////////////////////////////////////////////////////////////////////////////
191 // AppListView: 192 // AppListView:
192 193
193 AppListView::AppListView(AppListViewDelegate* delegate) 194 AppListView::AppListView(AppListViewDelegate* delegate)
194 : delegate_(delegate), 195 : delegate_(delegate),
195 app_list_main_view_(nullptr), 196 app_list_main_view_(nullptr),
196 speech_view_(nullptr), 197 speech_view_(nullptr),
197 search_box_focus_host_(nullptr), 198 search_box_focus_host_(nullptr),
198 search_box_widget_(nullptr), 199 search_box_widget_(nullptr),
199 search_box_view_(nullptr), 200 search_box_view_(nullptr),
201 is_fullscreen_app_list_enabled_(features::IsFullscreenAppListEnabled()),
200 app_list_state_(PEEKING), 202 app_list_state_(PEEKING),
201 display_observer_(this), 203 display_observer_(this),
202 overlay_view_(nullptr), 204 overlay_view_(nullptr),
203 animation_observer_(new HideViewAnimationObserver()) { 205 animation_observer_(new HideViewAnimationObserver()) {
204 CHECK(delegate); 206 CHECK(delegate);
205 207
206 delegate_->GetSpeechUI()->AddObserver(this); 208 delegate_->GetSpeechUI()->AddObserver(this);
207 209
208 if (IsFullscreenAppListEnabled()) 210 if (is_fullscreen_app_list_enabled_)
209 display_observer_.Add(display::Screen::GetScreen()); 211 display_observer_.Add(display::Screen::GetScreen());
210 } 212 }
211 213
212 AppListView::~AppListView() { 214 AppListView::~AppListView() {
213 delegate_->GetSpeechUI()->RemoveObserver(this); 215 delegate_->GetSpeechUI()->RemoveObserver(this);
214 animation_observer_.reset(); 216 animation_observer_.reset();
215 // Remove child views first to ensure no remaining dependencies on delegate_. 217 // Remove child views first to ensure no remaining dependencies on delegate_.
216 RemoveAllChildViews(true); 218 RemoveAllChildViews(true);
217 } 219 }
218 220
219 void AppListView::Initialize(gfx::NativeView parent, int initial_apps_page) { 221 void AppListView::Initialize(gfx::NativeView parent,
222 int initial_apps_page,
223 bool is_maximize_mode,
224 bool is_side_shelf) {
220 base::Time start_time = base::Time::Now(); 225 base::Time start_time = base::Time::Now();
226 is_maximize_mode_ = is_maximize_mode;
227 is_side_shelf_ = is_side_shelf;
221 InitContents(parent, initial_apps_page); 228 InitContents(parent, initial_apps_page);
222 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); 229 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
223 set_color(kContentsBackgroundColor); 230 set_color(kContentsBackgroundColor);
224 set_parent_window(parent); 231 set_parent_window(parent);
225 232
226 if (IsFullscreenAppListEnabled()) 233 if (is_fullscreen_app_list_enabled_)
227 InitializeFullscreen(parent, initial_apps_page); 234 InitializeFullscreen(parent, initial_apps_page);
228 else 235 else
229 InitializeBubble(parent, initial_apps_page); 236 InitializeBubble(parent, initial_apps_page);
230 237
231 InitChildWidgets(); 238 InitChildWidgets();
232 AddChildView(overlay_view_); 239 AddChildView(overlay_view_);
233 240
234 if (IsFullscreenAppListEnabled()) 241 if (is_fullscreen_app_list_enabled_)
235 SetState(app_list_state_); 242 SetState(app_list_state_);
236 243
237 if (delegate_) 244 if (delegate_)
238 delegate_->ViewInitialized(); 245 delegate_->ViewInitialized();
239 246
240 UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime", 247 UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime",
241 base::Time::Now() - start_time); 248 base::Time::Now() - start_time);
242 } 249 }
243 250
244 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { 251 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) {
245 GetBubbleFrameView()->bubble_border()->set_arrow(arrow); 252 GetBubbleFrameView()->bubble_border()->set_arrow(arrow);
246 SizeToContents(); // Recalcuates with new border. 253 SizeToContents(); // Recalcuates with new border.
247 GetBubbleFrameView()->SchedulePaint(); 254 GetBubbleFrameView()->SchedulePaint();
248 } 255 }
249 256
250 void AppListView::MaybeSetAnchorPoint(const gfx::Point& anchor_point) { 257 void AppListView::MaybeSetAnchorPoint(const gfx::Point& anchor_point) {
251 // if the AppListView is a bubble 258 // if the AppListView is a bubble
252 if (!IsFullscreenAppListEnabled()) 259 if (!is_fullscreen_app_list_enabled_)
253 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); 260 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size()));
254 } 261 }
255 262
256 void AppListView::SetDragAndDropHostOfCurrentAppList( 263 void AppListView::SetDragAndDropHostOfCurrentAppList(
257 ApplicationDragAndDropHost* drag_and_drop_host) { 264 ApplicationDragAndDropHost* drag_and_drop_host) {
258 app_list_main_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); 265 app_list_main_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host);
259 } 266 }
260 267
261 void AppListView::ShowWhenReady() { 268 void AppListView::ShowWhenReady() {
262 app_list_main_view_->ShowAppListWhenReady(); 269 app_list_main_view_->ShowAppListWhenReady();
263 } 270 }
264 271
265 void AppListView::UpdateBounds() { 272 void AppListView::UpdateBounds() {
266 // if the AppListView is a bubble 273 // if the AppListView is a bubble
267 if (!IsFullscreenAppListEnabled()) 274 if (!is_fullscreen_app_list_enabled_)
268 SizeToContents(); 275 SizeToContents();
269 } 276 }
270 277
271 void AppListView::SetAppListOverlayVisible(bool visible) { 278 void AppListView::SetAppListOverlayVisible(bool visible) {
272 DCHECK(overlay_view_); 279 DCHECK(overlay_view_);
273 280
274 // Display the overlay immediately so we can begin the animation. 281 // Display the overlay immediately so we can begin the animation.
275 overlay_view_->SetVisible(true); 282 overlay_view_->SetVisible(true);
276 283
277 ui::ScopedLayerAnimationSettings settings( 284 ui::ScopedLayerAnimationSettings settings(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 ->pagination_model(); 357 ->pagination_model();
351 } 358 }
352 359
353 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) { 360 void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) {
354 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and 361 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and
355 // crbug.com/441028 are fixed. 362 // crbug.com/441028 are fixed.
356 tracked_objects::ScopedTracker tracking_profile( 363 tracked_objects::ScopedTracker tracking_profile(
357 FROM_HERE_WITH_EXPLICIT_FUNCTION( 364 FROM_HERE_WITH_EXPLICIT_FUNCTION(
358 "440224, 441028 AppListView::InitContents")); 365 "440224, 441028 AppListView::InitContents"));
359 366
360 if (IsFullscreenAppListEnabled()) { 367 if (is_fullscreen_app_list_enabled_) {
361 // The shield view that colors the background of the app list and makes it 368 // The shield view that colors the background of the app list and makes it
362 // transparent. 369 // transparent.
363 app_list_background_shield_ = new views::View; 370 app_list_background_shield_ = new views::View;
364 app_list_background_shield_->SetPaintToLayer(ui::LAYER_SOLID_COLOR); 371 app_list_background_shield_->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
365 app_list_background_shield_->layer()->SetColor(SK_ColorBLACK); 372 app_list_background_shield_->layer()->SetColor(SK_ColorBLACK);
366 app_list_background_shield_->layer()->SetOpacity(kAppListOpacity); 373 app_list_background_shield_->layer()->SetOpacity(kAppListOpacity);
367 AddChildView(app_list_background_shield_); 374 AddChildView(app_list_background_shield_);
368 } 375 }
369 app_list_main_view_ = new AppListMainView(delegate_, this); 376 app_list_main_view_ = new AppListMainView(delegate_, this);
370 AddChildView(app_list_main_view_); 377 AddChildView(app_list_main_view_);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 518
512 void AppListView::EndDrag(const gfx::Point& location) { 519 void AppListView::EndDrag(const gfx::Point& location) {
513 // Change the app list state based on where the drag ended. If fling velocity 520 // Change the app list state based on where the drag ended. If fling velocity
514 // was over the threshold, snap to the next state in the direction of the 521 // was over the threshold, snap to the next state in the direction of the
515 // fling. 522 // fling.
516 int const new_y_position = location.y() - initial_drag_point_.y() + 523 int const new_y_position = location.y() - initial_drag_point_.y() +
517 fullscreen_widget_->GetWindowBoundsInScreen().y(); 524 fullscreen_widget_->GetWindowBoundsInScreen().y();
518 if (std::abs(last_fling_velocity_) > kAppListDragVelocityThreshold) { 525 if (std::abs(last_fling_velocity_) > kAppListDragVelocityThreshold) {
519 // If the user releases drag with velocity over the threshold, snap to 526 // If the user releases drag with velocity over the threshold, snap to
520 // the next state, ignoring the drag release position. 527 // the next state, ignoring the drag release position.
521 if (app_list_state_ == FULLSCREEN) {
522 if (last_fling_velocity_ > 0)
523 SetState(PEEKING);
524 528
529 if (last_fling_velocity_ > 0) {
530 switch (app_list_state_) {
531 case PEEKING:
532 case HALF:
533 case FULLSCREEN_SEARCH:
534 SetState(CLOSED);
535 break;
536 case FULLSCREEN_ALL_APPS:
537 SetState(is_maximize_mode_ || is_side_shelf_ ? CLOSED : PEEKING);
538 break;
539 case CLOSED:
540 NOTREACHED();
541 break;
542 }
525 } else { 543 } else {
526 SetState(last_fling_velocity_ > 0 ? CLOSED : FULLSCREEN); 544 switch (app_list_state_) {
545 case FULLSCREEN_ALL_APPS:
546 case FULLSCREEN_SEARCH:
547 SetState(app_list_state_);
548 break;
549 case HALF:
550 SetState(FULLSCREEN_SEARCH);
551 break;
552 case PEEKING:
553 SetState(FULLSCREEN_ALL_APPS);
554 break;
555 case CLOSED:
556 NOTREACHED();
557 break;
558 }
527 } 559 }
528 last_fling_velocity_ = 0;
529 } else { 560 } else {
530 int display_height = display::Screen::GetScreen() 561 int display_height = display::Screen::GetScreen()
531 ->GetDisplayNearestView(parent_window()) 562 ->GetDisplayNearestView(parent_window())
532 .work_area() 563 .work_area()
533 .height(); 564 .height();
oshima 2017/06/15 17:51:45 This is workarea height, which excludes the shelf.
newcomer 2017/06/15 18:20:26 That makes more sense. Thank you!
534 int default_peeking_y = display_height + kShelfSize - kPeekingAppListHeight; 565 int app_list_y_for_state = 0;
535 // The drag release velocity was too low, so use the release point. 566 int app_list_height = 0;
536 int app_list_snap_y = 567 switch (app_list_state_) {
537 (app_list_state_ == FULLSCREEN) ? 0 : default_peeking_y; 568 case FULLSCREEN_ALL_APPS:
538 // The DIP delta that must be exceeded for the app list to snap to the next 569 case FULLSCREEN_SEARCH:
539 // state. 570 app_list_y_for_state = 0;
540 int app_list_threshold = 571 app_list_height = display_height;
541 (fullscreen_widget_->GetWindowBoundsInScreen().height() + kShelfSize) / 572 break;
542 kAppListThresholdDenominator; 573 case HALF:
543 app_list_threshold -= 574 app_list_y_for_state = display_height - kHalfAppListHeight;
544 (app_list_state_ == FULLSCREEN ? 0 : kPeekingAppListHeight) / 575 app_list_height = kHalfAppListHeight;
545 kAppListThresholdDenominator; 576 break;
577 case PEEKING:
578 app_list_y_for_state = display_height - kPeekingAppListHeight;
579 app_list_height = kPeekingAppListHeight;
580 break;
581 case CLOSED:
582 NOTREACHED();
583 break;
584 }
546 585
547 // If the user releases +/- 1/3 of |app_list_threshold|, snap to the 586 int app_list_threshold = app_list_height / kAppListThresholdDenominator;
548 // next state. 587 int drag_delta = app_list_y_for_state - new_y_position;
549 if (std::abs(app_list_snap_y - new_y_position) < app_list_threshold) { 588 gfx::Point location_in_screen_coordinates = location;
550 // The drag was not far enough so set the app list bounds to the target 589 ConvertPointToScreen(this, &location_in_screen_coordinates);
551 // bounds for the current state. 590 switch (app_list_state_) {
552 SetState(app_list_state_); 591 case FULLSCREEN_ALL_APPS:
553 } else if ((app_list_snap_y + app_list_threshold) < new_y_position) { 592 if (std::abs(drag_delta) > app_list_threshold)
554 // The drag was far enough to change states and was a downward drag, so 593 SetState(is_maximize_mode_ || is_side_shelf_ ? CLOSED : PEEKING);
555 // set the app list bounds to the next state. 594 else
556 SetState(app_list_state_ == FULLSCREEN ? PEEKING : CLOSED); 595 SetState(app_list_state_);
557 } else { 596 break;
558 // The drag was far enough to change states and was an upward drag, so 597 case FULLSCREEN_SEARCH:
559 // set the app list bounds to the next state. 598 if (std::abs(drag_delta) > app_list_threshold)
560 SetState(FULLSCREEN); 599 SetState(CLOSED);
600 else
601 SetState(app_list_state_);
602 break;
603 case HALF:
604 if (std::abs(drag_delta) > app_list_threshold) {
605 SetState(drag_delta > 0 ? FULLSCREEN_SEARCH : CLOSED);
606 } else if (location_in_screen_coordinates.y() >=
607 display_height - kAppListBezelMargin) {
608 // If the user drags to the bezel, close the app list.
609 SetState(CLOSED);
610 } else {
611 SetState(app_list_state_);
612 }
613 break;
614 case PEEKING:
615 if (std::abs(drag_delta) > app_list_threshold) {
616 SetState(drag_delta > 0 ? FULLSCREEN_ALL_APPS : CLOSED);
617 } else if (location_in_screen_coordinates.y() >=
618 display_height - kAppListBezelMargin) {
619 // If the user drags to the bezel, close the app list.
620 SetState(CLOSED);
621 } else {
622 SetState(app_list_state_);
623 }
624 break;
625 case CLOSED:
626 NOTREACHED();
627 break;
561 } 628 }
562 } 629 }
563 } 630 }
564 631
632 void AppListView::SetStateFromSearchBoxView(bool search_box_is_empty) {
633 switch (app_list_state_) {
634 case PEEKING:
635 if (!search_box_is_empty)
636 SetState(HALF);
637 break;
638 case HALF:
639 if (search_box_is_empty)
640 SetState(PEEKING);
641 break;
642 case FULLSCREEN_SEARCH:
643 if (search_box_is_empty) {
644 SetState(FULLSCREEN_ALL_APPS);
645 app_list_main_view()->contents_view()->SetActiveState(
646 AppListModel::State::STATE_APPS);
647 }
648 break;
649 case FULLSCREEN_ALL_APPS:
650 if (!search_box_is_empty)
651 SetState(FULLSCREEN_SEARCH);
652 break;
653 case CLOSED:
654 NOTREACHED();
655 break;
656 }
657 }
658
659 void AppListView::OnMaximizeModeChanged(bool started) {
660 is_maximize_mode_ = started;
661 if (is_maximize_mode_ && !is_fullscreen()) {
662 // Set |app_list_state_| to a maximize mode friendly state.
663 SetState(app_list_state_ == PEEKING ? FULLSCREEN_ALL_APPS
664 : FULLSCREEN_SEARCH);
665 }
666 }
667
565 void AppListView::OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, 668 void AppListView::OnBeforeBubbleWidgetInit(views::Widget::InitParams* params,
566 views::Widget* widget) const { 669 views::Widget* widget) const {
567 if (!params->native_widget) { 670 if (!params->native_widget) {
568 views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance(); 671 views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance();
569 if (views_delegate && !views_delegate->native_widget_factory().is_null()) { 672 if (views_delegate && !views_delegate->native_widget_factory().is_null()) {
570 params->native_widget = 673 params->native_widget =
571 views_delegate->native_widget_factory().Run(*params, widget); 674 views_delegate->native_widget_factory().Run(*params, widget);
572 } 675 }
573 } 676 }
574 // Apply a WM-provided shadow (see ui/wm/core/). 677 // Apply a WM-provided shadow (see ui/wm/core/).
(...skipping 14 matching lines...) Expand all
589 } 692 }
590 693
591 void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const { 694 void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const {
592 DCHECK(mask); 695 DCHECK(mask);
593 DCHECK(GetBubbleFrameView()); 696 DCHECK(GetBubbleFrameView());
594 697
595 mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds())); 698 mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds()));
596 } 699 }
597 700
598 void AppListView::OnMouseEvent(ui::MouseEvent* event) { 701 void AppListView::OnMouseEvent(ui::MouseEvent* event) {
599 if (!IsFullscreenAppListEnabled()) 702 if (!is_fullscreen_app_list_enabled_)
600 return; 703 return;
601 704
602 switch (event->type()) { 705 switch (event->type()) {
603 case ui::ET_MOUSE_PRESSED: 706 case ui::ET_MOUSE_PRESSED:
604 StartDrag(event->location()); 707 StartDrag(event->location());
605 event->SetHandled(); 708 event->SetHandled();
606 break; 709 break;
607 case ui::ET_MOUSE_DRAGGED: 710 case ui::ET_MOUSE_DRAGGED:
608 UpdateDrag(event->location()); 711 UpdateDrag(event->location());
609 event->SetHandled(); 712 event->SetHandled();
610 break; 713 break;
611 case ui::ET_MOUSE_RELEASED: 714 case ui::ET_MOUSE_RELEASED:
612 EndDrag(event->location()); 715 EndDrag(event->location());
613 event->SetHandled(); 716 event->SetHandled();
614 break; 717 break;
615 default: 718 default:
616 break; 719 break;
617 } 720 }
618 } 721 }
619 722
620 void AppListView::OnGestureEvent(ui::GestureEvent* event) { 723 void AppListView::OnGestureEvent(ui::GestureEvent* event) {
621 if (!IsFullscreenAppListEnabled()) 724 if (!is_fullscreen_app_list_enabled_)
622 return; 725 return;
623 726
624 switch (event->type()) { 727 switch (event->type()) {
625 case ui::ET_GESTURE_SCROLL_BEGIN: 728 case ui::ET_GESTURE_SCROLL_BEGIN:
626 StartDrag(event->location()); 729 StartDrag(event->location());
627 event->SetHandled(); 730 event->SetHandled();
628 break; 731 break;
629 case ui::ET_GESTURE_SCROLL_UPDATE: 732 case ui::ET_GESTURE_SCROLL_UPDATE:
630 last_fling_velocity_ = event->details().velocity_y(); 733 last_fling_velocity_ = event->details().velocity_y();
631 UpdateDrag(event->location()); 734 UpdateDrag(event->location());
632 event->SetHandled(); 735 event->SetHandled();
633 break; 736 break;
634 case ui::ET_GESTURE_END: 737 case ui::ET_GESTURE_END:
635 EndDrag(event->location()); 738 EndDrag(event->location());
636 event->SetHandled(); 739 event->SetHandled();
637 break; 740 break;
638 default: 741 default:
639 break; 742 break;
640 } 743 }
641 } 744 }
642 745
643 bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) { 746 bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) {
644 DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code()); 747 DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code());
645 748
646 // If the ContentsView does not handle the back action, then this is the 749 // If the ContentsView does not handle the back action, then this is the
647 // top level, so we close the app list. 750 // top level, so we close the app list.
648 if (!app_list_main_view_->contents_view()->Back()) { 751 if (!app_list_main_view_->contents_view()->Back()) {
649 if (IsFullscreenAppListEnabled()) { 752 if (is_fullscreen_app_list_enabled_) {
650 SetState(CLOSED); 753 SetState(CLOSED);
651 } else { 754 } else {
652 app_list_main_view_->Close(); 755 app_list_main_view_->Close();
653 delegate_->Dismiss(); 756 delegate_->Dismiss();
654 } 757 }
655 GetWidget()->Deactivate(); 758 GetWidget()->Deactivate();
656 } 759 }
657 760
658 // Don't let DialogClientView handle the accelerator. 761 // Don't let DialogClientView handle the accelerator.
659 return true; 762 return true;
(...skipping 14 matching lines...) Expand all
674 if (speech_view_) { 777 if (speech_view_) {
675 gfx::Rect speech_bounds = centered_bounds; 778 gfx::Rect speech_bounds = centered_bounds;
676 int preferred_height = speech_view_->GetPreferredSize().height(); 779 int preferred_height = speech_view_->GetPreferredSize().height();
677 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin); 780 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin);
678 speech_bounds.set_height( 781 speech_bounds.set_height(
679 std::min(speech_bounds.height(), preferred_height)); 782 std::min(speech_bounds.height(), preferred_height));
680 speech_bounds.Inset(-speech_view_->GetInsets()); 783 speech_bounds.Inset(-speech_view_->GetInsets());
681 speech_view_->SetBoundsRect(speech_bounds); 784 speech_view_->SetBoundsRect(speech_bounds);
682 } 785 }
683 786
684 if (IsFullscreenAppListEnabled()) { 787 if (is_fullscreen_app_list_enabled_) {
685 app_list_main_view_->contents_view()->Layout(); 788 app_list_main_view_->contents_view()->Layout();
686 app_list_background_shield_->SetBoundsRect(contents_bounds); 789 app_list_background_shield_->SetBoundsRect(contents_bounds);
687 } 790 }
688 } 791 }
689 792
690 void AppListView::SchedulePaintInRect(const gfx::Rect& rect) { 793 void AppListView::SchedulePaintInRect(const gfx::Rect& rect) {
691 BubbleDialogDelegateView::SchedulePaintInRect(rect); 794 BubbleDialogDelegateView::SchedulePaintInRect(rect);
692 if (GetBubbleFrameView()) 795 if (GetBubbleFrameView())
693 GetBubbleFrameView()->SchedulePaint(); 796 GetBubbleFrameView()->SchedulePaint();
694 } 797 }
695 798
696 void AppListView::SetState(AppListState new_state) { 799 void AppListView::SetState(AppListState new_state) {
800 AppListState new_state_override = new_state;
801 if (is_side_shelf_ || is_maximize_mode_) {
802 // If side shelf or maximize mode are active, all transitions should be
803 // made to the maximize mode/side shelf friendly versions.
804 if (new_state == PEEKING)
805 new_state_override = FULLSCREEN_ALL_APPS;
806 else if (new_state == HALF)
807 new_state_override = FULLSCREEN_SEARCH;
808 }
809
697 gfx::Rect new_widget_bounds = fullscreen_widget_->GetWindowBoundsInScreen(); 810 gfx::Rect new_widget_bounds = fullscreen_widget_->GetWindowBoundsInScreen();
698 switch (new_state) { 811 int display_height = display::Screen::GetScreen()
812 ->GetDisplayNearestView(parent_window())
813 .work_area()
814 .bottom();
815
816 switch (new_state_override) {
699 case PEEKING: { 817 case PEEKING: {
700 int display_height = display::Screen::GetScreen() 818 switch (app_list_state_) {
701 ->GetDisplayNearestView(parent_window()) 819 case HALF:
702 .work_area() 820 case FULLSCREEN_ALL_APPS:
703 .bottom(); 821 case PEEKING: {
704 int default_peeking_y = 822 int peeking_app_list_y = display_height - kPeekingAppListHeight;
705 display_height + kShelfSize - kPeekingAppListHeight; 823 new_widget_bounds.set_y(peeking_app_list_y);
706 new_widget_bounds.set_y(default_peeking_y); 824 app_list_main_view_->contents_view()->SetActiveState(
825 AppListModel::STATE_START);
826 break;
827 }
828 case FULLSCREEN_SEARCH:
829 case CLOSED:
830 NOTREACHED();
831 break;
832 }
707 break; 833 break;
708 } 834 }
709 case FULLSCREEN: 835 case HALF:
836 switch (app_list_state_) {
837 case PEEKING:
838 case HALF: {
839 int half_app_list_y = display_height - kHalfAppListHeight;
840 new_widget_bounds.set_y(half_app_list_y);
841 break;
842 }
843 case FULLSCREEN_SEARCH:
844 case FULLSCREEN_ALL_APPS:
845 case CLOSED:
846 NOTREACHED();
847 break;
848 }
849 break;
850 case FULLSCREEN_ALL_APPS:
851 new_widget_bounds.set_y(0);
852 app_list_main_view_->contents_view()->SetActiveState(
853 AppListModel::STATE_APPS);
854 break;
855 case FULLSCREEN_SEARCH:
710 new_widget_bounds.set_y(0); 856 new_widget_bounds.set_y(0);
711 break; 857 break;
712 case CLOSED: 858 case CLOSED:
713 app_list_main_view_->Close(); 859 app_list_main_view_->Close();
714 delegate_->Dismiss(); 860 delegate_->Dismiss();
715 break; 861 break;
716 } 862 }
717 fullscreen_widget_->SetBounds(new_widget_bounds); 863 fullscreen_widget_->SetBounds(new_widget_bounds);
718 app_list_state_ = new_state; 864 app_list_state_ = new_state_override;
719 } 865 }
720 866
721 void AppListView::OnWidgetDestroying(views::Widget* widget) { 867 void AppListView::OnWidgetDestroying(views::Widget* widget) {
722 BubbleDialogDelegateView::OnWidgetDestroying(widget); 868 BubbleDialogDelegateView::OnWidgetDestroying(widget);
723 if (delegate_ && widget == GetWidget()) 869 if (delegate_ && widget == GetWidget())
724 delegate_->ViewClosing(); 870 delegate_->ViewClosing();
725 } 871 }
726 872
727 void AppListView::OnWidgetVisibilityChanged(views::Widget* widget, 873 void AppListView::OnWidgetVisibilityChanged(views::Widget* widget,
728 bool visible) { 874 bool visible) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 // Refocus the search box. However, if the app list widget does not have 943 // Refocus the search box. However, if the app list widget does not have
798 // focus, it means another window has already taken focus, and we *must not* 944 // focus, it means another window has already taken focus, and we *must not*
799 // focus the search box (or we would steal focus back into the app list). 945 // focus the search box (or we would steal focus back into the app list).
800 if (GetWidget()->IsActive()) 946 if (GetWidget()->IsActive())
801 search_box_view_->search_box()->RequestFocus(); 947 search_box_view_->search_box()->RequestFocus();
802 } 948 }
803 } 949 }
804 950
805 void AppListView::OnDisplayMetricsChanged(const display::Display& display, 951 void AppListView::OnDisplayMetricsChanged(const display::Display& display,
806 uint32_t changed_metrics) { 952 uint32_t changed_metrics) {
807 if (!IsFullscreenAppListEnabled()) 953 if (!is_fullscreen_app_list_enabled_)
808 return; 954 return;
809 955
810 // Set the |fullscreen_widget_| size to fit the new display metrics. 956 // Set the |fullscreen_widget_| size to fit the new display metrics.
811 gfx::Size size = display::Screen::GetScreen() 957 gfx::Size size = display::Screen::GetScreen()
812 ->GetDisplayNearestView(parent_window()) 958 ->GetDisplayNearestView(parent_window())
813 .work_area() 959 .work_area()
814 .size(); 960 .size();
815 size.Enlarge(0, kShelfSize); 961 size.Enlarge(0, kShelfSize);
816 fullscreen_widget_->SetSize(size); 962 fullscreen_widget_->SetSize(size);
817 963
818 // Update the |fullscreen_widget_| bounds to accomodate the new work area. 964 // Update the |fullscreen_widget_| bounds to accomodate the new work area.
819 SetState(app_list_state_); 965 SetState(app_list_state_);
820 } 966 }
821 967
822 } // namespace app_list 968 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698