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 "ash/ash_export.h" 9 #include "ash/shelf/background_animator.h" 10 #include "ash/shelf/shelf_layout_manager_observer.h" 11 #include "ash/shelf/shelf_types.h" 12 #include "ui/views/widget/widget.h" 13 #include "ui/views/widget/widget_observer.h" 14 15 namespace aura { 16 class Window; 17 } 18 19 namespace ash { 20 class Launcher; 21 22 namespace internal { 23 class FocusCycler; 24 class StatusAreaWidget; 25 class ShelfLayoutManager; 26 class WorkspaceController; 27 } 28 29 class ASH_EXPORT ShelfWidget : public views::Widget, 30 public views::WidgetObserver, 31 public ShelfLayoutManagerObserver { 32 public: 33 ShelfWidget( 34 aura::Window* shelf_container, 35 aura::Window* status_container, 36 internal::WorkspaceController* workspace_controller); 37 virtual ~ShelfWidget(); 38 39 // Returns if shelf alignment option is enabled, and the user is able 40 // to adjust the alignment (guest and supervised mode users cannot for 41 // example). 42 static bool ShelfAlignmentAllowed(); 43 44 void SetAlignment(ShelfAlignment alignmnet); 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 // Causes shelf items to be slightly dimmed (e.g. when a window is maximized). 53 void SetDimsShelf(bool dimming); 54 bool GetDimsShelf() const; 55 shelf_layout_manager()56 internal::ShelfLayoutManager* shelf_layout_manager() { 57 return shelf_layout_manager_; 58 } launcher()59 Launcher* launcher() const { return launcher_.get(); } status_area_widget()60 internal::StatusAreaWidget* status_area_widget() const { 61 return status_area_widget_; 62 } 63 64 void CreateLauncher(); 65 66 // Set visibility of the launcher component of the shelf. 67 void SetLauncherVisibility(bool visible); 68 bool IsLauncherVisible() const; 69 70 // Sets the focus cycler. Also adds the launcher to the cycle. 71 void SetFocusCycler(internal::FocusCycler* focus_cycler); 72 internal::FocusCycler* GetFocusCycler(); 73 74 // Called by the activation delegate, before the launcher is activated 75 // when no other windows are visible. WillActivateAsFallback()76 void WillActivateAsFallback() { activating_as_fallback_ = true; } 77 window_container()78 aura::Window* window_container() { return window_container_; } 79 80 // TODO(harrym): Remove when Status Area Widget is a child view. 81 void ShutdownStatusAreaWidget(); 82 83 // Force the shelf to be presented in an undimmed state. 84 void ForceUndimming(bool force); 85 86 // Overridden from views::WidgetObserver: 87 virtual void OnWidgetActivationChanged( 88 views::Widget* widget, bool active) OVERRIDE; 89 90 // A function to test the current alpha used by the dimming bar. If there is 91 // no dimmer active, the function will return -1. 92 int GetDimmingAlphaForTest(); 93 94 // A function to test the bounds of the dimming bar. Returns gfx::Rect() if 95 // the dimmer is inactive. 96 gfx::Rect GetDimmerBoundsForTest(); 97 98 // Disable dimming animations for running tests. 99 void DisableDimmingAnimationsForTest(); 100 101 // ShelfLayoutManagerObserver overrides: 102 virtual void WillDeleteShelf() OVERRIDE; 103 104 private: 105 class DelegateView; 106 107 internal::ShelfLayoutManager* shelf_layout_manager_; 108 scoped_ptr<Launcher> launcher_; 109 internal::StatusAreaWidget* status_area_widget_; 110 111 // delegate_view_ is attached to window_container_ and is cleaned up 112 // during CloseChildWindows of the associated RootWindowController. 113 DelegateView* delegate_view_; 114 internal::BackgroundAnimator background_animator_; 115 bool activating_as_fallback_; 116 aura::Window* window_container_; 117 }; 118 119 } // namespace ash 120 121 #endif // ASH_SHELF_SHELF_WIDGET_H_ 122