Home | History | Annotate | Download | only in shelf
      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_types.h"
     11 #include "ui/views/widget/widget.h"
     12 #include "ui/views/widget/widget_observer.h"
     13 
     14 namespace aura {
     15 class Window;
     16 }
     17 
     18 namespace ash {
     19 class Launcher;
     20 
     21 namespace internal {
     22 class FocusCycler;
     23 class StatusAreaWidget;
     24 class ShelfLayoutManager;
     25 class WorkspaceController;
     26 }
     27 
     28 class ASH_EXPORT ShelfWidget : public views::Widget,
     29                                public views::WidgetObserver {
     30  public:
     31   ShelfWidget(
     32       aura::Window* shelf_container,
     33       aura::Window* status_container,
     34       internal::WorkspaceController* workspace_controller);
     35   virtual ~ShelfWidget();
     36 
     37   void SetAlignment(ShelfAlignment alignmnet);
     38   ShelfAlignment GetAlignment() const;
     39 
     40   // Sets the shelf's background type.
     41   void SetPaintsBackground(
     42       ShelfBackgroundType background_type,
     43       internal::BackgroundAnimator::ChangeType change_type);
     44   ShelfBackgroundType GetBackgroundType() const;
     45 
     46   // Causes shelf items to be slightly dimmed (eg when a window is maximized).
     47   void SetDimsShelf(bool dimming);
     48   bool GetDimsShelf() const;
     49 
     50   internal::ShelfLayoutManager* shelf_layout_manager() {
     51     return shelf_layout_manager_;
     52   }
     53   Launcher* launcher() const { return launcher_.get(); }
     54   internal::StatusAreaWidget* status_area_widget() const {
     55     return status_area_widget_;
     56   }
     57 
     58   void CreateLauncher();
     59 
     60   // Set visibility of the launcher component of the shelf.
     61   void SetLauncherVisibility(bool visible);
     62   bool IsLauncherVisible() const;
     63 
     64   // Sets the focus cycler.  Also adds the launcher to the cycle.
     65   void SetFocusCycler(internal::FocusCycler* focus_cycler);
     66   internal::FocusCycler* GetFocusCycler();
     67 
     68   // Called by the activation delegate, before the launcher is activated
     69   // when no other windows are visible.
     70   void WillActivateAsFallback() { activating_as_fallback_ = true; }
     71 
     72   aura::Window* window_container() { return window_container_; }
     73 
     74   // TODO(harrym): Remove when Status Area Widget is a child view.
     75   void ShutdownStatusAreaWidget();
     76 
     77   // Set the bounds of the widget and the dim shelf overlay.
     78   void SetWidgetBounds(const gfx::Rect& rect);
     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  private:
     99   class DelegateView;
    100 
    101   internal::ShelfLayoutManager* shelf_layout_manager_;
    102   scoped_ptr<Launcher> launcher_;
    103   internal::StatusAreaWidget* status_area_widget_;
    104 
    105   // delegate_view_ is attached to window_container_ and is cleaned up
    106   // during CloseChildWindows of the associated RootWindowController.
    107   DelegateView* delegate_view_;
    108   internal::BackgroundAnimator background_animator_;
    109   bool activating_as_fallback_;
    110   aura::Window* window_container_;
    111 };
    112 
    113 }  // namespace ash
    114 
    115 #endif  // ASH_SHELF_SHELF_WIDGET_H_
    116