Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: ui/app_list/views/apps_grid_view.cc

Issue 599933004: AppsGridView: Use specific types instead of views::View*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/app_list/views/apps_grid_view.h ('K') | « ui/app_list/views/apps_grid_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/apps_grid_view.cc
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc
index 57ba390f441b307725b99073d684495768f69003..8d7db8e3059e040100923b4074cba36feee749ed 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -884,10 +884,8 @@ void AppsGridView::Prerender() {
int start = std::max(0, (selected_page - kPrerenderPages) * tiles_per_page());
int end = std::min(view_model_.view_size(),
(selected_page + 1 + kPrerenderPages) * tiles_per_page());
- for (int i = start; i < end; i++) {
- AppListItemView* v = static_cast<AppListItemView*>(view_model_.view_at(i));
- v->Prerender();
- }
+ for (int i = start; i < end; i++)
+ GetItemViewAt(i)->Prerender();
}
bool AppsGridView::IsAnimatingView(views::View* view) {
@@ -1096,7 +1094,7 @@ void AppsGridView::SetSelectedItemByIndex(const Index& index) {
if (GetIndexOfView(selected_view_) == index)
return;
- views::View* new_selection = GetViewAtIndex(index);
+ AppListItemView* new_selection = GetViewAtIndex(index);
if (!new_selection)
return; // Keep current selection.
@@ -1125,12 +1123,12 @@ AppsGridView::Index AppsGridView::GetIndexOfView(
return GetIndexFromModelIndex(model_index);
}
-views::View* AppsGridView::GetViewAtIndex(const Index& index) const {
+AppListItemView* AppsGridView::GetViewAtIndex(const Index& index) const {
if (!IsValidIndex(index))
return NULL;
const int model_index = GetModelIndexFromIndex(index);
- return view_model_.view_at(model_index);
+ return GetItemViewAt(model_index);
}
AppsGridView::Index AppsGridView::GetLastViewIndex() const {
@@ -1731,12 +1729,10 @@ void AppsGridView::MoveItemInModel(views::View* item_view,
pagination_model_.SelectPage(target.page, false);
}
-void AppsGridView::MoveItemToFolder(views::View* item_view,
+void AppsGridView::MoveItemToFolder(AppListItemView* item_view,
const Index& target) {
- const std::string& source_item_id =
- static_cast<AppListItemView*>(item_view)->item()->id();
- AppListItemView* target_view =
- static_cast<AppListItemView*>(GetViewAtSlotOnCurrentPage(target.slot));
+ const std::string& source_item_id = item_view->item()->id();
+ AppListItemView* target_view = GetViewAtSlotOnCurrentPage(target.slot);
const std::string& target_view_item_id = target_view->item()->id();
// Make change to data model.
@@ -1777,12 +1773,12 @@ void AppsGridView::MoveItemToFolder(views::View* item_view,
UpdatePaging();
}
-void AppsGridView::ReparentItemForReorder(views::View* item_view,
+void AppsGridView::ReparentItemForReorder(AppListItemView* item_view,
const Index& target) {
item_list_->RemoveObserver(this);
model_->RemoveObserver(this);
- AppListItem* reparent_item = static_cast<AppListItemView*>(item_view)->item();
+ AppListItem* reparent_item = item_view->item();
DCHECK(reparent_item->IsInFolder());
const std::string source_folder_id = reparent_item->folder_id();
AppListFolderItem* source_folder =
@@ -1819,19 +1815,18 @@ void AppsGridView::ReparentItemForReorder(views::View* item_view,
UpdatePaging();
}
-void AppsGridView::ReparentItemToAnotherFolder(views::View* item_view,
+void AppsGridView::ReparentItemToAnotherFolder(AppListItemView* item_view,
const Index& target) {
DCHECK(IsDraggingForReparentInRootLevelGridView());
- AppListItemView* target_view =
- static_cast<AppListItemView*>(GetViewAtSlotOnCurrentPage(target.slot));
+ AppListItemView* target_view = GetViewAtSlotOnCurrentPage(target.slot);
if (!target_view)
return;
// Make change to data model.
item_list_->RemoveObserver(this);
- AppListItem* reparent_item = static_cast<AppListItemView*>(item_view)->item();
+ AppListItem* reparent_item = item_view->item();
DCHECK(reparent_item->IsInFolder());
const std::string source_folder_id = reparent_item->folder_id();
AppListFolderItem* source_folder =
@@ -1942,11 +1937,8 @@ void AppsGridView::CancelFolderItemReparent(AppListItemView* drag_item_view) {
void AppsGridView::CancelContextMenusOnCurrentPage() {
int start = pagination_model_.selected_page() * tiles_per_page();
int end = std::min(view_model_.view_size(), start + tiles_per_page());
- for (int i = start; i < end; ++i) {
- AppListItemView* view =
- static_cast<AppListItemView*>(view_model_.view_at(i));
- view->CancelContextMenu();
- }
+ for (int i = start; i < end; ++i)
+ GetItemViewAt(i)->CancelContextMenu();
}
void AppsGridView::DeleteItemViewAtIndex(int index) {
@@ -1970,6 +1962,7 @@ void AppsGridView::ButtonPressed(views::Button* sender,
if (strcmp(sender->GetClassName(), AppListItemView::kViewClassName))
return;
+ AppListItemView* pressed_item_view = static_cast<AppListItemView*>(sender);
if (delegate_) {
// Always set the previous activated_folder_item_view_ to be visible. This
@@ -1979,15 +1972,12 @@ void AppsGridView::ButtonPressed(views::Button* sender,
if (!folder_delegate_) {
if (activated_folder_item_view_)
activated_folder_item_view_->SetVisible(true);
- AppListItemView* pressed_item_view =
- static_cast<AppListItemView*>(sender);
if (IsFolderItem(pressed_item_view->item()))
activated_folder_item_view_ = pressed_item_view;
else
activated_folder_item_view_ = NULL;
}
- delegate_->ActivateApp(static_cast<AppListItemView*>(sender)->item(),
- event.flags());
+ delegate_->ActivateApp(pressed_item_view->item(), event.flags());
}
}
@@ -2078,12 +2068,11 @@ bool AppsGridView::EnableFolderDragDropUI() {
}
bool AppsGridView::CanDropIntoTarget(const Index& drop_target) const {
- views::View* target_view = GetViewAtIndex(drop_target);
+ AppListItemView* target_view = GetViewAtIndex(drop_target);
if (!target_view)
return false;
- AppListItem* target_item =
- static_cast<AppListItemView*>(target_view)->item();
+ AppListItem* target_item = target_view->item();
// Items can be dropped into non-folders (which have no children) or folders
// that have fewer than the max allowed items.
// OEM folder does not allow to drag/drop other items in it.
@@ -2125,7 +2114,7 @@ gfx::Rect AppsGridView::GetExpectedTileBounds(int row, int col) const {
return tile_bounds;
}
-views::View* AppsGridView::GetViewAtSlotOnCurrentPage(int slot) {
+AppListItemView* AppsGridView::GetViewAtSlotOnCurrentPage(int slot) {
calamity 2014/09/26 01:47:26 Ugh. This needs to get a better name that indicate
Matt Giuca 2014/09/26 03:48:39 Done. Note that I called it GetViewDisplayedAtSlo
if (slot < 0)
return NULL;
@@ -2135,7 +2124,7 @@ views::View* AppsGridView::GetViewAtSlotOnCurrentPage(int slot) {
gfx::Rect tile_rect = GetExpectedTileBounds(row, col);
for (int i = 0; i < view_model_.view_size(); ++i) {
- views::View* view = view_model_.view_at(i);
+ AppListItemView* view = GetItemViewAt(i);
if (view->bounds() == tile_rect && view != drag_view_)
return view;
}
@@ -2144,9 +2133,7 @@ views::View* AppsGridView::GetViewAtSlotOnCurrentPage(int slot) {
void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index,
bool is_target_folder) {
- AppListItemView* target_view =
- static_cast<AppListItemView*>(
- GetViewAtSlotOnCurrentPage(target_index.slot));
+ AppListItemView* target_view = GetViewAtSlotOnCurrentPage(target_index.slot);
if (target_view)
target_view->SetAsAttemptedFolderTarget(is_target_folder);
}
« ui/app_list/views/apps_grid_view.h ('K') | « ui/app_list/views/apps_grid_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698