[go: nahoru, domu]

tree: 7db95f45b45d60119781536a8d40b21bd2fdac67 [path history] [tgz]
  1. test/
  2. assistant_overlay.cc
  3. assistant_overlay.h
  4. assistant_overlay_unittest.cc
  5. back_button.cc
  6. back_button.h
  7. back_button_unittest.cc
  8. desk_button_widget.cc
  9. desk_button_widget.h
  10. DIR_METADATA
  11. drag_handle.cc
  12. drag_handle.h
  13. drag_handle_unittest.cc
  14. drag_window_from_shelf_controller.cc
  15. drag_window_from_shelf_controller.h
  16. drag_window_from_shelf_controller_test_api.cc
  17. drag_window_from_shelf_controller_test_api.h
  18. drag_window_from_shelf_controller_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. kiosk_app_instruction_bubble.cc
  35. kiosk_app_instruction_bubble.h
  36. kiosk_apps_button.cc
  37. kiosk_apps_button.h
  38. launcher_nudge_controller.cc
  39. launcher_nudge_controller.h
  40. launcher_nudge_controller_unittest.cc
  41. login_shelf_button.cc
  42. login_shelf_button.h
  43. login_shelf_view.cc
  44. login_shelf_view.h
  45. login_shelf_view_pixeltest.cc
  46. login_shelf_view_unittest.cc
  47. login_shelf_widget.cc
  48. login_shelf_widget.h
  49. OWNERS
  50. README.md
  51. scroll_arrow_view.cc
  52. scroll_arrow_view.h
  53. scrollable_shelf_constants.cc
  54. scrollable_shelf_constants.h
  55. scrollable_shelf_view.cc
  56. scrollable_shelf_view.h
  57. scrollable_shelf_view_pixeltest.cc
  58. scrollable_shelf_view_unittest.cc
  59. shelf.cc
  60. shelf.h
  61. shelf_app_button.cc
  62. shelf_app_button.h
  63. shelf_application_menu_model.cc
  64. shelf_application_menu_model.h
  65. shelf_application_menu_model_unittest.cc
  66. shelf_background_animator.cc
  67. shelf_background_animator.h
  68. shelf_background_animator_observer.h
  69. shelf_background_animator_unittest.cc
  70. shelf_bubble.cc
  71. shelf_bubble.h
  72. shelf_button.cc
  73. shelf_button.h
  74. shelf_button_delegate.cc
  75. shelf_button_delegate.h
  76. shelf_button_pressed_metric_tracker.cc
  77. shelf_button_pressed_metric_tracker.h
  78. shelf_button_pressed_metric_tracker_test_api.cc
  79. shelf_button_pressed_metric_tracker_test_api.h
  80. shelf_button_pressed_metric_tracker_unittest.cc
  81. shelf_component.h
  82. shelf_config.cc
  83. shelf_config_unittest.cc
  84. shelf_container_view.cc
  85. shelf_container_view.h
  86. shelf_context_menu_model.cc
  87. shelf_context_menu_model.h
  88. shelf_context_menu_model_unittest.cc
  89. shelf_control_button.cc
  90. shelf_control_button.h
  91. shelf_controller.cc
  92. shelf_controller.h
  93. shelf_controller_unittest.cc
  94. shelf_drag_handle_unittest.cc
  95. shelf_focus_cycler.cc
  96. shelf_focus_cycler.h
  97. shelf_layout_manager.cc
  98. shelf_layout_manager.h
  99. shelf_layout_manager_observer.h
  100. shelf_layout_manager_pixeltest.cc
  101. shelf_layout_manager_unittest.cc
  102. shelf_locking_manager.cc
  103. shelf_locking_manager.h
  104. shelf_locking_manager_unittest.cc
  105. shelf_menu_model_adapter.cc
  106. shelf_menu_model_adapter.h
  107. shelf_metrics.h
  108. shelf_navigation_widget.cc
  109. shelf_navigation_widget.h
  110. shelf_observer.h
  111. shelf_shutdown_confirmation_bubble.cc
  112. shelf_shutdown_confirmation_bubble.h
  113. shelf_test_api.cc
  114. shelf_test_util.cc
  115. shelf_test_util.h
  116. shelf_tooltip_bubble.cc
  117. shelf_tooltip_bubble.h
  118. shelf_tooltip_delegate.h
  119. shelf_tooltip_manager.cc
  120. shelf_tooltip_manager.h
  121. shelf_tooltip_manager_unittest.cc
  122. shelf_unittest.cc
  123. shelf_view.cc
  124. shelf_view.h
  125. shelf_view_test_api.cc
  126. shelf_view_test_api.h
  127. shelf_view_unittest.cc
  128. shelf_widget.cc
  129. shelf_widget.h
  130. shelf_widget_unittest.cc
  131. shelf_window_targeter.cc
  132. shelf_window_targeter.h
  133. shelf_window_watcher.cc
  134. shelf_window_watcher.h
  135. shelf_window_watcher_item_delegate.cc
  136. shelf_window_watcher_item_delegate.h
  137. shelf_window_watcher_unittest.cc
  138. swipe_home_to_overview_controller.cc
  139. swipe_home_to_overview_controller.h
  140. swipe_home_to_overview_controller_unittest.cc
  141. window_preview.cc
  142. window_preview.h
  143. window_scale_animation.cc
  144. window_scale_animation.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.