shelf_widget.h revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef ASH_SHELF_SHELF_WIDGET_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define ASH_SHELF_SHELF_WIDGET_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/ash_export.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/shelf/background_animator.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/shelf/shelf_types.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/views/widget/widget.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/views/widget/widget_observer.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace aura {
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Window;
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace ash {
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Launcher;
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace internal {
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class FocusCycler;
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class StatusAreaWidget;
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ShelfLayoutManager;
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class WorkspaceController;
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ASH_EXPORT ShelfWidget : public views::Widget,
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                               public views::WidgetObserver {
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ShelfWidget(
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      aura::Window* shelf_container,
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      aura::Window* status_container,
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      internal::WorkspaceController* workspace_controller);
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~ShelfWidget();
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetAlignment(ShelfAlignment alignmnet);
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ShelfAlignment GetAlignment() const;
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Sets whether the shelf paints a background. Default is false, but is set
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // to true if a window overlaps the shelf.
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetPaintsBackground(
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      bool value,
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      internal::BackgroundAnimator::ChangeType change_type);
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool paints_background() const {
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return background_animator_.paints_background();
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Causes shelf items to be slightly dimmed (eg when a window is maximized).
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetDimsShelf(bool dimming);
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool GetDimsShelf() const;
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::ShelfLayoutManager* shelf_layout_manager() {
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return shelf_layout_manager_;
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Launcher* launcher() const { return launcher_.get(); }
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::StatusAreaWidget* status_area_widget() const {
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return status_area_widget_;
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void CreateLauncher();
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Set visibility of the launcher component of the shelf.
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetLauncherVisibility(bool visible);
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool IsLauncherVisible() const;
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Sets the focus cycler.  Also adds the launcher to the cycle.
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetFocusCycler(internal::FocusCycler* focus_cycler);
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::FocusCycler* GetFocusCycler();
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Called by the activation delegate, before the launcher is activated
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // when no other windows are visible.
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void WillActivateAsFallback() { activating_as_fallback_ = true; }
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
75c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  aura::Window* window_container() { return window_container_; }
76c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
77c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // TODO(harrym): Remove when Status Area Widget is a child view.
78c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void ShutdownStatusAreaWidget();
79c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
80c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Set the bounds of the widget and the dim shelf overlay.
81c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void SetWidgetBounds(const gfx::Rect& rect);
82c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
83c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Force the shelf to be presented in an undimmed state.
84c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void ForceUndimming(bool force);
85c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Overridden from views::WidgetObserver:
872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnWidgetActivationChanged(
882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      views::Widget* widget, bool active) OVERRIDE;
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
90c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // A function to test the current alpha used by the dimming bar. If there is
91c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // no dimmer active, the function will return -1.
92c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  int GetDimmingAlphaForTest();
932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
94c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // A function to test the bounds of the dimming bar. Returns gfx::Rect() if
95c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // the dimmer is inactive.
96c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  gfx::Rect GetDimmerBoundsForTest();
97c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
98c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Disable dimming animations for running tests.
99c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void DisableDimmingAnimationsForTest();
1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  class DelegateView;
1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::ShelfLayoutManager* shelf_layout_manager_;
1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_ptr<Launcher> launcher_;
1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::StatusAreaWidget* status_area_widget_;
1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // delegate_view_ is attached to window_container_ and is cleaned up
1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // during CloseChildWindows of the associated RootWindowController.
1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DelegateView* delegate_view_;
1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::BackgroundAnimator background_animator_;
1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool activating_as_fallback_;
1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  aura::Window* window_container_;
1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace ash
1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // ASH_SHELF_SHELF_WIDGET_H_
119