[email protected] | 1b62b89 | 2012-01-17 17:08:15 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 5 | #ifndef ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ |
| 6 | #define ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 7 | |
[email protected] | 6c4ad7e | 2013-06-07 19:57:58 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
[email protected] | 27f6af6 | 2012-03-21 05:34:40 | [diff] [blame] | 10 | #include "ash/ash_export.h" |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 11 | #include "ash/shelf/background_animator.h" |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 12 | #include "ash/shelf/shelf.h" |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 13 | #include "ash/shelf/shelf_types.h" |
[email protected] | 8e43cdf4 | 2012-05-11 17:03:31 | [diff] [blame] | 14 | #include "ash/shell_observer.h" |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 15 | #include "ash/system/status_area_widget.h" |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 16 | #include "ash/wm/dock/docked_window_layout_manager_observer.h" |
[email protected] | 0955068 | 2013-09-10 16:23:28 | [diff] [blame] | 17 | #include "ash/wm/lock_state_observer.h" |
[email protected] | a3e41271 | 2013-07-11 09:32:58 | [diff] [blame] | 18 | #include "ash/wm/workspace/workspace_types.h" |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 19 | #include "base/basictypes.h" |
| 20 | #include "base/compiler_specific.h" |
[email protected] | 1fcfb99 | 2012-12-05 01:47:23 | [diff] [blame] | 21 | #include "base/logging.h" |
[email protected] | cbc278f | 2012-07-10 03:40:21 | [diff] [blame] | 22 | #include "base/observer_list.h" |
[email protected] | 1e84c63 | 2013-06-27 23:12:21 | [diff] [blame] | 23 | #include "base/timer/timer.h" |
[email protected] | 1ae36165 | 2012-12-12 22:39:51 | [diff] [blame] | 24 | #include "ui/aura/client/activation_change_observer.h" |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 25 | #include "ui/aura/layout_manager.h" |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 26 | #include "ui/gfx/insets.h" |
| 27 | #include "ui/gfx/rect.h" |
[email protected] | 5416f28 | 2013-04-29 20:52:48 | [diff] [blame] | 28 | #include "ui/keyboard/keyboard_controller.h" |
| 29 | #include "ui/keyboard/keyboard_controller_observer.h" |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 30 | |
[email protected] | 8676f047 | 2012-03-29 20:30:12 | [diff] [blame] | 31 | namespace aura { |
| 32 | class RootWindow; |
| 33 | } |
| 34 | |
[email protected] | 3c6abbe | 2012-08-30 23:48:57 | [diff] [blame] | 35 | namespace ui { |
| 36 | class GestureEvent; |
[email protected] | 93946490 | 2013-08-14 23:48:19 | [diff] [blame] | 37 | class ImplicitAnimationObserver; |
[email protected] | 3c6abbe | 2012-08-30 23:48:57 | [diff] [blame] | 38 | } |
| 39 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 40 | namespace ash { |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 41 | class ScreenAsh; |
[email protected] | 7841e117 | 2013-05-07 03:53:33 | [diff] [blame] | 42 | class ShelfLayoutManagerObserver; |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 43 | class ShelfWidget; |
[email protected] | d93c6c4 | 2013-08-14 05:04:26 | [diff] [blame] | 44 | FORWARD_DECLARE_TEST(WebNotificationTrayTest, PopupAndFullscreen); |
| 45 | |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 46 | namespace internal { |
| 47 | |
[email protected] | 89d3c9b0 | 2013-04-27 07:01:42 | [diff] [blame] | 48 | class PanelLayoutManagerTest; |
[email protected] | 6c4ad7e | 2013-06-07 19:57:58 | [diff] [blame] | 49 | class ShelfBezelEventFilter; |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 50 | class ShelfLayoutManagerTest; |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 51 | class StatusAreaWidget; |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 52 | class WorkspaceController; |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 53 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 54 | // ShelfLayoutManager is the layout manager responsible for the shelf and |
| 55 | // status widgets. The shelf is given the total available width and told the |
| 56 | // width of the status area. This allows the shelf to draw the background and |
[email protected] | 22f9d31 | 2011-12-15 17:38:55 | [diff] [blame] | 57 | // layout to the status area. |
| 58 | // To respond to bounds changes in the status area StatusAreaLayoutManager works |
| 59 | // closely with ShelfLayoutManager. |
[email protected] | e76310a9 | 2012-06-04 19:06:11 | [diff] [blame] | 60 | class ASH_EXPORT ShelfLayoutManager : |
| 61 | public aura::LayoutManager, |
| 62 | public ash::ShellObserver, |
[email protected] | 5416f28 | 2013-04-29 20:52:48 | [diff] [blame] | 63 | public aura::client::ActivationChangeObserver, |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 64 | public DockedWindowLayoutManagerObserver, |
[email protected] | 0955068 | 2013-09-10 16:23:28 | [diff] [blame] | 65 | public keyboard::KeyboardControllerObserver, |
| 66 | public LockStateObserver { |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 67 | public: |
[email protected] | 7ed9895 | 2013-04-02 23:04:50 | [diff] [blame] | 68 | |
[email protected] | d3643b5 | 2013-05-01 16:00:48 | [diff] [blame] | 69 | // We reserve a small area on the edge of the workspace area to ensure that |
| 70 | // the resize handle at the edge of the window can be hit. |
| 71 | static const int kWorkspaceAreaVisibleInset; |
| 72 | |
| 73 | // When autohidden we extend the touch hit target onto the screen so that the |
| 74 | // user can drag the shelf out. |
| 75 | static const int kWorkspaceAreaAutoHideInset; |
[email protected] | bbb59f8 | 2012-03-14 04:04:35 | [diff] [blame] | 76 | |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 77 | // Size of the shelf when auto-hidden. |
| 78 | static const int kAutoHideSize; |
[email protected] | b1c37fc | 2012-03-22 03:36:13 | [diff] [blame] | 79 | |
[email protected] | fda64c9e | 2014-03-12 21:45:32 | [diff] [blame] | 80 | // The size of the shelf when shown (currently only used in alternate |
| 81 | // settings see ash::switches::UseAlternateShelfLayout). |
| 82 | static const int kShelfSize; |
| 83 | |
[email protected] | 98f8f4a | 2013-09-19 01:21:26 | [diff] [blame] | 84 | // Inset between the inner edge of the shelf (towards centre of screen), and |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 85 | // the shelf items, notifications, status area etc. |
[email protected] | 98f8f4a | 2013-09-19 01:21:26 | [diff] [blame] | 86 | static const int kShelfItemInset; |
| 87 | |
[email protected] | fda64c9e | 2014-03-12 21:45:32 | [diff] [blame] | 88 | // Returns the preferred size for the shelf (either kShelfPreferredSize or |
| 89 | // kShelfSize). |
| 90 | static int GetPreferredShelfSize(); |
| 91 | |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 92 | explicit ShelfLayoutManager(ShelfWidget* shelf); |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 93 | virtual ~ShelfLayoutManager(); |
| 94 | |
[email protected] | 09f3fc8 | 2012-03-26 23:26:56 | [diff] [blame] | 95 | // Sets the ShelfAutoHideBehavior. See enum description for details. |
| 96 | void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); |
| 97 | ShelfAutoHideBehavior auto_hide_behavior() const { |
| 98 | return auto_hide_behavior_; |
| 99 | } |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 100 | |
[email protected] | c2d58b4 | 2012-05-30 08:11:29 | [diff] [blame] | 101 | // Sets the alignment. Returns true if the alignment is changed. Otherwise, |
| 102 | // returns false. |
| 103 | bool SetAlignment(ShelfAlignment alignment); |
[email protected] | 0955068 | 2013-09-10 16:23:28 | [diff] [blame] | 104 | // Returns the desired alignment for the current state, either the user's |
| 105 | // set alignment (alignment_) or SHELF_ALIGNMENT_BOTTOM when the screen |
| 106 | // is locked. |
| 107 | ShelfAlignment GetAlignment() const; |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 108 | |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 109 | void set_workspace_controller(WorkspaceController* controller) { |
| 110 | workspace_controller_ = controller; |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 111 | } |
| 112 | |
[email protected] | 93946490 | 2013-08-14 23:48:19 | [diff] [blame] | 113 | bool updating_bounds() const { return updating_bounds_; } |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 114 | |
[email protected] | a3e41271 | 2013-07-11 09:32:58 | [diff] [blame] | 115 | // Clears internal data for shutdown process. |
| 116 | void PrepareForShutdown(); |
| 117 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 118 | // Returns whether the shelf and its contents (shelf, status) are visible |
[email protected] | 40429f0 | 2012-03-28 20:38:50 | [diff] [blame] | 119 | // on the screen. |
| 120 | bool IsVisible() const; |
| 121 | |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 122 | // Returns the ideal bounds of the shelf assuming it is visible. |
| 123 | gfx::Rect GetIdealBounds(); |
| 124 | |
[email protected] | 494b1ef | 2013-12-07 01:00:07 | [diff] [blame] | 125 | // Returns the docked area bounds. |
| 126 | const gfx::Rect& dock_bounds() const { return dock_bounds_; } |
| 127 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 128 | // Stops any animations and sets the bounds of the shelf and status |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 129 | // widgets. |
| 130 | void LayoutShelf(); |
| 131 | |
[email protected] | 8e837ec | 2013-01-31 01:48:33 | [diff] [blame] | 132 | // Returns shelf visibility state based on current value of auto hide |
| 133 | // behavior setting. |
| 134 | ShelfVisibilityState CalculateShelfVisibility(); |
| 135 | |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 136 | // Updates the visibility state. |
| 137 | void UpdateVisibilityState(); |
[email protected] | 203fe858 | 2012-03-24 06:17:14 | [diff] [blame] | 138 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 139 | // Invoked by the shelf when the auto-hide state may have changed. |
[email protected] | b1c37fc | 2012-03-22 03:36:13 | [diff] [blame] | 140 | void UpdateAutoHideState(); |
| 141 | |
[email protected] | ef80e430 | 2012-12-04 19:37:31 | [diff] [blame] | 142 | ShelfVisibilityState visibility_state() const { |
| 143 | return state_.visibility_state; |
| 144 | } |
| 145 | ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; } |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 146 | |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 147 | ShelfWidget* shelf_widget() { return shelf_; } |
| 148 | |
[email protected] | 27f6af6 | 2012-03-21 05:34:40 | [diff] [blame] | 149 | // Sets whether any windows overlap the shelf. If a window overlaps the shelf |
| 150 | // the shelf renders slightly differently. |
| 151 | void SetWindowOverlapsShelf(bool value); |
[email protected] | 2feee2f | 2012-08-24 20:43:50 | [diff] [blame] | 152 | bool window_overlaps_shelf() const { return window_overlaps_shelf_; } |
[email protected] | 27f6af6 | 2012-03-21 05:34:40 | [diff] [blame] | 153 | |
[email protected] | 7841e117 | 2013-05-07 03:53:33 | [diff] [blame] | 154 | void AddObserver(ShelfLayoutManagerObserver* observer); |
| 155 | void RemoveObserver(ShelfLayoutManagerObserver* observer); |
[email protected] | cbc278f | 2012-07-10 03:40:21 | [diff] [blame] | 156 | |
[email protected] | f734b224 | 2014-02-12 17:29:45 | [diff] [blame] | 157 | // Gesture related functions: |
| 158 | void OnGestureEdgeSwipe(const ui::GestureEvent& gesture); |
[email protected] | 3c6abbe | 2012-08-30 23:48:57 | [diff] [blame] | 159 | void StartGestureDrag(const ui::GestureEvent& gesture); |
[email protected] | c8e2e83 | 2012-09-12 21:48:28 | [diff] [blame] | 160 | enum DragState { |
| 161 | DRAG_SHELF, |
| 162 | DRAG_TRAY |
| 163 | }; |
| 164 | // Returns DRAG_SHELF if the gesture should continue to drag the entire shelf. |
| 165 | // Returns DRAG_TRAY if the gesture can start dragging the tray-bubble from |
| 166 | // this point on. |
| 167 | DragState UpdateGestureDrag(const ui::GestureEvent& gesture); |
[email protected] | 4982ee1 | 2012-09-04 22:16:10 | [diff] [blame] | 168 | void CompleteGestureDrag(const ui::GestureEvent& gesture); |
[email protected] | 3c6abbe | 2012-08-30 23:48:57 | [diff] [blame] | 169 | void CancelGestureDrag(); |
| 170 | |
[email protected] | 5cc1b659 | 2014-01-28 23:21:31 | [diff] [blame] | 171 | // Set an animation duration override for the show / hide animation of the |
| 172 | // shelf. Specifying 0 leads to use the default. |
| 173 | void SetAnimationDurationOverride(int duration_override_in_ms); |
| 174 | |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 175 | // Overridden from aura::LayoutManager: |
| 176 | virtual void OnWindowResized() OVERRIDE; |
| 177 | virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; |
| 178 | virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; |
[email protected] | fa893ab6 | 2012-04-20 01:26:51 | [diff] [blame] | 179 | virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE; |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 180 | virtual void OnChildWindowVisibilityChanged(aura::Window* child, |
| 181 | bool visible) OVERRIDE; |
| 182 | virtual void SetChildBounds(aura::Window* child, |
| 183 | const gfx::Rect& requested_bounds) OVERRIDE; |
| 184 | |
[email protected] | 8e43cdf4 | 2012-05-11 17:03:31 | [diff] [blame] | 185 | // Overridden from ash::ShellObserver: |
| 186 | virtual void OnLockStateChanged(bool locked) OVERRIDE; |
| 187 | |
[email protected] | e76310a9 | 2012-06-04 19:06:11 | [diff] [blame] | 188 | // Overriden from aura::client::ActivationChangeObserver: |
[email protected] | 1ae36165 | 2012-12-12 22:39:51 | [diff] [blame] | 189 | virtual void OnWindowActivated(aura::Window* gained_active, |
| 190 | aura::Window* lost_active) OVERRIDE; |
[email protected] | 8676f047 | 2012-03-29 20:30:12 | [diff] [blame] | 191 | |
[email protected] | 0955068 | 2013-09-10 16:23:28 | [diff] [blame] | 192 | // Overridden from ash::LockStateObserver: |
| 193 | virtual void OnLockStateEvent(LockStateObserver::EventType event) OVERRIDE; |
| 194 | |
[email protected] | 1fcfb99 | 2012-12-05 01:47:23 | [diff] [blame] | 195 | // TODO(harrym|oshima): These templates will be moved to |
| 196 | // new Shelf class. |
| 197 | // A helper function that provides a shortcut for choosing |
| 198 | // values specific to a shelf alignment. |
| 199 | template<typename T> |
[email protected] | 8572c487 | 2013-01-12 17:16:07 | [diff] [blame] | 200 | T SelectValueForShelfAlignment(T bottom, T left, T right, T top) const { |
[email protected] | 0955068 | 2013-09-10 16:23:28 | [diff] [blame] | 201 | switch (GetAlignment()) { |
[email protected] | 1fcfb99 | 2012-12-05 01:47:23 | [diff] [blame] | 202 | case SHELF_ALIGNMENT_BOTTOM: |
| 203 | return bottom; |
| 204 | case SHELF_ALIGNMENT_LEFT: |
| 205 | return left; |
| 206 | case SHELF_ALIGNMENT_RIGHT: |
| 207 | return right; |
[email protected] | 8572c487 | 2013-01-12 17:16:07 | [diff] [blame] | 208 | case SHELF_ALIGNMENT_TOP: |
| 209 | return top; |
[email protected] | 1fcfb99 | 2012-12-05 01:47:23 | [diff] [blame] | 210 | } |
| 211 | NOTREACHED(); |
| 212 | return right; |
| 213 | } |
| 214 | |
| 215 | template<typename T> |
| 216 | T PrimaryAxisValue(T horizontal, T vertical) const { |
| 217 | return IsHorizontalAlignment() ? horizontal : vertical; |
| 218 | } |
| 219 | |
| 220 | // Is the shelf's alignment horizontal? |
| 221 | bool IsHorizontalAlignment() const; |
| 222 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 223 | // Returns a ShelfLayoutManager on the display which has a shelf for |
| 224 | // given |window|. See RootWindowController::ForShelf for more info. |
| 225 | static ShelfLayoutManager* ForShelf(aura::Window* window); |
[email protected] | 1fcfb99 | 2012-12-05 01:47:23 | [diff] [blame] | 226 | |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 227 | private: |
[email protected] | b1c37fc | 2012-03-22 03:36:13 | [diff] [blame] | 228 | class AutoHideEventFilter; |
[email protected] | e4d9fe9 | 2012-09-10 14:04:49 | [diff] [blame] | 229 | class UpdateShelfObserver; |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 230 | friend class ash::ScreenAsh; |
[email protected] | 89d3c9b0 | 2013-04-27 07:01:42 | [diff] [blame] | 231 | friend class PanelLayoutManagerTest; |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 232 | friend class ShelfLayoutManagerTest; |
[email protected] | d93c6c4 | 2013-08-14 05:04:26 | [diff] [blame] | 233 | FRIEND_TEST_ALL_PREFIXES(ash::WebNotificationTrayTest, PopupAndFullscreen); |
[email protected] | b1c37fc | 2012-03-22 03:36:13 | [diff] [blame] | 234 | |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 235 | struct TargetBounds { |
[email protected] | 9e52129b9 | 2012-08-09 16:14:30 | [diff] [blame] | 236 | TargetBounds(); |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 237 | ~TargetBounds(); |
[email protected] | 27f6af6 | 2012-03-21 05:34:40 | [diff] [blame] | 238 | |
| 239 | float opacity; |
[email protected] | e4af7c6 | 2013-06-20 08:31:55 | [diff] [blame] | 240 | float status_opacity; |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 241 | gfx::Rect shelf_bounds_in_root; |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 242 | gfx::Rect shelf_bounds_in_shelf; |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 243 | gfx::Rect status_bounds_in_shelf; |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 244 | gfx::Insets work_area_insets; |
| 245 | }; |
| 246 | |
[email protected] | 27f6af6 | 2012-03-21 05:34:40 | [diff] [blame] | 247 | struct State { |
[email protected] | ef80e430 | 2012-12-04 19:37:31 | [diff] [blame] | 248 | State() : visibility_state(SHELF_VISIBLE), |
| 249 | auto_hide_state(SHELF_AUTO_HIDE_HIDDEN), |
[email protected] | a3e41271 | 2013-07-11 09:32:58 | [diff] [blame] | 250 | window_state(WORKSPACE_WINDOW_STATE_DEFAULT), |
[email protected] | 751444a | 2012-04-03 04:57:14 | [diff] [blame] | 251 | is_screen_locked(false) {} |
[email protected] | 27f6af6 | 2012-03-21 05:34:40 | [diff] [blame] | 252 | |
| 253 | // Returns true if the two states are considered equal. As |
[email protected] | ef80e430 | 2012-12-04 19:37:31 | [diff] [blame] | 254 | // |auto_hide_state| only matters if |visibility_state| is |
| 255 | // |SHELF_AUTO_HIDE|, Equals() ignores the |auto_hide_state| as |
| 256 | // appropriate. |
[email protected] | 27f6af6 | 2012-03-21 05:34:40 | [diff] [blame] | 257 | bool Equals(const State& other) const { |
| 258 | return other.visibility_state == visibility_state && |
[email protected] | ef80e430 | 2012-12-04 19:37:31 | [diff] [blame] | 259 | (visibility_state != SHELF_AUTO_HIDE || |
[email protected] | 751444a | 2012-04-03 04:57:14 | [diff] [blame] | 260 | other.auto_hide_state == auto_hide_state) && |
[email protected] | a3e41271 | 2013-07-11 09:32:58 | [diff] [blame] | 261 | other.window_state == window_state && |
[email protected] | 751444a | 2012-04-03 04:57:14 | [diff] [blame] | 262 | other.is_screen_locked == is_screen_locked; |
[email protected] | 27f6af6 | 2012-03-21 05:34:40 | [diff] [blame] | 263 | } |
| 264 | |
[email protected] | ef80e430 | 2012-12-04 19:37:31 | [diff] [blame] | 265 | ShelfVisibilityState visibility_state; |
| 266 | ShelfAutoHideState auto_hide_state; |
[email protected] | a3e41271 | 2013-07-11 09:32:58 | [diff] [blame] | 267 | WorkspaceWindowState window_state; |
[email protected] | 751444a | 2012-04-03 04:57:14 | [diff] [blame] | 268 | bool is_screen_locked; |
[email protected] | 27f6af6 | 2012-03-21 05:34:40 | [diff] [blame] | 269 | }; |
| 270 | |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 271 | // Sets the visibility of the shelf to |state|. |
[email protected] | ef80e430 | 2012-12-04 19:37:31 | [diff] [blame] | 272 | void SetState(ShelfVisibilityState visibility_state); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 273 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 274 | // Updates the bounds and opacity of the shelf and status widgets. |
[email protected] | 93946490 | 2013-08-14 23:48:19 | [diff] [blame] | 275 | // If |observer| is specified, it will be called back when the animations, if |
| 276 | // any, are complete. |
| 277 | void UpdateBoundsAndOpacity(const TargetBounds& target_bounds, |
| 278 | bool animate, |
| 279 | ui::ImplicitAnimationObserver* observer); |
| 280 | |
[email protected] | f20cde9 | 2013-07-02 08:19:33 | [diff] [blame] | 281 | // Stops any animations and progresses them to the end. |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 282 | void StopAnimating(); |
| 283 | |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 284 | // Returns the width (if aligned to the side) or height (if aligned to the |
| 285 | // bottom). |
| 286 | void GetShelfSize(int* width, int* height); |
| 287 | |
| 288 | // Insets |bounds| by |inset| on the edge the shelf is aligned to. |
| 289 | void AdjustBoundsBasedOnAlignment(int inset, gfx::Rect* bounds) const; |
| 290 | |
[email protected] | 35304ce | 2011-12-14 23:21:01 | [diff] [blame] | 291 | // Calculates the target bounds assuming visibility of |visible|. |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 292 | void CalculateTargetBounds(const State& state, TargetBounds* target_bounds); |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 293 | |
[email protected] | 3c6abbe | 2012-08-30 23:48:57 | [diff] [blame] | 294 | // Updates the target bounds if a gesture-drag is in progress. This is only |
| 295 | // used by |CalculateTargetBounds()|. |
| 296 | void UpdateTargetBoundsForGesture(TargetBounds* target_bounds) const; |
| 297 | |
[email protected] | a160baec | 2012-03-21 20:52:15 | [diff] [blame] | 298 | // Updates the background of the shelf. |
[email protected] | 494b1ef | 2013-12-07 01:00:07 | [diff] [blame] | 299 | void UpdateShelfBackground(BackgroundAnimatorChangeType type); |
[email protected] | a160baec | 2012-03-21 20:52:15 | [diff] [blame] | 300 | |
[email protected] | a3e41271 | 2013-07-11 09:32:58 | [diff] [blame] | 301 | // Returns how the shelf background is painted. |
| 302 | ShelfBackgroundType GetShelfBackgroundType() const; |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 303 | |
[email protected] | b1c37fc | 2012-03-22 03:36:13 | [diff] [blame] | 304 | // Updates the auto hide state immediately. |
| 305 | void UpdateAutoHideStateNow(); |
| 306 | |
[email protected] | dc08842 | 2013-08-07 22:57:29 | [diff] [blame] | 307 | // Stops the auto hide timer and clears |
| 308 | // |mouse_over_shelf_when_auto_hide_timer_started_|. |
| 309 | void StopAutoHideTimer(); |
| 310 | |
| 311 | // Returns the bounds of an additional region which can trigger showing the |
| 312 | // shelf. This region exists to make it easier to trigger showing the shelf |
| 313 | // when the shelf is auto hidden and the shelf is on the boundary between |
| 314 | // two displays. |
| 315 | gfx::Rect GetAutoHideShowShelfRegionInScreen() const; |
| 316 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 317 | // Returns the AutoHideState. This value is determined from the shelf and |
[email protected] | b1c37fc | 2012-03-22 03:36:13 | [diff] [blame] | 318 | // tray. |
[email protected] | ef80e430 | 2012-12-04 19:37:31 | [diff] [blame] | 319 | ShelfAutoHideState CalculateAutoHideState( |
| 320 | ShelfVisibilityState visibility_state) const; |
[email protected] | b1c37fc | 2012-03-22 03:36:13 | [diff] [blame] | 321 | |
[email protected] | 5f1d99dc | 2012-04-12 21:42:37 | [diff] [blame] | 322 | // Returns true if |window| is a descendant of the shelf. |
| 323 | bool IsShelfWindow(aura::Window* window); |
| 324 | |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 325 | int GetWorkAreaSize(const State& state, int size) const; |
| 326 | |
[email protected] | 5416f28 | 2013-04-29 20:52:48 | [diff] [blame] | 327 | // Return the bounds available in the parent, taking into account the bounds |
| 328 | // of the keyboard if necessary. |
| 329 | gfx::Rect GetAvailableBounds() const; |
| 330 | |
| 331 | // Overridden from keyboard::KeyboardControllerObserver: |
| 332 | virtual void OnKeyboardBoundsChanging( |
| 333 | const gfx::Rect& keyboard_bounds) OVERRIDE; |
| 334 | |
[email protected] | 494b1ef | 2013-12-07 01:00:07 | [diff] [blame] | 335 | // Overridden from DockedWindowLayoutManagerObserver: |
[email protected] | 4d22e60 | 2013-10-16 03:48:47 | [diff] [blame] | 336 | virtual void OnDockBoundsChanging( |
| 337 | const gfx::Rect& dock_bounds, |
| 338 | DockedWindowLayoutManagerObserver::Reason reason) OVERRIDE; |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 339 | |
[email protected] | 8676f047 | 2012-03-29 20:30:12 | [diff] [blame] | 340 | // The RootWindow is cached so that we don't invoke Shell::GetInstance() from |
| 341 | // our destructor. We avoid that as at the time we're deleted Shell is being |
| 342 | // deleted too. |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 343 | aura::Window* root_window_; |
[email protected] | 8676f047 | 2012-03-29 20:30:12 | [diff] [blame] | 344 | |
[email protected] | 93946490 | 2013-08-14 23:48:19 | [diff] [blame] | 345 | // True when inside UpdateBoundsAndOpacity() method. Used to prevent calling |
| 346 | // UpdateBoundsAndOpacity() again from SetChildBounds(). |
| 347 | bool updating_bounds_; |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 348 | |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 349 | // See description above setter. |
[email protected] | 09f3fc8 | 2012-03-26 23:26:56 | [diff] [blame] | 350 | ShelfAutoHideBehavior auto_hide_behavior_; |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 351 | |
[email protected] | 0955068 | 2013-09-10 16:23:28 | [diff] [blame] | 352 | // See description above getter. |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 353 | ShelfAlignment alignment_; |
| 354 | |
[email protected] | 27f6af6 | 2012-03-21 05:34:40 | [diff] [blame] | 355 | // Current state. |
| 356 | State state_; |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 357 | |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 358 | ShelfWidget* shelf_; |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 359 | |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 360 | WorkspaceController* workspace_controller_; |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 361 | |
[email protected] | 27f6af6 | 2012-03-21 05:34:40 | [diff] [blame] | 362 | // Do any windows overlap the shelf? This is maintained by WorkspaceManager. |
| 363 | bool window_overlaps_shelf_; |
| 364 | |
[email protected] | b1c37fc | 2012-03-22 03:36:13 | [diff] [blame] | 365 | base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_; |
| 366 | |
[email protected] | dc08842 | 2013-08-07 22:57:29 | [diff] [blame] | 367 | // Whether the mouse was over the shelf when the auto hide timer started. |
| 368 | // False when neither the auto hide timer nor the timer task are running. |
| 369 | bool mouse_over_shelf_when_auto_hide_timer_started_; |
| 370 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 371 | // EventFilter used to detect when user moves the mouse over the shelf to |
| 372 | // trigger showing the shelf. |
[email protected] | 6c4ad7e | 2013-06-07 19:57:58 | [diff] [blame] | 373 | scoped_ptr<AutoHideEventFilter> auto_hide_event_filter_; |
| 374 | |
| 375 | // EventFilter used to detect when user issues a gesture on a bezel sensor. |
| 376 | scoped_ptr<ShelfBezelEventFilter> bezel_event_filter_; |
[email protected] | 5b0ca08 | 2012-03-14 06:20:22 | [diff] [blame] | 377 | |
[email protected] | 7841e117 | 2013-05-07 03:53:33 | [diff] [blame] | 378 | ObserverList<ShelfLayoutManagerObserver> observers_; |
[email protected] | cbc278f | 2012-07-10 03:40:21 | [diff] [blame] | 379 | |
[email protected] | 3c6abbe | 2012-08-30 23:48:57 | [diff] [blame] | 380 | // The shelf reacts to gesture-drags, and can be set to auto-hide for certain |
| 381 | // gestures. Some shelf behaviour (e.g. visibility state, background color |
| 382 | // etc.) are affected by various stages of the drag. The enum keeps track of |
| 383 | // the present status of the gesture drag. |
| 384 | enum GestureDragStatus { |
| 385 | GESTURE_DRAG_NONE, |
| 386 | GESTURE_DRAG_IN_PROGRESS, |
[email protected] | 93946490 | 2013-08-14 23:48:19 | [diff] [blame] | 387 | GESTURE_DRAG_CANCEL_IN_PROGRESS, |
[email protected] | 4982ee1 | 2012-09-04 22:16:10 | [diff] [blame] | 388 | GESTURE_DRAG_COMPLETE_IN_PROGRESS |
[email protected] | 3c6abbe | 2012-08-30 23:48:57 | [diff] [blame] | 389 | }; |
| 390 | GestureDragStatus gesture_drag_status_; |
| 391 | |
| 392 | // Tracks the amount of the drag. The value is only valid when |
| 393 | // |gesture_drag_status_| is set to GESTURE_DRAG_IN_PROGRESS. |
| 394 | float gesture_drag_amount_; |
| 395 | |
[email protected] | 4982ee1 | 2012-09-04 22:16:10 | [diff] [blame] | 396 | // Manage the auto-hide state during the gesture. |
[email protected] | ef80e430 | 2012-12-04 19:37:31 | [diff] [blame] | 397 | ShelfAutoHideState gesture_drag_auto_hide_state_; |
[email protected] | 4982ee1 | 2012-09-04 22:16:10 | [diff] [blame] | 398 | |
[email protected] | e4d9fe9 | 2012-09-10 14:04:49 | [diff] [blame] | 399 | // Used to delay updating shelf background. |
| 400 | UpdateShelfObserver* update_shelf_observer_; |
| 401 | |
[email protected] | 5416f28 | 2013-04-29 20:52:48 | [diff] [blame] | 402 | // The bounds of the keyboard. |
| 403 | gfx::Rect keyboard_bounds_; |
| 404 | |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 405 | // The bounds of the dock. |
| 406 | gfx::Rect dock_bounds_; |
| 407 | |
[email protected] | 5cc1b659 | 2014-01-28 23:21:31 | [diff] [blame] | 408 | // The show hide animation duration override or 0 for default. |
| 409 | int duration_override_in_ms_; |
| 410 | |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 411 | DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); |
| 412 | }; |
| 413 | |
| 414 | } // namespace internal |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 415 | } // namespace ash |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 416 | |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 417 | #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ |