• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   // Hide the shelf behind a black bar during e.g. a user transition when |hide|
49   // is true. The |animation_time_ms| will be used as animation duration.
50   void HideShelfBehindBlackBar(bool hide, int animation_time_ms);
51   bool IsShelfHiddenBehindBlackBar() const;
52 
53   // Causes shelf items to be slightly dimmed (e.g. when a window is maximized).
54   void SetDimsShelf(bool dimming);
55   bool GetDimsShelf() const;
56 
shelf_layout_manager()57   ShelfLayoutManager* shelf_layout_manager() { return shelf_layout_manager_; }
shelf()58   Shelf* shelf() const { return shelf_.get(); }
status_area_widget()59   StatusAreaWidget* status_area_widget() const { return status_area_widget_; }
60 
61   void CreateShelf();
62 
63   // Set visibility of the shelf.
64   void SetShelfVisibility(bool visible);
65   bool IsShelfVisible() const;
66 
67   // Sets the focus cycler.  Also adds the shelf to the cycle.
68   void SetFocusCycler(FocusCycler* focus_cycler);
69   FocusCycler* GetFocusCycler();
70 
71   // Called by the activation delegate, before the shelf is activated
72   // when no other windows are visible.
WillActivateAsFallback()73   void WillActivateAsFallback() { activating_as_fallback_ = true; }
74 
window_container()75   aura::Window* window_container() { return window_container_; }
76 
77   // TODO(harrym): Remove when Status Area Widget is a child view.
78   void ShutdownStatusAreaWidget();
79 
80   // Force the shelf to be presented in an undimmed state.
81   void ForceUndimming(bool force);
82 
83   // Overridden from views::WidgetObserver:
84   virtual void OnWidgetActivationChanged(
85       views::Widget* widget, bool active) OVERRIDE;
86 
87   // A function to test the current alpha used by the dimming bar. If there is
88   // no dimmer active, the function will return -1.
89   int GetDimmingAlphaForTest();
90 
91   // A function to test the bounds of the dimming bar. Returns gfx::Rect() if
92   // the dimmer is inactive.
93   gfx::Rect GetDimmerBoundsForTest();
94 
95   // Disable dimming animations for running tests.
96   void DisableDimmingAnimationsForTest();
97 
98   // ShelfLayoutManagerObserver overrides:
99   virtual void WillDeleteShelf() OVERRIDE;
100 
101  private:
102   class DelegateView;
103 
104   ShelfLayoutManager* shelf_layout_manager_;
105   scoped_ptr<Shelf> shelf_;
106   StatusAreaWidget* status_area_widget_;
107 
108   // delegate_view_ is attached to window_container_ and is cleaned up
109   // during CloseChildWindows of the associated RootWindowController.
110   DelegateView* delegate_view_;
111   BackgroundAnimator background_animator_;
112   bool activating_as_fallback_;
113   aura::Window* window_container_;
114 };
115 
116 }  // namespace ash
117 
118 #endif  // ASH_SHELF_SHELF_WIDGET_H_
119