Commit d957303a authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Use button callback instead of listener and misc cleanup.

Bug: 772945
Change-Id: Id3e59075546185b145f7389a2bcf30388ac59060
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2464322
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816227}
parent 6bda43d7
......@@ -315,7 +315,7 @@ AppListItemView::AppListItemView(AppsGridView* apps_grid_view,
AppListItem* item,
AppListViewDelegate* delegate,
bool is_in_folder)
: Button(apps_grid_view),
: Button(),
is_folder_(item->GetItemType() == AppListFolderItem::kItemType),
item_weak_(item),
delegate_(delegate),
......
......@@ -397,8 +397,7 @@ AppsGridView::AppsGridView(ContentsView* contents_view,
AppsGridViewFolderDelegate* folder_delegate)
: folder_delegate_(folder_delegate),
contents_view_(contents_view),
page_flip_delay_in_ms_(kPageFlipDelayInMsFullscreen),
view_structure_(this) {
page_flip_delay_in_ms_(kPageFlipDelayInMsFullscreen) {
DCHECK(contents_view_);
SetPaintToLayer(ui::LAYER_NOT_DRAWN);
// Clip any icons that are outside the grid view's bounds. These icons would
......@@ -1397,6 +1396,9 @@ std::unique_ptr<AppListItemView> AppsGridView::CreateViewForItemAtIndex(
std::unique_ptr<AppListItemView> view = std::make_unique<AppListItemView>(
this, item_list_->item_at(index),
contents_view_->GetAppListMainView()->view_delegate());
view->set_callback(base::BindRepeating(
&AppsGridView::OnAppListItemViewPressed, base::Unretained(this),
base::Unretained(view.get())));
return view;
}
......@@ -2891,14 +2893,11 @@ bool AppsGridView::IsPointWithinBottomDragBuffer(
point_in_parent.y() < kBottomDragBufferMax;
}
void AppsGridView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
void AppsGridView::OnAppListItemViewPressed(AppListItemView* pressed_item_view,
const ui::Event& event) {
if (dragging())
return;
if (strcmp(sender->GetClassName(), AppListItemView::kViewClassName))
return;
if (contents_view_->apps_container_view()
->app_list_folder_view()
->IsAnimationRunning()) {
......@@ -2909,7 +2908,6 @@ void AppsGridView::ButtonPressed(views::Button* sender,
// prevents a case where the item would remain hidden due the
// |activated_folder_item_view_| changing during the animation. We only
// need to track |activated_folder_item_view_| in the root level grid view.
AppListItemView* pressed_item_view = static_cast<AppListItemView*>(sender);
if (!folder_delegate_) {
if (activated_folder_item_view_)
activated_folder_item_view_->SetVisible(true);
......
......@@ -34,15 +34,10 @@
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/views/animation/bounds_animator.h"
#include "ui/views/animation/bounds_animator_observer.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/view.h"
#include "ui/views/view_model.h"
namespace views {
class ButtonListener;
}
namespace ash {
namespace test {
......@@ -61,7 +56,7 @@ class GhostImageView;
// Represents the index to an item view in the grid.
struct APP_LIST_EXPORT GridIndex {
GridIndex() : page(-1), slot(-1) {}
GridIndex() = default;
GridIndex(int page, int slot) : page(page), slot(slot) {}
bool operator==(const GridIndex& other) const {
......@@ -75,13 +70,12 @@ struct APP_LIST_EXPORT GridIndex {
}
std::string ToString() const;
int page; // Which page an item view is on.
int slot; // Which slot in the page an item view is in.
int page = -1; // Which page an item view is on.
int slot = -1; // Which slot in the page an item view is in.
};
// AppsGridView displays a grid for AppListItemList sub model.
class APP_LIST_EXPORT AppsGridView : public views::View,
public views::ButtonListener,
public AppListItemListObserver,
public PaginationModelObserver,
public AppListModelObserver,
......@@ -512,8 +506,9 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// shelf.
bool IsPointWithinBottomDragBuffer(const gfx::Point& point) const;
// Overridden from views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// AppListItemView pressed callback binds here:
void OnAppListItemViewPressed(AppListItemView* pressed_item_view,
const ui::Event& event);
// Overridden from AppListItemListObserver:
void OnListItemAdded(size_t index, AppListItem* item) override;
......@@ -874,7 +869,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
bool is_end_gesture_ = false;
// view structure used only for non-folder.
PagedViewStructure view_structure_;
PagedViewStructure view_structure_{this};
// True if an extra page is opened after the user drags an app to the bottom
// of last page with intention to put it in a new page. This is only used for
......
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