Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2466)

Unified Diff: chrome/browser/ui/views/download/download_item_view_md.cc

Issue 1832963002: MD - add ripples to DL shelf items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bruthig feedback Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/download/download_item_view_md.cc
diff --git a/chrome/browser/ui/views/download/download_item_view_md.cc b/chrome/browser/ui/views/download/download_item_view_md.cc
index fa2da545bbf5740539589c2e260dcbed43a7352e..02d57c58466992e342c53c3314ce3e20c79ff2f0 100644
--- a/chrome/browser/ui/views/download/download_item_view_md.cc
+++ b/chrome/browser/ui/views/download/download_item_view_md.cc
@@ -57,7 +57,9 @@
#include "ui/gfx/text_elider.h"
#include "ui/gfx/text_utils.h"
#include "ui/gfx/vector_icons_public.h"
+#include "ui/views/animation/flood_fill_ink_drop_animation.h"
#include "ui/views/animation/ink_drop_delegate.h"
+#include "ui/views/animation/ink_drop_hover.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/label_button.h"
@@ -158,6 +160,7 @@ DownloadItemViewMd::DownloadItemViewMd(DownloadItem* download_item,
dragging_(false),
starting_drag_(false),
model_(download_item),
+ ink_drop_delegate_(this, this),
save_button_(nullptr),
discard_button_(nullptr),
dropdown_button_(new BarControlButton(this)),
@@ -185,9 +188,6 @@ DownloadItemViewMd::DownloadItemViewMd(DownloadItem* download_item,
status_font_list_ =
rb.GetFontList(ui::ResourceBundle::BaseFont).DeriveWithSizeDelta(-2);
- body_hover_animation_.reset(new gfx::SlideAnimation(this));
- drop_hover_animation_.reset(new gfx::SlideAnimation(this));
-
SetAccessibilityFocusable(true);
OnDownloadUpdated(download());
@@ -376,10 +376,12 @@ gfx::Size DownloadItemViewMd::GetPreferredSize() const {
2 * kMinimumVerticalPadding + child_height));
}
-// Handle a mouse click and open the context menu if the mouse is
-// over the drop-down region.
bool DownloadItemViewMd::OnMousePressed(const ui::MouseEvent& event) {
HandlePressEvent(event, event.IsOnlyLeftMouseButton());
+ if (!IsShowingWarningDialog()) {
+ last_ink_drop_location_ = event.location();
+ ink_drop_delegate_.OnAction(views::InkDropState::ACTION_PENDING);
+ }
return true;
}
@@ -392,6 +394,7 @@ bool DownloadItemViewMd::OnMouseDragged(const ui::MouseEvent& event) {
if (!starting_drag_) {
starting_drag_ = true;
drag_start_point_ = event.location();
+ ink_drop_delegate_.OnAction(views::InkDropState::HIDDEN);
}
if (dragging_) {
if (download()->GetState() == DownloadItem::COMPLETE) {
@@ -414,7 +417,7 @@ void DownloadItemViewMd::OnMouseReleased(const ui::MouseEvent& event) {
void DownloadItemViewMd::OnMouseCaptureLost() {
// Mouse should not activate us in dangerous mode.
- if (mode_ == DANGEROUS_MODE)
+ if (mode_ != NORMAL_MODE)
return;
if (dragging_) {
@@ -431,6 +434,8 @@ bool DownloadItemViewMd::OnKeyPressed(const ui::KeyEvent& event) {
if (event.key_code() == ui::VKEY_SPACE ||
event.key_code() == ui::VKEY_RETURN) {
+ last_ink_drop_location_ = GetLocalBounds().CenterPoint();
+ ink_drop_delegate_.OnAction(views::InkDropState::QUICK_ACTION);
// OpenDownload may delete this, so don't add any code after this line.
OpenDownload();
return true;
@@ -463,10 +468,34 @@ void DownloadItemViewMd::OnThemeChanged() {
UpdateColorsFromTheme();
}
+scoped_ptr<views::InkDropAnimation> DownloadItemViewMd::CreateInkDropAnimation()
+ const {
+ return make_scoped_ptr(new views::FloodFillInkDropAnimation(
+ size(), last_ink_drop_location_,
+ color_utils::DeriveDefaultIconColor(GetTextColor())));
+}
+
+scoped_ptr<views::InkDropHover> DownloadItemViewMd::CreateInkDropHover() const {
+ if (IsShowingWarningDialog())
+ return nullptr;
+
+ // TODO(estade): when the item is animating open and the user hovers, the
+ // effect gets stuck at that size and does not grow with the item. Using
+ // GetPreferredSize() instead of size() here does not fix it.
+ return make_scoped_ptr(new views::InkDropHover(
+ size(), kInkDropSmallCornerRadius,
+ GetLocalBounds().CenterPoint(),
+ color_utils::DeriveDefaultIconColor(GetTextColor())));
+}
+
void DownloadItemViewMd::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
HandlePressEvent(*event, true);
event->SetHandled();
+ if (mode_ == NORMAL_MODE) {
+ last_ink_drop_location_ = event->location();
+ ink_drop_delegate_.OnAction(views::InkDropState::QUICK_ACTION);
+ }
return;
}
@@ -810,6 +839,8 @@ void DownloadItemViewMd::HandleClickEvent(const ui::LocatedEvent& event,
if (!active_event || IsShowingWarningDialog())
return;
+ ink_drop_delegate_.OnAction(views::InkDropState::HIDDEN);
bruthig 2016/03/31 22:46:19 Is this necessary? The QUICK_ACTION animations sh
Evan Stade 2016/04/01 19:03:13 ok, no it's not.
+
// OpenDownload may delete this, so don't add any code after this line.
OpenDownload();
}
@@ -1073,10 +1104,10 @@ void DownloadItemViewMd::ProgressTimerFired() {
SchedulePaint();
}
-SkColor DownloadItemViewMd::GetTextColor() {
+SkColor DownloadItemViewMd::GetTextColor() const {
return GetTextColorForThemeProvider(GetThemeProvider());
}
-SkColor DownloadItemViewMd::GetDimmedTextColor() {
+SkColor DownloadItemViewMd::GetDimmedTextColor() const {
return SkColorSetA(GetTextColor(), 0xC7);
}
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view_md.h ('k') | ui/views/animation/flood_fill_ink_drop_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698