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

Unified Diff: chrome/browser/ui/views/location_bar/content_setting_image_view.cc

Issue 1763713004: Adjusts content bubble animation with respect to icon size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjusts content bubble animation with respect to icon size (constant speed) 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/location_bar/content_setting_image_view.cc
diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
index a3b7640cee9233d14d98151610c663c4d0eb3110..d66561e9e25562c70a5587d01d53715dc854b486 100644
--- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
@@ -56,7 +56,9 @@ ContentSettingImageView::ContentSettingImageView(
SetBackgroundImageGrid(kBackgroundImages);
}
- image()->SetHorizontalAlignment(views::ImageView::LEADING);
+ image()->SetHorizontalAlignment(base::i18n::IsRTL()
+ ? views::ImageView::TRAILING
+ : views::ImageView::LEADING);
image()->set_interactive(true);
image()->EnableCanvasFlippingForRTLUI(true);
image()->SetAccessibilityFocusable(true);
@@ -113,7 +115,8 @@ SkColor ContentSettingImageView::GetBorderColor() const {
}
bool ContentSettingImageView::ShouldShowBackground() const {
- return slide_animator_.is_animating() || pause_animation_;
+ return label()->visible() &&
+ (slide_animator_.is_animating() || pause_animation_);
}
double ContentSettingImageView::WidthMultiplier() const {
@@ -132,6 +135,13 @@ double ContentSettingImageView::WidthMultiplier() const {
return size_fraction;
}
+bool ContentSettingImageView::IsShrinking() const {
+ const double kOpenFraction =
+ static_cast<double>(kOpenTimeMS) / kAnimationDurationMS;
+ return (!pause_animation_ && slide_animator_.is_animating() &&
+ slide_animator_.GetCurrentValue() > (1.0 - kOpenFraction));
+}
+
void ContentSettingImageView::AnimationEnded(const gfx::Animation* animation) {
slide_animator_.Reset();
if (!pause_animation_) {
@@ -242,7 +252,18 @@ void ContentSettingImageView::OnWidgetVisibilityChanged(views::Widget* widget,
void ContentSettingImageView::OnClick() {
if (slide_animator_.is_animating()) {
- if (!pause_animation_) {
+ // If the user clicks while we're animating, the bubble arrow will be
+ // pointing to the image, and if we allow the animation to keep running, the
+ // image will move away from the arrow (or we'll have to move the bubble,
+ // which is even worse). So we want to stop the animation. We have two
+ // choices: jump to the final post-animation state (no label visible), or
+ // pause the animation where we are and continue running after the bubble
+ // closes. The former looks more jerky, so we avoid it unless the animation
+ // hasn't even fully exposed the image yet, in which case pausing with half
+ // an image visible will look broken.
+ const int final_width = image()->GetPreferredSize().width() +
+ GetBubbleOuterPadding(true) + GetBubbleOuterPadding(false);
+ if (!pause_animation_ && (width() > final_width)) {
pause_animation_ = true;
pause_animation_state_ = slide_animator_.GetCurrentValue();
}

Powered by Google App Engine
This is Rietveld 408576698