diff options
author | calamity <calamity@chromium.org> | 2014-08-26 19:11:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-27 02:12:47 +0000 |
commit | 51802a7764aacfad5804a92e82e4f4fbaf35cd9b (patch) | |
tree | d2b8e2d2448a4ba0fa4f083af681771479692a0c | |
parent | f70d95e5ef769fff2a61566cd484fc65c5dbf6ba (diff) | |
download | chromium_src-51802a7764aacfad5804a92e82e4f4fbaf35cd9b.zip chromium_src-51802a7764aacfad5804a92e82e4f4fbaf35cd9b.tar.gz chromium_src-51802a7764aacfad5804a92e82e4f4fbaf35cd9b.tar.bz2 |
Split AppListController::SetVisible into Show and Dismiss.
This CL is in preparation for passing a reason for showing the app list.
This split is necessary to pass a reason only when showing and not
when dismissing.
BUG=391348
Review URL: https://codereview.chromium.org/485453003
Cr-Commit-Position: refs/heads/master@{#292080}
-rw-r--r-- | ash/shell.cc | 4 | ||||
-rw-r--r-- | ash/wm/app_list_controller.cc | 50 | ||||
-rw-r--r-- | ash/wm/app_list_controller.h | 3 |
3 files changed, 40 insertions, 17 deletions
diff --git a/ash/shell.cc b/ash/shell.cc index 1f9ef2c..6aca4b2 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -298,13 +298,13 @@ void Shell::ShowAppList(aura::Window* window) { window = GetTargetRootWindow(); if (!app_list_controller_) app_list_controller_.reset(new AppListController); - app_list_controller_->SetVisible(true, window); + app_list_controller_->Show(window); } void Shell::DismissAppList() { if (!app_list_controller_) return; - app_list_controller_->SetVisible(false, GetTargetRootWindow()); + app_list_controller_->Dismiss(); } void Shell::ToggleAppList(aura::Window* window) { diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc index 99a0a65..7e60edc 100644 --- a/ash/wm/app_list_controller.cc +++ b/ash/wm/app_list_controller.cc @@ -173,11 +173,11 @@ AppListController::~AppListController() { Shell::GetInstance()->RemoveShellObserver(this); } -void AppListController::SetVisible(bool visible, aura::Window* window) { - if (visible == is_visible_) +void AppListController::Show(aura::Window* window) { + if (is_visible_) return; - is_visible_ = visible; + is_visible_ = true; // App list needs to know the new shelf layout in order to calculate its // UI layout when AppListView visibility changes. @@ -185,15 +185,8 @@ void AppListController::SetVisible(bool visible, aura::Window* window) { UpdateAutoHideState(); if (view_) { - // Our widget is currently active. When the animation completes we'll hide - // the widget, changing activation. If a menu is shown before the animation - // completes then the activation change triggers the menu to close. By - // deactivating now we ensure there is no activation change when the - // animation completes and any menus stay open. - if (!visible) - view_->GetWidget()->Deactivate(); ScheduleAnimation(); - } else if (is_visible_) { + } else { // AppListModel and AppListViewDelegate are owned by AppListView. They // will be released with AppListView on close. app_list::AppListView* view = new app_list::AppListView( @@ -244,6 +237,35 @@ void AppListController::SetVisible(bool visible, aura::Window* window) { Shelf::ForWindow(window)->GetAppListButtonView()->SchedulePaint(); } +void AppListController::Dismiss() { + if (!is_visible_) + return; + + // If the app list is currently visible, there should be an existing view. + DCHECK(view_); + + is_visible_ = false; + + // App list needs to know the new shelf layout in order to calculate its + // UI layout when AppListView visibility changes. + Shell::GetPrimaryRootWindowController() + ->GetShelfLayoutManager() + ->UpdateAutoHideState(); + + // Our widget is currently active. When the animation completes we'll hide + // the widget, changing activation. If a menu is shown before the animation + // completes then the activation change triggers the menu to close. By + // deactivating now we ensure there is no activation change when the + // animation completes and any menus stay open. + view_->GetWidget()->Deactivate(); + ScheduleAnimation(); + + // Update applist button status when app list visibility is changed. + Shelf::ForWindow(view_->GetWidget()->GetNativeView()) + ->GetAppListButtonView() + ->SchedulePaint(); +} + bool AppListController::IsVisible() const { return view_ && view_->GetWidget()->IsVisible(); } @@ -354,7 +376,7 @@ void AppListController::ProcessLocatedEvent(ui::LocatedEvent* event) { aura::Window* window = view_->GetWidget()->GetNativeView()->parent(); if (!window->Contains(target)) - SetVisible(false, window); + Dismiss(); } void AppListController::UpdateBounds() { @@ -392,7 +414,7 @@ void AppListController::OnWindowFocused(aura::Window* gained_focus, if (applist_container->Contains(lost_focus) && (!gained_focus || !applist_container->Contains(gained_focus))) { - SetVisible(false, applist_window); + Dismiss(); } } } @@ -421,7 +443,7 @@ void AppListController::OnImplicitAnimationsCompleted() { void AppListController::OnWidgetDestroying(views::Widget* widget) { DCHECK(view_->GetWidget() == widget); if (is_visible_) - SetVisible(false, widget->GetNativeView()); + Dismiss(); ResetView(); } diff --git a/ash/wm/app_list_controller.h b/ash/wm/app_list_controller.h index 954d789..65c4896 100644 --- a/ash/wm/app_list_controller.h +++ b/ash/wm/app_list_controller.h @@ -53,7 +53,8 @@ class AppListController : public ui::EventHandler, // Show/hide app list window. The |window| is used to deterime in // which display (in which the |window| exists) the app list should // be shown. - void SetVisible(bool visible, aura::Window* window); + void Show(aura::Window* window); + void Dismiss(); // Whether app list window is visible (shown or being shown). bool IsVisible() const; |