| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_SHELF_SHELF_WIDGET_H_ | |
| 6 #define ASH_SHELF_SHELF_WIDGET_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "ash/ash_export.h" | |
| 11 #include "ash/common/shelf/shelf_background_animator.h" | |
| 12 #include "ash/common/shelf/shelf_background_animator_observer.h" | |
| 13 #include "ash/common/shelf/shelf_types.h" | |
| 14 #include "ash/shelf/shelf_layout_manager_observer.h" | |
| 15 #include "base/macros.h" | |
| 16 #include "ui/views/widget/widget.h" | |
| 17 #include "ui/views/widget/widget_observer.h" | |
| 18 | |
| 19 namespace ash { | |
| 20 class FocusCycler; | |
| 21 class Shelf; | |
| 22 class ShelfLayoutManager; | |
| 23 class ShelfView; | |
| 24 class StatusAreaWidget; | |
| 25 class WmShelf; | |
| 26 class WmWindow; | |
| 27 | |
| 28 class ASH_EXPORT ShelfWidget : public views::Widget, | |
| 29 public views::WidgetObserver, | |
| 30 public ShelfBackgroundAnimatorObserver, | |
| 31 public ShelfLayoutManagerObserver { | |
| 32 public: | |
| 33 ShelfWidget(WmWindow* shelf_container, | |
| 34 WmWindow* status_container, | |
| 35 WmShelf* wm_shelf); | |
| 36 ~ShelfWidget() override; | |
| 37 | |
| 38 // Returns if shelf alignment option is enabled, and the user is able to | |
| 39 // adjust the alignment (guest and supervised mode users cannot for example). | |
| 40 static bool ShelfAlignmentAllowed(); | |
| 41 | |
| 42 void OnShelfAlignmentChanged(); | |
| 43 | |
| 44 // DEPRECATED: Prefer WmShelf::GetAlignment(). | |
| 45 ShelfAlignment GetAlignment() const; | |
| 46 | |
| 47 // Sets the shelf's background type. | |
| 48 void SetPaintsBackground(ShelfBackgroundType background_type, | |
| 49 BackgroundAnimatorChangeType change_type); | |
| 50 ShelfBackgroundType GetBackgroundType() const; | |
| 51 | |
| 52 // Hide the shelf behind a black bar during e.g. a user transition when |hide| | |
| 53 // is true. The |animation_time_ms| will be used as animation duration. | |
| 54 void HideShelfBehindBlackBar(bool hide, int animation_time_ms); | |
| 55 bool IsShelfHiddenBehindBlackBar() const; | |
| 56 | |
| 57 // Causes shelf items to be slightly dimmed (e.g. when a window is maximized). | |
| 58 void SetDimsShelf(bool dimming); | |
| 59 bool GetDimsShelf() const; | |
| 60 | |
| 61 // TODO(jamescook): Eliminate these. | |
| 62 Shelf* shelf() { return shelf_; } | |
| 63 void set_shelf(Shelf* shelf) { shelf_ = shelf; } | |
| 64 | |
| 65 ShelfLayoutManager* shelf_layout_manager() { return shelf_layout_manager_; } | |
| 66 StatusAreaWidget* status_area_widget() const { return status_area_widget_; } | |
| 67 | |
| 68 ShelfView* CreateShelfView(); | |
| 69 void PostCreateShelf(); | |
| 70 | |
| 71 // Set visibility of the shelf. | |
| 72 void SetShelfVisibility(bool visible); | |
| 73 bool IsShelfVisible() const; | |
| 74 | |
| 75 bool IsShowingContextMenu() const; | |
| 76 | |
| 77 bool IsShowingOverflowBubble() const; | |
| 78 | |
| 79 // Sets the focus cycler. Also adds the shelf to the cycle. | |
| 80 void SetFocusCycler(FocusCycler* focus_cycler); | |
| 81 FocusCycler* GetFocusCycler(); | |
| 82 | |
| 83 // Called by the activation delegate, before the shelf is activated | |
| 84 // when no other windows are visible. | |
| 85 void WillActivateAsFallback() { activating_as_fallback_ = true; } | |
| 86 | |
| 87 // Clean up prior to deletion. | |
| 88 void Shutdown(); | |
| 89 | |
| 90 // Force the shelf to be presented in an undimmed state. | |
| 91 void ForceUndimming(bool force); | |
| 92 | |
| 93 // Overridden from views::WidgetObserver: | |
| 94 void OnWidgetActivationChanged(views::Widget* widget, bool active) override; | |
| 95 | |
| 96 // A function to test the current alpha used by the dimming bar. If there is | |
| 97 // no dimmer active, the function will return -1. | |
| 98 int GetDimmingAlphaForTest(); | |
| 99 | |
| 100 // A function to test the bounds of the dimming bar. Returns gfx::Rect() if | |
| 101 // the dimmer is inactive. | |
| 102 gfx::Rect GetDimmerBoundsForTest(); | |
| 103 | |
| 104 // Disable dimming animations for running tests. | |
| 105 void DisableDimmingAnimationsForTest(); | |
| 106 | |
| 107 // ShelfBackgroundAnimatorObserver overrides: | |
| 108 void UpdateShelfItemBackground(int alpha) override; | |
| 109 | |
| 110 // ShelfLayoutManagerObserver overrides: | |
| 111 void WillDeleteShelfLayoutManager() override; | |
| 112 | |
| 113 private: | |
| 114 class DelegateView; | |
| 115 friend class DelegateView; | |
| 116 | |
| 117 WmShelf* wm_shelf_; | |
| 118 | |
| 119 // Owned by the shelf container's window. | |
| 120 ShelfLayoutManager* shelf_layout_manager_; | |
| 121 // Owned by the root window controller. | |
| 122 Shelf* shelf_; | |
| 123 StatusAreaWidget* status_area_widget_; | |
| 124 | |
| 125 // |delegate_view_| is the contents view of this widget and is cleaned up | |
| 126 // during CloseChildWindows of the associated RootWindowController. | |
| 127 DelegateView* delegate_view_; | |
| 128 // View containing the shelf items. Owned by the views hierarchy. | |
| 129 ShelfView* shelf_view_; | |
| 130 ShelfBackgroundAnimator background_animator_; | |
| 131 bool activating_as_fallback_; | |
| 132 | |
| 133 DISALLOW_COPY_AND_ASSIGN(ShelfWidget); | |
| 134 }; | |
| 135 | |
| 136 } // namespace ash | |
| 137 | |
| 138 #endif // ASH_SHELF_SHELF_WIDGET_H_ | |
| OLD | NEW |