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" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/shelf/shelf_layout_manager_observer.h" 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/shelf/shelf_types.h" 122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/views/widget/widget.h" 132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/views/widget/widget_observer.h" 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace aura { 162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Window; 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace ash { 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class FocusCycler; 21c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochclass Shelf; 222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ShelfLayoutManager; 23c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochclass StatusAreaWidget; 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class WorkspaceController; 252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ASH_EXPORT ShelfWidget : public views::Widget, 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public views::WidgetObserver, 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public ShelfLayoutManagerObserver { 292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public: 30c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ShelfWidget(aura::Window* shelf_container, 31c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch aura::Window* status_container, 32c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch WorkspaceController* workspace_controller); 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual ~ShelfWidget(); 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 353551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Returns if shelf alignment option is enabled, and the user is able 363551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // to adjust the alignment (guest and supervised mode users cannot for 373551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // example). 383551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) static bool ShelfAlignmentAllowed(); 393551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void SetAlignment(ShelfAlignment alignmnet); 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ShelfAlignment GetAlignment() const; 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 437dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // Sets the shelf's background type. 44a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void SetPaintsBackground(ShelfBackgroundType background_type, 45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) BackgroundAnimatorChangeType change_type); 467dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch ShelfBackgroundType GetBackgroundType() const; 472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Hide the shelf behind a black bar during e.g. a user transition when |hide| 495f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // is true. The |animation_time_ms| will be used as animation duration. 505f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) void HideShelfBehindBlackBar(bool hide, int animation_time_ms); 515f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) bool IsShelfHiddenBehindBlackBar() const; 525f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 53a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Causes shelf items to be slightly dimmed (e.g. when a window is maximized). 542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void SetDimsShelf(bool dimming); 552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool GetDimsShelf() const; 562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 57c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ShelfLayoutManager* shelf_layout_manager() { return shelf_layout_manager_; } 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Shelf* shelf() const { return shelf_.get(); } 59c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch StatusAreaWidget* status_area_widget() const { return status_area_widget_; } 602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void CreateShelf(); 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Set visibility of the shelf. 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void SetShelfVisibility(bool visible); 655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool IsShelfVisible() const; 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Sets the focus cycler. Also adds the shelf to the cycle. 68c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch void SetFocusCycler(FocusCycler* focus_cycler); 69c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch FocusCycler* GetFocusCycler(); 702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Called by the activation delegate, before the shelf 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) // 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) 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // ShelfLayoutManagerObserver overrides: 995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void WillDeleteShelf() OVERRIDE; 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private: 1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) class DelegateView; 1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 104c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ShelfLayoutManager* shelf_layout_manager_; 1055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<Shelf> shelf_; 106c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 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_; 111c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 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