Commit 0ee0ce70 authored by mgiuca's avatar mgiuca Committed by Commit bot

AppsGridView: Use specific types instead of views::View*.

Almost every views::View* in this class is actually an AppListItemView*,
and we are now specific about that. Also made a few explicit
PulsingBlockViews. This removes a mess of static_casts throughout the
file, and makes the interface to many methods type-safe and explicit.

Review URL: https://codereview.chromium.org/599933004

Cr-Commit-Position: refs/heads/master@{#297341}
parent 34e0ac22
...@@ -465,7 +465,7 @@ void AppsGridView::SetItemList(AppListItemList* item_list) { ...@@ -465,7 +465,7 @@ void AppsGridView::SetItemList(AppListItemList* item_list) {
Update(); Update();
} }
void AppsGridView::SetSelectedView(views::View* view) { void AppsGridView::SetSelectedView(AppListItemView* view) {
if (IsSelectedView(view) || IsDraggedView(view)) if (IsSelectedView(view) || IsDraggedView(view))
return; return;
...@@ -474,7 +474,7 @@ void AppsGridView::SetSelectedView(views::View* view) { ...@@ -474,7 +474,7 @@ void AppsGridView::SetSelectedView(views::View* view) {
SetSelectedItemByIndex(index); SetSelectedItemByIndex(index);
} }
void AppsGridView::ClearSelectedView(views::View* view) { void AppsGridView::ClearSelectedView(AppListItemView* view) {
if (view && IsSelectedView(view)) { if (view && IsSelectedView(view)) {
selected_view_->SchedulePaint(); selected_view_->SchedulePaint();
selected_view_ = NULL; selected_view_ = NULL;
...@@ -488,11 +488,11 @@ void AppsGridView::ClearAnySelectedView() { ...@@ -488,11 +488,11 @@ void AppsGridView::ClearAnySelectedView() {
} }
} }
bool AppsGridView::IsSelectedView(const views::View* view) const { bool AppsGridView::IsSelectedView(const AppListItemView* view) const {
return selected_view_ == view; return selected_view_ == view;
} }
void AppsGridView::EnsureViewVisible(const views::View* view) { void AppsGridView::EnsureViewVisible(const AppListItemView* view) {
if (pagination_model_.has_transition()) if (pagination_model_.has_transition())
return; return;
...@@ -762,7 +762,6 @@ void AppsGridView::StopPageFlipTimer() { ...@@ -762,7 +762,6 @@ void AppsGridView::StopPageFlipTimer() {
} }
AppListItemView* AppsGridView::GetItemViewAt(int index) const { AppListItemView* AppsGridView::GetItemViewAt(int index) const {
DCHECK(index >= 0 && index < view_model_.view_size());
return static_cast<AppListItemView*>(view_model_.view_at(index)); return static_cast<AppListItemView*>(view_model_.view_at(index));
} }
...@@ -842,7 +841,7 @@ void AppsGridView::UpdateDragFromReparentItem(Pointer pointer, ...@@ -842,7 +841,7 @@ void AppsGridView::UpdateDragFromReparentItem(Pointer pointer,
UpdateDrag(pointer, drag_point); UpdateDrag(pointer, drag_point);
} }
bool AppsGridView::IsDraggedView(const views::View* view) const { bool AppsGridView::IsDraggedView(const AppListItemView* view) const {
return drag_view_ == view; return drag_view_ == view;
} }
...@@ -884,13 +883,11 @@ void AppsGridView::Prerender() { ...@@ -884,13 +883,11 @@ void AppsGridView::Prerender() {
int start = std::max(0, (selected_page - kPrerenderPages) * tiles_per_page()); int start = std::max(0, (selected_page - kPrerenderPages) * tiles_per_page());
int end = std::min(view_model_.view_size(), int end = std::min(view_model_.view_size(),
(selected_page + 1 + kPrerenderPages) * tiles_per_page()); (selected_page + 1 + kPrerenderPages) * tiles_per_page());
for (int i = start; i < end; i++) { for (int i = start; i < end; i++)
AppListItemView* v = static_cast<AppListItemView*>(view_model_.view_at(i)); GetItemViewAt(i)->Prerender();
v->Prerender();
}
} }
bool AppsGridView::IsAnimatingView(views::View* view) { bool AppsGridView::IsAnimatingView(AppListItemView* view) {
return bounds_animator_.IsAnimating(view); return bounds_animator_.IsAnimating(view);
} }
...@@ -926,7 +923,7 @@ void AppsGridView::Layout() { ...@@ -926,7 +923,7 @@ void AppsGridView::Layout() {
CalculateIdealBounds(); CalculateIdealBounds();
for (int i = 0; i < view_model_.view_size(); ++i) { for (int i = 0; i < view_model_.view_size(); ++i) {
views::View* view = view_model_.view_at(i); AppListItemView* view = GetItemViewAt(i);
if (view != drag_view_) if (view != drag_view_)
view->SetBoundsRect(view_model_.ideal_bounds(i)); view->SetBoundsRect(view_model_.ideal_bounds(i));
} }
...@@ -945,7 +942,7 @@ void AppsGridView::Layout() { ...@@ -945,7 +942,7 @@ void AppsGridView::Layout() {
bool AppsGridView::OnKeyPressed(const ui::KeyEvent& event) { bool AppsGridView::OnKeyPressed(const ui::KeyEvent& event) {
bool handled = false; bool handled = false;
if (selected_view_) if (selected_view_)
handled = selected_view_->OnKeyPressed(event); handled = static_cast<views::View*>(selected_view_)->OnKeyPressed(event);
if (!handled) { if (!handled) {
const int forward_dir = base::i18n::IsRTL() ? -1 : 1; const int forward_dir = base::i18n::IsRTL() ? -1 : 1;
...@@ -1031,7 +1028,7 @@ void AppsGridView::Update() { ...@@ -1031,7 +1028,7 @@ void AppsGridView::Update() {
if (!item_list_ || !item_list_->item_count()) if (!item_list_ || !item_list_->item_count())
return; return;
for (size_t i = 0; i < item_list_->item_count(); ++i) { for (size_t i = 0; i < item_list_->item_count(); ++i) {
views::View* view = CreateViewForItemAtIndex(i); AppListItemView* view = CreateViewForItemAtIndex(i);
view_model_.Add(view, i); view_model_.Add(view, i);
AddChildView(view); AddChildView(view);
} }
...@@ -1060,19 +1057,23 @@ void AppsGridView::UpdatePulsingBlockViews() { ...@@ -1060,19 +1057,23 @@ void AppsGridView::UpdatePulsingBlockViews() {
return; return;
while (pulsing_blocks_model_.view_size() > desired) { while (pulsing_blocks_model_.view_size() > desired) {
views::View* view = pulsing_blocks_model_.view_at(0); PulsingBlockView* view = GetPulsingBlockViewAt(0);
pulsing_blocks_model_.Remove(0); pulsing_blocks_model_.Remove(0);
delete view; delete view;
} }
while (pulsing_blocks_model_.view_size() < desired) { while (pulsing_blocks_model_.view_size() < desired) {
views::View* view = new PulsingBlockView(GetTotalTileSize(), true); PulsingBlockView* view = new PulsingBlockView(GetTotalTileSize(), true);
pulsing_blocks_model_.Add(view, 0); pulsing_blocks_model_.Add(view, 0);
AddChildView(view); AddChildView(view);
} }
} }
views::View* AppsGridView::CreateViewForItemAtIndex(size_t index) { PulsingBlockView* AppsGridView::GetPulsingBlockViewAt(int index) const {
return static_cast<PulsingBlockView*>(pulsing_blocks_model_.view_at(index));
}
AppListItemView* AppsGridView::CreateViewForItemAtIndex(size_t index) {
// The drag_view_ might be pending for deletion, therefore view_model_ // The drag_view_ might be pending for deletion, therefore view_model_
// may have one more item than item_list_. // may have one more item than item_list_.
DCHECK_LE(index, item_list_->item_count()); DCHECK_LE(index, item_list_->item_count());
...@@ -1096,7 +1097,7 @@ void AppsGridView::SetSelectedItemByIndex(const Index& index) { ...@@ -1096,7 +1097,7 @@ void AppsGridView::SetSelectedItemByIndex(const Index& index) {
if (GetIndexOfView(selected_view_) == index) if (GetIndexOfView(selected_view_) == index)
return; return;
views::View* new_selection = GetViewAtIndex(index); AppListItemView* new_selection = GetViewAtIndex(index);
if (!new_selection) if (!new_selection)
return; // Keep current selection. return; // Keep current selection.
...@@ -1117,7 +1118,7 @@ bool AppsGridView::IsValidIndex(const Index& index) const { ...@@ -1117,7 +1118,7 @@ bool AppsGridView::IsValidIndex(const Index& index) const {
} }
AppsGridView::Index AppsGridView::GetIndexOfView( AppsGridView::Index AppsGridView::GetIndexOfView(
const views::View* view) const { const AppListItemView* view) const {
const int model_index = view_model_.GetIndexOfView(view); const int model_index = view_model_.GetIndexOfView(view);
if (model_index == -1) if (model_index == -1)
return Index(); return Index();
...@@ -1125,12 +1126,12 @@ AppsGridView::Index AppsGridView::GetIndexOfView( ...@@ -1125,12 +1126,12 @@ AppsGridView::Index AppsGridView::GetIndexOfView(
return GetIndexFromModelIndex(model_index); return GetIndexFromModelIndex(model_index);
} }
views::View* AppsGridView::GetViewAtIndex(const Index& index) const { AppListItemView* AppsGridView::GetViewAtIndex(const Index& index) const {
if (!IsValidIndex(index)) if (!IsValidIndex(index))
return NULL; return NULL;
const int model_index = GetModelIndexFromIndex(index); const int model_index = GetModelIndexFromIndex(index);
return view_model_.view_at(model_index); return GetItemViewAt(model_index);
} }
AppsGridView::Index AppsGridView::GetLastViewIndex() const { AppsGridView::Index AppsGridView::GetLastViewIndex() const {
...@@ -1264,7 +1265,7 @@ void AppsGridView::AnimateToIdealBounds() { ...@@ -1264,7 +1265,7 @@ void AppsGridView::AnimateToIdealBounds() {
CalculateIdealBounds(); CalculateIdealBounds();
for (int i = 0; i < view_model_.view_size(); ++i) { for (int i = 0; i < view_model_.view_size(); ++i) {
views::View* view = view_model_.view_at(i); AppListItemView* view = GetItemViewAt(i);
if (view == drag_view_) if (view == drag_view_)
continue; continue;
...@@ -1296,7 +1297,7 @@ void AppsGridView::AnimateToIdealBounds() { ...@@ -1296,7 +1297,7 @@ void AppsGridView::AnimateToIdealBounds() {
} }
} }
void AppsGridView::AnimationBetweenRows(views::View* view, void AppsGridView::AnimationBetweenRows(AppListItemView* view,
bool animate_current, bool animate_current,
const gfx::Rect& current, const gfx::Rect& current,
bool animate_target, bool animate_target,
...@@ -1717,7 +1718,7 @@ void AppsGridView::OnPageFlipTimer() { ...@@ -1717,7 +1718,7 @@ void AppsGridView::OnPageFlipTimer() {
pagination_model_.SelectPage(page_flip_target_, true); pagination_model_.SelectPage(page_flip_target_, true);
} }
void AppsGridView::MoveItemInModel(views::View* item_view, void AppsGridView::MoveItemInModel(AppListItemView* item_view,
const Index& target) { const Index& target) {
int current_model_index = view_model_.GetIndexOfView(item_view); int current_model_index = view_model_.GetIndexOfView(item_view);
DCHECK_GE(current_model_index, 0); DCHECK_GE(current_model_index, 0);
...@@ -1735,12 +1736,11 @@ void AppsGridView::MoveItemInModel(views::View* item_view, ...@@ -1735,12 +1736,11 @@ void AppsGridView::MoveItemInModel(views::View* item_view,
pagination_model_.SelectPage(target.page, false); pagination_model_.SelectPage(target.page, false);
} }
void AppsGridView::MoveItemToFolder(views::View* item_view, void AppsGridView::MoveItemToFolder(AppListItemView* item_view,
const Index& target) { const Index& target) {
const std::string& source_item_id = const std::string& source_item_id = item_view->item()->id();
static_cast<AppListItemView*>(item_view)->item()->id();
AppListItemView* target_view = AppListItemView* target_view =
static_cast<AppListItemView*>(GetViewAtSlotOnCurrentPage(target.slot)); GetViewDisplayedAtSlotOnCurrentPage(target.slot);
const std::string& target_view_item_id = target_view->item()->id(); const std::string& target_view_item_id = target_view->item()->id();
// Make change to data model. // Make change to data model.
...@@ -1760,7 +1760,7 @@ void AppsGridView::MoveItemToFolder(views::View* item_view, ...@@ -1760,7 +1760,7 @@ void AppsGridView::MoveItemToFolder(views::View* item_view,
int target_view_index = view_model_.GetIndexOfView(target_view); int target_view_index = view_model_.GetIndexOfView(target_view);
gfx::Rect target_view_bounds = target_view->bounds(); gfx::Rect target_view_bounds = target_view->bounds();
DeleteItemViewAtIndex(target_view_index); DeleteItemViewAtIndex(target_view_index);
views::View* target_folder_view = AppListItemView* target_folder_view =
CreateViewForItemAtIndex(folder_item_index); CreateViewForItemAtIndex(folder_item_index);
target_folder_view->SetBoundsRect(target_view_bounds); target_folder_view->SetBoundsRect(target_view_bounds);
view_model_.Add(target_folder_view, target_view_index); view_model_.Add(target_folder_view, target_view_index);
...@@ -1781,12 +1781,12 @@ void AppsGridView::MoveItemToFolder(views::View* item_view, ...@@ -1781,12 +1781,12 @@ void AppsGridView::MoveItemToFolder(views::View* item_view,
UpdatePaging(); UpdatePaging();
} }
void AppsGridView::ReparentItemForReorder(views::View* item_view, void AppsGridView::ReparentItemForReorder(AppListItemView* item_view,
const Index& target) { const Index& target) {
item_list_->RemoveObserver(this); item_list_->RemoveObserver(this);
model_->RemoveObserver(this); model_->RemoveObserver(this);
AppListItem* reparent_item = static_cast<AppListItemView*>(item_view)->item(); AppListItem* reparent_item = item_view->item();
DCHECK(reparent_item->IsInFolder()); DCHECK(reparent_item->IsInFolder());
const std::string source_folder_id = reparent_item->folder_id(); const std::string source_folder_id = reparent_item->folder_id();
AppListFolderItem* source_folder = AppListFolderItem* source_folder =
...@@ -1823,19 +1823,19 @@ void AppsGridView::ReparentItemForReorder(views::View* item_view, ...@@ -1823,19 +1823,19 @@ void AppsGridView::ReparentItemForReorder(views::View* item_view,
UpdatePaging(); UpdatePaging();
} }
void AppsGridView::ReparentItemToAnotherFolder(views::View* item_view, void AppsGridView::ReparentItemToAnotherFolder(AppListItemView* item_view,
const Index& target) { const Index& target) {
DCHECK(IsDraggingForReparentInRootLevelGridView()); DCHECK(IsDraggingForReparentInRootLevelGridView());
AppListItemView* target_view = AppListItemView* target_view =
static_cast<AppListItemView*>(GetViewAtSlotOnCurrentPage(target.slot)); GetViewDisplayedAtSlotOnCurrentPage(target.slot);
if (!target_view) if (!target_view)
return; return;
// Make change to data model. // Make change to data model.
item_list_->RemoveObserver(this); item_list_->RemoveObserver(this);
AppListItem* reparent_item = static_cast<AppListItemView*>(item_view)->item(); AppListItem* reparent_item = item_view->item();
DCHECK(reparent_item->IsInFolder()); DCHECK(reparent_item->IsInFolder());
const std::string source_folder_id = reparent_item->folder_id(); const std::string source_folder_id = reparent_item->folder_id();
AppListFolderItem* source_folder = AppListFolderItem* source_folder =
...@@ -1867,7 +1867,7 @@ void AppsGridView::ReparentItemToAnotherFolder(views::View* item_view, ...@@ -1867,7 +1867,7 @@ void AppsGridView::ReparentItemToAnotherFolder(views::View* item_view,
if (item_list_->FindItemIndex(new_folder_id, &new_folder_index)) { if (item_list_->FindItemIndex(new_folder_id, &new_folder_index)) {
int target_view_index = view_model_.GetIndexOfView(target_view); int target_view_index = view_model_.GetIndexOfView(target_view);
DeleteItemViewAtIndex(target_view_index); DeleteItemViewAtIndex(target_view_index);
views::View* new_folder_view = AppListItemView* new_folder_view =
CreateViewForItemAtIndex(new_folder_index); CreateViewForItemAtIndex(new_folder_index);
view_model_.Add(new_folder_view, target_view_index); view_model_.Add(new_folder_view, target_view_index);
AddChildView(new_folder_view); AddChildView(new_folder_view);
...@@ -1917,7 +1917,7 @@ void AppsGridView::RemoveLastItemFromReparentItemFolderIfNecessary( ...@@ -1917,7 +1917,7 @@ void AppsGridView::RemoveLastItemFromReparentItemFolderIfNecessary(
NOTREACHED(); NOTREACHED();
return; return;
} }
views::View* last_item_view = CreateViewForItemAtIndex(last_item_index); AppListItemView* last_item_view = CreateViewForItemAtIndex(last_item_index);
view_model_.Add(last_item_view, last_item_index); view_model_.Add(last_item_view, last_item_index);
AddChildView(last_item_view); AddChildView(last_item_view);
} }
...@@ -1946,15 +1946,12 @@ void AppsGridView::CancelFolderItemReparent(AppListItemView* drag_item_view) { ...@@ -1946,15 +1946,12 @@ void AppsGridView::CancelFolderItemReparent(AppListItemView* drag_item_view) {
void AppsGridView::CancelContextMenusOnCurrentPage() { void AppsGridView::CancelContextMenusOnCurrentPage() {
int start = pagination_model_.selected_page() * tiles_per_page(); int start = pagination_model_.selected_page() * tiles_per_page();
int end = std::min(view_model_.view_size(), start + tiles_per_page()); int end = std::min(view_model_.view_size(), start + tiles_per_page());
for (int i = start; i < end; ++i) { for (int i = start; i < end; ++i)
AppListItemView* view = GetItemViewAt(i)->CancelContextMenu();
static_cast<AppListItemView*>(view_model_.view_at(i));
view->CancelContextMenu();
}
} }
void AppsGridView::DeleteItemViewAtIndex(int index) { void AppsGridView::DeleteItemViewAtIndex(int index) {
views::View* item_view = view_model_.view_at(index); AppListItemView* item_view = GetItemViewAt(index);
view_model_.Remove(index); view_model_.Remove(index);
if (item_view == drag_view_) if (item_view == drag_view_)
drag_view_ = NULL; drag_view_ = NULL;
...@@ -1974,6 +1971,7 @@ void AppsGridView::ButtonPressed(views::Button* sender, ...@@ -1974,6 +1971,7 @@ void AppsGridView::ButtonPressed(views::Button* sender,
if (strcmp(sender->GetClassName(), AppListItemView::kViewClassName)) if (strcmp(sender->GetClassName(), AppListItemView::kViewClassName))
return; return;
AppListItemView* pressed_item_view = static_cast<AppListItemView*>(sender);
if (delegate_) { if (delegate_) {
// Always set the previous activated_folder_item_view_ to be visible. This // Always set the previous activated_folder_item_view_ to be visible. This
...@@ -1983,22 +1981,19 @@ void AppsGridView::ButtonPressed(views::Button* sender, ...@@ -1983,22 +1981,19 @@ void AppsGridView::ButtonPressed(views::Button* sender,
if (!folder_delegate_) { if (!folder_delegate_) {
if (activated_folder_item_view_) if (activated_folder_item_view_)
activated_folder_item_view_->SetVisible(true); activated_folder_item_view_->SetVisible(true);
AppListItemView* pressed_item_view =
static_cast<AppListItemView*>(sender);
if (IsFolderItem(pressed_item_view->item())) if (IsFolderItem(pressed_item_view->item()))
activated_folder_item_view_ = pressed_item_view; activated_folder_item_view_ = pressed_item_view;
else else
activated_folder_item_view_ = NULL; activated_folder_item_view_ = NULL;
} }
delegate_->ActivateApp(static_cast<AppListItemView*>(sender)->item(), delegate_->ActivateApp(pressed_item_view->item(), event.flags());
event.flags());
} }
} }
void AppsGridView::OnListItemAdded(size_t index, AppListItem* item) { void AppsGridView::OnListItemAdded(size_t index, AppListItem* item) {
EndDrag(true); EndDrag(true);
views::View* view = CreateViewForItemAtIndex(index); AppListItemView* view = CreateViewForItemAtIndex(index);
view_model_.Add(view, index); view_model_.Add(view, index);
AddChildView(view); AddChildView(view);
...@@ -2062,7 +2057,9 @@ void AppsGridView::OnAppListModelStatusChanged() { ...@@ -2062,7 +2057,9 @@ void AppsGridView::OnAppListModelStatusChanged() {
SchedulePaint(); SchedulePaint();
} }
void AppsGridView::SetViewHidden(views::View* view, bool hide, bool immediate) { void AppsGridView::SetViewHidden(AppListItemView* view,
bool hide,
bool immediate) {
ui::ScopedLayerAnimationSettings animator(view->layer()->GetAnimator()); ui::ScopedLayerAnimationSettings animator(view->layer()->GetAnimator());
animator.SetPreemptionStrategy( animator.SetPreemptionStrategy(
immediate ? ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET : immediate ? ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET :
...@@ -2082,12 +2079,11 @@ bool AppsGridView::EnableFolderDragDropUI() { ...@@ -2082,12 +2079,11 @@ bool AppsGridView::EnableFolderDragDropUI() {
} }
bool AppsGridView::CanDropIntoTarget(const Index& drop_target) const { bool AppsGridView::CanDropIntoTarget(const Index& drop_target) const {
views::View* target_view = GetViewAtIndex(drop_target); AppListItemView* target_view = GetViewAtIndex(drop_target);
if (!target_view) if (!target_view)
return false; return false;
AppListItem* target_item = AppListItem* target_item = target_view->item();
static_cast<AppListItemView*>(target_view)->item();
// Items can be dropped into non-folders (which have no children) or folders // Items can be dropped into non-folders (which have no children) or folders
// that have fewer than the max allowed items. // that have fewer than the max allowed items.
// OEM folder does not allow to drag/drop other items in it. // OEM folder does not allow to drag/drop other items in it.
...@@ -2130,7 +2126,7 @@ gfx::Rect AppsGridView::GetExpectedTileBounds(int row, int col) const { ...@@ -2130,7 +2126,7 @@ gfx::Rect AppsGridView::GetExpectedTileBounds(int row, int col) const {
return tile_bounds; return tile_bounds;
} }
views::View* AppsGridView::GetViewAtSlotOnCurrentPage(int slot) { AppListItemView* AppsGridView::GetViewDisplayedAtSlotOnCurrentPage(int slot) {
if (slot < 0) if (slot < 0)
return NULL; return NULL;
...@@ -2140,7 +2136,7 @@ views::View* AppsGridView::GetViewAtSlotOnCurrentPage(int slot) { ...@@ -2140,7 +2136,7 @@ views::View* AppsGridView::GetViewAtSlotOnCurrentPage(int slot) {
gfx::Rect tile_rect = GetExpectedTileBounds(row, col); gfx::Rect tile_rect = GetExpectedTileBounds(row, col);
for (int i = 0; i < view_model_.view_size(); ++i) { 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_) if (view->bounds() == tile_rect && view != drag_view_)
return view; return view;
} }
...@@ -2150,8 +2146,7 @@ views::View* AppsGridView::GetViewAtSlotOnCurrentPage(int slot) { ...@@ -2150,8 +2146,7 @@ views::View* AppsGridView::GetViewAtSlotOnCurrentPage(int slot) {
void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index,
bool is_target_folder) { bool is_target_folder) {
AppListItemView* target_view = AppListItemView* target_view =
static_cast<AppListItemView*>( GetViewDisplayedAtSlotOnCurrentPage(target_index.slot);
GetViewAtSlotOnCurrentPage(target_index.slot));
if (target_view) if (target_view)
target_view->SetAsAttemptedFolderTarget(is_target_folder); target_view->SetAsAttemptedFolderTarget(is_target_folder);
} }
......
...@@ -51,6 +51,7 @@ class AppsGridViewDelegate; ...@@ -51,6 +51,7 @@ class AppsGridViewDelegate;
class AppsGridViewFolderDelegate; class AppsGridViewFolderDelegate;
class PageSwitcher; class PageSwitcher;
class PaginationController; class PaginationController;
class PulsingBlockView;
// AppsGridView displays a grid for AppListItemList sub model. // AppsGridView displays a grid for AppListItemList sub model.
class APP_LIST_EXPORT AppsGridView : public views::View, class APP_LIST_EXPORT AppsGridView : public views::View,
...@@ -88,14 +89,14 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -88,14 +89,14 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// |item_list|. // |item_list|.
void SetItemList(AppListItemList* item_list); void SetItemList(AppListItemList* item_list);
void SetSelectedView(views::View* view); void SetSelectedView(AppListItemView* view);
void ClearSelectedView(views::View* view); void ClearSelectedView(AppListItemView* view);
void ClearAnySelectedView(); void ClearAnySelectedView();
bool IsSelectedView(const views::View* view) const; bool IsSelectedView(const AppListItemView* view) const;
// Ensures the view is visible. Note that if there is a running page // Ensures the view is visible. Note that if there is a running page
// transition, this does nothing. // transition, this does nothing.
void EnsureViewVisible(const views::View* view); void EnsureViewVisible(const AppListItemView* view);
void InitiateDrag(AppListItemView* view, void InitiateDrag(AppListItemView* view,
Pointer pointer, Pointer pointer,
...@@ -109,7 +110,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -109,7 +110,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// coordinates. // coordinates.
void UpdateDrag(Pointer pointer, const gfx::Point& point); void UpdateDrag(Pointer pointer, const gfx::Point& point);
void EndDrag(bool cancel); void EndDrag(bool cancel);
bool IsDraggedView(const views::View* view) const; bool IsDraggedView(const AppListItemView* view) const;
void ClearDragState(); void ClearDragState();
void SetDragViewVisible(bool visible); void SetDragViewVisible(bool visible);
...@@ -121,7 +122,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -121,7 +122,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
void Prerender(); void Prerender();
// Return true if the |bounds_animator_| is animating |view|. // Return true if the |bounds_animator_| is animating |view|.
bool IsAnimatingView(views::View* view); bool IsAnimatingView(AppListItemView* view);
bool has_dragged_view() const { return drag_view_ != NULL; } bool has_dragged_view() const { return drag_view_ != NULL; }
bool dragging() const { return drag_pointer_ != NONE; } bool dragging() const { return drag_pointer_ != NONE; }
...@@ -258,7 +259,11 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -258,7 +259,11 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// number of apps. // number of apps.
void UpdatePulsingBlockViews(); void UpdatePulsingBlockViews();
views::View* CreateViewForItemAtIndex(size_t index); // Returns the pulsing block view of the item at |index| in the pulsing block
// model.
PulsingBlockView* GetPulsingBlockViewAt(int index) const;
AppListItemView* CreateViewForItemAtIndex(size_t index);
// Convert between the model index and the visual index. The model index // Convert between the model index and the visual index. The model index
// is the index of the item in AppListModel. The visual index is the Index // is the index of the item in AppListModel. The visual index is the Index
...@@ -269,8 +274,8 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -269,8 +274,8 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
void SetSelectedItemByIndex(const Index& index); void SetSelectedItemByIndex(const Index& index);
bool IsValidIndex(const Index& index) const; bool IsValidIndex(const Index& index) const;
Index GetIndexOfView(const views::View* view) const; Index GetIndexOfView(const AppListItemView* view) const;
views::View* GetViewAtIndex(const Index& index) const; AppListItemView* GetViewAtIndex(const Index& index) const;
// Gets the index of the AppListItemView at the end of the view model. // Gets the index of the AppListItemView at the end of the view model.
Index GetLastViewIndex() const; Index GetLastViewIndex() const;
...@@ -287,7 +292,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -287,7 +292,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// to succeeding slot of |current|. |animate_current| controls whether to run // to succeeding slot of |current|. |animate_current| controls whether to run
// fading out animation from |current|. |animate_target| controls whether to // fading out animation from |current|. |animate_target| controls whether to
// run fading in animation to |target|. // run fading in animation to |target|.
void AnimationBetweenRows(views::View* view, void AnimationBetweenRows(AppListItemView* view,
bool animate_current, bool animate_current,
const gfx::Rect& current, const gfx::Rect& current,
bool animate_target, bool animate_target,
...@@ -327,20 +332,21 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -327,20 +332,21 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
void OnPageFlipTimer(); void OnPageFlipTimer();
// Updates |model_| to move item represented by |item_view| to |target| slot. // Updates |model_| to move item represented by |item_view| to |target| slot.
void MoveItemInModel(views::View* item_view, const Index& target); void MoveItemInModel(AppListItemView* item_view, const Index& target);
// Updates |model_| to move item represented by |item_view| into a folder // Updates |model_| to move item represented by |item_view| into a folder
// containing item located at |target| slot, also update |view_model_| for // containing item located at |target| slot, also update |view_model_| for
// the related view changes. // the related view changes.
void MoveItemToFolder(views::View* item_view, const Index& target); void MoveItemToFolder(AppListItemView* item_view, const Index& target);
// Updates both data model and view_model_ for re-parenting a folder item to a // Updates both data model and view_model_ for re-parenting a folder item to a
// new position in top level item list. // new position in top level item list.
void ReparentItemForReorder(views::View* item_view, const Index& target); void ReparentItemForReorder(AppListItemView* item_view, const Index& target);
// Updates both data model and view_model_ for re-parenting a folder item // Updates both data model and view_model_ for re-parenting a folder item
// to anther folder target. // to anther folder target.
void ReparentItemToAnotherFolder(views::View* item_view, const Index& target); void ReparentItemToAnotherFolder(AppListItemView* item_view,
const Index& target);
// If there is only 1 item left in the source folder after reparenting an item // If there is only 1 item left in the source folder after reparenting an item
// from it, updates both data model and view_model_ for removing last item // from it, updates both data model and view_model_ for removing last item
...@@ -390,7 +396,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -390,7 +396,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// changing the size of it. If |immediate| is set the change will be // changing the size of it. If |immediate| is set the change will be
// immediately applied - otherwise it will change gradually. // immediately applied - otherwise it will change gradually.
// If |hide| is set the view will get hidden, otherwise it gets shown. // If |hide| is set the view will get hidden, otherwise it gets shown.
void SetViewHidden(views::View* view, bool hide, bool immediate); void SetViewHidden(AppListItemView* view, bool hide, bool immediate);
// Whether the folder drag-and-drop UI should be enabled. // Whether the folder drag-and-drop UI should be enabled.
bool EnableFolderDragDropUI(); bool EnableFolderDragDropUI();
...@@ -412,9 +418,11 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -412,9 +418,11 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// Gets the bounds of the tile located at |row| and |col| on the current page. // Gets the bounds of the tile located at |row| and |col| on the current page.
gfx::Rect GetExpectedTileBounds(int row, int col) const; gfx::Rect GetExpectedTileBounds(int row, int col) const;
// Gets the item view located at |slot| on the current page. If there is // Gets the item view currently displayed at |slot| on the current page. If
// no item located at |slot|, returns NULL. // there is no item displayed at |slot|, returns NULL. Note that this finds an
views::View* GetViewAtSlotOnCurrentPage(int slot); // item *displayed* at a slot, which may differ from the item's location in
// the model (as it may have been temporarily moved during a drag operation).
AppListItemView* GetViewDisplayedAtSlotOnCurrentPage(int slot);
// Sets state of the view with |target_index| to |is_target_folder| for // Sets state of the view with |target_index| to |is_target_folder| for
// dropping |drag_view_|. // dropping |drag_view_|.
...@@ -474,13 +482,13 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -474,13 +482,13 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
int cols_; int cols_;
int rows_per_page_; int rows_per_page_;
// Tracks app item views. There is a view per item in |model_|. // List of AppListItemViews. There is a view per item in |model_|.
views::ViewModel view_model_; views::ViewModel view_model_;
// Tracks pulsing block views. // List of PulsingBlockViews.
views::ViewModel pulsing_blocks_model_; views::ViewModel pulsing_blocks_model_;
views::View* selected_view_; AppListItemView* selected_view_;
AppListItemView* drag_view_; AppListItemView* drag_view_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment