summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
Diffstat (limited to 'ash')
-rw-r--r--ash/app_list/OWNERS1
-rw-r--r--ash/app_list/app_list_bubble_border.cc213
-rw-r--r--ash/app_list/app_list_bubble_border.h53
-rw-r--r--ash/app_list/app_list_item_model.cc50
-rw-r--r--ash/app_list/app_list_item_model.h65
-rw-r--r--ash/app_list/app_list_item_model_observer.h30
-rw-r--r--ash/app_list/app_list_item_view.cc403
-rw-r--r--ash/app_list/app_list_item_view.h110
-rw-r--r--ash/app_list/app_list_model.cc39
-rw-r--r--ash/app_list/app_list_model.h48
-rw-r--r--ash/app_list/app_list_model_view.cc307
-rw-r--r--ash/app_list/app_list_model_view.h94
-rw-r--r--ash/app_list/app_list_unittest.cc64
-rw-r--r--ash/app_list/app_list_view.cc288
-rw-r--r--ash/app_list/app_list_view.h78
-rw-r--r--ash/app_list/app_list_view_delegate.h37
-rw-r--r--ash/app_list/drop_shadow_label.cc63
-rw-r--r--ash/app_list/drop_shadow_label.h46
-rw-r--r--ash/app_list/icon_cache.cc90
-rw-r--r--ash/app_list/icon_cache.h58
-rw-r--r--ash/app_list/page_switcher.cc158
-rw-r--r--ash/app_list/page_switcher.h49
-rw-r--r--ash/app_list/pagination_model.cc50
-rw-r--r--ash/app_list/pagination_model.h49
-rw-r--r--ash/app_list/pagination_model_observer.h27
-rw-r--r--ash/ash.gyp30
-rw-r--r--ash/shell.cc18
-rw-r--r--ash/shell.h6
-rw-r--r--ash/shell/app_list.cc30
-rw-r--r--ash/shell/example_factory.h6
-rw-r--r--ash/shell/shell_delegate_impl.cc2
-rw-r--r--ash/shell/shell_delegate_impl.h2
-rw-r--r--ash/shell_delegate.h7
-rw-r--r--ash/test/test_shell_delegate.cc2
-rw-r--r--ash/test/test_shell_delegate.h2
-rw-r--r--ash/wm/app_list_controller.cc (renamed from ash/app_list/app_list.cc)136
-rw-r--r--ash/wm/app_list_controller.h (renamed from ash/app_list/app_list.h)38
37 files changed, 152 insertions, 2597 deletions
diff --git a/ash/app_list/OWNERS b/ash/app_list/OWNERS
deleted file mode 100644
index ff3209c..0000000
--- a/ash/app_list/OWNERS
+++ /dev/null
@@ -1 +0,0 @@
-xiyuan@chromium.org
diff --git a/ash/app_list/app_list_bubble_border.cc b/ash/app_list/app_list_bubble_border.cc
deleted file mode 100644
index ca634cb..0000000
--- a/ash/app_list/app_list_bubble_border.cc
+++ /dev/null
@@ -1,213 +0,0 @@
-// Copyright (c) 2012 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 "ash/app_list/app_list_bubble_border.h"
-
-#include "third_party/skia/include/core/SkPath.h"
-#include "third_party/skia/include/core/SkPaint.h"
-#include "third_party/skia/include/effects/SkBlurDrawLooper.h"
-#include "third_party/skia/include/effects/SkGradientShader.h"
-#include "ui/gfx/canvas.h"
-
-namespace {
-
-const int kCornerRadius = 3;
-
-const int kArrowHeight = 10;
-const int kArrowWidth = 20;
-
-const SkColor kBorderColor = SkColorSetARGB(0xFF, 0, 0, 0);
-const int kBorderSize = 1;
-
-const SkColor kShadowColor = SkColorSetARGB(0xFF, 0, 0, 0);
-const int kShadowRadius = 4;
-
-const SkColor kModelViewGradientColor1 = SkColorSetARGB(0xFF, 0xFE, 0xFE, 0xFE);
-const SkColor kModelViewGradientColor2 = SkColorSetARGB(0xFF, 0xF8, 0xF8, 0xF8);
-const int kModelViewGradientSize = 10;
-
-const SkColor kFooterBorderGradientColor1 =
- SkColorSetARGB(0xFF, 0xA0, 0xA0, 0xA0);
-const SkColor kFooterBorderGradientColor2 =
- SkColorSetARGB(0xFF, 0xD4, 0xD4, 0xD4);
-const int kFooterBorderSize = 3;
-const SkColor kFooterBackground = SkColorSetARGB(0xFF, 0xDC, 0xDC, 0xDC);
-
-// TODO(xiyuan): Merge this with the one in skia_util.
-SkShader* CreateVerticalGradientShader(int start_point,
- int end_point,
- SkColor start_color,
- SkColor end_color,
- SkShader::TileMode mode) {
- SkColor grad_colors[2] = { start_color, end_color};
- SkPoint grad_points[2];
- grad_points[0].iset(0, start_point);
- grad_points[1].iset(0, end_point);
-
- return SkGradientShader::CreateLinear(grad_points,
- grad_colors,
- NULL,
- 2,
- mode);
-}
-
-// Builds a bubble shape for given |bounds|.
-void BuildShape(const gfx::Rect& bounds,
- SkScalar padding,
- SkScalar arrow_offset,
- SkPath* path) {
- const SkScalar left = SkIntToScalar(bounds.x()) + padding;
- const SkScalar top = SkIntToScalar(bounds.y()) + padding;
- const SkScalar right = SkIntToScalar(bounds.right()) - padding;
- const SkScalar bottom = SkIntToScalar(bounds.bottom()) - padding;
-
- const SkScalar center_x = SkIntToScalar((bounds.x() + bounds.right()) / 2);
- const SkScalar center_y = SkIntToScalar((bounds.y() + bounds.bottom()) / 2);
-
- const SkScalar half_array_width = SkIntToScalar(kArrowWidth / 2);
- const SkScalar arrow_height = SkIntToScalar(kArrowHeight) - padding;
-
- path->reset();
- path->incReserve(12);
-
- path->moveTo(center_x, top);
- path->arcTo(left, top, left, center_y, SkIntToScalar(kCornerRadius));
- path->arcTo(left, bottom, center_x - half_array_width, bottom,
- SkIntToScalar(kCornerRadius));
- path->lineTo(center_x + arrow_offset - half_array_width, bottom);
- path->lineTo(center_x + arrow_offset, bottom + arrow_height);
- path->lineTo(center_x + arrow_offset + half_array_width, bottom);
- path->arcTo(right, bottom, right, center_y, SkIntToScalar(kCornerRadius));
- path->arcTo(right, top, center_x, top, SkIntToScalar(kCornerRadius));
- path->close();
-}
-
-} // namespace
-
-namespace ash {
-
-AppListBubbleBorder::AppListBubbleBorder(views::View* app_list_view)
- : views::BubbleBorder(views::BubbleBorder::BOTTOM_RIGHT,
- views::BubbleBorder::NO_SHADOW),
- app_list_view_(app_list_view),
- arrow_offset_(0) {
-}
-
-AppListBubbleBorder::~AppListBubbleBorder() {
-}
-
-void AppListBubbleBorder::PaintModelViewBackground(
- gfx::Canvas* canvas,
- const gfx::Rect& bounds) const {
- const views::View* page_switcher = app_list_view_->child_at(1);
- const gfx::Rect page_switcher_bounds =
- app_list_view_->ConvertRectToWidget(page_switcher->bounds());
- gfx::Rect rect(bounds.x(),
- bounds.y(),
- bounds.width(),
- page_switcher_bounds.y() - bounds.y());
-
- SkPaint paint;
- paint.setStyle(SkPaint::kFill_Style);
- SkSafeUnref(paint.setShader(CreateVerticalGradientShader(
- rect.y(),
- rect.y() + kModelViewGradientSize,
- kModelViewGradientColor1,
- kModelViewGradientColor2,
- SkShader::kClamp_TileMode)));
- canvas->DrawRect(rect, paint);
-}
-
-void AppListBubbleBorder::PaintPageSwitcherBackground(
- gfx::Canvas* canvas,
- const gfx::Rect& bounds) const {
- const views::View* page_switcher = app_list_view_->child_at(1);
- const gfx::Rect page_switcher_bounds =
- app_list_view_->ConvertRectToWidget(page_switcher->bounds());
-
- gfx::Rect rect(bounds.x(),
- page_switcher_bounds.y(),
- bounds.width(),
- kFooterBorderSize);
- SkPaint paint;
- paint.setStyle(SkPaint::kFill_Style);
- SkSafeUnref(paint.setShader(CreateVerticalGradientShader(
- rect.y(),
- rect.bottom(),
- kFooterBorderGradientColor1,
- kFooterBorderGradientColor2,
- SkShader::kClamp_TileMode)));
- canvas->DrawRect(rect, paint);
-
- rect.set_y(rect.bottom());
- rect.set_height(bounds.bottom() - rect.y() + kArrowHeight - kBorderSize);
- canvas->FillRect(rect, kFooterBackground);
-}
-
-void AppListBubbleBorder::GetInsets(gfx::Insets* insets) const {
- insets->Set(kShadowRadius + kBorderSize,
- kShadowRadius + kBorderSize,
- kShadowRadius + kBorderSize + kArrowHeight,
- kShadowRadius + kBorderSize);
-}
-
-gfx::Rect AppListBubbleBorder::GetBounds(
- const gfx::Rect& position_relative_to,
- const gfx::Size& contents_size) const {
- gfx::Size border_size(contents_size);
- gfx::Insets insets;
- GetInsets(&insets);
- border_size.Enlarge(insets.width(), insets.height());
-
- int anchor_x = (position_relative_to.x() + position_relative_to.right()) / 2;
- int arrow_tip_x = border_size.width() / 2 + arrow_offset_;
-
- return gfx::Rect(
- gfx::Point(anchor_x - arrow_tip_x,
- position_relative_to.y() - border_size.height() +
- kShadowRadius),
- border_size);
-}
-
-void AppListBubbleBorder::Paint(const views::View& view,
- gfx::Canvas* canvas) const {
- gfx::Insets insets;
- GetInsets(&insets);
-
- gfx::Rect bounds = view.bounds();
- bounds.Inset(insets);
-
- SkPath path;
-
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setColor(kBorderColor);
- SkSafeUnref(paint.setLooper(
- new SkBlurDrawLooper(kShadowRadius,
- 0, 0,
- kShadowColor,
- SkBlurDrawLooper::kHighQuality_BlurFlag)));
- // Pads with 0.5 pixel since anti alias is used.
- BuildShape(bounds,
- SkDoubleToScalar(0.5),
- SkIntToScalar(arrow_offset_),
- &path);
- canvas->DrawPath(path, paint);
-
- // Pads with kBoprderSize pixels to leave space for border lines.
- BuildShape(bounds,
- SkIntToScalar(kBorderSize),
- SkIntToScalar(arrow_offset_),
- &path);
- canvas->Save();
- canvas->ClipPath(path);
-
- PaintModelViewBackground(canvas, bounds);
- PaintPageSwitcherBackground(canvas, bounds);
-
- canvas->Restore();
-}
-
-} // namespace ash
diff --git a/ash/app_list/app_list_bubble_border.h b/ash/app_list/app_list_bubble_border.h
deleted file mode 100644
index 345e4eb..0000000
--- a/ash/app_list/app_list_bubble_border.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_APP_LIST_BUBBLE_BORDER_H_
-#define ASH_APP_LIST_APP_LIST_BUBBLE_BORDER_H_
-#pragma once
-
-#include "base/basictypes.h"
-#include "ui/views/bubble/bubble_border.h"
-
-namespace ash {
-
-// A class to paint bubble border and background.
-class AppListBubbleBorder : public views::BubbleBorder {
- public:
- explicit AppListBubbleBorder(views::View* app_list_view);
- virtual ~AppListBubbleBorder();
-
- int arrow_offset() const {
- return arrow_offset_;
- }
- void set_arrow_offset(int arrow_offset) {
- arrow_offset_ = arrow_offset;
- }
-
- private:
- void PaintModelViewBackground(gfx::Canvas* canvas,
- const gfx::Rect& bounds) const;
- void PaintPageSwitcherBackground(gfx::Canvas* canvas,
- const gfx::Rect& bounds) const;
-
- // views::BubbleBorder overrides:
- virtual void GetInsets(gfx::Insets* insets) const OVERRIDE;
- virtual gfx::Rect GetBounds(const gfx::Rect& position_relative_to,
- const gfx::Size& contents_size) const OVERRIDE;
-
- // views::Border overrides:
- virtual void Paint(const views::View& view,
- gfx::Canvas* canvas) const OVERRIDE;
-
- // AppListView hosted inside this bubble.
- views::View* app_list_view_;
-
- // Offset in pixels relative the default middle position.
- int arrow_offset_;
-
- DISALLOW_COPY_AND_ASSIGN(AppListBubbleBorder);
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_APP_LIST_BUBBLE_BORDER_H_
diff --git a/ash/app_list/app_list_item_model.cc b/ash/app_list/app_list_item_model.cc
deleted file mode 100644
index c8c5938..0000000
--- a/ash/app_list/app_list_item_model.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2012 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 "ash/app_list/app_list_item_model.h"
-
-#include "ash/app_list/app_list_item_model_observer.h"
-
-namespace ash {
-
-AppListItemModel::AppListItemModel() : highlighted_(false) {
-}
-
-AppListItemModel::~AppListItemModel() {
-}
-
-void AppListItemModel::SetIcon(const SkBitmap& icon) {
- icon_ = icon;
- FOR_EACH_OBSERVER(AppListItemModelObserver, observers_,
- ItemIconChanged());
-}
-
-void AppListItemModel::SetTitle(const std::string& title) {
- title_ = title;
- FOR_EACH_OBSERVER(AppListItemModelObserver, observers_,
- ItemTitleChanged());
-}
-
-void AppListItemModel::SetHighlighted(bool highlighted) {
- if (highlighted_ == highlighted)
- return;
-
- highlighted_ = highlighted;
- FOR_EACH_OBSERVER(AppListItemModelObserver, observers_,
- ItemHighlightedChanged());
-}
-
-void AppListItemModel::AddObserver(AppListItemModelObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void AppListItemModel::RemoveObserver(AppListItemModelObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
-ui::MenuModel* AppListItemModel::GetContextMenuModel() {
- return NULL;
-}
-
-} // namespace ash
diff --git a/ash/app_list/app_list_item_model.h b/ash/app_list/app_list_item_model.h
deleted file mode 100644
index 9dec482..0000000
--- a/ash/app_list/app_list_item_model.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef UI_AURA_SHELL_APP_LIST_APP_LIST_ITEM_MODEL_H_
-#define UI_AURA_SHELL_APP_LIST_APP_LIST_ITEM_MODEL_H_
-#pragma once
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/observer_list.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ash/ash_export.h"
-
-namespace ui {
-class MenuModel;
-}
-
-namespace ash {
-
-class AppListItemModelObserver;
-
-// AppListItemModel provides icon and title to be shown in a AppListItemView
-// and action to be executed when the AppListItemView is activated.
-class ASH_EXPORT AppListItemModel {
- public:
- AppListItemModel();
- virtual ~AppListItemModel();
-
- void SetIcon(const SkBitmap& icon);
- const SkBitmap& icon() const {
- return icon_;
- }
-
- void SetTitle(const std::string& title);
- const std::string& title() const {
- return title_;
- }
-
- void SetHighlighted(bool highlighted);
- bool highlighted() const {
- return highlighted_;
- }
-
- void AddObserver(AppListItemModelObserver* observer);
- void RemoveObserver(AppListItemModelObserver* observer);
-
- // Returns the context menu model for this item.
- // Note the menu model is owned by this item.
- virtual ui::MenuModel* GetContextMenuModel();
-
- private:
- SkBitmap icon_;
- std::string title_;
- bool highlighted_;
-
- ObserverList<AppListItemModelObserver> observers_;
-
- DISALLOW_COPY_AND_ASSIGN(AppListItemModel);
-};
-
-} // namespace ash
-
-#endif // #define ASH_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_
diff --git a/ash/app_list/app_list_item_model_observer.h b/ash/app_list/app_list_item_model_observer.h
deleted file mode 100644
index 0162a31..0000000
--- a/ash/app_list/app_list_item_model_observer.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_
-#define ASH_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_
-#pragma once
-
-#include "ash/ash_export.h"
-
-namespace ash {
-
-class ASH_EXPORT AppListItemModelObserver {
- public:
- // Invoked after item's icon is changed.
- virtual void ItemIconChanged() = 0;
-
- // Invoked after item's title is changed.
- virtual void ItemTitleChanged() = 0;
-
- // Invoked after item's highlighted state is changed.
- virtual void ItemHighlightedChanged() = 0;
-
- protected:
- virtual ~AppListItemModelObserver() {}
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_
diff --git a/ash/app_list/app_list_item_view.cc b/ash/app_list/app_list_item_view.cc
deleted file mode 100644
index 869e6a4..0000000
--- a/ash/app_list/app_list_item_view.cc
+++ /dev/null
@@ -1,403 +0,0 @@
-// Copyright (c) 2012 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 "ash/app_list/app_list_item_view.h"
-
-#include "ash/app_list/app_list.h"
-#include "ash/app_list/app_list_item_model.h"
-#include "ash/app_list/app_list_model_view.h"
-#include "ash/app_list/drop_shadow_label.h"
-#include "ash/app_list/icon_cache.h"
-#include "base/bind.h"
-#include "base/message_loop.h"
-#include "base/synchronization/cancellation_flag.h"
-#include "base/threading/worker_pool.h"
-#include "base/utf_string_conversions.h"
-#include "ui/base/accessibility/accessible_view_state.h"
-#include "ui/base/animation/throb_animation.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/font.h"
-#include "ui/gfx/shadow_value.h"
-#include "ui/gfx/skbitmap_operations.h"
-#include "ui/views/controls/image_view.h"
-#include "ui/views/controls/menu/menu_item_view.h"
-#include "ui/views/controls/menu/menu_model_adapter.h"
-#include "ui/views/controls/menu/menu_runner.h"
-
-namespace ash {
-
-namespace {
-
-const int kTopBottomPadding = 10;
-const int kIconTitleSpacing = 10;
-
-const SkColor kTitleColor = SK_ColorWHITE;
-const SkColor kTitleColorV2 = SkColorSetARGB(0xFF, 0x88, 0x88, 0x88);
-
-// 0.33 black
-const SkColor kHoverAndPushedColor = SkColorSetARGB(0x55, 0x00, 0x00, 0x00);
-
-// 0.16 black
-const SkColor kSelectedColor = SkColorSetARGB(0x2A, 0x00, 0x00, 0x00);
-
-const SkColor kHighlightedColor = kHoverAndPushedColor;
-
-// FontSize/IconSize ratio = 24 / 128, which means we should get 24 font size
-// when icon size is 128.
-const float kFontSizeToIconSizeRatio = 0.1875f;
-
-// Font smaller than kBoldFontSize needs to be bold.
-const int kBoldFontSize = 14;
-
-const int kMinFontSize = 12;
-
-const int kMinTitleChars = 15;
-
-const int kLeftRightPaddingChars = 1;
-
-const gfx::Font& GetTitleFontForIconSize(const gfx::Size& size) {
- static int icon_height;
- static gfx::Font* font = NULL;
-
- if (font && icon_height == size.height())
- return *font;
-
- delete font;
-
- icon_height = size.height();
- int font_size = std::max(
- static_cast<int>(icon_height * kFontSizeToIconSizeRatio),
- kMinFontSize);
-
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- gfx::Font title_font(rb.GetFont(ui::ResourceBundle::BaseFont).GetFontName(),
- font_size);
- if (font_size <= kBoldFontSize)
- title_font = title_font.DeriveFont(0, gfx::Font::BOLD);
- font = new gfx::Font(title_font);
- return *font;
-}
-
-// An image view that is not interactive.
-class StaticImageView : public views::ImageView {
- public:
- StaticImageView() : ImageView() {
- }
-
- private:
- // views::View overrides:
- virtual bool HitTest(const gfx::Point& l) const OVERRIDE {
- return false;
- }
-
- DISALLOW_COPY_AND_ASSIGN(StaticImageView);
-};
-
-// A minimum title width set by test to override the default logic that derives
-// the min width from font.
-int g_min_title_width = 0;
-
-} // namespace
-
-// static
-const char AppListItemView::kViewClassName[] = "ash/app_list/AppListItemView";
-
-// AppListItemView::IconOperation wraps background icon processing.
-class AppListItemView::IconOperation
- : public base::RefCountedThreadSafe<AppListItemView::IconOperation> {
- public:
- IconOperation(const SkBitmap& bitmap, const gfx::Size& size)
- : bitmap_(bitmap),
- size_(size) {
- }
-
- static void Run(scoped_refptr<IconOperation> op) {
- op->ResizeAndGenerateShadow();
- }
-
- // Padding space around icon to contain its shadow. Note it should be at least
- // the max size of shadow radius + shadow offset in shadow generation code.
- static const int kShadowPadding = 15;
-
- void ResizeAndGenerateShadow() {
- // If you change shadow radius and shadow offset, please also update
- // kShadowPaddingAbove.
- const SkColor kShadowColor[] = {
- SkColorSetARGB(0xCC, 0, 0, 0),
- SkColorSetARGB(0x33, 0, 0, 0),
- SkColorSetARGB(0x4C, 0, 0, 0),
- };
- const gfx::Point kShadowOffset[] = {
- gfx::Point(0, 0),
- gfx::Point(0, 4),
- gfx::Point(0, 5),
- };
- const SkScalar kShadowRadius[] = {
- SkIntToScalar(2),
- SkIntToScalar(4),
- SkIntToScalar(10),
- };
-
- if (cancel_flag_.IsSet())
- return;
-
- if (size_ != gfx::Size(bitmap_.width(), bitmap_.height()))
- bitmap_ = SkBitmapOperations::CreateResizedBitmap(bitmap_, size_);
-
- if (cancel_flag_.IsSet())
- return;
-
- bitmap_ = SkBitmapOperations::CreateDropShadow(
- bitmap_,
- arraysize(kShadowColor),
- kShadowColor,
- kShadowOffset,
- kShadowRadius);
- }
-
- void Cancel() {
- cancel_flag_.Set();
- }
-
- const SkBitmap& bitmap() const {
- return bitmap_;
- }
-
- private:
- friend class base::RefCountedThreadSafe<AppListItemView::IconOperation>;
-
- base::CancellationFlag cancel_flag_;
-
- SkBitmap bitmap_;
- const gfx::Size size_;
-
- DISALLOW_COPY_AND_ASSIGN(IconOperation);
-};
-
-AppListItemView::AppListItemView(AppListModelView* list_model_view,
- AppListItemModel* model,
- views::ButtonListener* listener)
- : CustomButton(listener),
- model_(model),
- list_model_view_(list_model_view),
- icon_(new StaticImageView),
- title_(new DropShadowLabel),
- selected_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(apply_shadow_factory_(this)) {
- title_->SetBackgroundColor(0);
-
- if (internal::AppList::UseAppListV2()) {
- title_->SetEnabledColor(kTitleColorV2);
- } else {
- title_->SetEnabledColor(kTitleColor);
- const gfx::ShadowValue kTitleShadows[] = {
- gfx::ShadowValue(gfx::Point(0, 0), 1, SkColorSetARGB(0x66, 0, 0, 0)),
- gfx::ShadowValue(gfx::Point(0, 0), 10, SkColorSetARGB(0x66, 0, 0, 0)),
- gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x66, 0, 0, 0)),
- gfx::ShadowValue(gfx::Point(0, 2), 4, SkColorSetARGB(0x66, 0, 0, 0)),
- };
- title_->SetTextShadows(arraysize(kTitleShadows), kTitleShadows);
- }
-
- AddChildView(icon_);
- AddChildView(title_);
-
- ItemIconChanged();
- ItemTitleChanged();
- model_->AddObserver(this);
-
- set_context_menu_controller(this);
- set_request_focus_on_press(false);
- set_focusable(true);
-}
-
-AppListItemView::~AppListItemView() {
- model_->RemoveObserver(this);
- CancelPendingIconOperation();
-}
-
-// static
-gfx::Size AppListItemView::GetPreferredSizeForIconSize(
- const gfx::Size& icon_size) {
- int min_title_width = g_min_title_width;
- // Fixed 20px is used for left/right padding before switching to padding
- // based on number of chars. It is also a number used for test case
- // AppList.ModelViewCalculateLayout.
- int left_right_padding = 20;
- if (min_title_width == 0) {
- const gfx::Font& title_font = GetTitleFontForIconSize(icon_size);
- // Use big char such as 'G' to calculate min title width.
- min_title_width = kMinTitleChars *
- title_font.GetStringWidth(ASCIIToUTF16("G"));
- left_right_padding = kLeftRightPaddingChars *
- title_font.GetAverageCharacterWidth();
- }
-
- int dimension = std::max(icon_size.width() * 2, min_title_width);
- gfx::Size size(dimension, dimension);
- size.Enlarge(left_right_padding, kTopBottomPadding);
- return size;
-}
-
-// static
-void AppListItemView::SetMinTitleWidth(int width) {
- g_min_title_width = width;
-}
-
-void AppListItemView::SetIconSize(const gfx::Size& size) {
- if (icon_size_ == size)
- return;
-
- icon_size_ = size;
- title_->SetFont(GetTitleFontForIconSize(size));
- UpdateIcon();
-}
-
-void AppListItemView::SetSelected(bool selected) {
- if (selected == selected_)
- return;
-
- RequestFocus();
- selected_ = selected;
- SchedulePaint();
-}
-
-void AppListItemView::UpdateIcon() {
- // Skip if |icon_size_| has not been determined.
- if (icon_size_.IsEmpty())
- return;
-
- SkBitmap icon = model_->icon();
- // Clear icon and bail out if model icon is empty.
- if (icon.empty()) {
- icon_->SetImage(NULL);
- return;
- }
-
- CancelPendingIconOperation();
-
- SkBitmap shadow;
- if (IconCache::GetInstance()->Get(icon, icon_size_, &shadow)) {
- icon_->SetImage(shadow);
- } else {
- // Schedule resize and shadow generation.
- icon_op_ = new IconOperation(icon, icon_size_);
- base::WorkerPool::PostTaskAndReply(
- FROM_HERE,
- base::Bind(&IconOperation::Run, icon_op_),
- base::Bind(&AppListItemView::ApplyShadow,
- apply_shadow_factory_.GetWeakPtr(),
- icon_op_),
- true /* task_is_slow */);
- }
-}
-
-void AppListItemView::CancelPendingIconOperation() {
- // Set canceled flag of previous request to skip unneeded processing.
- if (icon_op_.get())
- icon_op_->Cancel();
-
- // Cancel reply callback for previous request.
- apply_shadow_factory_.InvalidateWeakPtrs();
-}
-
-void AppListItemView::ApplyShadow(scoped_refptr<IconOperation> op) {
- icon_->SetImage(op->bitmap());
- IconCache::GetInstance()->Put(model_->icon(), icon_size_, op->bitmap());
-
- DCHECK(op.get() == icon_op_.get());
- icon_op_ = NULL;
-}
-
-void AppListItemView::ItemIconChanged() {
- UpdateIcon();
-}
-
-void AppListItemView::ItemTitleChanged() {
- title_->SetText(UTF8ToUTF16(model_->title()));
-}
-
-void AppListItemView::ItemHighlightedChanged() {
- SchedulePaint();
-}
-
-std::string AppListItemView::GetClassName() const {
- return kViewClassName;
-}
-
-gfx::Size AppListItemView::GetPreferredSize() {
- return GetPreferredSizeForIconSize(icon_size_);
-}
-
-void AppListItemView::Layout() {
- gfx::Rect rect(GetContentsBounds());
-
- int left_right_padding = kLeftRightPaddingChars *
- title_->font().GetAverageCharacterWidth();
- rect.Inset(left_right_padding, kTopBottomPadding);
-
- gfx::Size title_size = title_->GetPreferredSize();
- int height = icon_size_.height() + kIconTitleSpacing +
- title_size.height();
- int y = rect.y() + (rect.height() - height) / 2;
-
- gfx::Rect icon_bounds(rect.x(), y, rect.width(), icon_size_.height());
- icon_bounds.Inset(0, -IconOperation::kShadowPadding);
- icon_->SetBoundsRect(icon_bounds);
-
- title_->SetBounds(rect.x(),
- y + icon_size_.height() + kIconTitleSpacing,
- rect.width(),
- title_size.height());
-}
-
-void AppListItemView::OnPaint(gfx::Canvas* canvas) {
- gfx::Rect rect(GetContentsBounds());
-
- if (model_->highlighted()) {
- canvas->FillRect(rect, kHighlightedColor);
- } else if (hover_animation_->is_animating()) {
- int alpha = SkColorGetA(kHoverAndPushedColor) *
- hover_animation_->GetCurrentValue();
- canvas->FillRect(rect, SkColorSetA(kHoverAndPushedColor, alpha));
- } else if (state() == BS_HOT || state() == BS_PUSHED) {
- canvas->FillRect(rect, kHoverAndPushedColor);
- } else if (selected_) {
- canvas->FillRect(rect, kSelectedColor);
- }
-}
-
-void AppListItemView::GetAccessibleState(ui::AccessibleViewState* state) {
- state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
- state->name = UTF8ToUTF16(model_->title());
-}
-
-void AppListItemView::ShowContextMenuForView(views::View* source,
- const gfx::Point& point) {
- ui::MenuModel* menu_model = model_->GetContextMenuModel();
- if (!menu_model)
- return;
-
- views::MenuModelAdapter menu_adapter(menu_model);
- context_menu_runner_.reset(
- new views::MenuRunner(new views::MenuItemView(&menu_adapter)));
- menu_adapter.BuildMenu(context_menu_runner_->GetMenu());
- if (context_menu_runner_->RunMenuAt(
- GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
- views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) ==
- views::MenuRunner::MENU_DELETED)
- return;
-}
-
-void AppListItemView::StateChanged() {
- if (state() == BS_HOT || state() == BS_PUSHED) {
- list_model_view_->SetSelectedItem(this);
- } else {
- list_model_view_->ClearSelectedItem(this);
- model_->SetHighlighted(false);
- }
-}
-
-} // namespace ash
diff --git a/ash/app_list/app_list_item_view.h b/ash/app_list/app_list_item_view.h
deleted file mode 100644
index da377e8..0000000
--- a/ash/app_list/app_list_item_view.h
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_
-#define ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_
-#pragma once
-
-#include "ash/app_list/app_list_item_model_observer.h"
-#include "ash/ash_export.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "ui/views/context_menu_controller.h"
-#include "ui/views/controls/button/custom_button.h"
-
-class SkBitmap;
-
-namespace views {
-class ImageView;
-class MenuRunner;
-}
-
-namespace ash {
-
-class AppListItemModel;
-class AppListModelView;
-class DropShadowLabel;
-
-class ASH_EXPORT AppListItemView : public views::CustomButton,
- public views::ContextMenuController,
- public AppListItemModelObserver {
- public:
- AppListItemView(AppListModelView* list_model_view,
- AppListItemModel* model,
- views::ButtonListener* listener);
- virtual ~AppListItemView();
-
- static gfx::Size GetPreferredSizeForIconSize(const gfx::Size& icon_size);
-
- // For testing. Testing calls this function to set minimum title width in
- // pixels to get rid dependency on default font width.
- static void SetMinTitleWidth(int width);
-
- void SetSelected(bool selected);
- bool selected() const {
- return selected_;
- }
-
- void SetIconSize(const gfx::Size& size);
-
- AppListItemModel* model() const {
- return model_;
- }
-
- // Internal class name.
- static const char kViewClassName[];
-
- private:
- class IconOperation;
-
- // Get icon from model and schedule background processing.
- void UpdateIcon();
-
- // Cancel pending icon operation and reply callback.
- void CancelPendingIconOperation();
-
- // Reply callback from background shadow generation. |op| is the finished
- // operation and holds the result image.
- void ApplyShadow(scoped_refptr<IconOperation> op);
-
- // AppListItemModelObserver overrides:
- virtual void ItemIconChanged() OVERRIDE;
- virtual void ItemTitleChanged() OVERRIDE;
- virtual void ItemHighlightedChanged() OVERRIDE;
-
- // views::View overrides:
- virtual std::string GetClassName() const OVERRIDE;
- virtual gfx::Size GetPreferredSize() OVERRIDE;
- virtual void Layout() OVERRIDE;
- virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
- virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
-
- // views::ContextMenuController overrides:
- virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
-
- // views::CustomButton overrides:
- virtual void StateChanged() OVERRIDE;
-
- AppListItemModel* model_;
-
- AppListModelView* list_model_view_;
- views::ImageView* icon_;
- DropShadowLabel* title_;
-
- scoped_ptr<views::MenuRunner> context_menu_runner_;
-
- gfx::Size icon_size_;
- bool selected_;
-
- scoped_refptr<IconOperation> icon_op_;
- base::WeakPtrFactory<AppListItemView> apply_shadow_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(AppListItemView);
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_
diff --git a/ash/app_list/app_list_model.cc b/ash/app_list/app_list_model.cc
deleted file mode 100644
index ff42d92..0000000
--- a/ash/app_list/app_list_model.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2012 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 "ash/app_list/app_list_model.h"
-
-namespace ash {
-
-AppListModel::AppListModel() {
-}
-
-AppListModel::~AppListModel() {
-}
-
-void AppListModel::AddItem(AppListItemModel* item) {
- items_.Add(item);
-}
-
-void AppListModel::AddItemAt(int index, AppListItemModel* item) {
- items_.AddAt(index, item);
-}
-
-void AppListModel::DeleteItemAt(int index) {
- items_.DeleteAt(index);
-}
-
-AppListItemModel* AppListModel::GetItem(int index) {
- return items_.item_at(index);
-}
-
-void AppListModel::AddObserver(ui::ListModelObserver* observer) {
- items_.AddObserver(observer);
-}
-
-void AppListModel::RemoveObserver(ui::ListModelObserver* observer) {
- items_.RemoveObserver(observer);
-}
-
-} // namespace ash
diff --git a/ash/app_list/app_list_model.h b/ash/app_list/app_list_model.h
deleted file mode 100644
index 6ec296c..0000000
--- a/ash/app_list/app_list_model.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_APP_LIST_MODEL_H_
-#define ASH_APP_LIST_APP_LIST_MODEL_H_
-#pragma once
-
-#include "ash/app_list/app_list_item_model.h"
-#include "ash/ash_export.h"
-#include "base/basictypes.h"
-#include "ui/base/models/list_model.h"
-
-namespace ash {
-
-class AppListItemModel;
-
-// Model for AppListModelView that owns a list of AppListItemModels.
-class ASH_EXPORT AppListModel {
- public:
- AppListModel();
- virtual ~AppListModel();
-
- // Adds an item to the model. The model takes ownership of |item|.
- void AddItem(AppListItemModel* item);
- void AddItemAt(int index, AppListItemModel* item);
-
- void DeleteItemAt(int index);
-
- AppListItemModel* GetItem(int index);
-
- void AddObserver(ui::ListModelObserver* observer);
- void RemoveObserver(ui::ListModelObserver* observer);
-
- int item_count() const {
- return items_.item_count();
- }
-
- private:
- typedef ui::ListModel<AppListItemModel> Items;
- Items items_;
-
- DISALLOW_COPY_AND_ASSIGN(AppListModel);
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_APP_LIST_MODEL_H_
diff --git a/ash/app_list/app_list_model_view.cc b/ash/app_list/app_list_model_view.cc
deleted file mode 100644
index db984d3..0000000
--- a/ash/app_list/app_list_model_view.cc
+++ /dev/null
@@ -1,307 +0,0 @@
-// Copyright (c) 2012 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 "ash/app_list/app_list_model_view.h"
-
-#include "ash/app_list/app_list_item_view.h"
-#include "ash/app_list/app_list_model.h"
-#include "ash/app_list/pagination_model.h"
-
-namespace ash {
-
-AppListModelView::AppListModelView(views::ButtonListener* listener,
- PaginationModel* pagination_model)
- : model_(NULL),
- listener_(listener),
- pagination_model_(pagination_model),
- fixed_layout_(false),
- cols_(0),
- rows_per_page_(0),
- selected_item_index_(-1) {
- set_focusable(true);
- pagination_model_->AddObserver(this);
-}
-
-AppListModelView::~AppListModelView() {
- if (model_)
- model_->RemoveObserver(this);
- pagination_model_->RemoveObserver(this);
-}
-
-void AppListModelView::SetLayout(int icon_size, int cols, int rows_per_page) {
- fixed_layout_ = true;
-
- icon_size_.SetSize(icon_size, icon_size);
- cols_ = cols;
- rows_per_page_ = rows_per_page;
-}
-
-void AppListModelView::CalculateLayout(const gfx::Size& content_size,
- int num_of_tiles,
- gfx::Size* icon_size,
- int* rows,
- int* cols) {
- DCHECK(!content_size.IsEmpty() && num_of_tiles);
-
- // Icon sizes to try.
- const int kIconSizes[] = { 128, 96, 64, 48, 32 };
-
- double aspect = static_cast<double>(content_size.width()) /
- content_size.height();
-
- // Chooses the biggest icon size that could fit all tiles.
- gfx::Size tile_size;
- for (size_t i = 0; i < arraysize(kIconSizes); ++i) {
- icon_size->SetSize(kIconSizes[i], kIconSizes[i]);
- tile_size = AppListItemView::GetPreferredSizeForIconSize(
- *icon_size);
-
- int max_cols = content_size.width() / tile_size.width();
- int max_rows = content_size.height() / tile_size.height();
-
- // Skip if |tile_size| could not fit into |content_size|.
- if (max_cols * max_rows < num_of_tiles)
- continue;
-
- // Find a rows/cols pair that has a aspect ratio closest to |aspect|.
- double min_aspect_diff = 1e5;
- for (int c = std::max(max_cols / 2, 1); c <= max_cols; ++c) {
- int r = std::min((num_of_tiles - 1) / c + 1, max_rows);
- if (c * r < num_of_tiles)
- continue;
-
- double aspect_diff = fabs(static_cast<double>(c) / r - aspect);
- if (aspect_diff < min_aspect_diff) {
- *cols = c;
- *rows = r;
- min_aspect_diff = aspect_diff;
- }
- }
-
- DCHECK((*rows) * (*cols) >= num_of_tiles);
- return;
- }
-
- // No icon size that could fit all tiles.
- *cols = std::max(content_size.width() / tile_size.width(), 1);
- *rows = (num_of_tiles - 1) / (*cols) + 1;
-}
-
-void AppListModelView::SetModel(AppListModel* model) {
- if (model_)
- model_->RemoveObserver(this);
-
- model_ = model;
- if (model_)
- model_->AddObserver(this);
- Update();
-}
-
-void AppListModelView::SetSelectedItem(AppListItemView* item) {
- int index = GetIndexOf(item);
- if (index >= 0)
- SetSelectedItemByIndex(index);
-}
-
-void AppListModelView::ClearSelectedItem(AppListItemView* item) {
- int index = GetIndexOf(item);
- if (index == selected_item_index_)
- SetSelectedItemByIndex(-1);
-}
-
-void AppListModelView::Update() {
- selected_item_index_ = -1;
- RemoveAllChildViews(true);
- if (!model_ || model_->item_count() == 0)
- return;
-
- for (int i = 0; i < model_->item_count(); ++i)
- AddChildView(new AppListItemView(this, model_->GetItem(i), listener_));
-
- Layout();
- SchedulePaint();
-}
-
-AppListItemView* AppListModelView::GetItemViewAtIndex(int index) {
- return static_cast<AppListItemView*>(child_at(index));
-}
-
-void AppListModelView::SetSelectedItemByIndex(int index) {
- if (selected_item_index_ == index)
- return;
-
- if (selected_item_index_ >= 0)
- GetItemViewAtIndex(selected_item_index_)->SetSelected(false);
-
- if (index < 0 || index >= child_count()) {
- selected_item_index_ = -1;
- } else {
- selected_item_index_ = index;
- GetItemViewAtIndex(selected_item_index_)->SetSelected(true);
-
- if (tiles_per_page())
- pagination_model_->SelectPage(selected_item_index_ / tiles_per_page());
- }
-}
-
-gfx::Size AppListModelView::GetPreferredSize() {
- if (!fixed_layout_)
- return gfx::Size();
-
- gfx::Size tile_size = AppListItemView::GetPreferredSizeForIconSize(
- icon_size_);
- return gfx::Size(tile_size.width() * cols_,
- tile_size.height() * rows_per_page_);
-}
-
-void AppListModelView::Layout() {
- gfx::Rect rect(GetContentsBounds());
- if (rect.IsEmpty() || child_count() == 0)
- return;
-
- gfx::Size tile_size;
- if (fixed_layout_) {
- tile_size = AppListItemView::GetPreferredSizeForIconSize(icon_size_);
- } else {
- int rows = 0;
- CalculateLayout(rect.size(), child_count(), &icon_size_, &rows, &cols_);
-
- tile_size = AppListItemView::GetPreferredSizeForIconSize(
- icon_size_);
- rows_per_page_ = tile_size.height() ?
- std::max(rect.height() / tile_size.height(), 1) : 1;
-
- tile_size.set_width(std::max(rect.width() / (cols_ + 1),
- tile_size.width()));
- tile_size.set_height(std::max(rect.height() / (rows_per_page_ + 1),
- tile_size.height()));
- }
-
- if (!tiles_per_page())
- return;
-
- pagination_model_->SetTotalPages((child_count() - 1) / tiles_per_page() + 1);
- if (pagination_model_->selected_page() < 0)
- pagination_model_->SelectPage(0);
-
- gfx::Rect grid_rect = rect.Center(
- gfx::Size(tile_size.width() * cols_,
- tile_size.height() * rows_per_page_));
- grid_rect = grid_rect.Intersect(rect);
-
- // Layouts items.
- const int page = pagination_model_->selected_page();
- const int first_visible_index = page * tiles_per_page();
- const int last_visible_index = (page + 1) * tiles_per_page() - 1;
- gfx::Rect current_tile(grid_rect.origin(), tile_size);
- for (int i = 0; i < child_count(); ++i) {
- views::View* view = child_at(i);
- static_cast<AppListItemView*>(view)->SetIconSize(icon_size_);
-
- if (i < first_visible_index || i > last_visible_index) {
- view->SetVisible(false);
- continue;
- }
-
- view->SetBoundsRect(current_tile);
- view->SetVisible(rect.Contains(current_tile));
-
- current_tile.Offset(tile_size.width(), 0);
- if ((i + 1) % cols_ == 0) {
- current_tile.set_x(grid_rect.x());
- current_tile.set_y(current_tile.y() + tile_size.height());
- }
- }
-}
-
-bool AppListModelView::OnKeyPressed(const views::KeyEvent& event) {
- bool handled = false;
- if (selected_item_index_ >= 0)
- handled = GetItemViewAtIndex(selected_item_index_)->OnKeyPressed(event);
-
- if (!handled) {
- switch (event.key_code()) {
- case ui::VKEY_LEFT:
- SetSelectedItemByIndex(std::max(selected_item_index_ - 1, 0));
- return true;
- case ui::VKEY_RIGHT:
- SetSelectedItemByIndex(std::min(selected_item_index_ + 1,
- child_count() - 1));
- return true;
- case ui::VKEY_UP:
- SetSelectedItemByIndex(std::max(selected_item_index_ - cols_,
- 0));
- return true;
- case ui::VKEY_DOWN:
- if (selected_item_index_ < 0) {
- SetSelectedItemByIndex(0);
- } else {
- SetSelectedItemByIndex(std::min(selected_item_index_ + cols_,
- child_count() - 1));
- }
- return true;
- case ui::VKEY_PRIOR: {
- SetSelectedItemByIndex(
- std::max(selected_item_index_ - tiles_per_page(),
- 0));
- return true;
- }
- case ui::VKEY_NEXT: {
- if (selected_item_index_ < 0) {
- SetSelectedItemByIndex(0);
- } else {
- SetSelectedItemByIndex(
- std::min(selected_item_index_ + tiles_per_page(),
- child_count() - 1));
- }
- }
- default:
- break;
- }
- }
-
- return handled;
-}
-
-bool AppListModelView::OnKeyReleased(const views::KeyEvent& event) {
- bool handled = false;
- if (selected_item_index_ >= 0)
- handled = GetItemViewAtIndex(selected_item_index_)->OnKeyReleased(event);
-
- return handled;
-}
-
-void AppListModelView::OnPaintFocusBorder(gfx::Canvas* canvas) {
- // Override to not paint focus frame.
-}
-
-void AppListModelView::ListItemsAdded(int start, int count) {
- for (int i = start; i < start + count; ++i) {
- AddChildViewAt(new AppListItemView(this, model_->GetItem(i), listener_),
- i);
- }
- Layout();
- SchedulePaint();
-}
-
-void AppListModelView::ListItemsRemoved(int start, int count) {
- for (int i = 0; i < count; ++i)
- delete child_at(start);
-
- Layout();
- SchedulePaint();
-}
-
-void AppListModelView::ListItemsChanged(int start, int count) {
- NOTREACHED();
-}
-
-void AppListModelView::TotalPagesChanged() {
-}
-
-void AppListModelView::SelectedPageChanged(int old_selected, int new_selected) {
- Layout();
-}
-
-} // namespace ash
diff --git a/ash/app_list/app_list_model_view.h b/ash/app_list/app_list_model_view.h
deleted file mode 100644
index 31fec61..0000000
--- a/ash/app_list/app_list_model_view.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_APP_LIST_MODEL_VIEW_H_
-#define ASH_APP_LIST_APP_LIST_MODEL_VIEW_H_
-#pragma once
-
-#include "ash/ash_export.h"
-#include "ash/app_list/pagination_model_observer.h"
-#include "ui/base/models/list_model_observer.h"
-#include "ui/views/view.h"
-
-namespace views {
-class ButtonListener;
-}
-
-namespace ash {
-
-class AppListItemView;
-class AppListModel;
-class PaginationModel;
-
-// AppListModelView displays the UI for an AppListModel.
-class ASH_EXPORT AppListModelView : public views::View,
- public ui::ListModelObserver,
- public PaginationModelObserver {
- public:
- AppListModelView(views::ButtonListener* listener,
- PaginationModel* pagination_model);
- virtual ~AppListModelView();
-
- // Sets fixed layout parameters. After setting this, CalculateLayout below
- // is no longer called to dynamically choosing those layout params.
- void SetLayout(int icon_size, int cols, int rows_per_page);
-
- // Calculate preferred icon size, rows and cols for given |content_size| and
- // |num_of_tiles|.
- static void CalculateLayout(const gfx::Size& content_size,
- int num_of_tiles,
- gfx::Size* icon_size,
- int* rows,
- int* cols);
-
- // Sets |model| to use. Note this does not take ownership of |model|.
- void SetModel(AppListModel* model);
-
- void SetSelectedItem(AppListItemView* item);
- void ClearSelectedItem(AppListItemView* item);
-
- int tiles_per_page() const {
- return cols_ * rows_per_page_;
- }
-
- private:
- // Updates from model.
- void Update();
-
- AppListItemView* GetItemViewAtIndex(int index);
- void SetSelectedItemByIndex(int index);
-
- // Overridden from views::View:
- virtual gfx::Size GetPreferredSize() OVERRIDE;
- virtual void Layout() OVERRIDE;
- virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE;
- virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE;
- virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
-
- // Overridden from ListModelObserver:
- virtual void ListItemsAdded(int start, int count) OVERRIDE;
- virtual void ListItemsRemoved(int start, int count) OVERRIDE;
- virtual void ListItemsChanged(int start, int count) OVERRIDE;
-
- // Overridden from PaginationModelObserver:
- virtual void TotalPagesChanged() OVERRIDE;
- virtual void SelectedPageChanged(int old_selected, int new_selected) OVERRIDE;
-
- AppListModel* model_; // Owned by parent AppListView.
- views::ButtonListener* listener_;
- PaginationModel* pagination_model_; // Owned by AppListView.
-
- bool fixed_layout_;
- gfx::Size icon_size_;
- int cols_;
- int rows_per_page_;
-
- int selected_item_index_;
-
- DISALLOW_COPY_AND_ASSIGN(AppListModelView);
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_APP_LIST_MODEL_VIEW_H_
diff --git a/ash/app_list/app_list_unittest.cc b/ash/app_list/app_list_unittest.cc
deleted file mode 100644
index 824eee4..0000000
--- a/ash/app_list/app_list_unittest.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2012 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 "ash/app_list/app_list_item_view.h"
-#include "ash/app_list/app_list_model_view.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-struct ModelViewCalculateLayoutCase {
- gfx::Size screen_size;
- int num_of_tiles;
- gfx::Size expected_icon_size;
- int expected_rows;
- int expected_cols;
-};
-
-} // namespace
-
-TEST(AppListTest, ModelViewCalculateLayout) {
- // kMinTitleWidth is the average width of 15 chars of default size 12 font in
- // chromeos. Override here to avoid flakiness from different default font on
- // bots.
- const int kMinTitleWidth = 90;
- ash::AppListItemView::SetMinTitleWidth(kMinTitleWidth);
-
- const int kLauncherHeight = 50;
- const ModelViewCalculateLayoutCase kCases[] = {
- { gfx::Size(1024, 768), 4, gfx::Size(128, 128), 2, 3 },
- { gfx::Size(1024, 768), 29, gfx::Size(64, 64), 5, 6 },
- { gfx::Size(1024, 768), 40, gfx::Size(48, 48), 5, 8 },
- { gfx::Size(1024, 768), 48, gfx::Size(48, 48), 6, 8 },
-
- { gfx::Size(1280, 1024), 4, gfx::Size(128, 128), 2, 3 },
- { gfx::Size(1280, 1024), 29, gfx::Size(64, 64), 5, 7 },
- { gfx::Size(1280, 1024), 50, gfx::Size(64, 64), 7, 8 },
- { gfx::Size(1280, 1024), 70, gfx::Size(48, 48), 7, 10 },
- { gfx::Size(1280, 1024), 99, gfx::Size(48, 48), 9, 11 },
-
- { gfx::Size(1600, 900), 4, gfx::Size(128, 128), 2, 3 },
- { gfx::Size(1600, 900), 29, gfx::Size(64, 64), 4, 8 },
-
- // Not able to fit into screen case.
- { gfx::Size(1024, 768), 50, gfx::Size(32, 32), 6, 9 },
- { gfx::Size(1280, 1024), 100, gfx::Size(32, 32), 10, 11 },
- };
-
- for (size_t i = 0; i < arraysize(kCases); ++i) {
- gfx::Size icon_size;
- int rows = 0;
- int cols = 0;
- gfx::Size content_size(kCases[i].screen_size.width(),
- kCases[i].screen_size.height() - kLauncherHeight);
- ash::AppListModelView::CalculateLayout(content_size,
- kCases[i].num_of_tiles,
- &icon_size,
- &rows,
- &cols);
- EXPECT_EQ(kCases[i].expected_icon_size, icon_size) << "i=" << i;
- EXPECT_EQ(kCases[i].expected_rows, rows) << "i=" << i;
- EXPECT_EQ(kCases[i].expected_cols, cols) << "i=" << i;
- }
-}
diff --git a/ash/app_list/app_list_view.cc b/ash/app_list/app_list_view.cc
deleted file mode 100644
index beecfbe..0000000
--- a/ash/app_list/app_list_view.cc
+++ /dev/null
@@ -1,288 +0,0 @@
-// Copyright (c) 2012 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 "ash/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 "ui/compositor/layer.h"
-#include "ui/compositor/scoped_layer_animation_settings.h"
-#include "ui/gfx/screen.h"
-#include "ui/gfx/transform_util.h"
-#include "ui/views/background.h"
-#include "ui/views/bubble/bubble_frame_view.h"
-#include "ui/views/layout/box_layout.h"
-#include "ui/views/widget/widget.h"
-
-namespace ash {
-
-namespace {
-
-// 0.2 black
-const SkColor kWidgetBackgroundColor = SkColorSetARGB(0x33, 0, 0, 0);
-
-const float kModelViewAnimationScaleFactor = 0.9f;
-
-const int kPreferredIconDimension = 48;
-const int kPreferredCols = 4;
-const int kPreferredRows = 4;
-// Padding space in pixels between model view and page switcher footer.
-const int kModelViewFooterPadding = 10;
-
-ui::Transform GetScaleTransform(AppListModelView* model_view) {
- gfx::Rect pixel_bounds = model_view->GetLayerBoundsInPixel();
- gfx::Point center(pixel_bounds.width() / 2, pixel_bounds.height() / 2);
- 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
-
-////////////////////////////////////////////////////////////////////////////////
-// AppListView:
-
-AppListView::AppListView(AppListViewDelegate* delegate)
- : delegate_(delegate),
- pagination_model_(new PaginationModel),
- bubble_style_(false),
- bubble_border_(NULL),
- model_view_(NULL) {
- if (internal::AppList::UseAppListV2())
- InitAsBubble();
- else
- InitAsFullscreenWidget();
-}
-
-AppListView::~AppListView() {
- // Model is going away, so set to NULL before superclass deletes child views.
- if (model_view_)
- 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() {
- bubble_style_ = false;
- set_background(views::Background::CreateSolidBackground(
- kWidgetBackgroundColor));
-
- model_view_ = new AppListModelView(this, pagination_model_.get());
- model_view_->SetPaintToLayer(true);
- model_view_->layer()->SetFillsBoundsOpaquely(false);
- AddChildView(model_view_);
-
- views::Widget::InitParams widget_params(
- views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- widget_params.delegate = this;
- widget_params.transparent = true;
- widget_params.parent = Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_AppListContainer);
-
- views::Widget* widget = new views::Widget;
- widget->Init(widget_params);
- widget->SetContentsView(this);
-
- widget->SetBounds(GetFullScreenBounds());
-
- // Turns off default animation.
- widget->SetVisibilityChangedAnimationsEnabled(false);
-
- // Sets initial transform. AnimateShow changes it back to identity transform.
- model_view_->SetTransform(GetScaleTransform(model_view_));
- UpdateModel();
-}
-
-void AppListView::InitAsBubble() {
- bubble_style_ = true;
- set_background(NULL);
-
- SetLayoutManager(new views::BoxLayout(
- views::BoxLayout::kVertical, 0, 0, kModelViewFooterPadding));
-
- model_view_ = new AppListModelView(this, pagination_model_.get());
- model_view_->SetLayout(kPreferredIconDimension,
- kPreferredCols,
- kPreferredRows);
- AddChildView(model_view_);
-
- 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_close_on_deactivate(false);
- views::BubbleDelegateView::CreateBubble(this);
-
- // Resets default background since AppListBubbleBorder paints background.
- GetBubbleFrameView()->set_background(NULL);
-
- // Overrides border with AppListBubbleBorder.
- bubble_border_ = new AppListBubbleBorder(this);
- GetBubbleFrameView()->SetBubbleBorder(bubble_border_);
- SizeToContents(); // Recalcuates with new border.
-
- UpdateModel();
-}
-
-void AppListView::UpdateModel() {
- if (delegate_.get()) {
- scoped_ptr<AppListModel> new_model(new AppListModel);
- delegate_->SetModel(new_model.get());
- delegate_->UpdateModel(std::string());
- model_view_->SetModel(new_model.get());
- model_.reset(new_model.release());
- }
-}
-
-views::View* AppListView::GetInitiallyFocusedView() {
- return model_view_;
-}
-
-void AppListView::Layout() {
- gfx::Rect rect(GetContentsBounds());
- if (rect.IsEmpty())
- return;
-
- if (bubble_style_) {
- 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();
-
- // Converts |workarea| into view's coordinates.
- gfx::Point origin(workarea.origin());
- views::View::ConvertPointFromScreen(this, &origin);
- workarea.Offset(-origin.x(), -origin.y());
-
- rect = rect.Intersect(workarea);
- model_view_->SetBoundsRect(rect);
- }
-}
-
-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) {
- // For full screen mode, if mouse click reaches us, this means user clicks
- // on blank area. So close.
- if (!bubble_style_)
- Close();
-
- return true;
-}
-
-void AppListView::ButtonPressed(views::Button* sender,
- const views::Event& event) {
- if (sender->GetClassName() != AppListItemView::kViewClassName)
- return;
-
- if (delegate_.get()) {
- delegate_->OnAppListItemActivated(
- static_cast<AppListItemView*>(sender)->model(),
- event.flags());
- }
- Close();
-}
-
-gfx::Rect AppListView::GetBubbleBounds() {
- // This happens before replacing the default border.
- if (!bubble_border_)
- return views::BubbleDelegateView::GetBubbleBounds();
-
- const int old_arrow_offset = bubble_border_->arrow_offset();
- const gfx::Rect anchor_rect = GetAnchorRect();
-
- bubble_border_->set_arrow_offset(0);
- gfx::Rect bubble_rect = GetBubbleFrameView()->GetUpdatedWindowBounds(
- anchor_rect,
- GetPreferredSize(),
- false /* try_mirroring_arrow */);
-
- gfx::Rect monitor_rect = gfx::Screen::GetMonitorNearestPoint(
- anchor_rect.CenterPoint()).work_area();
- if (monitor_rect.IsEmpty() || monitor_rect.Contains(bubble_rect))
- return bubble_rect;
-
- int offset = 0;
- if (bubble_rect.x() < monitor_rect.x())
- offset = monitor_rect.x() - bubble_rect.x();
- else if (bubble_rect.right() > monitor_rect.right())
- offset = monitor_rect.right() - bubble_rect.right();
-
- bubble_rect.set_x(bubble_rect.x() + offset);
-
- // Moves bubble arrow in the opposite direction. i.e. If bubble bounds is
- // moved to right (positive offset), we need to move arrow to left so that
- // it points to the same position before the move.
- bubble_border_->set_arrow_offset(-offset);
-
- // Repaints border if arrow offset is changed.
- if (bubble_border_->arrow_offset() != old_arrow_offset)
- GetBubbleFrameView()->SchedulePaint();
-
- return bubble_rect;
-}
-
-} // namespace ash
diff --git a/ash/app_list/app_list_view.h b/ash/app_list/app_list_view.h
deleted file mode 100644
index 73e9543..0000000
--- a/ash/app_list/app_list_view.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_APP_LIST_VIEW_H_
-#define ASH_APP_LIST_APP_LIST_VIEW_H_
-#pragma once
-
-#include "base/memory/scoped_ptr.h"
-#include "ui/views/bubble/bubble_delegate.h"
-#include "ui/views/controls/button/button.h"
-
-namespace views {
-class View;
-}
-
-namespace ash {
-
-class AppListBubbleBorder;
-class AppListModel;
-class AppListModelView;
-class AppListViewDelegate;
-class PaginationModel;
-
-// AppListView is the top-level view and controller of app list UI. It creates
-// and hosts a AppListModelView and passes AppListModel to it for display.
-class AppListView : public views::BubbleDelegateView,
- public views::ButtonListener {
- public:
- // Takes ownership of |delegate|.
- explicit AppListView(AppListViewDelegate* delegate);
- virtual ~AppListView();
-
- void AnimateShow(int duration_ms);
- void AnimateHide(int duration_ms);
-
- void Close();
- void UpdateBounds();
-
- private:
- // Initializes the window.
- void InitAsFullscreenWidget();
- void InitAsBubble();
-
- // Updates model using query text in search box.
- void UpdateModel();
-
- // Overridden from views::WidgetDelegateView:
- virtual views::View* GetInitiallyFocusedView() OVERRIDE;
-
- // Overridden from views::View:
- virtual void Layout() OVERRIDE;
- virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE;
- virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
-
- // Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender,
- const views::Event& event) OVERRIDE;
-
- // Overridden from views::BubbleDelegate:
- virtual gfx::Rect GetBubbleBounds() OVERRIDE;
-
- scoped_ptr<AppListModel> model_;
- scoped_ptr<AppListViewDelegate> delegate_;
-
- // PaginationModel for model view and page switcher.
- scoped_ptr<PaginationModel> pagination_model_;
-
- bool bubble_style_;
- AppListBubbleBorder* bubble_border_; // Owned by views hierarchy.
- AppListModelView* model_view_;
-
- DISALLOW_COPY_AND_ASSIGN(AppListView);
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_APP_LIST_VIEW_H_
diff --git a/ash/app_list/app_list_view_delegate.h b/ash/app_list/app_list_view_delegate.h
deleted file mode 100644
index 1950a12..0000000
--- a/ash/app_list/app_list_view_delegate.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
-#define ASH_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
-#pragma once
-
-#include <string>
-
-#include "ash/ash_export.h"
-
-namespace ash {
-
-class AppListItemModel;
-class AppListModel;
-
-class ASH_EXPORT AppListViewDelegate {
- public:
- // AppListView owns the delegate.
- virtual ~AppListViewDelegate() {}
-
- // Invoked to set the model that AppListView uses.
- // Note that AppListView owns the model.
- virtual void SetModel(AppListModel* model) = 0;
-
- // Invoked to ask the delegate to populate the model for given |query|.
- virtual void UpdateModel(const std::string& query) = 0;
-
- // Invoked an AppListeItemModelView is activated by click or enter key.
- virtual void OnAppListItemActivated(AppListItemModel* item,
- int event_flags) = 0;
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
diff --git a/ash/app_list/drop_shadow_label.cc b/ash/app_list/drop_shadow_label.cc
deleted file mode 100644
index c897e2a..0000000
--- a/ash/app_list/drop_shadow_label.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2012 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 "ash/app_list/drop_shadow_label.h"
-
-#include "base/utf_string_conversions.h"
-#include "third_party/skia/include/effects/SkGradientShader.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/color_utils.h"
-#include "ui/gfx/insets.h"
-#include "ui/gfx/skbitmap_operations.h"
-
-using views::Label;
-
-namespace ash {
-
-DropShadowLabel::DropShadowLabel() {
-}
-
-DropShadowLabel::~DropShadowLabel() {
-}
-
-void DropShadowLabel::SetTextShadows(int shadow_count,
- const gfx::ShadowValue* shadows) {
- text_shadows_.clear();
-
- if (shadow_count && shadows) {
- for (int i = 0; i < shadow_count; ++i)
- text_shadows_.push_back(shadows[i]);
- }
-}
-
-gfx::Insets DropShadowLabel::GetInsets() const {
- gfx::Insets insets = views::Label::GetInsets();
- gfx::Insets shadow_margin = gfx::ShadowValue::GetMargin(text_shadows_);
- // Negate |shadow_margin| to convert it to a padding insets needed inside
- // the bounds and combine with label's insets.
- insets += -shadow_margin;
- return insets;
-}
-
-void DropShadowLabel::PaintText(gfx::Canvas* canvas,
- const string16& text,
- const gfx::Rect& text_bounds,
- int flags) {
- SkColor text_color = enabled() ? enabled_color() : disabled_color();
- canvas->DrawStringWithShadows(text,
- font(),
- text_color,
- text_bounds,
- flags,
- text_shadows_);
-
- if (HasFocus() || paint_as_focused()) {
- gfx::Rect focus_bounds = text_bounds;
- focus_bounds.Inset(-Label::kFocusBorderPadding,
- -Label::kFocusBorderPadding);
- canvas->DrawFocusRect(focus_bounds);
- }
-}
-
-} // namespace ash
diff --git a/ash/app_list/drop_shadow_label.h b/ash/app_list/drop_shadow_label.h
deleted file mode 100644
index 25a24e1..0000000
--- a/ash/app_list/drop_shadow_label.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_DROP_SHADOW_LABEL_H_
-#define ASH_APP_LIST_DROP_SHADOW_LABEL_H_
-#pragma once
-
-#include <vector>
-
-#include "ui/gfx/shadow_value.h"
-#include "ui/views/controls/label.h"
-
-namespace ash {
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DropShadowLabel class
-//
-// A drop shadow label is a view subclass that can display a string
-// with a drop shadow.
-//
-/////////////////////////////////////////////////////////////////////////////
-class DropShadowLabel : public views::Label {
- public:
- DropShadowLabel();
- virtual ~DropShadowLabel();
-
- void SetTextShadows(int shadow_count, const gfx::ShadowValue* shadows);
-
- private:
- // Overridden from views::Label:
- virtual gfx::Insets GetInsets() const OVERRIDE;
- virtual void PaintText(gfx::Canvas* canvas,
- const string16& text,
- const gfx::Rect& text_bounds,
- int flags) OVERRIDE;
-
- std::vector<gfx::ShadowValue> text_shadows_;
-
- DISALLOW_COPY_AND_ASSIGN(DropShadowLabel);
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_DROP_SHADOW_LABEL_H_
diff --git a/ash/app_list/icon_cache.cc b/ash/app_list/icon_cache.cc
deleted file mode 100644
index 92fdd90..0000000
--- a/ash/app_list/icon_cache.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) 2012 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 "ash/app_list/icon_cache.h"
-
-#include "base/logging.h"
-#include "base/md5.h"
-#include "ui/gfx/size.h"
-
-namespace {
-
-// Gets cache key based on |image| contents and desired |size|.
-std::string GetKey(const SkBitmap& image, const gfx::Size& size) {
- SkAutoLockPixels image_lock(image);
- base::MD5Digest digest;
- MD5Sum(image.getPixels(), image.getSize(), &digest);
-
- return MD5DigestToBase16(digest) + "." + size.ToString();
-}
-
-} // namespace
-
-namespace ash {
-
-// static
-IconCache* IconCache::instance_ = NULL;
-
-// static
-void IconCache::CreateInstance() {
- DCHECK(!instance_);
- instance_ = new IconCache;
-}
-
-// static
-void IconCache::DeleteInstance() {
- DCHECK(instance_);
- delete instance_;
- instance_ = NULL;
-}
-
-// static
-IconCache* IconCache::GetInstance() {
- DCHECK(instance_);
- return instance_;
-}
-
-void IconCache::MarkAllEntryUnused() {
- for (Cache::iterator i = cache_.begin(); i != cache_.end(); ++i)
- i->second.used = false;
-}
-
-void IconCache::PurgeAllUnused() {
- for (Cache::iterator i = cache_.begin(); i != cache_.end();) {
- Cache::iterator current(i);
- ++i;
- if (!current->second.used)
- cache_.erase(current);
- }
-}
-
-bool IconCache::Get(const SkBitmap& src,
- const gfx::Size& size,
- SkBitmap* processed) {
- Cache::iterator it = cache_.find(GetKey(src, size));
- if (it == cache_.end())
- return false;
-
- it->second.used = true;
-
- if (processed)
- *processed = it->second.image;
- return true;
-}
-
-void IconCache::Put(const SkBitmap& src,
- const gfx::Size& size,
- const SkBitmap& processed) {
- const std::string key = GetKey(src, size);
- cache_[key].image = processed;
- cache_[key].used = true;
-}
-
-IconCache::IconCache() {
-}
-
-IconCache::~IconCache() {
-}
-
-} // namespace ash
diff --git a/ash/app_list/icon_cache.h b/ash/app_list/icon_cache.h
deleted file mode 100644
index f06ac1d..0000000
--- a/ash/app_list/icon_cache.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_ICON_CACHE_H_
-#define ASH_APP_LIST_ICON_CACHE_H_
-#pragma once
-
-#include <map>
-#include <string>
-
-#include "base/basictypes.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-namespace gfx {
-class Size;
-}
-
-namespace ash {
-
-// IconCache stores processed image, keyed by the source image and desired size.
-class IconCache {
- public:
- static void CreateInstance();
- static void DeleteInstance();
-
- static IconCache* GetInstance();
-
- void MarkAllEntryUnused();
- void PurgeAllUnused();
-
- bool Get(const SkBitmap& src,
- const gfx::Size& size,
- SkBitmap* processed);
- void Put(const SkBitmap& src,
- const gfx::Size& size,
- const SkBitmap& processed);
-
- private:
- struct Item {
- SkBitmap image;
- bool used;
- };
- typedef std::map<std::string, Item> Cache;
-
- IconCache();
- ~IconCache();
-
- static IconCache* instance_;
-
- Cache cache_;
-
- DISALLOW_COPY_AND_ASSIGN(IconCache);
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_ICON_CACHE_H_
diff --git a/ash/app_list/page_switcher.cc b/ash/app_list/page_switcher.cc
deleted file mode 100644
index 275cc09..0000000
--- a/ash/app_list/page_switcher.cc
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright (c) 2012 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 "ash/app_list/page_switcher.h"
-
-#include "ash/app_list/pagination_model.h"
-#include "third_party/skia/include/core/SkPath.h"
-#include "ui/base/animation/throb_animation.h"
-#include "ui/gfx/canvas.h"
-#include "ui/views/controls/button/custom_button.h"
-#include "ui/views/layout/box_layout.h"
-
-namespace {
-
-const int kButtonSpacing = 10;
-const int kButtonWidth = 60;
-const int kButtonHeight = 6;
-const int kButtonHeightPadding = 10;
-const int kButtonCornerRadius = 2;
-
-// 0.16 black
-const SkColor kHoverColor = SkColorSetARGB(0x2A, 0x00, 0x00, 0x00);
-
-// 0.2 black
-const SkColor kNormalColor = SkColorSetARGB(0x33, 0x00, 0x00, 0x00);
-
-// 0.33 black
-const SkColor kSelectedColor = SkColorSetARGB(0x55, 0x00, 0x00, 0x00);
-
-class PageSwitcherButton : public views::CustomButton {
- public:
- PageSwitcherButton(views::ButtonListener* listener)
- : views::CustomButton(listener),
- selected_(false) {
- }
- virtual ~PageSwitcherButton() {}
-
- void SetSelected(bool selected) {
- if (selected == selected_)
- return;
-
- selected_ = selected;
- SchedulePaint();
- }
-
- // Overridden from views::View:
- virtual gfx::Size GetPreferredSize() OVERRIDE {
- return gfx::Size(kButtonWidth, kButtonHeight + kButtonHeightPadding);
- }
-
- virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
- if (selected_ || state() == BS_PUSHED) {
- PaintButton(canvas, kSelectedColor);
- } else if (state() == BS_HOT) {
- PaintButton(canvas, kHoverColor);
- } else {
- PaintButton(canvas, kNormalColor);
- }
- }
-
- private:
- // Paints a button that has two rounded corner at bottom.
- void PaintButton(gfx::Canvas* canvas, SkColor color) {
- gfx::Rect rect(GetContentsBounds());
- rect.set_height(kButtonHeight);
-
- gfx::Point center = rect.CenterPoint();
-
- SkPath path;
- path.incReserve(12);
- path.moveTo(SkIntToScalar(rect.x()), SkIntToScalar(rect.y()));
- path.arcTo(SkIntToScalar(rect.x()), SkIntToScalar(rect.bottom()),
- SkIntToScalar(center.x()), SkIntToScalar(rect.bottom()),
- SkIntToScalar(kButtonCornerRadius));
- path.arcTo(SkIntToScalar(rect.right()), SkIntToScalar(rect.bottom()),
- SkIntToScalar(rect.right()), SkIntToScalar(rect.y()),
- SkIntToScalar(kButtonCornerRadius));
- path.lineTo(SkIntToScalar(rect.right()), SkIntToScalar(rect.y()));
- path.close();
-
- SkPaint paint;
- paint.setStyle(SkPaint::kFill_Style);
- paint.setColor(color);
- canvas->DrawPath(path, paint);
- }
-
- bool selected_;
-
- DISALLOW_COPY_AND_ASSIGN(PageSwitcherButton);
-};
-
-// Gets PageSwitcherButton at |index| in |buttons|.
-PageSwitcherButton* GetButtonByIndex(views::View* buttons, int index) {
- return static_cast<PageSwitcherButton*>(buttons->child_at(index));
-}
-
-} // namespace
-
-namespace ash {
-
-PageSwitcher::PageSwitcher(PaginationModel* model)
- : model_(model),
- buttons_(NULL) {
- buttons_ = new views::View;
- buttons_->SetLayoutManager(new views::BoxLayout(
- views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing));
- AddChildView(buttons_);
-
- TotalPagesChanged();
- SelectedPageChanged(-1, model->selected_page());
- model_->AddObserver(this);
-}
-
-PageSwitcher::~PageSwitcher() {
- model_->RemoveObserver(this);
-}
-
-gfx::Size PageSwitcher::GetPreferredSize() {
- // Always return a size with correct height so that container resize is not
- // needed when more pages are added.
- return gfx::Size(kButtonWidth, kButtonHeight + kButtonHeightPadding);
-}
-
-void PageSwitcher::Layout() {
- gfx::Rect rect(GetContentsBounds());
- buttons_->SetBoundsRect(rect.Center(buttons_->GetPreferredSize()));
-}
-
-void PageSwitcher::ButtonPressed(views::Button* sender,
- const views::Event& event) {
- for (int i = 0; i < buttons_->child_count(); ++i) {
- if (sender == static_cast<views::Button*>(buttons_->child_at(i))) {
- model_->SelectPage(i);
- break;
- }
- }
-}
-
-void PageSwitcher::TotalPagesChanged() {
- buttons_->RemoveAllChildViews(true);
- for (int i = 0; i < model_->total_pages(); ++i) {
- PageSwitcherButton* button = new PageSwitcherButton(this);
- button->SetSelected(i == model_->selected_page());
- buttons_->AddChildView(button);
- }
- buttons_->SetVisible(model_->total_pages() > 1);
- Layout();
-}
-
-void PageSwitcher::SelectedPageChanged(int old_selected, int new_selected) {
- if (old_selected >= 0 && old_selected < buttons_->child_count())
- GetButtonByIndex(buttons_, old_selected)->SetSelected(false);
- if (new_selected >= 0 && new_selected < buttons_->child_count())
- GetButtonByIndex(buttons_, new_selected)->SetSelected(true);
-}
-
-} // namespace ash
diff --git a/ash/app_list/page_switcher.h b/ash/app_list/page_switcher.h
deleted file mode 100644
index 36168df..0000000
--- a/ash/app_list/page_switcher.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_PAGE_SWITCHER_H_
-#define ASH_APP_LIST_PAGE_SWITCHER_H_
-#pragma once
-
-#include "ash/app_list/pagination_model_observer.h"
-#include "base/basictypes.h"
-#include "ui/views/controls/button/button.h"
-#include "ui/views/view.h"
-
-namespace ash {
-
-class PaginationModel;
-
-// PageSwitcher represents its underlying PaginationModel with a button strip.
-// Each page in the PageinationModel has a button in the strip and when the
-// button is clicked, the corresponding page becomes selected.
-class PageSwitcher : public views::View,
- public views::ButtonListener,
- public PaginationModelObserver {
- public:
- explicit PageSwitcher(PaginationModel* model);
- virtual ~PageSwitcher();
-
- private:
- // Overridden from views::View:
- virtual gfx::Size GetPreferredSize() OVERRIDE;
- virtual void Layout() OVERRIDE;
-
- // Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender,
- const views::Event& event) OVERRIDE;
-
- // Overridden from PaginationModelObserver:
- virtual void TotalPagesChanged() OVERRIDE;
- virtual void SelectedPageChanged(int old_selected, int new_selected) OVERRIDE;
-
- PaginationModel* model_; // Owned by parent AppListView.
- views::View* buttons_; // Owned by views hierarchy.
-
- DISALLOW_COPY_AND_ASSIGN(PageSwitcher);
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_PAGE_SWITCHER_H_
diff --git a/ash/app_list/pagination_model.cc b/ash/app_list/pagination_model.cc
deleted file mode 100644
index 413a632..0000000
--- a/ash/app_list/pagination_model.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2012 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 "ash/app_list/pagination_model.h"
-
-#include "ash/app_list/pagination_model_observer.h"
-
-namespace ash {
-
-PaginationModel::PaginationModel()
- : total_pages_(-1),
- selected_page_(-1) {
-}
-
-PaginationModel::~PaginationModel() {
-}
-
-void PaginationModel::SetTotalPages(int total_pages) {
- if (total_pages == total_pages_)
- return;
-
- total_pages_ = total_pages;
- FOR_EACH_OBSERVER(PaginationModelObserver,
- observers_,
- TotalPagesChanged());
-}
-
-void PaginationModel::SelectPage(int page) {
- DCHECK(page >= 0 && page < total_pages_);
-
- if (page == selected_page_)
- return;
-
- int old_selected = selected_page_;
- selected_page_ = page;
- FOR_EACH_OBSERVER(PaginationModelObserver,
- observers_,
- SelectedPageChanged(old_selected, selected_page_));
-}
-
-void PaginationModel::AddObserver(PaginationModelObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void PaginationModel::RemoveObserver(PaginationModelObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
-} // namespace ash
diff --git a/ash/app_list/pagination_model.h b/ash/app_list/pagination_model.h
deleted file mode 100644
index 981c229..0000000
--- a/ash/app_list/pagination_model.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_PAGINATION_MODEL_H_
-#define ASH_APP_LIST_PAGINATION_MODEL_H_
-#pragma once
-
-#include "ash/ash_export.h"
-#include "base/basictypes.h"
-#include "base/observer_list.h"
-
-namespace ash {
-
-class PaginationModelObserver;
-
-// A simple pagination model that consists of two numbers: the total pages and
-// the currently selected page. The model is a single selection model that at
-// the most one page can become selected at any time.
-class ASH_EXPORT PaginationModel {
- public:
- PaginationModel();
- ~PaginationModel();
-
- void SetTotalPages(int total_pages);
- void SelectPage(int page);
-
- void AddObserver(PaginationModelObserver* observer);
- void RemoveObserver(PaginationModelObserver* observer);
-
- int total_pages() const {
- return total_pages_;
- }
-
- int selected_page() const {
- return selected_page_;
- }
-
- private:
- int total_pages_;
- int selected_page_;
- ObserverList<PaginationModelObserver> observers_;
-
- DISALLOW_COPY_AND_ASSIGN(PaginationModel);
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_PAGINATION_MODEL_H_
diff --git a/ash/app_list/pagination_model_observer.h b/ash/app_list/pagination_model_observer.h
deleted file mode 100644
index 44136e8..0000000
--- a/ash/app_list/pagination_model_observer.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_APP_LIST_PAGINATION_MODEL_OBSERVER_H_
-#define ASH_APP_LIST_PAGINATION_MODEL_OBSERVER_H_
-#pragma once
-
-#include "ash/ash_export.h"
-
-namespace ash {
-
-class ASH_EXPORT PaginationModelObserver {
- public:
- // Invoked when the total number of page is changed.
- virtual void TotalPagesChanged() = 0;
-
- // Invoked when the selected page index is changed.
- virtual void SelectedPageChanged(int old_selected, int new_selected) = 0;
-
- protected:
- virtual ~PaginationModelObserver() {}
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_PAGINATION_MODEL_OBSERVER_H_
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 189cfb8..9b53f00 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -25,6 +25,7 @@
'../skia/skia.gyp:skia',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
+ '../ui/app_list/app_list.gyp:app_list',
'../ui/aura/aura.gyp:aura',
'../ui/base/strings/ui_strings.gyp:ui_strings',
'../ui/compositor/compositor.gyp:compositor',
@@ -49,31 +50,6 @@
'accelerators/accelerator_table.h',
'accelerators/nested_dispatcher_controller.cc',
'accelerators/nested_dispatcher_controller.h',
- 'app_list/app_list.cc',
- 'app_list/app_list.h',
- 'app_list/app_list_bubble_border.cc',
- 'app_list/app_list_bubble_border.h',
- 'app_list/app_list_item_model.cc',
- 'app_list/app_list_item_model.h',
- 'app_list/app_list_item_model_observer.h',
- 'app_list/app_list_item_view.cc',
- 'app_list/app_list_item_view.h',
- 'app_list/app_list_model.cc',
- 'app_list/app_list_model.h',
- 'app_list/app_list_model_view.cc',
- 'app_list/app_list_model_view.h',
- 'app_list/app_list_view.cc',
- 'app_list/app_list_view.h',
- 'app_list/app_list_view_delegate.h',
- 'app_list/drop_shadow_label.cc',
- 'app_list/drop_shadow_label.h',
- 'app_list/icon_cache.cc',
- 'app_list/icon_cache.h',
- 'app_list/page_switcher.cc',
- 'app_list/page_switcher.h',
- 'app_list/pagination_model.cc',
- 'app_list/pagination_model.h',
- 'app_list/pagination_model_observer.h',
'ash_switches.cc',
'ash_switches.h',
'caps_lock_delegate.h',
@@ -196,6 +172,8 @@
'tooltips/tooltip_controller.cc',
'tooltips/tooltip_controller.h',
'volume_control_delegate.h',
+ 'wm/app_list_controller.cc',
+ 'wm/app_list_controller.h',
'wm/activation_controller.cc',
'wm/activation_controller.h',
'wm/always_on_top_controller.cc',
@@ -361,7 +339,6 @@
'accelerators/accelerator_filter_unittest.cc',
'accelerators/accelerator_table_unittest.cc',
'accelerators/nested_dispatcher_controller_unittest.cc',
- 'app_list/app_list_unittest.cc',
'dip_unittest.cc',
'drag_drop/drag_drop_controller_unittest.cc',
'focus_cycler_unittest.cc',
@@ -465,6 +442,7 @@
'../skia/skia.gyp:skia',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
+ '../ui/app_list/app_list.gyp:app_list',
'../ui/aura/aura.gyp:aura',
'../ui/compositor/compositor.gyp:compositor',
'../ui/compositor/compositor.gyp:compositor_test_support',
diff --git a/ash/shell.cc b/ash/shell.cc
index 19944f2..6799e0e 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -5,8 +5,8 @@
#include "ash/shell.h"
#include <algorithm>
+#include <string>
-#include "ash/app_list/app_list.h"
#include "ash/ash_switches.h"
#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/desktop_background/desktop_background_resources.h"
@@ -29,6 +29,7 @@
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/tooltips/tooltip_controller.h"
#include "ash/wm/activation_controller.h"
+#include "ash/wm/app_list_controller.h"
#include "ash/wm/base_layout_manager.h"
#include "ash/wm/custom_frame_view_ash.h"
#include "ash/wm/dialog_frame_view.h"
@@ -66,7 +67,6 @@
#include "ui/aura/env.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/monitor_manager.h"
-#include "ui/aura/monitor_manager.h"
#include "ui/aura/root_window.h"
#include "ui/aura/ui_controls_aura.h"
#include "ui/aura/window.h"
@@ -241,7 +241,7 @@ class DummyUserWallpaperDelegate : public UserWallpaperDelegate {
}
private:
- DISALLOW_COPY_AND_ASSIGN(DummyUserWallpaperDelegate);
+ DISALLOW_COPY_AND_ASSIGN(DummyUserWallpaperDelegate);
};
class DummySystemTrayDelegate : public SystemTrayDelegate {
@@ -258,7 +258,6 @@ class DummySystemTrayDelegate : public SystemTrayDelegate {
virtual ~DummySystemTrayDelegate() {}
private:
-
virtual bool GetTrayVisibilityOnStartup() OVERRIDE { return true; }
// Overridden from SystemTrayDelegate:
@@ -774,17 +773,18 @@ void Shell::ShowBackgroundMenu(views::Widget* widget,
}
void Shell::ToggleAppList() {
- if (!app_list_.get())
- app_list_.reset(new internal::AppList);
- app_list_->SetVisible(!app_list_->IsVisible());
+ if (!app_list_controller_.get())
+ app_list_controller_.reset(new internal::AppListController);
+ app_list_controller_->SetVisible(!app_list_controller_->IsVisible());
}
bool Shell::GetAppListTargetVisibility() const {
- return app_list_.get() && app_list_->GetTargetVisibility();
+ return app_list_controller_.get() &&
+ app_list_controller_->GetTargetVisibility();
}
aura::Window* Shell::GetAppListWindow() {
- return app_list_.get() ? app_list_->GetWindow() : NULL;
+ return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL;
}
bool Shell::IsScreenLocked() const {
diff --git a/ash/shell.h b/ash/shell.h
index 2f47db3..8ec275b 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -62,9 +62,9 @@ class VideoDetector;
class WindowCycleController;
namespace internal {
-class ActivationController;
class AcceleratorFilter;
-class AppList;
+class ActivationController;
+class AppListController;
class DragDropController;
class EventClientImpl;
class FocusCycler;
@@ -323,7 +323,7 @@ class ASH_EXPORT Shell {
scoped_ptr<Launcher> launcher_;
- scoped_ptr<internal::AppList> app_list_;
+ scoped_ptr<internal::AppListController> app_list_controller_;
scoped_ptr<internal::ShellContextMenu> shell_context_menu_;
scoped_ptr<internal::StackingController> stacking_controller_;
diff --git a/ash/shell/app_list.cc b/ash/shell/app_list.cc
index 2e4fd77..4430e7b 100644
--- a/ash/shell/app_list.cc
+++ b/ash/shell/app_list.cc
@@ -2,16 +2,16 @@
// 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_item_model.h"
-#include "ash/app_list/app_list_item_view.h"
-#include "ash/app_list/app_list_model.h"
-#include "ash/app_list/app_list_view.h"
-#include "ash/app_list/app_list_view_delegate.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell/example_factory.h"
#include "ash/shell/toplevel_window.h"
#include "base/basictypes.h"
+#include "ui/app_list/app_list_item_model.h"
+#include "ui/app_list/app_list_item_view.h"
+#include "ui/app_list/app_list_model.h"
+#include "ui/app_list/app_list_view.h"
+#include "ui/app_list/app_list_view_delegate.h"
#include "ui/views/examples/examples_window.h"
namespace ash {
@@ -19,7 +19,7 @@ namespace shell {
namespace {
-class WindowTypeLauncherItem : public ash::AppListItemModel {
+class WindowTypeLauncherItem : public app_list::AppListItemModel {
public:
enum Type {
TOPLEVEL_WINDOW = 0,
@@ -30,7 +30,7 @@ class WindowTypeLauncherItem : public ash::AppListItemModel {
LAST_TYPE,
};
- WindowTypeLauncherItem(Type type) : type_(type) {
+ explicit WindowTypeLauncherItem(Type type) : type_(type) {
SetIcon(GetIcon(type));
SetTitle(GetTitle(type));
}
@@ -108,13 +108,13 @@ class WindowTypeLauncherItem : public ash::AppListItemModel {
DISALLOW_COPY_AND_ASSIGN(WindowTypeLauncherItem);
};
-class ExampleAppListViewDelegate : public ash::AppListViewDelegate {
+class ExampleAppListViewDelegate : public app_list::AppListViewDelegate {
public:
ExampleAppListViewDelegate() : model_(NULL) {}
private:
// Overridden from ash::AppListViewDelegate:
- virtual void SetModel(AppListModel* model) OVERRIDE {
+ virtual void SetModel(app_list::AppListModel* model) OVERRIDE {
model_ = model;
}
@@ -133,19 +133,25 @@ class ExampleAppListViewDelegate : public ash::AppListViewDelegate {
}
}
- virtual void OnAppListItemActivated(ash::AppListItemModel* item,
+ virtual void OnAppListItemActivated(app_list::AppListItemModel* item,
int event_flags) OVERRIDE {
static_cast<WindowTypeLauncherItem*>(item)->Activate(event_flags);
}
- AppListModel* model_;
+ virtual void Close() OVERRIDE {
+ DCHECK(ash::Shell::HasInstance());
+ if (Shell::GetInstance()->GetAppListTargetVisibility())
+ Shell::GetInstance()->ToggleAppList();
+ }
+
+ app_list::AppListModel* model_;
DISALLOW_COPY_AND_ASSIGN(ExampleAppListViewDelegate);
};
} // namespace
-ash::AppListViewDelegate* CreateAppListViewDelegate() {
+app_list::AppListViewDelegate* CreateAppListViewDelegate() {
return new ExampleAppListViewDelegate;
}
diff --git a/ash/shell/example_factory.h b/ash/shell/example_factory.h
index 225a2fb..7ce4f5f 100644
--- a/ash/shell/example_factory.h
+++ b/ash/shell/example_factory.h
@@ -6,7 +6,7 @@
#define ASH_SHELL_EXAMPLE_FACTORY_H_
#pragma once
-namespace ash {
+namespace app_list {
class AppListModel;
class AppListViewDelegate;
}
@@ -25,9 +25,9 @@ void CreateLockScreen();
// Creates a window showing samples of commonly used widgets.
void CreateWidgetsWindow();
-void BuildAppListModel(ash::AppListModel* model);
+void BuildAppListModel(app_list::AppListModel* model);
-ash::AppListViewDelegate* CreateAppListViewDelegate();
+app_list::AppListViewDelegate* CreateAppListViewDelegate();
} // namespace shell
} // namespace ash
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index 31edb6a..f1d52bb 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -82,7 +82,7 @@ content::BrowserContext* ShellDelegateImpl::GetCurrentBrowserContext() {
void ShellDelegateImpl::ToggleSpokenFeedback() {
}
-ash::AppListViewDelegate* ShellDelegateImpl::CreateAppListViewDelegate() {
+app_list::AppListViewDelegate* ShellDelegateImpl::CreateAppListViewDelegate() {
return ash::shell::CreateAppListViewDelegate();
}
diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h
index 71b65b2..de999f8 100644
--- a/ash/shell/shell_delegate_impl.h
+++ b/ash/shell/shell_delegate_impl.h
@@ -35,7 +35,7 @@ class ShellDelegateImpl : public ash::ShellDelegate {
virtual void OpenMobileSetup() OVERRIDE;
virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE;
virtual void ToggleSpokenFeedback() OVERRIDE;
- virtual ash::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
+ virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
virtual void StartPartialScreenshot(
ash::ScreenshotDelegate* screenshot_delegate) OVERRIDE;
virtual ash::LauncherDelegate* CreateLauncherDelegate(
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index 43c1593..ce857f8 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -13,6 +13,10 @@
#include "base/callback.h"
#include "base/string16.h"
+namespace app_list {
+class AppListViewDelegate;
+}
+
namespace aura {
class Window;
}
@@ -23,7 +27,6 @@ class Widget;
namespace ash {
-class AppListViewDelegate;
class LauncherDelegate;
class LauncherModel;
struct LauncherItem;
@@ -80,7 +83,7 @@ class ASH_EXPORT ShellDelegate {
// Invoked to create an AppListViewDelegate. Shell takes the ownership of
// the created delegate.
- virtual AppListViewDelegate* CreateAppListViewDelegate() = 0;
+ virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() = 0;
// Invoked to start taking partial screenshot.
virtual void StartPartialScreenshot(
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index 0dcd167..56f208b 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -67,7 +67,7 @@ content::BrowserContext* TestShellDelegate::GetCurrentBrowserContext() {
void TestShellDelegate::ToggleSpokenFeedback() {
}
-AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() {
+app_list::AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() {
return NULL;
}
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
index 1c13794..d59972d 100644
--- a/ash/test/test_shell_delegate.h
+++ b/ash/test/test_shell_delegate.h
@@ -31,7 +31,7 @@ class TestShellDelegate : public ShellDelegate {
virtual void OpenMobileSetup() OVERRIDE;
virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE;
virtual void ToggleSpokenFeedback() OVERRIDE;
- virtual AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
+ virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
virtual void StartPartialScreenshot(
ScreenshotDelegate* screenshot_delegate) OVERRIDE;
virtual LauncherDelegate* CreateLauncherDelegate(
diff --git a/ash/app_list/app_list.cc b/ash/wm/app_list_controller.cc
index f5fae714..9e7f895 100644
--- a/ash/app_list/app_list.cc
+++ b/ash/wm/app_list_controller.cc
@@ -2,22 +2,24 @@
// 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.h"
+#include "ash/wm/app_list_controller.h"
-#include "ash/app_list/app_list_view.h"
-#include "ash/app_list/icon_cache.h"
#include "ash/ash_switches.h"
+#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
+#include "ui/app_list/app_list_view.h"
+#include "ui/app_list/icon_cache.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
+#include "ui/gfx/screen.h"
#include "ui/gfx/transform_util.h"
namespace ash {
@@ -37,27 +39,44 @@ ui::Layer* GetLayer(views::Widget* widget) {
return widget->GetNativeView()->layer();
}
+// Bounds returned is used for full screen app list. Use full monitor rect
+// so that the app list shade goes behind the launcher.
+gfx::Rect GetFullScreenBoundsForWidget(views::Widget* widget) {
+ gfx::NativeView window = widget->GetNativeView();
+ return gfx::Screen::GetMonitorNearestWindow(window).bounds();
+}
+
+// Return work area rect for full screen app list layout. This function is
+// needed to get final work area in one shot instead of waiting for shelf
+// animation to finish.
+gfx::Rect GetWorkAreaBoundsForWidget(views::Widget* widget) {
+ gfx::NativeView window = widget->GetNativeView();
+ return Shell::GetInstance()->shelf()->IsVisible() ?
+ ScreenAsh::GetUnmaximizedWorkAreaBounds(window) :
+ gfx::Screen::GetMonitorNearestWindow(window).work_area();
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
-// AppList, public:
+// AppListController, public:
-AppList::AppList() : is_visible_(false), view_(NULL) {
- IconCache::CreateInstance();
+AppListController::AppListController() : is_visible_(false), view_(NULL) {
+ app_list::IconCache::CreateInstance();
}
-AppList::~AppList() {
+AppListController::~AppListController() {
ResetView();
- IconCache::DeleteInstance();
+ app_list::IconCache::DeleteInstance();
}
// static
-bool AppList::UseAppListV2() {
+bool AppListController::UseAppListV2() {
return CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableAppListV2);
}
-void AppList::SetVisible(bool visible) {
+void AppListController::SetVisible(bool visible) {
if (visible == is_visible_)
return;
@@ -72,27 +91,40 @@ void AppList::SetVisible(bool visible) {
} else if (is_visible_) {
// AppListModel and AppListViewDelegate are owned by AppListView. They
// will be released with AppListView on close.
- SetView(new AppListView(
- Shell::GetInstance()->delegate()->CreateAppListViewDelegate()));
+ app_list::AppListView* view = new app_list::AppListView(
+ Shell::GetInstance()->delegate()->CreateAppListViewDelegate());
+ if (UseAppListV2()) {
+ view->InitAsBubble(
+ Shell::GetInstance()->GetContainer(kShellWindowId_AppListContainer),
+ Shell::GetInstance()->launcher()->GetAppListButtonView());
+ } else {
+ views::Widget* launcher_widget =
+ Shell::GetInstance()->launcher()->widget();
+ view->InitAsFullscreenWidget(Shell::GetInstance()->GetContainer(
+ kShellWindowId_AppListContainer),
+ GetFullScreenBoundsForWidget(launcher_widget),
+ GetWorkAreaBoundsForWidget(launcher_widget));
+ }
+ SetView(view);
}
}
-bool AppList::IsVisible() {
+bool AppListController::IsVisible() const {
return view_ && view_->GetWidget()->IsVisible();
}
-aura::Window* AppList::GetWindow() {
+aura::Window* AppListController::GetWindow() {
return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : NULL;
}
////////////////////////////////////////////////////////////////////////////////
-// AppList, private:
+// AppListController, private:
-void AppList::SetView(AppListView* view) {
+void AppListController::SetView(app_list::AppListView* view) {
DCHECK(view_ == NULL);
if (is_visible_) {
- IconCache::GetInstance()->MarkAllEntryUnused();
+ app_list::IconCache::GetInstance()->MarkAllEntryUnused();
view_ = view;
views::Widget* widget = view_->GetWidget();
@@ -109,7 +141,7 @@ void AppList::SetView(AppListView* view) {
}
}
-void AppList::ResetView() {
+void AppListController::ResetView() {
if (!view_)
return;
@@ -120,10 +152,10 @@ void AppList::ResetView() {
widget->GetNativeView()->GetRootWindow()->RemoveRootWindowObserver(this);
view_ = NULL;
- IconCache::GetInstance()->PurgeAllUnused();
+ app_list::IconCache::GetInstance()->PurgeAllUnused();
}
-void AppList::ScheduleAnimation() {
+void AppListController::ScheduleAnimation() {
second_animation_timer_.Stop();
// Stop observing previous animation.
@@ -141,19 +173,18 @@ void AppList::ScheduleAnimation() {
FROM_HERE,
base::TimeDelta::FromMilliseconds(kSecondAnimationStartDelay),
this,
- &AppList::ScheduleAppListAnimation);
+ &AppListController::ScheduleAppListAnimation);
} else {
ScheduleAppListAnimation();
second_animation_timer_.Start(
FROM_HERE,
base::TimeDelta::FromMilliseconds(kSecondAnimationStartDelay),
this,
- &AppList::ScheduleBrowserWindowsAnimation);
+ &AppListController::ScheduleBrowserWindowsAnimation);
}
-
}
-void AppList::ScheduleBrowserWindowsAnimationForContainer(
+void AppListController::ScheduleBrowserWindowsAnimationForContainer(
aura::Window* container) {
DCHECK(container);
ui::Layer* layer = container->layer();
@@ -174,19 +205,19 @@ void AppList::ScheduleBrowserWindowsAnimationForContainer(
ui::Transform());
}
-void AppList::ScheduleBrowserWindowsAnimation() {
+void AppListController::ScheduleBrowserWindowsAnimation() {
// Note: containers could be NULL during Shell shutdown.
aura::Window* default_container = Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_DefaultContainer);
+ kShellWindowId_DefaultContainer);
if (default_container)
ScheduleBrowserWindowsAnimationForContainer(default_container);
- aura::Window* always_on_top_container = Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_AlwaysOnTopContainer);
+ aura::Window* always_on_top_container = Shell::GetInstance()->
+ GetContainer(kShellWindowId_AlwaysOnTopContainer);
if (always_on_top_container)
ScheduleBrowserWindowsAnimationForContainer(always_on_top_container);
}
-void AppList::ScheduleDimmingAnimation() {
+void AppListController::ScheduleDimmingAnimation() {
ui::Layer* layer = GetLayer(view_->GetWidget());
layer->GetAnimator()->StopAnimating();
@@ -201,7 +232,7 @@ void AppList::ScheduleDimmingAnimation() {
layer->SetOpacity(is_visible_ ? 1.0 : 0.0);
}
-void AppList::ScheduleAppListAnimation() {
+void AppListController::ScheduleAppListAnimation() {
if (is_visible_)
view_->AnimateShow(kAnimationDurationMs);
else
@@ -209,15 +240,15 @@ void AppList::ScheduleAppListAnimation() {
}
////////////////////////////////////////////////////////////////////////////////
-// AppList, aura::EventFilter implementation:
+// AppListController, aura::EventFilter implementation:
-bool AppList::PreHandleKeyEvent(aura::Window* target,
- aura::KeyEvent* event) {
+bool AppListController::PreHandleKeyEvent(aura::Window* target,
+ aura::KeyEvent* event) {
return false;
}
-bool AppList::PreHandleMouseEvent(aura::Window* target,
- aura::MouseEvent* event) {
+bool AppListController::PreHandleMouseEvent(aura::Window* target,
+ aura::MouseEvent* event) {
if (view_ && is_visible_ && event->type() == ui::ET_MOUSE_PRESSED) {
views::Widget* widget = view_->GetWidget();
aura::MouseEvent translated(*event, target, widget->GetNativeView());
@@ -227,31 +258,36 @@ bool AppList::PreHandleMouseEvent(aura::Window* target,
return false;
}
-ui::TouchStatus AppList::PreHandleTouchEvent(aura::Window* target,
- aura::TouchEvent* event) {
+ui::TouchStatus AppListController::PreHandleTouchEvent(
+ aura::Window* target,
+ aura::TouchEvent* event) {
return ui::TOUCH_STATUS_UNKNOWN;
}
-ui::GestureStatus AppList::PreHandleGestureEvent(
+ui::GestureStatus AppListController::PreHandleGestureEvent(
aura::Window* target,
aura::GestureEvent* event) {
return ui::GESTURE_STATUS_UNKNOWN;
}
////////////////////////////////////////////////////////////////////////////////
-// AppList, ura::RootWindowObserver implementation:
-void AppList::OnRootWindowResized(const aura::RootWindow* root,
- const gfx::Size& old_size) {
- if (view_ && is_visible_)
- view_->UpdateBounds();
+// AppListController, aura::RootWindowObserver implementation:
+void AppListController::OnRootWindowResized(const aura::RootWindow* root,
+ const gfx::Size& old_size) {
+ if (view_ && is_visible_) {
+ views::Widget* launcher_widget =
+ Shell::GetInstance()->launcher()->widget();
+ view_->UpdateBounds(GetFullScreenBoundsForWidget(launcher_widget),
+ GetWorkAreaBoundsForWidget(launcher_widget));
+ }
}
-void AppList::OnWindowFocused(aura::Window* window) {
+void AppListController::OnWindowFocused(aura::Window* window) {
if (view_ && is_visible_) {
aura::Window* applist_container = Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_AppListContainer);
+ kShellWindowId_AppListContainer);
aura::Window* bubble_container = Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_SettingBubbleContainer);
+ kShellWindowId_SettingBubbleContainer);
if (window->parent() != applist_container &&
window->parent() != bubble_container) {
SetVisible(false);
@@ -260,9 +296,9 @@ void AppList::OnWindowFocused(aura::Window* window) {
}
////////////////////////////////////////////////////////////////////////////////
-// AppList, ui::ImplicitAnimationObserver implementation:
+// AppListController, ui::ImplicitAnimationObserver implementation:
-void AppList::OnImplicitAnimationsCompleted() {
+void AppListController::OnImplicitAnimationsCompleted() {
if (is_visible_ )
view_->GetWidget()->Activate();
else
@@ -270,9 +306,9 @@ void AppList::OnImplicitAnimationsCompleted() {
}
////////////////////////////////////////////////////////////////////////////////
-// AppList, views::Widget::Observer implementation:
+// AppListController, views::Widget::Observer implementation:
-void AppList::OnWidgetClosing(views::Widget* widget) {
+void AppListController::OnWidgetClosing(views::Widget* widget) {
DCHECK(view_->GetWidget() == widget);
if (is_visible_)
SetVisible(false);
diff --git a/ash/app_list/app_list.h b/ash/wm/app_list_controller.h
index 6230f94..95ea61c 100644
--- a/ash/app_list/app_list.h
+++ b/ash/wm/app_list_controller.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_APP_LIST_APP_LIST_H_
-#define ASH_APP_LIST_APP_LIST_H_
+#ifndef ASH_WM_APP_LIST_CONTROLLER_H_
+#define ASH_WM_APP_LIST_CONTROLLER_H_
#pragma once
#include "base/basictypes.h"
@@ -14,23 +14,24 @@
#include "ui/compositor/layer_animation_observer.h"
#include "ui/views/widget/widget.h"
-namespace ash {
-
+namespace app_list {
class AppListView;
+}
+namespace ash {
namespace internal {
-// AppList is a controller that manages app list UI for shell. To show the UI,
-// it requests app list widget from ShellDelegate and shows it when ready.
+// AppListController is a controller that manages app list UI for shell.
+// It creates AppListView and schedules showing/hiding animation.
// While the UI is visible, it monitors things such as app list widget's
// activation state and desktop mouse click to auto dismiss the UI.
-class AppList : public aura::EventFilter,
- public aura::RootWindowObserver,
- public ui::ImplicitAnimationObserver,
- public views::Widget::Observer {
+class AppListController : public aura::EventFilter,
+ public aura::RootWindowObserver,
+ public ui::ImplicitAnimationObserver,
+ public views::Widget::Observer {
public:
- AppList();
- virtual ~AppList();
+ AppListController();
+ virtual ~AppListController();
// Returns true if AppListV2 is enabled.
static bool UseAppListV2();
@@ -39,7 +40,7 @@ class AppList : public aura::EventFilter,
void SetVisible(bool visible);
// Whether app list window is visible (shown or being shown).
- bool IsVisible();
+ bool IsVisible() const;
// Returns target visibility. This differs from IsVisible() if an animation
// is ongoing.
@@ -51,7 +52,7 @@ class AppList : public aura::EventFilter,
private:
// Sets app list view. If we are in visible mode, start showing animation.
// Otherwise, we just close it.
- void SetView(AppListView* view);
+ void SetView(app_list::AppListView* view);
// Forgets the view.
void ResetView();
@@ -98,16 +99,17 @@ class AppList : public aura::EventFilter,
bool is_visible_;
// The AppListView this class manages, owned by its widget.
- AppListView* view_;
+ app_list::AppListView* view_;
// Timer to schedule the 2nd step animation, started when the first step
// animation is scheduled in ScheduleAnimation.
- base::OneShotTimer<AppList> second_animation_timer_;
+ base::OneShotTimer<AppListController> second_animation_timer_;
- DISALLOW_COPY_AND_ASSIGN(AppList);
+ DISALLOW_COPY_AND_ASSIGN(AppListController);
};
} // namespace internal
} // namespace ash
-#endif // ASH_APP_LIST_APP_LIST_H_
+#endif // ASH_WM_APP_LIST_CONTROLLER_H_
+