| Index: ui/aura_shell/app_list/app_list_view.cc
|
| diff --git a/ui/aura_shell/app_list/app_list_view.cc b/ui/aura_shell/app_list/app_list_view.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..01eb658b90b785a7e88f6a06b4336055fcd2a12d
|
| --- /dev/null
|
| +++ b/ui/aura_shell/app_list/app_list_view.cc
|
| @@ -0,0 +1,80 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/aura_shell/app_list/app_list_view.h"
|
| +
|
| +#include "ui/aura_shell/app_list/app_list_groups_view.h"
|
| +#include "ui/aura_shell/app_list/app_list_item_view.h"
|
| +#include "ui/aura_shell/app_list/app_list_model.h"
|
| +#include "ui/aura_shell/app_list/app_list_view_delegate.h"
|
| +#include "ui/aura_shell/shell.h"
|
| +#include "ui/views/layout/fill_layout.h"
|
| +#include "ui/views/widget/widget.h"
|
| +
|
| +namespace aura_shell {
|
| +
|
| +AppListView::AppListView(
|
| + AppListModel* model,
|
| + AppListViewDelegate* delegate,
|
| + const gfx::Rect& bounds,
|
| + const aura_shell::ShellDelegate::SetWidgetCallback& callback)
|
| + : model_(model),
|
| + delegate_(delegate) {
|
| + Init(bounds, callback);
|
| +}
|
| +
|
| +AppListView::~AppListView() {
|
| +}
|
| +
|
| +void AppListView::Close() {
|
| + if (GetWidget()->IsVisible())
|
| + Shell::GetInstance()->ToggleAppList();
|
| +}
|
| +
|
| +void AppListView::Init(const gfx::Rect& bounds,
|
| + const ShellDelegate::SetWidgetCallback& callback) {
|
| + SetLayoutManager(new views::FillLayout);
|
| + AppListGroupsView* groups_view = new AppListGroupsView(model_.get(), this);
|
| + AddChildView(groups_view);
|
| +
|
| + views::Widget::InitParams widget_params(
|
| + views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
|
| + widget_params.bounds = bounds;
|
| + widget_params.delegate = this;
|
| + widget_params.keep_on_top = true;
|
| + widget_params.transparent = true;
|
| +
|
| + views::Widget* widget = new views::Widget;
|
| + widget->Init(widget_params);
|
| + widget->SetContentsView(this);
|
| +
|
| + callback.Run(widget);
|
| + if (groups_view->GetFocusedTile())
|
| + groups_view->GetFocusedTile()->RequestFocus();
|
| +}
|
| +
|
| +bool AppListView::OnKeyPressed(const views::KeyEvent& event) {
|
| + if (event.key_code() == ui::VKEY_ESCAPE) {
|
| + Close();
|
| + return true;
|
| + }
|
| +
|
| + return false;
|
| +}
|
| +
|
| +bool AppListView::OnMousePressed(const views::MouseEvent& event) {
|
| + // If mouse click reaches us, this means user clicks on blank area. So close.
|
| + Close();
|
| +
|
| + return true;
|
| +}
|
| +
|
| +void AppListView::AppListItemActivated(AppListItemView* sender,
|
| + int event_flags) {
|
| + if (delegate_.get())
|
| + delegate_->OnAppListItemActivated(sender->model(), event_flags);
|
| + Close();
|
| +}
|
| +
|
| +} // namespace aura_shell
|
|
|