| 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_COMMON_SHELF_SHELF_WIDGET_H_ | |
| 6 #define ASH_COMMON_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_layout_manager_observer.h" | |
| 14 #include "ash/public/cpp/shelf_types.h" | |
| 15 #include "base/macros.h" | |
| 16 #include "ui/views/widget/widget.h" | |
| 17 #include "ui/views/widget/widget_observer.h" | |
| 18 | |
| 19 namespace app_list { | |
| 20 class ApplicationDragAndDropHost; | |
| 21 } | |
| 22 | |
| 23 namespace ash { | |
| 24 enum class AnimationChangeType; | |
| 25 class AppListButton; | |
| 26 class FocusCycler; | |
| 27 class ShelfLayoutManager; | |
| 28 class ShelfView; | |
| 29 class StatusAreaWidget; | |
| 30 class WmShelf; | |
| 31 class WmWindow; | |
| 32 | |
| 33 // The ShelfWidget manages the shelf view (which contains the shelf icons) and | |
| 34 // the status area widget. There is one ShelfWidget per display. It is created | |
| 35 // early during RootWindowController initialization. | |
| 36 class ASH_EXPORT ShelfWidget : public views::Widget, | |
| 37 public views::WidgetObserver, | |
| 38 public ShelfBackgroundAnimatorObserver, | |
| 39 public ShelfLayoutManagerObserver { | |
| 40 public: | |
| 41 ShelfWidget(WmWindow* shelf_container, WmShelf* wm_shelf); | |
| 42 ~ShelfWidget() override; | |
| 43 | |
| 44 void CreateStatusAreaWidget(WmWindow* status_container); | |
| 45 | |
| 46 void OnShelfAlignmentChanged(); | |
| 47 | |
| 48 // Sets the shelf's background type. | |
| 49 void SetPaintsBackground(ShelfBackgroundType background_type, | |
| 50 AnimationChangeType change_type); | |
| 51 ShelfBackgroundType GetBackgroundType() const; | |
| 52 | |
| 53 // Hide the shelf behind a black bar during e.g. a user transition when |hide| | |
| 54 // is true. The |animation_time_ms| will be used as animation duration. | |
| 55 void HideShelfBehindBlackBar(bool hide, int animation_time_ms); | |
| 56 bool IsShelfHiddenBehindBlackBar() const; | |
| 57 | |
| 58 ShelfLayoutManager* shelf_layout_manager() { return shelf_layout_manager_; } | |
| 59 StatusAreaWidget* status_area_widget() const { return status_area_widget_; } | |
| 60 | |
| 61 // Creates the shelf view and populates it with icons. Called after the user | |
| 62 // session is active (and hence the user profile is available). | |
| 63 ShelfView* CreateShelfView(); | |
| 64 void PostCreateShelf(); | |
| 65 | |
| 66 bool IsShelfVisible() const; | |
| 67 | |
| 68 bool IsShowingAppList() const; | |
| 69 bool IsShowingContextMenu() const; | |
| 70 bool IsShowingOverflowBubble() const; | |
| 71 | |
| 72 // Sets the focus cycler. Also adds the shelf to the cycle. | |
| 73 void SetFocusCycler(FocusCycler* focus_cycler); | |
| 74 FocusCycler* GetFocusCycler(); | |
| 75 | |
| 76 // Called by the activation delegate, before the shelf is activated | |
| 77 // when no other windows are visible. | |
| 78 void WillActivateAsFallback() { activating_as_fallback_ = true; } | |
| 79 | |
| 80 // Clean up prior to deletion. | |
| 81 void Shutdown(); | |
| 82 | |
| 83 // See WmShelf::UpdateIconPositionForPanel(). | |
| 84 void UpdateIconPositionForPanel(WmWindow* panel); | |
| 85 | |
| 86 // See WmShelf::GetScreenBoundsOfItemIconForWindow(). | |
| 87 gfx::Rect GetScreenBoundsOfItemIconForWindow(WmWindow* window); | |
| 88 | |
| 89 // Returns the button that opens the app launcher. | |
| 90 AppListButton* GetAppListButton() const; | |
| 91 | |
| 92 // Returns the ApplicationDragAndDropHost for this shelf. | |
| 93 app_list::ApplicationDragAndDropHost* GetDragAndDropHostForAppList(); | |
| 94 | |
| 95 // Overridden from views::WidgetObserver: | |
| 96 void OnWidgetActivationChanged(views::Widget* widget, bool active) override; | |
| 97 | |
| 98 // ShelfBackgroundAnimatorObserver overrides: | |
| 99 void UpdateShelfItemBackground(SkColor color) override; | |
| 100 | |
| 101 // ShelfLayoutManagerObserver overrides: | |
| 102 void WillDeleteShelfLayoutManager() override; | |
| 103 | |
| 104 private: | |
| 105 class DelegateView; | |
| 106 friend class DelegateView; | |
| 107 | |
| 108 WmShelf* wm_shelf_; | |
| 109 | |
| 110 // Owned by the shelf container's window. | |
| 111 ShelfLayoutManager* shelf_layout_manager_; | |
| 112 | |
| 113 // Owned by the native widget. | |
| 114 StatusAreaWidget* status_area_widget_; | |
| 115 | |
| 116 // |delegate_view_| is the contents view of this widget and is cleaned up | |
| 117 // during CloseChildWindows of the associated RootWindowController. | |
| 118 DelegateView* delegate_view_; | |
| 119 // View containing the shelf items. Owned by the views hierarchy. Null when | |
| 120 // at the login screen. | |
| 121 ShelfView* shelf_view_; | |
| 122 ShelfBackgroundAnimator background_animator_; | |
| 123 bool activating_as_fallback_; | |
| 124 | |
| 125 DISALLOW_COPY_AND_ASSIGN(ShelfWidget); | |
| 126 }; | |
| 127 | |
| 128 } // namespace ash | |
| 129 | |
| 130 #endif // ASH_COMMON_SHELF_SHELF_WIDGET_H_ | |
| OLD | NEW |