| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_COMMON_SHELF_WM_SHELF_H_ | 5 #ifndef ASH_COMMON_SHELF_WM_SHELF_H_ |
| 6 #define ASH_COMMON_SHELF_WM_SHELF_H_ | 6 #define ASH_COMMON_SHELF_WM_SHELF_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/common/shelf/shelf_types.h" | 9 #include "ash/common/shelf/shelf_types.h" |
| 10 #include "ash/shelf/shelf_layout_manager_observer.h" |
| 11 #include "base/observer_list.h" |
| 10 | 12 |
| 11 namespace gfx { | 13 namespace gfx { |
| 12 class Rect; | 14 class Rect; |
| 13 } | 15 } |
| 14 | 16 |
| 15 namespace ui { | 17 namespace ui { |
| 16 class GestureEvent; | 18 class GestureEvent; |
| 17 } | 19 } |
| 18 | 20 |
| 19 namespace ash { | 21 namespace ash { |
| 20 | 22 |
| 23 class Shelf; |
| 24 class ShelfLayoutManager; |
| 21 class ShelfLockingManager; | 25 class ShelfLockingManager; |
| 22 class ShelfView; | 26 class ShelfView; |
| 23 class WmDimmerView; | 27 class WmDimmerView; |
| 24 class WmShelfObserver; | 28 class WmShelfObserver; |
| 25 class WmWindow; | 29 class WmWindow; |
| 26 | 30 |
| 27 // Used for accessing global state. | 31 // Used for accessing global state. |
| 28 class ASH_EXPORT WmShelf { | 32 class ASH_EXPORT WmShelf : public ShelfLayoutManagerObserver { |
| 29 public: | 33 public: |
| 34 void SetShelf(Shelf* shelf); |
| 35 void ClearShelf(); |
| 36 Shelf* shelf() const { return shelf_; } |
| 37 |
| 38 virtual void SetShelfLayoutManager(ShelfLayoutManager* manager); |
| 39 ShelfLayoutManager* shelf_layout_manager() const { |
| 40 return shelf_layout_manager_; |
| 41 } |
| 42 |
| 30 // Returns the window showing the shelf. | 43 // Returns the window showing the shelf. |
| 31 virtual WmWindow* GetWindow() = 0; | 44 WmWindow* GetWindow(); |
| 32 | 45 |
| 33 virtual ShelfAlignment GetAlignment() const = 0; | 46 ShelfAlignment GetAlignment() const; |
| 34 virtual void SetAlignment(ShelfAlignment alignment) = 0; | 47 void SetAlignment(ShelfAlignment alignment); |
| 35 | 48 |
| 36 // Returns true if the shelf alignment is horizontal (i.e. at the bottom). | 49 // Returns true if the shelf alignment is horizontal (i.e. at the bottom). |
| 37 bool IsHorizontalAlignment() const; | 50 bool IsHorizontalAlignment() const; |
| 38 | 51 |
| 39 // Returns a value based on shelf alignment. | 52 // Returns a value based on shelf alignment. |
| 40 int SelectValueForShelfAlignment(int bottom, int left, int right) const; | 53 int SelectValueForShelfAlignment(int bottom, int left, int right) const; |
| 41 | 54 |
| 42 // Returns |horizontal| is shelf is horizontal, otherwise |vertical|. | 55 // Returns |horizontal| is shelf is horizontal, otherwise |vertical|. |
| 43 int PrimaryAxisValue(int horizontal, int vertical) const; | 56 int PrimaryAxisValue(int horizontal, int vertical) const; |
| 44 | 57 |
| 45 virtual ShelfAutoHideBehavior GetAutoHideBehavior() const = 0; | 58 ShelfAutoHideBehavior GetAutoHideBehavior() const; |
| 46 virtual void SetAutoHideBehavior(ShelfAutoHideBehavior behavior) = 0; | 59 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); |
| 47 | 60 |
| 48 virtual ShelfAutoHideState GetAutoHideState() const = 0; | 61 ShelfAutoHideState GetAutoHideState() const; |
| 49 | 62 |
| 50 // Invoke when the auto-hide state may have changed (for example, when the | 63 // Invoke when the auto-hide state may have changed (for example, when the |
| 51 // system tray bubble opens it should force the shelf to be visible). | 64 // system tray bubble opens it should force the shelf to be visible). |
| 52 virtual void UpdateAutoHideState() = 0; | 65 void UpdateAutoHideState(); |
| 53 | 66 |
| 54 virtual ShelfBackgroundType GetBackgroundType() const = 0; | 67 ShelfBackgroundType GetBackgroundType() const; |
| 55 | 68 |
| 56 // Creates a view that dims shelf items. The returned view is owned by its | 69 // Creates a view that dims shelf items. The returned view is owned by its |
| 57 // widget. Returns null if shelf dimming is not supported (e.g. on mus). | 70 // widget. Returns null if shelf dimming is not supported (e.g. on mus). |
| 58 // TODO(jamescook): Delete this after material design ships, as MD will not | 71 // TODO(jamescook): Delete this after material design ships, as MD will not |
| 59 // require shelf dimming. http://crbug.com/614453 | 72 // require shelf dimming. http://crbug.com/614453 |
| 60 virtual WmDimmerView* CreateDimmerView(bool disable_animations_for_test) = 0; | 73 virtual WmDimmerView* CreateDimmerView(bool disable_animations_for_test); |
| 61 | 74 |
| 62 // Shelf items are slightly dimmed (e.g. when a window is maximized). | 75 // Shelf items are slightly dimmed (e.g. when a window is maximized). |
| 63 // TODO(jamescook): Delete this after material design ships, as MD will not | 76 // TODO(jamescook): Delete this after material design ships, as MD will not |
| 64 // require shelf dimming. http://crbug.com/614453 | 77 // require shelf dimming. http://crbug.com/614453 |
| 65 virtual bool IsDimmed() const = 0; | 78 bool IsDimmed() const; |
| 66 | 79 |
| 67 // Schedules a repaint for all shelf buttons. | 80 // Schedules a repaint for all shelf buttons. |
| 68 // TODO(jamescook): Eliminate when ShelfView moves to //ash/common. | 81 // TODO(jamescook): Eliminate when ShelfView moves to //ash/common. |
| 69 // http://crbug.com/615155 | 82 // http://crbug.com/615155 |
| 70 virtual void SchedulePaint() = 0; | 83 void SchedulePaint(); |
| 71 | 84 |
| 72 // Whether the shelf view is visible. | 85 // Whether the shelf view is visible. |
| 73 // TODO(jamescook): Consolidate this with GetVisibilityState(). | 86 // TODO(jamescook): Consolidate this with GetVisibilityState(). |
| 74 virtual bool IsVisible() const = 0; | 87 bool IsVisible() const; |
| 75 | 88 |
| 76 virtual void UpdateVisibilityState() = 0; | 89 void UpdateVisibilityState(); |
| 77 | 90 |
| 78 virtual ShelfVisibilityState GetVisibilityState() const = 0; | 91 ShelfVisibilityState GetVisibilityState() const; |
| 79 | 92 |
| 80 // Returns the ideal bounds of the shelf assuming it is visible. | 93 // Returns the ideal bounds of the shelf assuming it is visible. |
| 81 virtual gfx::Rect GetIdealBounds() = 0; | 94 gfx::Rect GetIdealBounds(); |
| 82 | 95 |
| 83 virtual gfx::Rect GetUserWorkAreaBounds() const = 0; | 96 gfx::Rect GetUserWorkAreaBounds() const; |
| 84 | 97 |
| 85 virtual void UpdateIconPositionForWindow(WmWindow* window) = 0; | 98 void UpdateIconPositionForWindow(WmWindow* window); |
| 86 | 99 |
| 87 // Returns the screen bounds of the item for the specified window. If there is | 100 // Returns the screen bounds of the item for the specified window. If there is |
| 88 // no item for the specified window an empty rect is returned. | 101 // no item for the specified window an empty rect is returned. |
| 89 virtual gfx::Rect GetScreenBoundsOfItemIconForWindow(WmWindow* window) = 0; | 102 gfx::Rect GetScreenBoundsOfItemIconForWindow(WmWindow* window); |
| 90 | 103 |
| 91 // Handles a gesture |event| coming from a source outside the shelf widget | 104 // Handles a gesture |event| coming from a source outside the shelf widget |
| 92 // (e.g. the status area widget). Allows support for behaviors like toggling | 105 // (e.g. the status area widget). Allows support for behaviors like toggling |
| 93 // auto-hide with a swipe, even if that gesture event hits another window. | 106 // auto-hide with a swipe, even if that gesture event hits another window. |
| 94 // Returns true if the event was handled. | 107 // Returns true if the event was handled. |
| 95 virtual bool ProcessGestureEvent(const ui::GestureEvent& event) = 0; | 108 bool ProcessGestureEvent(const ui::GestureEvent& event); |
| 96 | 109 |
| 97 virtual void AddObserver(WmShelfObserver* observer) = 0; | 110 void AddObserver(WmShelfObserver* observer); |
| 98 virtual void RemoveObserver(WmShelfObserver* observer) = 0; | 111 void RemoveObserver(WmShelfObserver* observer); |
| 99 | 112 |
| 100 // Simulates a virtual keyboard bounds update. | 113 void NotifyShelfIconPositionsChanged(); |
| 101 virtual void SetKeyboardBoundsForTesting(const gfx::Rect& bounds) = 0; | |
| 102 | 114 |
| 103 virtual ShelfLockingManager* GetShelfLockingManagerForTesting() = 0; | 115 void SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds); |
| 104 virtual ShelfView* GetShelfViewForTesting() = 0; | 116 ShelfLockingManager* GetShelfLockingManagerForTesting(); |
| 117 ShelfView* GetShelfViewForTesting(); |
| 105 | 118 |
| 106 protected: | 119 protected: |
| 107 virtual ~WmShelf() {} | 120 WmShelf(); |
| 121 ~WmShelf() override; |
| 122 |
| 123 // ShelfLayoutManagerObserver: |
| 124 void WillDeleteShelfLayoutManager() override; |
| 125 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; |
| 126 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; |
| 127 void OnBackgroundUpdated(ShelfBackgroundType background_type, |
| 128 BackgroundAnimatorChangeType change_type) override; |
| 129 |
| 130 private: |
| 131 // Legacy shelf controller. Null before login and in secondary display init. |
| 132 // Instance lifetimes are managed by ash::RootWindowController and WmShelfMus. |
| 133 Shelf* shelf_ = nullptr; |
| 134 |
| 135 // Layout manager for the shelf container window. Instances are constructed by |
| 136 // ShelfWidget and lifetimes are managed by the container windows themselves. |
| 137 ShelfLayoutManager* shelf_layout_manager_ = nullptr; |
| 138 |
| 139 base::ObserverList<WmShelfObserver> observers_; |
| 140 |
| 141 DISALLOW_COPY_AND_ASSIGN(WmShelf); |
| 108 }; | 142 }; |
| 109 | 143 |
| 110 } // namespace ash | 144 } // namespace ash |
| 111 | 145 |
| 112 #endif // ASH_COMMON_SHELF_WM_SHELF_H_ | 146 #endif // ASH_COMMON_SHELF_WM_SHELF_H_ |
| OLD | NEW |