summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-02 01:36:37 +0000
committermgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-02 01:36:37 +0000
commit08f2fd122063528486c5abd4059a0f07c7b758c1 (patch)
tree9a89546b0e62e4232ee8552e1cbd806ef3940353
parent7d7970e0a9944347d83a40a1a49698fa0d07de01 (diff)
downloadchromium_src-08f2fd122063528486c5abd4059a0f07c7b758c1.zip
chromium_src-08f2fd122063528486c5abd4059a0f07c7b758c1.tar.gz
chromium_src-08f2fd122063528486c5abd4059a0f07c7b758c1.tar.bz2
AppListController now responsible for ensuring app list stays centered.
Just a refactor; effectively reverting SVN 266176 and rewriting it so that AppListController re-centers the app list when the screen bounds change (AppListView no longer needs to do this itself). Rationale: This architecture is simpler. On subsequent CLs I was having trouble plumbing more state (specifically, the virtual keyboard state) down into AppListView; this will mean we can do it from AppListController which has easy access to the virtual keyboard. BUG=363928 Review URL: https://codereview.chromium.org/260663002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267720 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/wm/app_list_controller.cc22
-rw-r--r--ash/wm/app_list_controller.h3
-rw-r--r--ui/app_list/views/app_list_view.cc28
-rw-r--r--ui/app_list/views/app_list_view.h21
4 files changed, 21 insertions, 53 deletions
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc
index bf631e7..b3df2d3 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -113,6 +113,11 @@ gfx::Vector2d GetAnchorPositionOffsetToShelf(
}
}
+// Gets the point at the center of the screen.
+gfx::Point GetScreenCenter() {
+ return Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint();
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -121,6 +126,7 @@ gfx::Vector2d GetAnchorPositionOffsetToShelf(
AppListController::AppListController()
: pagination_model_(new app_list::PaginationModel),
is_visible_(false),
+ is_centered_(false),
view_(NULL),
should_snap_back_(false) {
Shell::GetInstance()->AddShellObserver(this);
@@ -165,12 +171,13 @@ void AppListController::SetVisible(bool visible, aura::Window* window) {
aura::Window* root_window = window->GetRootWindow();
aura::Window* container = GetRootWindowController(root_window)->
GetContainer(kShellWindowId_AppListContainer);
- if (app_list::switches::IsExperimentalAppListPositionEnabled()) {
+ is_centered_ = app_list::switches::IsExperimentalAppListPositionEnabled();
+ if (is_centered_) {
// The experimental app list is centered over the primary display.
- view->InitAsBubbleCenteredOnPrimaryDisplay(
+ view->InitAsBubbleAtFixedLocation(
NULL,
pagination_model_.get(),
- Shell::GetScreen(),
+ GetScreenCenter(),
views::BubbleBorder::FLOAT,
true /* border_accepts_events */);
} else {
@@ -302,8 +309,13 @@ void AppListController::ProcessLocatedEvent(ui::LocatedEvent* event) {
}
void AppListController::UpdateBounds() {
- if (view_ && is_visible_)
- view_->UpdateBounds();
+ if (!view_ || !is_visible_)
+ return;
+
+ view_->UpdateBounds();
+
+ if (is_centered_)
+ view_->SetAnchorPoint(GetScreenCenter());
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/ash/wm/app_list_controller.h b/ash/wm/app_list_controller.h
index c2eb0ad..b8c212b 100644
--- a/ash/wm/app_list_controller.h
+++ b/ash/wm/app_list_controller.h
@@ -125,6 +125,9 @@ class AppListController : public ui::EventHandler,
// Whether we should show or hide app list widget.
bool is_visible_;
+ // Whether the app list should remain centered.
+ bool is_centered_;
+
// The AppListView this class manages, owned by its widget.
app_list::AppListView* view_;
diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc
index 4924eb9..0233aaa 100644
--- a/ui/app_list/views/app_list_view.cc
+++ b/ui/app_list/views/app_list_view.cc
@@ -28,11 +28,9 @@
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
-#include "ui/gfx/display.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/path.h"
-#include "ui/gfx/screen.h"
#include "ui/gfx/skia_util.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/bubble/bubble_window_targeter.h"
@@ -131,8 +129,7 @@ AppListView::AppListView(AppListViewDelegate* delegate)
app_list_main_view_(NULL),
signin_view_(NULL),
speech_view_(NULL),
- animation_observer_(new HideViewAnimationObserver()),
- screen_to_keep_centered_on_(NULL) {
+ animation_observer_(new HideViewAnimationObserver()) {
CHECK(delegate);
delegate_->AddObserver(this);
@@ -157,7 +154,6 @@ void AppListView::InitAsBubbleAttachedToAnchor(
SetAnchorView(anchor);
InitAsBubbleInternal(
parent, pagination_model, arrow, border_accepts_events, anchor_offset);
- screen_to_keep_centered_on_ = NULL;
}
void AppListView::InitAsBubbleAtFixedLocation(
@@ -170,20 +166,6 @@ void AppListView::InitAsBubbleAtFixedLocation(
SetAnchorRect(gfx::Rect(anchor_point_in_screen, gfx::Size()));
InitAsBubbleInternal(
parent, pagination_model, arrow, border_accepts_events, gfx::Vector2d());
- screen_to_keep_centered_on_ = NULL;
-}
-
-void AppListView::InitAsBubbleCenteredOnPrimaryDisplay(
- gfx::NativeView parent,
- PaginationModel* pagination_model,
- gfx::Screen* screen_to_keep_centered_on,
- views::BubbleBorder::Arrow arrow,
- bool border_accepts_events) {
- screen_to_keep_centered_on_ = screen_to_keep_centered_on;
- SetAnchorView(NULL);
- SetAnchorRect(gfx::Rect(GetCenterPoint(), gfx::Size()));
- InitAsBubbleInternal(
- parent, pagination_model, arrow, border_accepts_events, gfx::Vector2d());
}
void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) {
@@ -211,8 +193,6 @@ void AppListView::Close() {
}
void AppListView::UpdateBounds() {
- if (screen_to_keep_centered_on_)
- SetAnchorRect(gfx::Rect(GetCenterPoint(), gfx::Size()));
SizeToContents();
}
@@ -357,12 +337,6 @@ void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
delegate_->ViewInitialized();
}
-gfx::Point AppListView::GetCenterPoint() {
- DCHECK(screen_to_keep_centered_on_);
- gfx::Rect bounds = screen_to_keep_centered_on_->GetPrimaryDisplay().bounds();
- return bounds.CenterPoint();
-}
-
void AppListView::OnBeforeBubbleWidgetInit(
views::Widget::InitParams* params,
views::Widget* widget) const {
diff --git a/ui/app_list/views/app_list_view.h b/ui/app_list/views/app_list_view.h
index 5eb79c1..61c1659 100644
--- a/ui/app_list/views/app_list_view.h
+++ b/ui/app_list/views/app_list_view.h
@@ -17,10 +17,6 @@ namespace base {
class FilePath;
}
-namespace gfx {
-class Screen;
-}
-
namespace app_list {
class ApplicationDragAndDropHost;
class AppListMainView;
@@ -61,15 +57,6 @@ class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView,
views::BubbleBorder::Arrow arrow,
bool border_accepts_events);
- // Initializes the widget and use the center of the primary display for
- // positioning.
- void InitAsBubbleCenteredOnPrimaryDisplay(
- gfx::NativeView parent,
- PaginationModel* pagination_model,
- gfx::Screen* screen_to_keep_centered_on,
- views::BubbleBorder::Arrow arrow,
- bool border_accepts_events);
-
void SetBubbleArrow(views::BubbleBorder::Arrow arrow);
void SetAnchorPoint(const gfx::Point& anchor_point);
@@ -123,10 +110,6 @@ class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView,
bool border_accepts_events,
const gfx::Vector2d& anchor_offset);
- // Gets the point at the center of the current screen.
- // |screen_to_keep_centered_on_| must not be NULL.
- gfx::Point GetCenterPoint();
-
// Overridden from views::BubbleDelegateView:
virtual void OnBeforeBubbleWidgetInit(
views::Widget::InitParams* params,
@@ -165,10 +148,6 @@ class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView,
ObserverList<AppListViewObserver> observers_;
scoped_ptr<HideViewAnimationObserver> animation_observer_;
- // If non-NULL, the app list will remain centered on this screen's primary
- // display.
- gfx::Screen* screen_to_keep_centered_on_;
-
DISALLOW_COPY_AND_ASSIGN(AppListView);
};