summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormukai <mukai@chromium.org>2014-11-24 19:23:35 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-25 03:24:35 +0000
commitd5e8fd97be07ca0b391c5f94293423503513b51a (patch)
tree6ec1c1219b0be246d23a9606f9a157270949dcb3
parent5c5b7fbc336416a0d9923329df0f428cc72ec293 (diff)
downloadchromium_src-d5e8fd97be07ca0b391c5f94293423503513b51a.zip
chromium_src-d5e8fd97be07ca0b391c5f94293423503513b51a.tar.gz
chromium_src-d5e8fd97be07ca0b391c5f94293423503513b51a.tar.bz2
Add AppListView::InitAsFramelessWindow() for fullscreen view.
This CL is for the fullscreen view mode of experimental applist which will look similar to Athena's home card. - Allow supporting to init as a non-bubble widget. Especially, in that case it won't have BubbleFrameView(). - Create InitContents() for the views initialization and separate it from bubble initialization. - |overlay_view_| as a custom view class, to put the property initialization into its ctor. - Layout() needs to centralize the contents if it's wider. BUG=434113 R=mgiuca@chromium.org, flackr@chromium.org TEST=manually Review URL: https://codereview.chromium.org/734833002 Cr-Commit-Position: refs/heads/master@{#305574}
-rw-r--r--ash/ash_switches.cc3
-rw-r--r--ash/ash_switches.h1
-rw-r--r--ash/wm/app_list_controller.cc16
-rw-r--r--ui/app_list/views/app_list_view.cc102
-rw-r--r--ui/app_list/views/app_list_view.h7
5 files changed, 95 insertions, 34 deletions
diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc
index 91ebb56..3bbab18 100644
--- a/ash/ash_switches.cc
+++ b/ash/ash_switches.cc
@@ -53,6 +53,9 @@ const char kAshDisableTouchExplorationMode[] =
"ash-disable-touch-exploration-mode";
#if defined(OS_CHROMEOS)
+// Enables fullscreen app list if Ash is in maximize mode.
+const char kAshEnableFullscreenAppList[] = "ash-enable-fullscreen-app-list";
+
// Enables key bindings to scroll magnified screen.
const char kAshEnableMagnifierKeyScroller[] =
"ash-enable-magnifier-key-scroller";
diff --git a/ash/ash_switches.h b/ash/ash_switches.h
index 9e2c11d..0e8842b 100644
--- a/ash/ash_switches.h
+++ b/ash/ash_switches.h
@@ -28,6 +28,7 @@ ASH_EXPORT extern const char kAshDisableLockLayoutManager[];
ASH_EXPORT extern const char kAshDisableTextFilteringInOverviewMode[];
ASH_EXPORT extern const char kAshDisableTouchExplorationMode[];
#if defined(OS_CHROMEOS)
+ASH_EXPORT extern const char kAshEnableFullscreenAppList[];
ASH_EXPORT extern const char kAshEnableMagnifierKeyScroller[];
#endif
ASH_EXPORT extern const char kAshEnableMirroredScreen[];
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc
index 3ac2139..0e068fa 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -12,6 +12,7 @@
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
+#include "ash/wm/maximize_mode/maximize_mode_controller.h"
#include "base/command_line.h"
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/app_list_switches.h"
@@ -197,7 +198,20 @@ void AppListController::Show(aura::Window* window) {
views::View* applist_button =
Shelf::ForWindow(container)->GetAppListButtonView();
is_centered_ = view->ShouldCenterWindow();
- if (is_centered_) {
+ bool is_fullscreen = false;
+#if defined(OS_CHROMEOS)
+ is_fullscreen = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAshEnableFullscreenAppList) &&
+ app_list::switches::IsExperimentalAppListEnabled() &&
+ Shell::GetInstance()
+ ->maximize_mode_controller()
+ ->IsMaximizeModeWindowManagerEnabled();
+#endif
+ if (is_fullscreen) {
+ view->InitAsFramelessWindow(
+ container, current_apps_page_,
+ ScreenUtil::GetDisplayWorkAreaBoundsInParent(container));
+ } else if (is_centered_) {
// Note: We can't center the app list until we have its dimensions, so we
// init at (0, 0) and then reset its anchor point.
view->InitAsBubbleAtFixedLocation(container,
diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc
index 8c695f3c..02276da 100644
--- a/ui/app_list/views/app_list_view.cc
+++ b/ui/app_list/views/app_list_view.cc
@@ -81,26 +81,30 @@ bool SupportsShadow() {
return true;
}
-// The background for the App List overlay, which appears as a white rounded
-// rectangle with the given radius and the same size as the target view.
-class AppListOverlayBackground : public views::Background {
+// The view for the App List overlay, which appears as a white rounded
+// rectangle with the given radius.
+class AppListOverlayView : public views::View {
public:
- AppListOverlayBackground(int corner_radius)
- : corner_radius_(corner_radius) {};
- ~AppListOverlayBackground() override{};
+ AppListOverlayView(int corner_radius) : corner_radius_(corner_radius) {
+ SetPaintToLayer(true);
+ SetVisible(false);
+ layer()->SetOpacity(0.0f);
+ }
+
+ ~AppListOverlayView() override {}
- // Overridden from views::Background:
- void Paint(gfx::Canvas* canvas, views::View* view) const override {
+ // Overridden from views::View:
+ void OnPaint(gfx::Canvas* canvas) override {
SkPaint paint;
paint.setStyle(SkPaint::kFill_Style);
paint.setColor(SK_ColorWHITE);
- canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint);
+ canvas->DrawRoundRect(GetContentsBounds(), corner_radius_, paint);
}
private:
const int corner_radius_;
- DISALLOW_COPY_AND_ASSIGN(AppListOverlayBackground);
+ DISALLOW_COPY_AND_ASSIGN(AppListOverlayView);
};
} // namespace
@@ -194,6 +198,23 @@ void AppListView::InitAsBubbleAtFixedLocation(
parent, initial_apps_page, arrow, border_accepts_events, gfx::Vector2d());
}
+void AppListView::InitAsFramelessWindow(gfx::NativeView parent,
+ int initial_apps_page,
+ gfx::Rect bounds) {
+ InitContents(parent, initial_apps_page);
+ overlay_view_ = new AppListOverlayView(0 /* no corners */);
+ AddChildView(overlay_view_);
+ set_background(new AppListBackground(0, app_list_main_view_));
+
+ views::Widget* widget = new views::Widget();
+ views::Widget::InitParams params(
+ views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ params.parent = parent;
+ params.delegate = this;
+ widget->Init(params);
+ widget->SetBounds(bounds);
+}
+
void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) {
GetBubbleFrameView()->bubble_border()->set_arrow(arrow);
SizeToContents(); // Recalcuates with new border.
@@ -321,13 +342,7 @@ PaginationModel* AppListView::GetAppsPaginationModel() {
->pagination_model();
}
-void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
- int initial_apps_page,
- views::BubbleBorder::Arrow arrow,
- bool border_accepts_events,
- const gfx::Vector2d& anchor_offset) {
- base::Time start_time = base::Time::Now();
-
+void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) {
app_list_main_view_ = new AppListMainView(delegate_);
AddChildView(app_list_main_view_);
app_list_main_view_->SetPaintToLayer(true);
@@ -365,6 +380,17 @@ void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
}
OnProfilesChanged();
+}
+
+void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
+ int initial_apps_page,
+ views::BubbleBorder::Arrow arrow,
+ bool border_accepts_events,
+ const gfx::Vector2d& anchor_offset) {
+ base::Time start_time = base::Time::Now();
+
+ InitContents(parent, initial_apps_page);
+
set_color(kContentsBackgroundColor);
set_margins(gfx::Insets());
set_parent_window(parent);
@@ -402,14 +428,6 @@ void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
GetWidget()->Hide();
#endif
- // To make the overlay view, construct a view with a white background, rather
- // than a white rectangle in it. This is because we need overlay_view_ to be
- // drawn to its own layer (so it appears correctly in the foreground).
- overlay_view_ = new views::View();
- overlay_view_->SetPaintToLayer(true);
- overlay_view_->SetBoundsRect(GetContentsBounds());
- overlay_view_->SetVisible(false);
- overlay_view_->layer()->SetOpacity(0.0f);
// On platforms that don't support a shadow, the rounded border of the app
// list is constructed _inside_ the view, so a rectangular background goes
// over the border in the rounded corners. To fix this, give the background a
@@ -417,8 +435,9 @@ void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
// doesn't cover it.
const int kOverlayCornerRadius =
GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius();
- overlay_view_->set_background(new AppListOverlayBackground(
- kOverlayCornerRadius - (SupportsShadow() ? 0 : 1)));
+ overlay_view_ =
+ new AppListOverlayView(kOverlayCornerRadius - (SupportsShadow() ? 0 : 1));
+ overlay_view_->SetBoundsRect(GetContentsBounds());
AddChildView(overlay_view_);
if (delegate_)
@@ -468,11 +487,13 @@ gfx::ImageSkia AppListView::GetWindowIcon() {
}
bool AppListView::WidgetHasHitTestMask() const {
- return true;
+ return GetBubbleFrameView() != nullptr;
}
void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const {
DCHECK(mask);
+ DCHECK(GetBubbleFrameView());
+
mask->addRect(gfx::RectToSkRect(
GetBubbleFrameView()->GetContentsBounds()));
}
@@ -511,14 +532,26 @@ bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) {
}
void AppListView::Layout() {
- search_box_view_->SetBoundsRect(
- app_list_main_view_->contents_view()->GetDefaultSearchBoxBounds());
-
const gfx::Rect contents_bounds = GetContentsBounds();
- app_list_main_view_->SetBoundsRect(contents_bounds);
+
+ // Make sure to layout |app_list_main_view_| and |speech_view_| at the center
+ // of the widget.
+ gfx::Rect centered_bounds = contents_bounds;
+ centered_bounds.ClampToCenteredSize(gfx::Size(
+ app_list_main_view_->contents_view()->GetDefaultContentsBounds().width(),
+ contents_bounds.height()));
+
+ app_list_main_view_->SetBoundsRect(centered_bounds);
+
+ // GetDefaultSearchBoxBounds() returns the bounds in |contents_view|'s
+ // coordinate, therefore convert it to this coordinate.
+ ContentsView* contents_view = app_list_main_view_->contents_view();
+ gfx::RectF search_box_bounds = contents_view->GetDefaultSearchBoxBounds();
+ ConvertRectToTarget(contents_view, this, &search_box_bounds);
+ search_box_view_->SetBoundsRect(gfx::ToNearestRect(search_box_bounds));
if (speech_view_) {
- gfx::Rect speech_bounds = contents_bounds;
+ gfx::Rect speech_bounds = centered_bounds;
int preferred_height = speech_view_->GetPreferredSize().height();
speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin);
speech_bounds.set_height(std::min(speech_bounds.height(),
@@ -535,6 +568,9 @@ void AppListView::Layout() {
contents_bounds.height() - image_bounds.height()));
experimental_banner_view_->SetBoundsRect(image_bounds);
}
+
+ if (overlay_view_)
+ overlay_view_->SetBoundsRect(contents_bounds);
}
void AppListView::SchedulePaintInRect(const gfx::Rect& rect) {
diff --git a/ui/app_list/views/app_list_view.h b/ui/app_list/views/app_list_view.h
index b9a5a61..f32434e 100644
--- a/ui/app_list/views/app_list_view.h
+++ b/ui/app_list/views/app_list_view.h
@@ -64,6 +64,11 @@ class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView,
views::BubbleBorder::Arrow arrow,
bool border_accepts_events);
+ // Initializes the widget as a frameless window, not a bubble.
+ void InitAsFramelessWindow(gfx::NativeView parent,
+ int initial_apps_page,
+ gfx::Rect bounds);
+
void SetBubbleArrow(views::BubbleBorder::Arrow arrow);
void SetAnchorPoint(const gfx::Point& anchor_point);
@@ -129,6 +134,8 @@ class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView,
private:
friend class ::test::AppListViewTestApi;
+ void InitContents(gfx::NativeView parent, int initial_apps_page);
+
void InitAsBubbleInternal(gfx::NativeView parent,
int initial_apps_page,
views::BubbleBorder::Arrow arrow,