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