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