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