tree: 7deab62fd5b243bbc5d15d6d35c8170e3a584727 [path history] [tgz]
  1. DIR_METADATA
  2. OWNERS
  3. README.md
  4. assistant_overlay.cc
  5. assistant_overlay.h
  6. back_button.cc
  7. back_button.h
  8. back_button_unittest.cc
  9. contextual_nudge.cc
  10. contextual_nudge.h
  11. contextual_nudge_status_tracker.cc
  12. contextual_nudge_status_tracker.h
  13. contextual_tooltip.cc
  14. contextual_tooltip.h
  15. contextual_tooltip_unittest.cc
  16. drag_handle.cc
  17. drag_handle.h
  18. drag_handle_unittest.cc
  19. home_button.cc
  20. home_button.h
  21. home_button_controller.cc
  22. home_button_controller.h
  23. home_button_unittest.cc
  24. home_to_overview_nudge_controller.cc
  25. home_to_overview_nudge_controller.h
  26. home_to_overview_nudge_controller_unittest.cc
  27. hotseat_transition_animator.cc
  28. hotseat_transition_animator.h
  29. hotseat_widget.cc
  30. hotseat_widget.h
  31. hotseat_widget_unittest.cc
  32. in_app_to_home_nudge_controller.cc
  33. in_app_to_home_nudge_controller.h
  34. login_shelf_gesture_controller.cc
  35. login_shelf_gesture_controller.h
  36. login_shelf_gesture_controller_unittest.cc
  37. login_shelf_view.cc
  38. login_shelf_view.h
  39. login_shelf_view_unittest.cc
  40. scroll_arrow_view.cc
  41. scroll_arrow_view.h
  42. scrollable_shelf_view.cc
  43. scrollable_shelf_view.h
  44. scrollable_shelf_view_unittest.cc
  45. shelf.cc
  46. shelf.h
  47. shelf_app_button.cc
  48. shelf_app_button.h
  49. shelf_app_button_unittest.cc
  50. shelf_application_menu_model.cc
  51. shelf_application_menu_model.h
  52. shelf_application_menu_model_unittest.cc
  53. shelf_background_animator.cc
  54. shelf_background_animator.h
  55. shelf_background_animator_observer.h
  56. shelf_background_animator_unittest.cc
  57. shelf_bubble.cc
  58. shelf_bubble.h
  59. shelf_button.cc
  60. shelf_button.h
  61. shelf_button_delegate.cc
  62. shelf_button_delegate.h
  63. shelf_button_pressed_metric_tracker.cc
  64. shelf_button_pressed_metric_tracker.h
  65. shelf_button_pressed_metric_tracker_test_api.cc
  66. shelf_button_pressed_metric_tracker_test_api.h
  67. shelf_button_pressed_metric_tracker_unittest.cc
  68. shelf_component.h
  69. shelf_config.cc
  70. shelf_config_unittest.cc
  71. shelf_container_view.cc
  72. shelf_container_view.h
  73. shelf_context_menu_model.cc
  74. shelf_context_menu_model.h
  75. shelf_context_menu_model_unittest.cc
  76. shelf_control_button.cc
  77. shelf_control_button.h
  78. shelf_controller.cc
  79. shelf_controller.h
  80. shelf_controller_unittest.cc
  81. shelf_drag_handle_unittest.cc
  82. shelf_focus_cycler.cc
  83. shelf_focus_cycler.h
  84. shelf_layout_manager.cc
  85. shelf_layout_manager.h
  86. shelf_layout_manager_observer.h
  87. shelf_layout_manager_unittest.cc
  88. shelf_locking_manager.cc
  89. shelf_locking_manager.h
  90. shelf_locking_manager_unittest.cc
  91. shelf_menu_model_adapter.cc
  92. shelf_menu_model_adapter.h
  93. shelf_metrics.h
  94. shelf_navigation_widget.cc
  95. shelf_navigation_widget.h
  96. shelf_observer.h
  97. shelf_test_api.cc
  98. shelf_test_util.cc
  99. shelf_test_util.h
  100. shelf_tooltip_bubble.cc
  101. shelf_tooltip_bubble.h
  102. shelf_tooltip_delegate.h
  103. shelf_tooltip_manager.cc
  104. shelf_tooltip_manager.h
  105. shelf_tooltip_manager_unittest.cc
  106. shelf_tooltip_preview_bubble.cc
  107. shelf_tooltip_preview_bubble.h
  108. shelf_unittest.cc
  109. shelf_view.cc
  110. shelf_view.h
  111. shelf_view_test_api.cc
  112. shelf_view_test_api.h
  113. shelf_view_unittest.cc
  114. shelf_widget.cc
  115. shelf_widget.h
  116. shelf_widget_unittest.cc
  117. shelf_window_targeter.cc
  118. shelf_window_targeter.h
  119. shelf_window_watcher.cc
  120. shelf_window_watcher.h
  121. shelf_window_watcher_item_delegate.cc
  122. shelf_window_watcher_item_delegate.h
  123. shelf_window_watcher_unittest.cc
  124. test/
  125. window_preview.cc
  126. window_preview.h
