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)
407dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // Sets the shelf's background type.
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetPaintsBackground(
427dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch      ShelfBackgroundType background_type,
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      internal::BackgroundAnimator::ChangeType change_type);
447dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  ShelfBackgroundType GetBackgroundType() const;
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Causes shelf items to be slightly dimmed (eg when a window is maximized).
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetDimsShelf(bool dimming);
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool GetDimsShelf() const;
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::ShelfLayoutManager* shelf_layout_manager() {
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return shelf_layout_manager_;
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Launcher* launcher() const { return launcher_.get(); }
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::StatusAreaWidget* status_area_widget() const {
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return status_area_widget_;
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void CreateLauncher();
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Set visibility of the launcher component of the shelf.
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetLauncherVisibility(bool visible);
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool IsLauncherVisible() const;
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Sets the focus cycler.  Also adds the launcher to the cycle.
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetFocusCycler(internal::FocusCycler* focus_cycler);
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::FocusCycler* GetFocusCycler();
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Called by the activation delegate, before the launcher is activated
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // when no other windows are visible.
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void WillActivateAsFallback() { activating_as_fallback_ = true; }
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
72c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  aura::Window* window_container() { return window_container_; }
73c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
74c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // TODO(harrym): Remove when Status Area Widget is a child view.
75c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void ShutdownStatusAreaWidget();
76c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
77c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Set the bounds of the widget and the dim shelf overlay.
78c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void SetWidgetBounds(const gfx::Rect& rect);
79c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
80c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Force the shelf to be presented in an undimmed state.
81c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void ForceUndimming(bool force);
82c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Overridden from views::WidgetObserver:
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnWidgetActivationChanged(
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      views::Widget* widget, bool active) OVERRIDE;
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
87c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // A function to test the current alpha used by the dimming bar. If there is
88c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // no dimmer active, the function will return -1.
89c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  int GetDimmingAlphaForTest();
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
91c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // A function to test the bounds of the dimming bar. Returns gfx::Rect() if
92c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // the dimmer is inactive.
93c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  gfx::Rect GetDimmerBoundsForTest();
94c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
95c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Disable dimming animations for running tests.
96c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void DisableDimmingAnimationsForTest();
972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  class DelegateView;
1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::ShelfLayoutManager* shelf_layout_manager_;
1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_ptr<Launcher> launcher_;
1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::StatusAreaWidget* status_area_widget_;
1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // delegate_view_ is attached to window_container_ and is cleaned up
1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // during CloseChildWindows of the associated RootWindowController.
1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DelegateView* delegate_view_;
1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::BackgroundAnimator background_animator_;
1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool activating_as_fallback_;
1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  aura::Window* window_container_;
1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace ash
1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // ASH_SHELF_SHELF_WIDGET_H_
116