| Index: ui/app_list/apps_grid_view.cc
|
| diff --git a/ui/app_list/app_list_model_view.cc b/ui/app_list/apps_grid_view.cc
|
| similarity index 86%
|
| rename from ui/app_list/app_list_model_view.cc
|
| rename to ui/app_list/apps_grid_view.cc
|
| index e594277b844edca93e50f438ff0cd338afe908a6..298b52f04b1d408b234ee34bda81c43d60d5c01a 100644
|
| --- a/ui/app_list/app_list_model_view.cc
|
| +++ b/ui/app_list/apps_grid_view.cc
|
| @@ -2,13 +2,13 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "ui/app_list/app_list_model_view.h"
|
| +#include "ui/app_list/apps_grid_view.h"
|
|
|
| #include <algorithm>
|
|
|
| #include "ui/app_list/app_list_item_view.h"
|
| -#include "ui/app_list/app_list_model.h"
|
| #include "ui/app_list/pagination_model.h"
|
| +#include "ui/app_list/view_ids.h"
|
| #include "ui/views/border.h"
|
|
|
| namespace {
|
| @@ -25,7 +25,7 @@ const int kPreferredTileHeight = 88;
|
|
|
| namespace app_list {
|
|
|
| -AppListModelView::AppListModelView(views::ButtonListener* listener,
|
| +AppsGridView::AppsGridView(views::ButtonListener* listener,
|
| PaginationModel* pagination_model)
|
| : model_(NULL),
|
| listener_(listener),
|
| @@ -34,17 +34,18 @@ AppListModelView::AppListModelView(views::ButtonListener* listener,
|
| cols_(0),
|
| rows_per_page_(0),
|
| selected_item_index_(-1) {
|
| + set_id(VIEW_ID_APPS_GRID);
|
| set_focusable(true);
|
| pagination_model_->AddObserver(this);
|
| }
|
|
|
| -AppListModelView::~AppListModelView() {
|
| +AppsGridView::~AppsGridView() {
|
| if (model_)
|
| model_->RemoveObserver(this);
|
| pagination_model_->RemoveObserver(this);
|
| }
|
|
|
| -void AppListModelView::CalculateLayout(const gfx::Size& content_size,
|
| +void AppsGridView::CalculateLayout(const gfx::Size& content_size,
|
| int num_of_tiles,
|
| gfx::Size* icon_size,
|
| int* rows,
|
| @@ -95,7 +96,7 @@ void AppListModelView::CalculateLayout(const gfx::Size& content_size,
|
| *rows = (num_of_tiles - 1) / (*cols) + 1;
|
| }
|
|
|
| -void AppListModelView::SetLayout(int icon_size, int cols, int rows_per_page) {
|
| +void AppsGridView::SetLayout(int icon_size, int cols, int rows_per_page) {
|
| fixed_layout_ = true;
|
|
|
| icon_size_.SetSize(icon_size, icon_size);
|
| @@ -108,7 +109,7 @@ void AppListModelView::SetLayout(int icon_size, int cols, int rows_per_page) {
|
| kTopLeftRightPadding));
|
| }
|
|
|
| -void AppListModelView::SetModel(AppListModel* model) {
|
| +void AppsGridView::SetModel(AppListModel::Apps* model) {
|
| if (model_)
|
| model_->RemoveObserver(this);
|
|
|
| @@ -118,19 +119,19 @@ void AppListModelView::SetModel(AppListModel* model) {
|
| Update();
|
| }
|
|
|
| -void AppListModelView::SetSelectedItem(AppListItemView* item) {
|
| +void AppsGridView::SetSelectedItem(AppListItemView* item) {
|
| int index = GetIndexOf(item);
|
| if (index >= 0)
|
| SetSelectedItemByIndex(index);
|
| }
|
|
|
| -void AppListModelView::ClearSelectedItem(AppListItemView* item) {
|
| +void AppsGridView::ClearSelectedItem(AppListItemView* item) {
|
| int index = GetIndexOf(item);
|
| if (index == selected_item_index_)
|
| SetSelectedItemByIndex(-1);
|
| }
|
|
|
| -void AppListModelView::Update() {
|
| +void AppsGridView::Update() {
|
| selected_item_index_ = -1;
|
| RemoveAllChildViews(true);
|
| if (!model_ || model_->item_count() == 0)
|
| @@ -143,11 +144,11 @@ void AppListModelView::Update() {
|
| SchedulePaint();
|
| }
|
|
|
| -AppListItemView* AppListModelView::GetItemViewAtIndex(int index) {
|
| +AppListItemView* AppsGridView::GetItemViewAtIndex(int index) {
|
| return static_cast<AppListItemView*>(child_at(index));
|
| }
|
|
|
| -void AppListModelView::SetSelectedItemByIndex(int index) {
|
| +void AppsGridView::SetSelectedItemByIndex(int index) {
|
| if (selected_item_index_ == index)
|
| return;
|
|
|
| @@ -165,7 +166,7 @@ void AppListModelView::SetSelectedItemByIndex(int index) {
|
| }
|
| }
|
|
|
| -gfx::Size AppListModelView::GetPreferredSize() {
|
| +gfx::Size AppsGridView::GetPreferredSize() {
|
| if (!fixed_layout_)
|
| return gfx::Size();
|
|
|
| @@ -175,7 +176,7 @@ gfx::Size AppListModelView::GetPreferredSize() {
|
| tile_size.height() * rows_per_page_ + insets.height());
|
| }
|
|
|
| -void AppListModelView::Layout() {
|
| +void AppsGridView::Layout() {
|
| gfx::Rect rect(GetContentsBounds());
|
| if (rect.IsEmpty() || child_count() == 0)
|
| return;
|
| @@ -235,7 +236,7 @@ void AppListModelView::Layout() {
|
| }
|
| }
|
|
|
| -bool AppListModelView::OnKeyPressed(const views::KeyEvent& event) {
|
| +bool AppsGridView::OnKeyPressed(const views::KeyEvent& event) {
|
| bool handled = false;
|
| if (selected_item_index_ >= 0)
|
| handled = GetItemViewAtIndex(selected_item_index_)->OnKeyPressed(event);
|
| @@ -284,7 +285,7 @@ bool AppListModelView::OnKeyPressed(const views::KeyEvent& event) {
|
| return handled;
|
| }
|
|
|
| -bool AppListModelView::OnKeyReleased(const views::KeyEvent& event) {
|
| +bool AppsGridView::OnKeyReleased(const views::KeyEvent& event) {
|
| bool handled = false;
|
| if (selected_item_index_ >= 0)
|
| handled = GetItemViewAtIndex(selected_item_index_)->OnKeyReleased(event);
|
| @@ -292,11 +293,11 @@ bool AppListModelView::OnKeyReleased(const views::KeyEvent& event) {
|
| return handled;
|
| }
|
|
|
| -void AppListModelView::OnPaintFocusBorder(gfx::Canvas* canvas) {
|
| +void AppsGridView::OnPaintFocusBorder(gfx::Canvas* canvas) {
|
| // Override to not paint focus frame.
|
| }
|
|
|
| -void AppListModelView::ListItemsAdded(size_t start, size_t count) {
|
| +void AppsGridView::ListItemsAdded(size_t start, size_t count) {
|
| for (size_t i = start; i < start + count; ++i) {
|
| AddChildViewAt(new AppListItemView(this, model_->GetItemAt(i), listener_),
|
| i);
|
| @@ -305,7 +306,7 @@ void AppListModelView::ListItemsAdded(size_t start, size_t count) {
|
| SchedulePaint();
|
| }
|
|
|
| -void AppListModelView::ListItemsRemoved(size_t start, size_t count) {
|
| +void AppsGridView::ListItemsRemoved(size_t start, size_t count) {
|
| for (size_t i = 0; i < count; ++i)
|
| delete child_at(start);
|
|
|
| @@ -313,14 +314,14 @@ void AppListModelView::ListItemsRemoved(size_t start, size_t count) {
|
| SchedulePaint();
|
| }
|
|
|
| -void AppListModelView::ListItemsChanged(size_t start, size_t count) {
|
| +void AppsGridView::ListItemsChanged(size_t start, size_t count) {
|
| NOTREACHED();
|
| }
|
|
|
| -void AppListModelView::TotalPagesChanged() {
|
| +void AppsGridView::TotalPagesChanged() {
|
| }
|
|
|
| -void AppListModelView::SelectedPageChanged(int old_selected, int new_selected) {
|
| +void AppsGridView::SelectedPageChanged(int old_selected, int new_selected) {
|
| Layout();
|
| }
|
|
|
|
|