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