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.
5 #ifndef ASH_SHELF_SHELF_WIDGET_H_
6 #define ASH_SHELF_SHELF_WIDGET_H_
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"
24 class StatusAreaWidget;
25 class ShelfLayoutManager;
26 class WorkspaceController;
29 class ASH_EXPORT ShelfWidget : public views::Widget,
30 public views::WidgetObserver,
31 public ShelfLayoutManagerObserver {
34 aura::Window* shelf_container,
35 aura::Window* status_container,
36 internal::WorkspaceController* workspace_controller);
37 virtual ~ShelfWidget();
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
42 static bool ShelfAlignmentAllowed();
44 void SetAlignment(ShelfAlignment alignmnet);
45 ShelfAlignment GetAlignment() const;
47 // Sets the shelf's background type.
48 void SetPaintsBackground(ShelfBackgroundType background_type,
49 BackgroundAnimatorChangeType change_type);
50 ShelfBackgroundType GetBackgroundType() const;
52 // Causes shelf items to be slightly dimmed (e.g. when a window is maximized).
53 void SetDimsShelf(bool dimming);
54 bool GetDimsShelf() const;
56 internal::ShelfLayoutManager* shelf_layout_manager() {
57 return shelf_layout_manager_;
59 Shelf* shelf() const { return shelf_.get(); }
60 internal::StatusAreaWidget* status_area_widget() const {
61 return status_area_widget_;
66 // Set visibility of the shelf.
67 void SetShelfVisibility(bool visible);
68 bool IsShelfVisible() const;
70 // Sets the focus cycler. Also adds the shelf to the cycle.
71 void SetFocusCycler(internal::FocusCycler* focus_cycler);
72 internal::FocusCycler* GetFocusCycler();
74 // Called by the activation delegate, before the shelf is activated
75 // when no other windows are visible.
76 void WillActivateAsFallback() { activating_as_fallback_ = true; }
78 aura::Window* window_container() { return window_container_; }
80 // TODO(harrym): Remove when Status Area Widget is a child view.
81 void ShutdownStatusAreaWidget();
83 // Force the shelf to be presented in an undimmed state.
84 void ForceUndimming(bool force);
86 // Overridden from views::WidgetObserver:
87 virtual void OnWidgetActivationChanged(
88 views::Widget* widget, bool active) OVERRIDE;
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();
94 // A function to test the bounds of the dimming bar. Returns gfx::Rect() if
95 // the dimmer is inactive.
96 gfx::Rect GetDimmerBoundsForTest();
98 // Disable dimming animations for running tests.
99 void DisableDimmingAnimationsForTest();
101 // ShelfLayoutManagerObserver overrides:
102 virtual void WillDeleteShelf() OVERRIDE;
107 internal::ShelfLayoutManager* shelf_layout_manager_;
108 scoped_ptr<Shelf> shelf_;
109 internal::StatusAreaWidget* status_area_widget_;
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_;
121 #endif // ASH_SHELF_SHELF_WIDGET_H_