| 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 2a1be91f97cb2a39c98e458b0cd518b89c0b5d5e..3ea99ee85a14aef687cf3fd035fa725a3875470b 100644
|
| --- a/ui/app_list/views/app_list_view.cc
|
| +++ b/ui/app_list/views/app_list_view.cc
|
| @@ -31,6 +31,8 @@
|
| #include "ui/compositor/layer.h"
|
| #include "ui/compositor/layer_animation_observer.h"
|
| #include "ui/compositor/scoped_layer_animation_settings.h"
|
| +#include "ui/display/display.h"
|
| +#include "ui/display/screen.h"
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/geometry/insets.h"
|
| #include "ui/gfx/image/image_skia.h"
|
| @@ -129,10 +131,7 @@ class SearchBoxWindowTargeter : public wm::MaskedWindowTargeter {
|
| // An animation observer to hide the view at the end of the animation.
|
| class HideViewAnimationObserver : public ui::ImplicitAnimationObserver {
|
| public:
|
| - HideViewAnimationObserver()
|
| - : frame_(NULL),
|
| - target_(NULL) {
|
| - }
|
| + HideViewAnimationObserver() : frame_(NULL), target_(NULL) {}
|
|
|
| ~HideViewAnimationObserver() override {
|
| if (target_)
|
| @@ -190,37 +189,22 @@ AppListView::~AppListView() {
|
| RemoveAllChildViews(true);
|
| }
|
|
|
| -void AppListView::InitAsBubble(gfx::NativeView parent, int initial_apps_page) {
|
| +void AppListView::Initialize(gfx::NativeView parent, int initial_apps_page) {
|
| base::Time start_time = base::Time::Now();
|
| -
|
| InitContents(parent, initial_apps_page);
|
| -
|
| AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
|
| - set_margins(gfx::Insets());
|
| - set_parent_window(parent);
|
| - set_close_on_deactivate(false);
|
| - set_shadow(views::BubbleBorder::NO_ASSETS);
|
| set_color(kContentsBackgroundColor);
|
| - // This creates the app list widget. (Before this, child widgets cannot be
|
| - // created.)
|
| - views::BubbleDialogDelegateView::CreateBubble(this);
|
| -
|
| - SetBubbleArrow(views::BubbleBorder::FLOAT);
|
| - // We can now create the internal widgets.
|
| - InitChildWidgets();
|
| + set_parent_window(parent);
|
|
|
| - aura::Window* window = GetWidget()->GetNativeWindow();
|
| - window->SetEventTargeter(base::MakeUnique<views::BubbleWindowTargeter>(this));
|
| + if (switches::IsFullscreenAppListEnabled())
|
| + InitializeFullscreen(parent, initial_apps_page);
|
| + else
|
| + InitializeBubble(parent, initial_apps_page);
|
|
|
| - const int kOverlayCornerRadius =
|
| - GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius();
|
| - overlay_view_ = new AppListOverlayView(kOverlayCornerRadius);
|
| - overlay_view_->SetBoundsRect(GetContentsBounds());
|
| + InitChildWidgets();
|
| AddChildView(overlay_view_);
|
| -
|
| if (delegate_)
|
| delegate_->ViewInitialized();
|
| -
|
| UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime",
|
| base::Time::Now() - start_time);
|
| }
|
| @@ -231,8 +215,10 @@ void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) {
|
| GetBubbleFrameView()->SchedulePaint();
|
| }
|
|
|
| -void AppListView::SetAnchorPoint(const gfx::Point& anchor_point) {
|
| - SetAnchorRect(gfx::Rect(anchor_point, gfx::Size()));
|
| +void AppListView::MaybeSetAnchorPoint(const gfx::Point& anchor_point) {
|
| + // if the AppListView is a bubble
|
| + if (!switches::IsFullscreenAppListEnabled())
|
| + SetAnchorRect(gfx::Rect(anchor_point, gfx::Size()));
|
| }
|
|
|
| void AppListView::SetDragAndDropHostOfCurrentAppList(
|
| @@ -250,7 +236,9 @@ void AppListView::CloseAppList() {
|
| }
|
|
|
| void AppListView::UpdateBounds() {
|
| - SizeToContents();
|
| + // if the AppListView is a bubble
|
| + if (!switches::IsFullscreenAppListEnabled())
|
| + SizeToContents();
|
| }
|
|
|
| void AppListView::SetAppListOverlayVisible(bool visible) {
|
| @@ -304,6 +292,10 @@ void AppListView::OnPaint(gfx::Canvas* canvas) {
|
| }
|
| }
|
|
|
| +const char* AppListView::GetClassName() const {
|
| + return "AppListView";
|
| +}
|
| +
|
| bool AppListView::ShouldHandleSystemCommands() const {
|
| return true;
|
| }
|
| @@ -343,7 +335,6 @@ void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) {
|
| app_list_main_view_->SetPaintToLayer();
|
| app_list_main_view_->layer()->SetFillsBoundsOpaquely(false);
|
| app_list_main_view_->layer()->SetMasksToBounds(true);
|
| -
|
| // This will be added to the |search_box_widget_| after the app list widget is
|
| // initialized.
|
| search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_);
|
| @@ -410,9 +401,50 @@ void AppListView::InitChildWidgets() {
|
| app_list_main_view_->contents_view()->Layout();
|
| }
|
|
|
| -void AppListView::OnBeforeBubbleWidgetInit(
|
| - views::Widget::InitParams* params,
|
| - views::Widget* widget) const {
|
| +void AppListView::InitializeFullscreen(gfx::NativeView parent,
|
| + int initial_apps_page) {
|
| +
|
| + views::Widget* widget = new views::Widget;
|
| + views::Widget::InitParams app_list_overlay_view_params(
|
| + views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
|
| +
|
| + app_list_overlay_view_params.parent = parent;
|
| + app_list_overlay_view_params.delegate = this;
|
| + app_list_overlay_view_params.opacity =
|
| + views::Widget::InitParams::TRANSLUCENT_WINDOW;
|
| + app_list_overlay_view_params.bounds =
|
| + display::Screen::GetScreen()->
|
| + GetDisplayNearestView(parent).work_area();
|
| + widget->Init(app_list_overlay_view_params);
|
| + widget->GetLayer()->SetBackgroundBlur(10);
|
| +
|
| + overlay_view_ = new AppListOverlayView(0 /* no corners */);
|
| +}
|
| +
|
| +void AppListView::InitializeBubble(gfx::NativeView parent,
|
| + int initial_apps_page) {
|
| + set_margins(gfx::Insets());
|
| + set_close_on_deactivate(false);
|
| + set_shadow(views::BubbleBorder::NO_ASSETS);
|
| +
|
| + // This creates the app list widget. (Before this, child widgets cannot be
|
| + // created.)
|
| + views::BubbleDialogDelegateView::CreateBubble(this);
|
| +
|
| + SetBubbleArrow(views::BubbleBorder::FLOAT);
|
| + // We can now create the internal widgets.
|
| +
|
| + aura::Window* window = GetWidget()->GetNativeWindow();
|
| + window->SetEventTargeter(base::MakeUnique<views::BubbleWindowTargeter>(this));
|
| +
|
| + const int kOverlayCornerRadius =
|
| + GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius();
|
| + overlay_view_ = new AppListOverlayView(kOverlayCornerRadius);
|
| + overlay_view_->SetBoundsRect(GetContentsBounds());
|
| +}
|
| +
|
| +void AppListView::OnBeforeBubbleWidgetInit(views::Widget::InitParams* params,
|
| + views::Widget* widget) const {
|
| if (!params->native_widget) {
|
| views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance();
|
| if (views_delegate && !views_delegate->native_widget_factory().is_null()) {
|
| @@ -441,8 +473,7 @@ void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const {
|
| DCHECK(mask);
|
| DCHECK(GetBubbleFrameView());
|
|
|
| - mask->addRect(gfx::RectToSkRect(
|
| - GetBubbleFrameView()->GetContentsBounds()));
|
| + mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds()));
|
| }
|
|
|
| bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
| @@ -475,8 +506,8 @@ void AppListView::Layout() {
|
| 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(),
|
| - preferred_height));
|
| + speech_bounds.set_height(
|
| + std::min(speech_bounds.height(), preferred_height));
|
| speech_bounds.Inset(-speech_view_->GetInsets());
|
| speech_view_->SetBoundsRect(speech_bounds);
|
| }
|
| @@ -522,8 +553,7 @@ void AppListView::OnSpeechRecognitionStateChanged(
|
|
|
| animation_observer_->set_frame(GetBubbleFrameView());
|
| gfx::Transform speech_transform;
|
| - speech_transform.Translate(
|
| - 0, SkFloatToMScalar(kSpeechUIAppearingPosition));
|
| + speech_transform.Translate(0, SkFloatToMScalar(kSpeechUIAppearingPosition));
|
| if (will_appear)
|
| speech_view_->layer()->SetTransform(speech_transform);
|
|
|
|
|