| Index: ash/shelf/app_list_button.cc
|
| diff --git a/ash/shelf/app_list_button.cc b/ash/shelf/app_list_button.cc
|
| index 885b534f0ef1a4b3aea6bb8ff317e35c747a1fdc..38bb8aa31c45a89481ff2c05eaa46177a6a201a7 100644
|
| --- a/ash/shelf/app_list_button.cc
|
| +++ b/ash/shelf/app_list_button.cc
|
| @@ -26,6 +26,7 @@
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/paint_vector_icon.h"
|
| #include "ui/gfx/vector_icons_public.h"
|
| +#include "ui/views/animation/square_ink_drop_ripple.h"
|
| #include "ui/views/painter.h"
|
|
|
| namespace ash {
|
| @@ -39,6 +40,11 @@ AppListButton::AppListButton(InkDropButtonListener* listener,
|
| draw_background_as_active_(false),
|
| listener_(listener),
|
| shelf_view_(shelf_view) {
|
| + if (ash::MaterialDesignController::IsShelfMaterial()) {
|
| + SetHasInkDrop(true, false);
|
| + set_ink_drop_base_color(kShelfInkDropBaseColor);
|
| + set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity);
|
| + }
|
| SetAccessibleName(
|
| app_list::switches::IsExperimentalAppListEnabled()
|
| ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)
|
| @@ -52,6 +58,14 @@ AppListButton::AppListButton(InkDropButtonListener* listener,
|
|
|
| AppListButton::~AppListButton() {}
|
|
|
| +void AppListButton::OnAppListShown() {
|
| + AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr);
|
| +}
|
| +
|
| +void AppListButton::OnAppListDismissed() {
|
| + AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr);
|
| +}
|
| +
|
| bool AppListButton::OnMousePressed(const ui::MouseEvent& event) {
|
| ImageButton::OnMousePressed(event);
|
| shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event);
|
| @@ -75,10 +89,15 @@ bool AppListButton::OnMouseDragged(const ui::MouseEvent& event) {
|
| }
|
|
|
| void AppListButton::OnGestureEvent(ui::GestureEvent* event) {
|
| + const bool is_material = ash::MaterialDesignController::IsShelfMaterial();
|
| + const bool touch_feedback =
|
| + !is_material && switches::IsTouchFeedbackEnabled();
|
| switch (event->type()) {
|
| case ui::ET_GESTURE_SCROLL_BEGIN:
|
| - if (switches::IsTouchFeedbackEnabled())
|
| + if (touch_feedback)
|
| SetDrawBackgroundAsActive(false);
|
| + else if (is_material)
|
| + AnimateInkDrop(views::InkDropState::HIDDEN, event);
|
| shelf_view_->PointerPressedOnButton(this, ShelfView::TOUCH, *event);
|
| event->SetHandled();
|
| return;
|
| @@ -92,13 +111,15 @@ void AppListButton::OnGestureEvent(ui::GestureEvent* event) {
|
| event->SetHandled();
|
| return;
|
| case ui::ET_GESTURE_TAP_DOWN:
|
| - if (switches::IsTouchFeedbackEnabled())
|
| + if (touch_feedback)
|
| SetDrawBackgroundAsActive(true);
|
| + else if (is_material && !Shell::GetInstance()->IsApplistVisible())
|
| + AnimateInkDrop(views::InkDropState::ACTION_PENDING, event);
|
| ImageButton::OnGestureEvent(event);
|
| break;
|
| case ui::ET_GESTURE_TAP_CANCEL:
|
| case ui::ET_GESTURE_TAP:
|
| - if (switches::IsTouchFeedbackEnabled())
|
| + if (touch_feedback)
|
| SetDrawBackgroundAsActive(false);
|
| ImageButton::OnGestureEvent(event);
|
| break;
|
| @@ -149,17 +170,6 @@ void AppListButton::PaintBackgroundMD(gfx::Canvas* canvas) {
|
|
|
| canvas->DrawCircle(circle_center, kAppListButtonBackgroundRadius,
|
| background_paint);
|
| -
|
| - if (Shell::GetInstance()->GetAppListTargetVisibility() ||
|
| - draw_background_as_active_) {
|
| - SkPaint highlight_paint;
|
| - highlight_paint.setColor(kShelfButtonActivatedHighlightColor);
|
| - highlight_paint.setFlags(SkPaint::kAntiAlias_Flag);
|
| - highlight_paint.setStyle(SkPaint::kFill_Style);
|
| -
|
| - canvas->DrawCircle(circle_center, kAppListButtonBackgroundRadius,
|
| - highlight_paint);
|
| - }
|
| }
|
|
|
| void AppListButton::PaintForegroundMD(gfx::Canvas* canvas,
|
| @@ -241,12 +251,36 @@ void AppListButton::GetAccessibleState(ui::AXViewState* state) {
|
| state->name = shelf_view_->GetTitleForView(this);
|
| }
|
|
|
| +std::unique_ptr<views::InkDropRipple> AppListButton::CreateInkDropRipple()
|
| + const {
|
| + // TODO(mohsen): A circular SquareInkDropRipple is created with equal small
|
| + // and large sizes to mimic a circular flood fill. Replace with an actual
|
| + // flood fill when circular flood fills are implemented.
|
| + auto ink_drop_ripple = new views::SquareInkDropRipple(
|
| + gfx::Size(kAppListButtonBackgroundRadius * 2,
|
| + kAppListButtonBackgroundRadius * 2),
|
| + 0, gfx::Size(2 * kAppListButtonBackgroundRadius,
|
| + 2 * kAppListButtonBackgroundRadius),
|
| + 0, GetContentsBounds().CenterPoint(), GetInkDropBaseColor(),
|
| + ink_drop_visible_opacity());
|
| + ink_drop_ripple->set_activated_shape(views::SquareInkDropRipple::CIRCLE);
|
| + return base::WrapUnique(ink_drop_ripple);
|
| +}
|
| +
|
| void AppListButton::NotifyClick(const ui::Event& event) {
|
| ImageButton::NotifyClick(event);
|
| if (listener_)
|
| listener_->ButtonPressed(this, event, ink_drop());
|
| }
|
|
|
| +bool AppListButton::ShouldEnterPushedState(const ui::Event& event) {
|
| + return !Shell::GetInstance()->IsApplistVisible();
|
| +}
|
| +
|
| +bool AppListButton::ShouldShowInkDropHighlight() const {
|
| + return false;
|
| +}
|
| +
|
| void AppListButton::SetDrawBackgroundAsActive(
|
| bool draw_background_as_active) {
|
| if (draw_background_as_active_ == draw_background_as_active)
|
|
|