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

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

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