| Index: ash/shelf/shelf_button.cc
|
| diff --git a/ash/shelf/shelf_button.cc b/ash/shelf/shelf_button.cc
|
| index 6e91f535133c7aa784899a2fd830b99ebd9c06f0..0f5d112c0e32b15f1d9895984aa45c1f98d86ce3 100644
|
| --- a/ash/shelf/shelf_button.cc
|
| +++ b/ash/shelf/shelf_button.cc
|
| @@ -10,6 +10,7 @@
|
| #include "ash/common/ash_constants.h"
|
| #include "ash/common/material_design/material_design_controller.h"
|
| #include "ash/common/shelf/shelf_constants.h"
|
| +#include "ash/shelf/ink_drop_button_listener.h"
|
| #include "ash/shelf/shelf.h"
|
| #include "ash/shelf/shelf_view.h"
|
| #include "base/time/time.h"
|
| @@ -28,6 +29,7 @@
|
| #include "ui/gfx/image/image.h"
|
| #include "ui/gfx/image/image_skia_operations.h"
|
| #include "ui/gfx/skbitmap_operations.h"
|
| +#include "ui/views/animation/square_ink_drop_ripple.h"
|
| #include "ui/views/controls/image_view.h"
|
|
|
| namespace {
|
| @@ -48,6 +50,12 @@ const SkColor kIndicatorColor = SK_ColorWHITE;
|
| // the highest possible device scale factors.
|
| const int kIndicatorCanvasScale = 5;
|
|
|
| +// Shelf item ripple constants.
|
| +const int kInkDropSmallSize = 48;
|
| +const int kInkDropLargeSize = 60;
|
| +const int kInkDropLargeCornerRadius = 4;
|
| +const SkColor kInkDropBaseColor = SK_ColorWHITE;
|
| +
|
| // Paints an activity indicator on |canvas| whose |size| is specified in DIP.
|
| void PaintIndicatorOnCanvas(gfx::Canvas* canvas, const gfx::Size& size) {
|
| SkPaint paint;
|
| @@ -242,14 +250,19 @@ class ShelfButton::BarView : public views::ImageView,
|
| // static
|
| const char ShelfButton::kViewClassName[] = "ash/ShelfButton";
|
|
|
| -ShelfButton::ShelfButton(ShelfView* shelf_view)
|
| - : CustomButton(shelf_view),
|
| +ShelfButton::ShelfButton(InkDropButtonListener* listener, ShelfView* shelf_view)
|
| + : CustomButton(nullptr),
|
| + listener_(listener),
|
| shelf_view_(shelf_view),
|
| icon_view_(new views::ImageView()),
|
| bar_(new BarView(shelf_view->shelf())),
|
| state_(STATE_NORMAL),
|
| destroyed_flag_(nullptr) {
|
| SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
|
| + if (ash::MaterialDesignController::IsShelfMaterial()) {
|
| + SetHasInkDrop(true);
|
| + set_ink_drop_base_color(kInkDropBaseColor);
|
| + }
|
|
|
| const gfx::ShadowValue kShadows[] = {
|
| gfx::ShadowValue(gfx::Vector2d(0, 2), 0, SkColorSetARGB(0x1A, 0, 0, 0)),
|
| @@ -332,6 +345,10 @@ gfx::Rect ShelfButton::GetIconBounds() const {
|
| return icon_view_->bounds();
|
| }
|
|
|
| +void ShelfButton::OnDragStarted() {
|
| + AnimateInkDrop(views::InkDropState::HIDDEN);
|
| +}
|
| +
|
| void ShelfButton::ShowContextMenu(const gfx::Point& p,
|
| ui::MenuSourceType source_type) {
|
| if (!context_menu_controller())
|
| @@ -481,6 +498,31 @@ void ShelfButton::OnGestureEvent(ui::GestureEvent* event) {
|
| }
|
| }
|
|
|
| +std::unique_ptr<views::InkDropRipple> ShelfButton::CreateInkDropRipple() const {
|
| + return base::WrapUnique(new views::SquareInkDropRipple(
|
| + gfx::Size(kInkDropLargeSize, kInkDropLargeSize),
|
| + kInkDropLargeCornerRadius,
|
| + gfx::Size(kInkDropSmallSize, kInkDropSmallSize),
|
| + kInkDropSmallCornerRadius, GetInkDropCenter(), GetInkDropBaseColor()));
|
| +}
|
| +
|
| +bool ShelfButton::ShouldEnterPushedState(const ui::Event& event) {
|
| + if (!shelf_view_->ShouldEventActivateButton(this, event))
|
| + return false;
|
| +
|
| + return CustomButton::ShouldEnterPushedState(event);
|
| +}
|
| +
|
| +bool ShelfButton::ShouldShowInkDropHighlight() const {
|
| + return false;
|
| +}
|
| +
|
| +void ShelfButton::NotifyClick(const ui::Event& event) {
|
| + CustomButton::NotifyClick(event);
|
| + if (listener_)
|
| + listener_->ButtonPressed(this, event, ink_drop());
|
| +}
|
| +
|
| void ShelfButton::UpdateState() {
|
| UpdateBar();
|
| Shelf* shelf = shelf_view_->shelf();
|
|
|