Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/shelf/shelf_button.h" | 5 #include "ash/shelf/shelf_button.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/shelf/ink_drop_button_listener.h" | 10 #include "ash/shelf/ink_drop_button_listener.h" |
| 11 #include "ash/shelf/shelf_constants.h" | 11 #include "ash/shelf/shelf_constants.h" |
| 12 #include "ash/shelf/shelf_view.h" | 12 #include "ash/shelf/shelf_view.h" |
| 13 #include "ash/shelf/wm_shelf.h" | 13 #include "ash/shelf/wm_shelf.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "skia/ext/image_operations.h" | 16 #include "skia/ext/image_operations.h" |
| 17 #include "ui/accessibility/ax_node_data.h" | 17 #include "ui/accessibility/ax_node_data.h" |
| 18 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
| 19 #include "ui/gfx/animation/animation_delegate.h" | 19 #include "ui/gfx/animation/animation_delegate.h" |
| 20 #include "ui/gfx/animation/throb_animation.h" | 20 #include "ui/gfx/animation/throb_animation.h" |
| 21 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
| 22 #include "ui/gfx/geometry/vector2d.h" | 22 #include "ui/gfx/geometry/vector2d.h" |
| 23 #include "ui/gfx/image/image_skia_operations.h" | 23 #include "ui/gfx/image/image_skia_operations.h" |
| 24 #include "ui/gfx/scoped_canvas.h" | 24 #include "ui/gfx/scoped_canvas.h" |
| 25 #include "ui/gfx/skbitmap_operations.h" | 25 #include "ui/gfx/skbitmap_operations.h" |
| 26 #include "ui/views/animation/ink_drop_impl.h" | 26 #include "ui/views/animation/ink_drop_impl.h" |
| 27 #include "ui/views/animation/square_ink_drop_ripple.h" | 27 #include "ui/views/animation/square_ink_drop_ripple.h" |
| 28 #include "ui/views/controls/image_view.h" | 28 #include "ui/views/controls/image_view.h" |
| 29 #include "ui/views/controls/menu/menu_controller.h" | |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 const int kIconSize = 32; | 33 const int kIconSize = 32; |
| 33 const int kAttentionThrobDurationMS = 800; | 34 const int kAttentionThrobDurationMS = 800; |
| 34 const int kMaxAnimationSeconds = 10; | 35 const int kMaxAnimationSeconds = 10; |
| 35 const int kIndicatorOffsetFromBottom = 3; | 36 const int kIndicatorOffsetFromBottom = 3; |
| 36 const int kIndicatorRadiusDip = 2; | 37 const int kIndicatorRadiusDip = 2; |
| 37 const SkColor kIndicatorColor = SK_ColorWHITE; | 38 const SkColor kIndicatorColor = SK_ColorWHITE; |
| 38 | 39 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 return; | 455 return; |
| 455 case ui::ET_GESTURE_SCROLL_UPDATE: | 456 case ui::ET_GESTURE_SCROLL_UPDATE: |
| 456 shelf_view_->PointerDraggedOnButton(this, ShelfView::TOUCH, *event); | 457 shelf_view_->PointerDraggedOnButton(this, ShelfView::TOUCH, *event); |
| 457 event->SetHandled(); | 458 event->SetHandled(); |
| 458 return; | 459 return; |
| 459 case ui::ET_GESTURE_SCROLL_END: | 460 case ui::ET_GESTURE_SCROLL_END: |
| 460 case ui::ET_SCROLL_FLING_START: | 461 case ui::ET_SCROLL_FLING_START: |
| 461 shelf_view_->PointerReleasedOnButton(this, ShelfView::TOUCH, false); | 462 shelf_view_->PointerReleasedOnButton(this, ShelfView::TOUCH, false); |
| 462 event->SetHandled(); | 463 event->SetHandled(); |
| 463 return; | 464 return; |
| 465 case ui::ET_GESTURE_LONG_TAP: { | |
| 466 views::MenuController* controller = | |
|
msw
2017/05/17 23:03:30
Can you comment on what this is doing and why?
minch1
2017/05/18 17:42:57
1.LONG_PRESS the shelf items until the context men
msw
2017/05/18 20:42:20
It's not clear to me (at least from that explanati
minch1
2017/05/18 22:02:53
We handled the LONG_TAP here to make it will not o
msw
2017/05/18 22:14:47
Right, I don't understand *why* we don't want the
| |
| 467 views::MenuController::GetActiveInstance(); | |
| 468 if (controller) | |
| 469 controller->set_owner_needs_gesture_events(false); | |
|
sky
2017/05/18 16:33:30
Instead of changing the menu code, could you accom
minch1
2017/05/18 17:42:57
I think the reason we need to transfer events here
xiyuan
2017/05/18 18:00:47
Each widget has a GestureProvider that translates
sky
2017/05/18 19:43:12
Why is that a problem though? Shouldn't the user c
minch1
2017/05/18 22:02:53
I guess this is a requirement from UX?
| |
| 470 event->SetHandled(); | |
| 471 return; | |
| 472 } | |
| 464 default: | 473 default: |
| 465 return CustomButton::OnGestureEvent(event); | 474 return CustomButton::OnGestureEvent(event); |
| 466 } | 475 } |
| 467 } | 476 } |
| 468 | 477 |
| 469 std::unique_ptr<views::InkDropRipple> ShelfButton::CreateInkDropRipple() const { | 478 std::unique_ptr<views::InkDropRipple> ShelfButton::CreateInkDropRipple() const { |
| 470 return base::MakeUnique<views::SquareInkDropRipple>( | 479 return base::MakeUnique<views::SquareInkDropRipple>( |
| 471 gfx::Size(kInkDropLargeSize, kInkDropLargeSize), | 480 gfx::Size(kInkDropLargeSize, kInkDropLargeSize), |
| 472 kInkDropLargeCornerRadius, | 481 kInkDropLargeCornerRadius, |
| 473 gfx::Size(kInkDropSmallSize, kInkDropSmallSize), | 482 gfx::Size(kInkDropSmallSize, kInkDropSmallSize), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 icon_view_->SetHorizontalAlignment(is_horizontal_shelf | 514 icon_view_->SetHorizontalAlignment(is_horizontal_shelf |
| 506 ? views::ImageView::CENTER | 515 ? views::ImageView::CENTER |
| 507 : views::ImageView::LEADING); | 516 : views::ImageView::LEADING); |
| 508 icon_view_->SetVerticalAlignment(is_horizontal_shelf | 517 icon_view_->SetVerticalAlignment(is_horizontal_shelf |
| 509 ? views::ImageView::LEADING | 518 ? views::ImageView::LEADING |
| 510 : views::ImageView::CENTER); | 519 : views::ImageView::CENTER); |
| 511 SchedulePaint(); | 520 SchedulePaint(); |
| 512 } | 521 } |
| 513 | 522 |
| 514 } // namespace ash | 523 } // namespace ash |
| OLD | NEW |