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

Side by Side Diff: ui/views/animation/flood_fill_ink_drop_animation.cc

Issue 1915983009: Fixed material design ink drop location for the MD download shelf buttons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "Removed FloodFillInkDropAnimation ctor. Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/views/animation/flood_fill_ink_drop_animation.h" 5 #include "ui/views/animation/flood_fill_ink_drop_animation.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "third_party/skia/include/core/SkColor.h" 10 #include "third_party/skia/include/core/SkColor.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 ? 1 100 ? 1
101 : views::InkDropAnimation::kSlowAnimationDurationFactor) * 101 : views::InkDropAnimation::kSlowAnimationDurationFactor) *
102 kAnimationDurationInMs[state]); 102 kAnimationDurationInMs[state]);
103 } 103 }
104 104
105 } // namespace 105 } // namespace
106 106
107 namespace views { 107 namespace views {
108 108
109 FloodFillInkDropAnimation::FloodFillInkDropAnimation( 109 FloodFillInkDropAnimation::FloodFillInkDropAnimation(
110 const gfx::Size& size, 110 const gfx::Rect& clip_bounds,
111 const gfx::Point& center_point, 111 const gfx::Point& center_point,
112 SkColor color) 112 SkColor color)
113 : size_(size), 113 : clip_bounds_(clip_bounds),
114 center_point_(center_point), 114 center_point_(center_point),
115 root_layer_(ui::LAYER_NOT_DRAWN), 115 root_layer_(ui::LAYER_NOT_DRAWN),
116 circle_layer_delegate_(color, 116 circle_layer_delegate_(
117 std::max(size_.width(), size_.height()) / 2.f), 117 color,
118 std::max(clip_bounds_.width(), clip_bounds_.height()) / 2.f),
118 ink_drop_state_(InkDropState::HIDDEN) { 119 ink_drop_state_(InkDropState::HIDDEN) {
119 root_layer_.set_name("FloodFillInkDropAnimation:ROOT_LAYER"); 120 root_layer_.set_name("FloodFillInkDropAnimation:ROOT_LAYER");
120 root_layer_.SetMasksToBounds(true); 121 root_layer_.SetMasksToBounds(true);
121 root_layer_.SetBounds(gfx::Rect(size_)); 122 root_layer_.SetBounds(clip_bounds);
122 123
123 const gfx::Vector2dF translate_vector = 124 const int painted_size_length =
124 center_point_ - root_layer_.bounds().CenterPoint(); 125 2 * std::max(clip_bounds_.width(), clip_bounds_.height());
125 gfx::Transform transfrom;
126 transfrom.Translate(translate_vector.x(), translate_vector.y());
127 root_layer_.SetTransform(transfrom);
128
129 const int painted_size_length = 2 * std::max(size_.width(), size_.height());
130 126
131 painted_layer_.SetBounds(gfx::Rect(painted_size_length, painted_size_length)); 127 painted_layer_.SetBounds(gfx::Rect(painted_size_length, painted_size_length));
132 painted_layer_.SetFillsBoundsOpaquely(false); 128 painted_layer_.SetFillsBoundsOpaquely(false);
133 painted_layer_.set_delegate(&circle_layer_delegate_); 129 painted_layer_.set_delegate(&circle_layer_delegate_);
134 painted_layer_.SetVisible(true); 130 painted_layer_.SetVisible(true);
135 painted_layer_.SetOpacity(1.0); 131 painted_layer_.SetOpacity(1.0);
136 painted_layer_.SetMasksToBounds(false); 132 painted_layer_.SetMasksToBounds(false);
137 painted_layer_.set_name("FloodFillInkDropAnimation:PAINTED_LAYER"); 133 painted_layer_.set_name("FloodFillInkDropAnimation:PAINTED_LAYER");
138 134
139 root_layer_.Add(&painted_layer_); 135 root_layer_.Add(&painted_layer_);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 animator->StartAnimation(animation_sequence); 302 animator->StartAnimation(animation_sequence);
307 } 303 }
308 304
309 gfx::Transform FloodFillInkDropAnimation::CalculateTransform( 305 gfx::Transform FloodFillInkDropAnimation::CalculateTransform(
310 float target_radius) const { 306 float target_radius) const {
311 const float target_scale = target_radius / circle_layer_delegate_.radius(); 307 const float target_scale = target_radius / circle_layer_delegate_.radius();
312 const gfx::Point drawn_center_point = 308 const gfx::Point drawn_center_point =
313 ToRoundedPoint(circle_layer_delegate_.GetCenterPoint()); 309 ToRoundedPoint(circle_layer_delegate_.GetCenterPoint());
314 310
315 gfx::Transform transform = gfx::Transform(); 311 gfx::Transform transform = gfx::Transform();
316 transform.Translate(root_layer_.bounds().CenterPoint().x(), 312 transform.Translate(center_point_.x(), center_point_.y());
317 root_layer_.bounds().CenterPoint().y());
318 transform.Scale(target_scale, target_scale); 313 transform.Scale(target_scale, target_scale);
319 transform.Translate(-drawn_center_point.x(), -drawn_center_point.y()); 314 transform.Translate(-drawn_center_point.x() - root_layer_.bounds().x(),
315 -drawn_center_point.y() - root_layer_.bounds().y());
320 316
321 return transform; 317 return transform;
322 } 318 }
323 319
324 gfx::Transform FloodFillInkDropAnimation::GetMaxSizeTargetTransform() const { 320 gfx::Transform FloodFillInkDropAnimation::GetMaxSizeTargetTransform() const {
325 // TODO(estade): get rid of this 2, but make the fade out start before the 321 // TODO(estade): get rid of this 2, but make the fade out start before the
326 // active/action transform is done. 322 // active/action transform is done.
327 return CalculateTransform( 323 return CalculateTransform(
328 gfx::Vector2dF(size_.width(), size_.height()).Length() / 2); 324 gfx::Vector2dF(clip_bounds_.width(), clip_bounds_.height()).Length() / 2);
329 } 325 }
330 326
331 } // namespace views 327 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/flood_fill_ink_drop_animation.h ('k') | ui/views/animation/ink_drop_animation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698