diff options
Diffstat (limited to 'ash/wm')
-rw-r--r-- | ash/wm/shelf_auto_hide_behavior.h | 24 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager.cc | 23 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager.h | 11 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager_unittest.cc | 24 |
4 files changed, 66 insertions, 16 deletions
diff --git a/ash/wm/shelf_auto_hide_behavior.h b/ash/wm/shelf_auto_hide_behavior.h new file mode 100644 index 0000000..29c35da --- /dev/null +++ b/ash/wm/shelf_auto_hide_behavior.h @@ -0,0 +1,24 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_WM_SHELF_AUTO_HIDE_BEHAVIOR_H_ +#define ASH_WM_SHELF_AUTO_HIDE_BEHAVIOR_H_ +#pragma once + +namespace ash { + +enum ShelfAutoHideBehavior { + // The default; maximized windows trigger an auto-hide. + SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT, + + // Always auto-hide. + SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, + + // Never auto-hide. + SHELF_AUTO_HIDE_BEHAVIOR_NEVER, +}; + +} // namespace ash + +#endif // ASH_WM_SHELF_AUTO_HIDE_BEHAVIOR_H_ diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc index 951fa73..6fd6e1b 100644 --- a/ash/wm/shelf_layout_manager.cc +++ b/ash/wm/shelf_layout_manager.cc @@ -106,7 +106,7 @@ ShelfLayoutManager::AutoHideEventFilter::PreHandleGestureEvent( ShelfLayoutManager::ShelfLayoutManager(views::Widget* status) : in_layout_(false), - always_auto_hide_(false), + auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT), shelf_height_(status->GetWindowScreenBounds().height()), launcher_(NULL), status_(status), @@ -117,10 +117,10 @@ ShelfLayoutManager::ShelfLayoutManager(views::Widget* status) ShelfLayoutManager::~ShelfLayoutManager() { } -void ShelfLayoutManager::SetAlwaysAutoHide(bool value) { - if (always_auto_hide_ == value) +void ShelfLayoutManager::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) { + if (auto_hide_behavior_ == behavior) return; - always_auto_hide_ = value; + auto_hide_behavior_ = behavior; UpdateVisibilityState(); } @@ -128,8 +128,13 @@ gfx::Rect ShelfLayoutManager::GetMaximizedWindowBounds( aura::Window* window) const { // TODO: needs to be multi-mon aware. gfx::Rect bounds(gfx::Screen::GetMonitorAreaNearestWindow(window)); - bounds.set_height(bounds.height() - kAutoHideHeight); - return bounds; + if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT || + auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) { + bounds.set_height(bounds.height() - kAutoHideHeight); + return bounds; + } + // SHELF_AUTO_HIDE_BEHAVIOR_NEVER maximized windows don't get any taller. + return GetUnmaximizedWorkAreaBounds(window); } gfx::Rect ShelfLayoutManager::GetUnmaximizedWorkAreaBounds( @@ -183,12 +188,14 @@ void ShelfLayoutManager::UpdateVisibilityState() { break; case WorkspaceManager::WINDOW_STATE_MAXIMIZED: - SetState(AUTO_HIDE); + SetState(auto_hide_behavior_ != SHELF_AUTO_HIDE_BEHAVIOR_NEVER ? + AUTO_HIDE : VISIBLE); break; case WorkspaceManager::WINDOW_STATE_WINDOW_OVERLAPS_SHELF: case WorkspaceManager::WINDOW_STATE_DEFAULT: - SetState(always_auto_hide_ ? AUTO_HIDE : VISIBLE); + SetState(auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ? + AUTO_HIDE : VISIBLE); SetWindowOverlapsShelf(window_state == WorkspaceManager::WINDOW_STATE_WINDOW_OVERLAPS_SHELF); } diff --git a/ash/wm/shelf_layout_manager.h b/ash/wm/shelf_layout_manager.h index 05e3e7a..850aa80 100644 --- a/ash/wm/shelf_layout_manager.h +++ b/ash/wm/shelf_layout_manager.h @@ -8,6 +8,7 @@ #include "ash/ash_export.h" #include "ash/launcher/launcher.h" +#include "ash/wm/shelf_auto_hide_behavior.h" #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/timer.h" @@ -63,9 +64,11 @@ class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager { explicit ShelfLayoutManager(views::Widget* status); virtual ~ShelfLayoutManager(); - // Sets whether the shelf always auto-hides. Default is false. - void SetAlwaysAutoHide(bool value); - bool always_auto_hide() const { return always_auto_hide_; } + // Sets the ShelfAutoHideBehavior. See enum description for details. + void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); + ShelfAutoHideBehavior auto_hide_behavior() const { + return auto_hide_behavior_; + } void set_workspace_manager(WorkspaceManager* manager) { workspace_manager_ = manager; @@ -174,7 +177,7 @@ class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager { bool in_layout_; // See description above setter. - bool always_auto_hide_; + ShelfAutoHideBehavior auto_hide_behavior_; // Current state. State state_; diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc index f33605e..cd30b3d 100644 --- a/ash/wm/shelf_layout_manager_unittest.cc +++ b/ash/wm/shelf_layout_manager_unittest.cc @@ -263,8 +263,8 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); } -// Assertions around SetAlwaysAutoHide. -TEST_F(ShelfLayoutManagerTest, SetAlwaysAutoHide) { +// Assertions around SetAutoHideBehavior. +TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { ShelfLayoutManager* shelf = GetShelfLayoutManager(); views::Widget* widget = new views::Widget; views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); @@ -272,12 +272,28 @@ TEST_F(ShelfLayoutManagerTest, SetAlwaysAutoHide) { // Widget is now owned by the parent window. widget->Init(params); widget->Show(); + aura::Window* window = widget->GetNativeWindow(); + gfx::Rect monitor_bounds(gfx::Screen::GetMonitorAreaNearestWindow(window)); + EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight, + shelf->GetMaximizedWindowBounds(window).bottom()); EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); - shelf->SetAlwaysAutoHide(true); + shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); + EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight, + shelf->GetMaximizedWindowBounds(window).bottom()); - shelf->SetAlwaysAutoHide(FALSE); + shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT); + EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); + EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight, + shelf->GetMaximizedWindowBounds(window).bottom()); + + shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); + EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); + EXPECT_GT(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight, + shelf->GetMaximizedWindowBounds(window).bottom()); + + widget->Maximize(); EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); } |