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

Unified Diff: ui/views/animation/ink_drop_host_view.cc

Issue 2447523002: [ash-md] Added different highlighting modes to the InkDropImpl. (Closed)
Patch Set: Fixed compile errors. Created 4 years, 1 month 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: ui/views/animation/ink_drop_host_view.cc
diff --git a/ui/views/animation/ink_drop_host_view.cc b/ui/views/animation/ink_drop_host_view.cc
index 89f320d2a50664a66dac3f9aafdfd320ef91dceb..e1048f2e9940de00d7231fbc53cf5c753ca3a539 100644
--- a/ui/views/animation/ink_drop_host_view.cc
+++ b/ui/views/animation/ink_drop_host_view.cc
@@ -19,7 +19,6 @@ namespace {
// Default sizes for ink drop effects.
const int kInkDropSize = 24;
-const int kInkDropLargeCornerRadius = 4;
// The scale factor to compute the large ink drop size.
const float kLargeInkDropScale = 1.333f;
@@ -27,14 +26,11 @@ const float kLargeInkDropScale = 1.333f;
// Default opacity of the ink drop when it is visible.
const float kInkDropVisibleOpacity = 0.175f;
-gfx::Size CalculateLargeInkDropSize(const gfx::Size small_size) {
- return gfx::ScaleToCeiledSize(gfx::Size(small_size), kLargeInkDropScale);
-}
-
} // namespace
// static
const int InkDropHostView::kInkDropSmallCornerRadius = 2;
+const int InkDropHostView::kInkDropLargeCornerRadius = 4;
// An EventHandler that is guaranteed to be invoked and is not prone to
// InkDropHostView descendents who do not call
@@ -106,9 +102,15 @@ class InkDropHostView::InkDropGestureHandler : public ui::EventHandler {
DISALLOW_COPY_AND_ASSIGN(InkDropGestureHandler);
};
+// static
+
+gfx::Size InkDropHostView::CalculateLargeInkDropSize(
+ const gfx::Size small_size) {
+ return gfx::ScaleToCeiledSize(gfx::Size(small_size), kLargeInkDropScale);
+}
+
InkDropHostView::InkDropHostView()
: ink_drop_(new InkDropStub()),
- ink_drop_size_(kInkDropSize, kInkDropSize),
ink_drop_visible_opacity_(kInkDropVisibleOpacity),
old_paint_to_layer_(false),
destroying_(false) {}
@@ -137,6 +139,10 @@ void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
SetPaintToLayer(old_paint_to_layer_);
}
+std::unique_ptr<InkDrop> InkDropHostView::CreateInkDrop() {
+ return CreateDefaultInkDropImpl();
+}
+
std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const {
return CreateDefaultInkDropRipple(GetLocalBounds().CenterPoint());
}
@@ -150,19 +156,21 @@ std::unique_ptr<InkDropHighlight> InkDropHostView::CreateInkDropHighlight()
std::unique_ptr<InkDropRipple> InkDropHostView::CreateDefaultInkDropRipple(
const gfx::Point& center_point) const {
std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple(
- CalculateLargeInkDropSize(ink_drop_size_), kInkDropLargeCornerRadius,
- ink_drop_size_, kInkDropSmallCornerRadius, center_point,
- GetInkDropBaseColor(), ink_drop_visible_opacity()));
+ CalculateLargeInkDropSize(gfx::Size(kInkDropSize, kInkDropSize)),
+ kInkDropLargeCornerRadius, gfx::Size(kInkDropSize, kInkDropSize),
+ kInkDropSmallCornerRadius, center_point, GetInkDropBaseColor(),
+ ink_drop_visible_opacity()));
return ripple;
}
std::unique_ptr<InkDropHighlight>
InkDropHostView::CreateDefaultInkDropHighlight(
const gfx::PointF& center_point) const {
- std::unique_ptr<InkDropHighlight> highlight(
- new InkDropHighlight(ink_drop_size_, kInkDropSmallCornerRadius,
- center_point, GetInkDropBaseColor()));
- highlight->set_explode_size(CalculateLargeInkDropSize(ink_drop_size_));
+ std::unique_ptr<InkDropHighlight> highlight(new InkDropHighlight(
+ gfx::Size(kInkDropSize, kInkDropSize), kInkDropSmallCornerRadius,
+ center_point, GetInkDropBaseColor()));
+ highlight->set_explode_size(
+ CalculateLargeInkDropSize(gfx::Size(kInkDropSize, kInkDropSize)));
return highlight;
}
@@ -218,6 +226,9 @@ void InkDropHostView::OnMouseEvent(ui::MouseEvent* event) {
case ui::ET_MOUSE_EXITED:
ink_drop_->SetHovered(false);
break;
+ case ui::ET_MOUSE_DRAGGED:
+ ink_drop_->SetHovered(GetLocalBounds().Contains(event->location()));
+ break;
default:
break;
}
@@ -237,7 +248,7 @@ void InkDropHostView::SetInkDropMode(InkDropMode ink_drop_mode) {
if (ink_drop_mode == InkDropMode::OFF)
ink_drop_.reset(new InkDropStub());
else
- ink_drop_.reset(new InkDropImpl(this));
+ ink_drop_ = CreateInkDrop();
if (ink_drop_mode != InkDropMode::ON)
gesture_handler_.reset();
@@ -245,4 +256,20 @@ void InkDropHostView::SetInkDropMode(InkDropMode ink_drop_mode) {
gesture_handler_.reset(new InkDropGestureHandler(this));
}
+std::unique_ptr<InkDropImpl> InkDropHostView::CreateDefaultInkDropImpl() {
+ std::unique_ptr<InkDropImpl> ink_drop(new InkDropImpl(this));
sky 2016/11/02 02:52:11 MakeUnique.
bruthig 2016/11/04 18:50:36 Done.
+ ink_drop->SetAutoHighlightMode(
+ views::InkDropImpl::AutoHighlightMode::HIDE_ON_RIPPLE);
+ return ink_drop;
+}
+
+std::unique_ptr<InkDropImpl>
+InkDropHostView::CreateDefaultFloodFillInkDropImpl() {
+ std::unique_ptr<views::InkDropImpl> ink_drop =
+ InkDropHostView::CreateDefaultInkDropImpl();
+ ink_drop->SetAutoHighlightMode(
+ views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE);
+ return ink_drop;
+}
+
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698