folder_background_view.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/app_list/views/folder_background_view.h"
  5. #include "ash/app_list/views/app_list_folder_view.h"
  6. #include "ash/keyboard/ui/keyboard_ui_controller.h"
  7. namespace ash {
  8. FolderBackgroundView::FolderBackgroundView(AppListFolderView* folder_view)
  9. : folder_view_(folder_view) {}
  10. FolderBackgroundView::~FolderBackgroundView() = default;
  11. const char* FolderBackgroundView::GetClassName() const {
  12. return "FolderBackgroundView";
  13. }
  14. bool FolderBackgroundView::OnMousePressed(const ui::MouseEvent& event) {
  15. HandleClickOrTap();
  16. return true;
  17. }
  18. void FolderBackgroundView::OnGestureEvent(ui::GestureEvent* event) {
  19. // A fix for the current folder close animation should be implemented to allow
  20. // for a folder to close while pages are changing. Until this, we should
  21. // always close the folder before movement.
  22. // https://crbug.com/875133
  23. HandleClickOrTap();
  24. event->SetHandled();
  25. }
  26. void FolderBackgroundView::HandleClickOrTap() {
  27. // If the virtual keyboard is visible, dismiss the keyboard and return early
  28. auto* const keyboard_controller = keyboard::KeyboardUIController::Get();
  29. if (keyboard_controller->IsKeyboardVisible()) {
  30. keyboard_controller->HideKeyboardByUser();
  31. return;
  32. }
  33. // TODO(ginko): make the first tap close the keyboard only, and the second tap
  34. // close the folder. Bug: https://crbug.com/879329
  35. folder_view_->CloseFolderPage();
  36. }
  37. } // namespace ash