Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: ui/app_list/views/app_list_view.cc

Issue 237533015: ChromeOS: Keep app list centered when the display rotates by 90 degrees. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Formatting. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/app_list_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/app_list_view.cc
diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc
index 0233aaa9c3ee987ea52935f6048b8c73631b97e0..4924eb94504f515821c1d83c180ae4488c036d45 100644
--- a/ui/app_list/views/app_list_view.cc
+++ b/ui/app_list/views/app_list_view.cc
@@ -28,9 +28,11 @@
#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"
@@ -129,7 +131,8 @@ AppListView::AppListView(AppListViewDelegate* delegate)
app_list_main_view_(NULL),
signin_view_(NULL),
speech_view_(NULL),
- animation_observer_(new HideViewAnimationObserver()) {
+ animation_observer_(new HideViewAnimationObserver()),
+ screen_to_keep_centered_on_(NULL) {
CHECK(delegate);
delegate_->AddObserver(this);
@@ -154,6 +157,7 @@ void AppListView::InitAsBubbleAttachedToAnchor(
SetAnchorView(anchor);
InitAsBubbleInternal(
parent, pagination_model, arrow, border_accepts_events, anchor_offset);
+ screen_to_keep_centered_on_ = NULL;
}
void AppListView::InitAsBubbleAtFixedLocation(
@@ -166,6 +170,20 @@ 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) {
@@ -193,6 +211,8 @@ void AppListView::Close() {
}
void AppListView::UpdateBounds() {
+ if (screen_to_keep_centered_on_)
+ SetAnchorRect(gfx::Rect(GetCenterPoint(), gfx::Size()));
SizeToContents();
}
@@ -337,6 +357,12 @@ void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
delegate_->ViewInitialized();
}
+gfx::Point AppListView::GetCenterPoint() {
Matt Giuca 2014/04/24 10:03:19 Note: It may seem a bit trivial to abstract out th
+ 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 {
« no previous file with comments | « ui/app_list/views/app_list_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698