Chromium Code Reviews| 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..96f47a602e6960713927e0f51f03542afc1b529d 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,10 @@ 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); |
| + } |
| SetAccessibleName( |
| app_list::switches::IsExperimentalAppListEnabled() |
| ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE) |
| @@ -52,6 +57,14 @@ AppListButton::AppListButton(InkDropButtonListener* listener, |
| AppListButton::~AppListButton() {} |
| +void AppListButton::OnAppListShown() { |
| + AnimateInkDrop(views::InkDropState::ACTIVATED); |
| +} |
| + |
| +void AppListButton::OnAppListDismissed() { |
| + AnimateInkDrop(views::InkDropState::DEACTIVATED); |
| +} |
| + |
| bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { |
| ImageButton::OnMousePressed(event); |
| shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event); |
| @@ -75,10 +88,14 @@ bool AppListButton::OnMouseDragged(const ui::MouseEvent& event) { |
| } |
| void AppListButton::OnGestureEvent(ui::GestureEvent* event) { |
| + bool is_material = ash::MaterialDesignController::IsShelfMaterial(); |
|
bruthig
2016/06/17 17:58:45
nit: const, same below
mohsen
2016/06/18 06:25:15
Done.
|
| + 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); |
| shelf_view_->PointerPressedOnButton(this, ShelfView::TOUCH, *event); |
| event->SetHandled(); |
| return; |
| @@ -92,15 +109,19 @@ 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); |
| 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); |
| + if (is_material && !Shell::GetInstance()->GetAppListTargetVisibility()) |
| + AnimateInkDrop(views::InkDropState::HIDDEN); |
|
bruthig
2016/06/17 17:58:45
What's the use case for this? Won't the ripple be
mohsen
2016/06/18 06:25:15
I guess this was needed for when default gesture h
|
| break; |
| default: |
| ImageButton::OnGestureEvent(event); |
| @@ -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,35 @@ 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, GetInkDropCenter(), GetInkDropBaseColor()); |
| + 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) |