Chromium Code Reviews| Index: ash/shelf/shelf_button.cc |
| diff --git a/ash/shelf/shelf_button.cc b/ash/shelf/shelf_button.cc |
| index 7aa67dcba1e31b223df0f5e7e67efc6be607e2e2..b7e5a266599197608dd508fd233ce722d0fa1610 100644 |
| --- a/ash/shelf/shelf_button.cc |
| +++ b/ash/shelf/shelf_button.cc |
| @@ -28,6 +28,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 +49,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; |
| @@ -243,13 +250,17 @@ class ShelfButton::BarView : public views::ImageView, |
| const char ShelfButton::kViewClassName[] = "ash/ShelfButton"; |
| ShelfButton::ShelfButton(ShelfView* shelf_view) |
| - : CustomButton(shelf_view), |
| + : CustomButton(nullptr), |
| 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 +343,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 +496,30 @@ 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_->WillIgnoreEventOnButton(this, event)) |
| + return false; |
| + |
| + return CustomButton::ShouldEnterPushedState(event); |
| +} |
| + |
| +bool ShelfButton::ShouldShowInkDropHighlight() const { |
|
bruthig
2016/06/09 03:25:59
I can't remember what we discussed in person. Am
mohsen
2016/06/09 21:24:50
Yes. We don't want hover effect on shelf buttons.
bruthig
2016/06/10 15:25:19
Acknowledged.
|
| + return false; |
| +} |
| + |
| +void ShelfButton::NotifyClick(const ui::Event& event) { |
| + CustomButton::NotifyClick(event); |
| + shelf_view_->ButtonPressed(this, event, ink_drop()); |
| +} |
| + |
| void ShelfButton::UpdateState() { |
| UpdateBar(); |
| Shelf* shelf = shelf_view_->shelf(); |