diff options
Diffstat (limited to 'ash/shelf')
-rw-r--r-- | ash/shelf/shelf.cc | 8 | ||||
-rw-r--r-- | ash/shelf/shelf.h | 4 | ||||
-rw-r--r-- | ash/shelf/shelf_alignment_menu.cc | 36 | ||||
-rw-r--r-- | ash/shelf/shelf_alignment_menu.h | 10 | ||||
-rw-r--r-- | ash/shelf/shelf_layout_manager.cc | 24 | ||||
-rw-r--r-- | ash/shelf/shelf_layout_manager.h | 14 | ||||
-rw-r--r-- | ash/shelf/shelf_view.cc | 3 |
7 files changed, 47 insertions, 52 deletions
diff --git a/ash/shelf/shelf.cc b/ash/shelf/shelf.cc index 18dd34a..58904c4 100644 --- a/ash/shelf/shelf.cc +++ b/ash/shelf/shelf.cc @@ -79,6 +79,14 @@ bool Shelf::IsHorizontalAlignment() const { alignment_ == SHELF_ALIGNMENT_TOP; } +void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) { + shelf_widget_->shelf_layout_manager()->SetAutoHideBehavior(behavior); +} + +ShelfAutoHideBehavior Shelf::GetAutoHideBehavior() const { + return shelf_widget_->shelf_layout_manager()->auto_hide_behavior(); +} + gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow( const aura::Window* window) { ShelfID id = GetShelfIDForWindow(window); diff --git a/ash/shelf/shelf.h b/ash/shelf/shelf.h index 597dd37..f884458 100644 --- a/ash/shelf/shelf.h +++ b/ash/shelf/shelf.h @@ -60,6 +60,10 @@ class ASH_EXPORT Shelf { ShelfAlignment alignment() const { return alignment_; } bool IsHorizontalAlignment() const; + // Sets the ShelfAutoHideBehavior. See enum description for details. + void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); + ShelfAutoHideBehavior GetAutoHideBehavior() const; + // A helper functions that chooses values specific to a shelf alignment. template <typename T> T SelectValueForShelfAlignment(T bottom, T left, T right, T top) const { diff --git a/ash/shelf/shelf_alignment_menu.cc b/ash/shelf/shelf_alignment_menu.cc index 5b14e8f..6d67ed4 100644 --- a/ash/shelf/shelf_alignment_menu.cc +++ b/ash/shelf/shelf_alignment_menu.cc @@ -6,17 +6,18 @@ #include "ash/metrics/user_metrics_recorder.h" #include "ash/shelf/shelf.h" +#include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_types.h" +#include "ash/shelf/shelf_widget.h" #include "ash/shell.h" #include "grit/ash_strings.h" #include "ui/aura/window.h" namespace ash { -ShelfAlignmentMenu::ShelfAlignmentMenu(aura::Window* root) - : ui::SimpleMenuModel(NULL), - root_window_(root) { - DCHECK(root_window_); +ShelfAlignmentMenu::ShelfAlignmentMenu(Shelf* shelf) + : ui::SimpleMenuModel(nullptr), shelf_(shelf) { + DCHECK(shelf_); int align_group_id = 1; set_delegate(this); AddRadioItemWithStringId(MENU_ALIGN_LEFT, @@ -33,10 +34,9 @@ ShelfAlignmentMenu::ShelfAlignmentMenu(aura::Window* root) ShelfAlignmentMenu::~ShelfAlignmentMenu() {} bool ShelfAlignmentMenu::IsCommandIdChecked(int command_id) const { - return Shelf::ForWindow(root_window_) - ->SelectValueForShelfAlignment(MENU_ALIGN_BOTTOM == command_id, - MENU_ALIGN_LEFT == command_id, - MENU_ALIGN_RIGHT == command_id, false); + return shelf_->SelectValueForShelfAlignment( + MENU_ALIGN_BOTTOM == command_id, MENU_ALIGN_LEFT == command_id, + MENU_ALIGN_RIGHT == command_id, false); } bool ShelfAlignmentMenu::IsCommandIdEnabled(int command_id) const { @@ -50,24 +50,20 @@ bool ShelfAlignmentMenu::GetAcceleratorForCommandId( } void ShelfAlignmentMenu::ExecuteCommand(int command_id, int event_flags) { + Shell* shell = Shell::GetInstance(); + ShelfLayoutManager* manager = shelf_->shelf_widget()->shelf_layout_manager(); switch (static_cast<MenuItem>(command_id)) { case MENU_ALIGN_LEFT: - Shell::GetInstance()->metrics()-> - RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_LEFT); - Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, - root_window_); + shell->metrics()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_LEFT); + manager->SetAlignment(SHELF_ALIGNMENT_LEFT); break; case MENU_ALIGN_BOTTOM: - Shell::GetInstance()->metrics()-> - RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_BOTTOM); - Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM, - root_window_); + shell->metrics()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_BOTTOM); + manager->SetAlignment(SHELF_ALIGNMENT_BOTTOM); break; case MENU_ALIGN_RIGHT: - Shell::GetInstance()->metrics()-> - RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT); - Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, - root_window_); + shell->metrics()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT); + manager->SetAlignment(SHELF_ALIGNMENT_RIGHT); break; } } diff --git a/ash/shelf/shelf_alignment_menu.h b/ash/shelf/shelf_alignment_menu.h index add20f0..98d1eef 100644 --- a/ash/shelf/shelf_alignment_menu.h +++ b/ash/shelf/shelf_alignment_menu.h @@ -9,17 +9,15 @@ #include "base/macros.h" #include "ui/base/models/simple_menu_model.h" -namespace aura { -class RootWindow; -} - namespace ash { +class Shelf; + // Submenu for choosing the alignment of the launcher. class ASH_EXPORT ShelfAlignmentMenu : public ui::SimpleMenuModel, public ui::SimpleMenuModel::Delegate { public: - explicit ShelfAlignmentMenu(aura::Window* root); + explicit ShelfAlignmentMenu(Shelf* shelf); ~ShelfAlignmentMenu() override; // ui::SimpleMenuModel::Delegate overrides: @@ -37,7 +35,7 @@ class ASH_EXPORT ShelfAlignmentMenu : public ui::SimpleMenuModel, MENU_ALIGN_BOTTOM, }; - aura::Window* root_window_; + Shelf* shelf_; DISALLOW_COPY_AND_ASSIGN(ShelfAlignmentMenu); }; diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index 2509d47..8b779fd 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc @@ -247,21 +247,20 @@ bool ShelfLayoutManager::IsVisible() const { state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); } -bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { +void ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { if (alignment_ == alignment) - return false; + return; alignment_ = alignment; // The shelf will itself move to the bottom while locked or obscured by user // login. If a request is sent to move while being obscured, we postpone the // move until the user session is resumed. - if (IsAlignmentLocked()) - return false; - - // This should not be called during the lock screen transitions. - shelf_->SetAlignment(alignment); - LayoutShelf(); - return true; + if (!IsAlignmentLocked()) { + shelf_->SetAlignment(alignment); + LayoutShelf(); + Shell::GetInstance()->OnShelfAlignmentChanged( + shelf_->GetNativeWindow()->GetRootWindow()); + } } ShelfAlignment ShelfLayoutManager::GetAlignment() const { @@ -296,11 +295,6 @@ void ShelfLayoutManager::LayoutShelf() { ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() { switch(auto_hide_behavior_) { case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: -#if defined(OS_WIN) - // Disable shelf auto-hide behavior on screen sides in Metro mode. - if (GetAlignment() != SHELF_ALIGNMENT_BOTTOM) - return SHELF_VISIBLE; -#endif return SHELF_AUTO_HIDE; case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: return SHELF_VISIBLE; @@ -1149,6 +1143,8 @@ void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { shelf_->SetAlignment(GetAlignment()); UpdateVisibilityState(); LayoutShelf(); + Shell::GetInstance()->OnShelfAlignmentChanged( + shelf_->GetNativeWindow()->GetRootWindow()); } bool ShelfLayoutManager::IsAlignmentLocked() const { diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h index 3f21f004..ae4a281 100644 --- a/ash/shelf/shelf_layout_manager.h +++ b/ash/shelf/shelf_layout_manager.h @@ -90,16 +90,11 @@ class ASH_EXPORT ShelfLayoutManager return auto_hide_behavior_; } - // Sets the alignment. Returns true if the alignment got changed. If nothing - // has visually be changed, false will be returned. This can happen if either - // the alignment was already set, or the shelf is currently locked and cannot - // be changed at this time. In the latter case the change will be performed - // once the shelf gets unlocked. - bool SetAlignment(ShelfAlignment alignment); + // Sets the alignment; changes are delayed if the screen is locked. + void SetAlignment(ShelfAlignment alignment); // Returns the desired alignment for the current state, either the user's - // set alignment (alignment_) or SHELF_ALIGNMENT_BOTTOM when the screen - // is locked. + // selected alignment or SHELF_ALIGNMENT_BOTTOM when the screen is locked. ShelfAlignment GetAlignment() const; void set_workspace_controller(WorkspaceController* controller) { @@ -127,8 +122,7 @@ class ASH_EXPORT ShelfLayoutManager return user_work_area_bounds_; } - // Stops any animations and sets the bounds of the shelf and status - // widgets. + // Stops any animations and sets the bounds of the shelf and status widgets. void LayoutShelf(); // Returns shelf visibility state based on current value of auto hide diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc index 9088f6c..d15cccd 100644 --- a/ash/shelf/shelf_view.cc +++ b/ash/shelf/shelf_view.cc @@ -1794,8 +1794,7 @@ void ShelfView::ShowContextMenuForView(views::View* source, } context_menu_model_.reset(Shell::GetInstance()->delegate()->CreateContextMenu( - source->GetWidget()->GetNativeView()->GetRootWindow(), - &model_->items()[view_index])); + shelf_, &model_->items()[view_index])); if (!context_menu_model_) return; |