app_list_util.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright (c) 2017 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. #ifndef ASH_APP_LIST_APP_LIST_UTIL_H_
  5. #define ASH_APP_LIST_APP_LIST_UTIL_H_
  6. #include "ash/ash_export.h"
  7. #include "third_party/skia/include/core/SkColor.h"
  8. #include "ui/events/keycodes/keyboard_codes.h"
  9. namespace gfx {
  10. class Canvas;
  11. class ImageSkia;
  12. class Point;
  13. } // namespace gfx
  14. namespace ui {
  15. class KeyEvent;
  16. } // namespace ui
  17. namespace views {
  18. class Textfield;
  19. class View;
  20. } // namespace views
  21. namespace ash {
  22. class AppListItem;
  23. // Returns true if the key event is an unhandled left or right arrow (unmodified
  24. // by ctrl, shift, or alt)
  25. ASH_EXPORT bool IsUnhandledLeftRightKeyEvent(const ui::KeyEvent& event);
  26. // Returns true if the key event is an unhandled up or down arrow (unmodified by
  27. // ctrl, shift, or alt)
  28. ASH_EXPORT bool IsUnhandledUpDownKeyEvent(const ui::KeyEvent& event);
  29. // Returns true if the key event is an unhandled arrow key event of any type
  30. // (unmodified by ctrl, shift, or alt)
  31. ASH_EXPORT bool IsUnhandledArrowKeyEvent(const ui::KeyEvent& event);
  32. // Returns whether the event is an arrow key event.
  33. ASH_EXPORT bool IsArrowKeyEvent(const ui::KeyEvent& event);
  34. // Returns true if the keyboard code is one of: |VKEY_UP|, |VKEY_LEFT|,
  35. // |VKEY_RIGHT|, |VKEY_DOWN|
  36. ASH_EXPORT bool IsArrowKey(const ui::KeyboardCode& key_code);
  37. // Returns true if the `item` is a folder item.
  38. ASH_EXPORT bool IsFolderItem(AppListItem* item);
  39. // Returns true if the arrow key event should move focus away from the
  40. // `textfield`. This is usually when the insertion point would move away from
  41. // text.
  42. ASH_EXPORT bool LeftRightKeyEventShouldExitText(views::Textfield* textfield,
  43. const ui::KeyEvent& key_event);
  44. // Processes left/right key traversal for the given `textfield`. Returns true
  45. // if focus is moved.
  46. ASH_EXPORT bool ProcessLeftRightKeyTraversalForTextfield(
  47. views::Textfield* textfield,
  48. const ui::KeyEvent& key_event);
  49. // Returns a new image with the `icon` atop a circle background with
  50. // `background_color`.
  51. ASH_EXPORT gfx::ImageSkia CreateIconWithCircleBackground(
  52. const gfx::ImageSkia& icon);
  53. // Paints a rounded focus bar on `canvas` starting at `content_origin` extending
  54. // `height` dips vertically.
  55. ASH_EXPORT void PaintFocusBar(gfx::Canvas* canvas,
  56. const gfx::Point& content_origin,
  57. int height);
  58. // Paints a circle on `canvas` centered at `content_origin` with inner radius
  59. // `radius`.
  60. ASH_EXPORT void PaintFocusRing(gfx::Canvas* canvas,
  61. const gfx::Point& content_origin,
  62. int outer_radius);
  63. // Sets a view as an ignored leaf node, so that it and its child views will be
  64. // ignored by ChromeVox.
  65. ASH_EXPORT void SetViewIgnoredForAccessibility(views::View* view, bool ignored);
  66. // Get the scale factor for the cardified apps grid and app icons.
  67. ASH_EXPORT float GetAppsGridCardifiedScale();
  68. } // namespace ash
  69. #endif // ASH_APP_LIST_APP_LIST_UTIL_H_