| Index: ui/app_list/app_list_view.cc
|
| ===================================================================
|
| --- ui/app_list/app_list_view.cc (revision 0)
|
| +++ ui/app_list/app_list_view.cc (working copy)
|
| @@ -2,21 +2,17 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "ash/app_list/app_list_view.h"
|
| +#include "ui/app_list/app_list_view.h"
|
|
|
| -#include "ash/app_list/app_list.h"
|
| -#include "ash/app_list/app_list_bubble_border.h"
|
| -#include "ash/app_list/app_list_item_view.h"
|
| -#include "ash/app_list/app_list_model.h"
|
| -#include "ash/app_list/app_list_model_view.h"
|
| -#include "ash/app_list/app_list_view_delegate.h"
|
| -#include "ash/app_list/page_switcher.h"
|
| -#include "ash/app_list/pagination_model.h"
|
| -#include "ash/launcher/launcher.h"
|
| -#include "ash/screen_ash.h"
|
| -#include "ash/shell.h"
|
| -#include "ash/shell_window_ids.h"
|
| -#include "ash/wm/shelf_layout_manager.h"
|
| +#include <string>
|
| +
|
| +#include "ui/app_list/app_list_bubble_border.h"
|
| +#include "ui/app_list/app_list_item_view.h"
|
| +#include "ui/app_list/app_list_model.h"
|
| +#include "ui/app_list/app_list_model_view.h"
|
| +#include "ui/app_list/app_list_view_delegate.h"
|
| +#include "ui/app_list/page_switcher.h"
|
| +#include "ui/app_list/pagination_model.h"
|
| #include "ui/compositor/layer.h"
|
| #include "ui/compositor/scoped_layer_animation_settings.h"
|
| #include "ui/gfx/screen.h"
|
| @@ -26,7 +22,7 @@
|
| #include "ui/views/layout/box_layout.h"
|
| #include "ui/views/widget/widget.h"
|
|
|
| -namespace ash {
|
| +namespace app_list {
|
|
|
| namespace {
|
|
|
| @@ -47,13 +43,6 @@
|
| return ui::GetScaleTransform(center, kModelViewAnimationScaleFactor);
|
| }
|
|
|
| -// Bounds returned is used for full screen mode. Use full monitor rect so that
|
| -// the app list shade goes behind the launcher.
|
| -gfx::Rect GetFullScreenBounds() {
|
| - gfx::Point cursor = gfx::Screen::GetCursorScreenPoint();
|
| - return gfx::Screen::GetMonitorNearestPoint(cursor).bounds();
|
| -}
|
| -
|
| } // namespace
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -65,10 +54,6 @@
|
| bubble_style_(false),
|
| bubble_border_(NULL),
|
| model_view_(NULL) {
|
| - if (internal::AppList::UseAppListV2())
|
| - InitAsBubble();
|
| - else
|
| - InitAsFullscreenWidget();
|
| }
|
|
|
| AppListView::~AppListView() {
|
| @@ -77,46 +62,13 @@
|
| model_view_->SetModel(NULL);
|
| }
|
|
|
| -void AppListView::AnimateShow(int duration_ms) {
|
| - if (bubble_style_)
|
| - return;
|
| -
|
| - ui::Layer* layer = model_view_->layer();
|
| - ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
|
| - animation.SetTransitionDuration(
|
| - base::TimeDelta::FromMilliseconds(duration_ms));
|
| - animation.SetTweenType(ui::Tween::EASE_OUT);
|
| - model_view_->SetTransform(ui::Transform());
|
| -}
|
| -
|
| -void AppListView::AnimateHide(int duration_ms) {
|
| - if (bubble_style_)
|
| - return;
|
| -
|
| - ui::Layer* layer = model_view_->layer();
|
| - ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
|
| - animation.SetTransitionDuration(
|
| - base::TimeDelta::FromMilliseconds(duration_ms));
|
| - animation.SetTweenType(ui::Tween::EASE_IN);
|
| - model_view_->SetTransform(GetScaleTransform(model_view_));
|
| -}
|
| -
|
| -void AppListView::Close() {
|
| - if (GetWidget()->IsVisible())
|
| - Shell::GetInstance()->ToggleAppList();
|
| -}
|
| -
|
| -void AppListView::UpdateBounds() {
|
| - if (bubble_style_)
|
| - SizeToContents();
|
| - else
|
| - GetWidget()->SetBounds(GetFullScreenBounds());
|
| -}
|
| -
|
| -void AppListView::InitAsFullscreenWidget() {
|
| +void AppListView::InitAsFullscreenWidget(gfx::NativeView parent,
|
| + const gfx::Rect& screen_bounds,
|
| + const gfx::Rect& work_area) {
|
| bubble_style_ = false;
|
| set_background(views::Background::CreateSolidBackground(
|
| kWidgetBackgroundColor));
|
| + work_area_ = work_area;
|
|
|
| model_view_ = new AppListModelView(this, pagination_model_.get());
|
| model_view_->SetPaintToLayer(true);
|
| @@ -127,15 +79,13 @@
|
| views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
|
| widget_params.delegate = this;
|
| widget_params.transparent = true;
|
| - widget_params.parent = Shell::GetInstance()->GetContainer(
|
| - internal::kShellWindowId_AppListContainer);
|
| + widget_params.parent = parent;
|
|
|
| views::Widget* widget = new views::Widget;
|
| widget->Init(widget_params);
|
| widget->SetContentsView(this);
|
| + widget->SetBounds(screen_bounds);
|
|
|
| - widget->SetBounds(GetFullScreenBounds());
|
| -
|
| // Turns off default animation.
|
| widget->SetVisibilityChangedAnimationsEnabled(false);
|
|
|
| @@ -144,7 +94,7 @@
|
| UpdateModel();
|
| }
|
|
|
| -void AppListView::InitAsBubble() {
|
| +void AppListView::InitAsBubble(gfx::NativeView parent, views::View* anchor) {
|
| bubble_style_ = true;
|
| set_background(NULL);
|
|
|
| @@ -160,9 +110,8 @@
|
| PageSwitcher* page_switcher = new PageSwitcher(pagination_model_.get());
|
| AddChildView(page_switcher);
|
|
|
| - set_anchor_view(Shell::GetInstance()->launcher()->GetAppListButtonView());
|
| - set_parent_window(Shell::GetInstance()->GetContainer(
|
| - internal::kShellWindowId_AppListContainer));
|
| + set_anchor_view(anchor);
|
| + set_parent_window(parent);
|
| set_close_on_deactivate(false);
|
| views::BubbleDelegateView::CreateBubble(this);
|
|
|
| @@ -177,6 +126,47 @@
|
| UpdateModel();
|
| }
|
|
|
| +void AppListView::AnimateShow(int duration_ms) {
|
| + if (bubble_style_)
|
| + return;
|
| +
|
| + ui::Layer* layer = model_view_->layer();
|
| + ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
|
| + animation.SetTransitionDuration(
|
| + base::TimeDelta::FromMilliseconds(duration_ms));
|
| + animation.SetTweenType(ui::Tween::EASE_OUT);
|
| + model_view_->SetTransform(ui::Transform());
|
| +}
|
| +
|
| +void AppListView::AnimateHide(int duration_ms) {
|
| + if (bubble_style_)
|
| + return;
|
| +
|
| + ui::Layer* layer = model_view_->layer();
|
| + ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
|
| + animation.SetTransitionDuration(
|
| + base::TimeDelta::FromMilliseconds(duration_ms));
|
| + animation.SetTweenType(ui::Tween::EASE_IN);
|
| + model_view_->SetTransform(GetScaleTransform(model_view_));
|
| +}
|
| +
|
| +void AppListView::Close() {
|
| + if (delegate_.get())
|
| + delegate_->Close();
|
| + else
|
| + GetWidget()->Close();
|
| +}
|
| +
|
| +void AppListView::UpdateBounds(const gfx::Rect& screen_bounds,
|
| + const gfx::Rect& work_area) {
|
| + if (bubble_style_) {
|
| + SizeToContents();
|
| + } else {
|
| + work_area_ = work_area;
|
| + GetWidget()->SetBounds(screen_bounds);
|
| + }
|
| +}
|
| +
|
| void AppListView::UpdateModel() {
|
| if (delegate_.get()) {
|
| scoped_ptr<AppListModel> new_model(new AppListModel);
|
| @@ -200,10 +190,7 @@
|
| views::View::Layout();
|
| } else {
|
| // Gets work area rect, which is in screen coordinates.
|
| - gfx::Rect workarea = Shell::GetInstance()->shelf()->IsVisible() ?
|
| - ScreenAsh::GetUnmaximizedWorkAreaBounds(GetWidget()->GetNativeView()) :
|
| - gfx::Screen::GetMonitorNearestWindow(
|
| - GetWidget()->GetNativeView()).work_area();
|
| + gfx::Rect workarea(work_area_);
|
|
|
| // Converts |workarea| into view's coordinates.
|
| gfx::Point origin(workarea.origin());
|
| @@ -285,4 +272,4 @@
|
| return bubble_rect;
|
| }
|
|
|
| -} // namespace ash
|
| +} // namespace app_list
|
|
|