ash/shelf/README.md

Shelf

This is the ash shelf, the system interface surface that allows users to launch application shortcuts or go to the home screen, among other things.

Components

The shelf contains the following components, each of which lives in its own widget:

  • The shelf widget contains no actionable UI but contains the semi-opaque background shown behind the whole shelf as well as the drag handle (in certain circumstances) to give users a hint that gestures can be performed. In that sense, even though the shelf widget does not actually contain other components, it usually serves as a backdrop for them.

  • The navigation widget contains the home and back buttons. It is usually shown in clamshell mode (but only with the home button) and hidden in tablet mode, unless the activation of select accessibility features forces it to be shown. When the navigation widget is not shown, the user can achieve the same actions by performing gestures.

  • The hotseat widget contains icons for application shortcuts and running applications. In clamshell mode, it is always visually contained within the shelf widget; in tablet mode, it can appear and move independently.

  • The status area widget (whose code lives in ash/system) shows information such as the clock or current battery level, and can toggle the system tray.

Alignment

The shelf is aligned to the bottom of the screen by default, but the user can choose (only in clamshell mode) to align it to the left or right of the screen. It always occupies the entirety of the corresponding dimension (width for a horizontal shelf, height otherwise), with the navigation widget shown at the start (top or left in left-to-right interfaces, bottom or right in right-to-left) and the status area at the other end.

Auto-hiding

The system allows the user to set a boolean preference, on a per-display basis, specifying whether the shelf should “auto-hide”. In that case, the shelf and its components will be hidden from the screen most of the time, unless there are no un-minimized windows or unless the user actively brings up the shelf with the mouse or with a swipe.

Centering

The hotseat widget is centered on the screen according to the following principle:

  • All icons are placed at the center of the whole display if they can fit without overlapping with any other shelf component.

  • Otherwise, they are centered within the space available to the hotseat.

  • If there are too many icons to fit in that space, the hotseat becomes scrollable.

Responsive layout

The shelf and its components need to adjust to a certain number of changes that may or may not be user-triggered:

  • Switching between clamshell and tablet mode.

  • Changing the display size (for smaller displays, the shelf becomes more compact) or orientation.

  • Changing the shelf alignment.

  • User events (clicks, taps, swipes).

Coordination

All shelf components need to react to these changes in a coordinated manner to maintain the smoothness of animations.

Components should not register themselves as observers of these changes and react to them on their own, because an adequate reaction may involve other components as well. For instance, whether the navigation widget is shown (or is scheduled to be shown at the end of the animation) will influence the amount of space the hotseat widget can occupy.

Instead, listening to those changes are handled at the ShelfLayoutManager level, which is then responsible for making the changes trickling down to each component as necessary.

Aim first, move second

In reaction to any of these global changes, each component must first determine where it wants to be at the end of the animation (“aim”). That calculation may depend on the other shelf components. Then, and only then, should the change of bounds be actually committed to each widget and the animations triggered (“move”). Failing to respect this “two-phase” approach may lead to janky animations as each component may realize, only after it has started moving, that another component's movement forces it to alter its final destination.

ShelfComponent interface

Each of the shelf components exposes an API to other classes in order to ease the process of responding to layout changes:

  • CalculateTargetBounds is the “aim” phase, where each component figures out where it wants to be given the new conditions. This method must be called on each component by order of dependency (a component B “depends” on another component A if B needs to know A's target bounds before calculating its own).

  • GetTargetBounds allows for components depending on this one to calculate their own target bounds accordingly.

  • UpdateLayout is the “move” phase, where each component actually changes it bounds according to its target.

  • UpdateTargetBoundsForGesture allows each component to respond to a gesture in progress by determining how (and whether) it should follow other components along in the gesture.

Layout inputs

Each shelf component is aware of the set of inputs that can cause its layout to change. Each time the UpdateLayout method is called on it, it determines whether any of its inputs has changed. If not, the method returns early and avoids any actual re-layout for itself as well as other components that depend solely on it.

Keyboard navigation

In order for keyboard users to navigate smoothly between the various parts of the shelf as they would expect, the ShelfFocusCycler class passes the focus to each shelf component as appropriate, depending on which component has just reliquished focus and on which direction the focus is going. The ShelfWidget class is the only shelf component that doesn't receive keyboard focus since it does not have any activatable elements.

Buttons

The base class for all buttons on shelf components is ShelfButton, which handles basic logic for keyboard navigation and ink drops. This class is then derived into ShelfControlButton for things like the home or back button, and ShelfAppButton for application shortcuts.

Tooltips

Tooltips for elements on the shelf require some specific logic on top of the common tooltips because as a user hovers over each app shortcut, trying to figure out what each one does, we do not want to adopt the default tooltip behavior which would be to dismiss the previous tooltip and make the user wait for the common timeout before showing the next one.