Commit f5d45796 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Eliminate custom animation disable hook for IconLabelBubbleView separator.

This not only simplifies the code, it allows moving the SeparatorView class to
be a private member, which will allow it to access a private data member of
IconLabelBubbleView in a future CL.

Bug: 1033922
Change-Id: Ic1fe818e997b36dd3c96c082c8de0de4faaf2e25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1983454
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727828}
parent 6adf67f0
...@@ -107,15 +107,10 @@ void IconLabelBubbleView::SeparatorView::UpdateOpacity() { ...@@ -107,15 +107,10 @@ void IconLabelBubbleView::SeparatorView::UpdateOpacity() {
duration = kIconLabelBubbleFadeInDurationMs; duration = kIconLabelBubbleFadeInDurationMs;
} }
if (disable_animation_for_test_) { ui::ScopedLayerAnimationSettings animation(layer()->GetAnimator());
layer()->SetOpacity(opacity); animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds(duration));
} else { animation.SetTweenType(gfx::Tween::Type::EASE_IN);
ui::ScopedLayerAnimationSettings animation(layer()->GetAnimator()); layer()->SetOpacity(opacity);
animation.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(duration));
animation.SetTweenType(gfx::Tween::Type::EASE_IN);
layer()->SetOpacity(opacity);
}
} }
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
......
...@@ -58,30 +58,6 @@ class IconLabelBubbleView : public views::InkDropObserver, ...@@ -58,30 +58,6 @@ class IconLabelBubbleView : public views::InkDropObserver,
virtual SkColor GetIconLabelBubbleInkDropColor() const; virtual SkColor GetIconLabelBubbleInkDropColor() const;
}; };
// A view that draws the separator.
class SeparatorView : public views::View {
public:
explicit SeparatorView(IconLabelBubbleView* owner);
// views::View:
void OnPaint(gfx::Canvas* canvas) override;
// Updates the opacity based on the ink drop's state.
void UpdateOpacity();
void set_disable_animation_for_test(bool disable_animation_for_test) {
disable_animation_for_test_ = disable_animation_for_test;
}
private:
// Weak.
IconLabelBubbleView* owner_;
bool disable_animation_for_test_ = false;
DISALLOW_COPY_AND_ASSIGN(SeparatorView);
};
IconLabelBubbleView(const gfx::FontList& font_list, Delegate* delegate); IconLabelBubbleView(const gfx::FontList& font_list, Delegate* delegate);
~IconLabelBubbleView() override; ~IconLabelBubbleView() override;
...@@ -103,7 +79,7 @@ class IconLabelBubbleView : public views::InkDropObserver, ...@@ -103,7 +79,7 @@ class IconLabelBubbleView : public views::InkDropObserver,
SkColor GetParentBackgroundColor() const; SkColor GetParentBackgroundColor() const;
// Exposed for testing. // Exposed for testing.
SeparatorView* separator_view() const { return separator_view_; } views::View* separator_view() const { return separator_view_; }
// Exposed for testing. // Exposed for testing.
bool is_animating_label() const { return slide_animation_.is_animating(); } bool is_animating_label() const { return slide_animation_.is_animating(); }
...@@ -206,6 +182,24 @@ class IconLabelBubbleView : public views::InkDropObserver, ...@@ -206,6 +182,24 @@ class IconLabelBubbleView : public views::InkDropObserver,
private: private:
class HighlightPathGenerator; class HighlightPathGenerator;
// A view that draws the separator.
class SeparatorView : public views::View {
public:
explicit SeparatorView(IconLabelBubbleView* owner);
// views::View:
void OnPaint(gfx::Canvas* canvas) override;
// Updates the opacity based on the ink drop's state.
void UpdateOpacity();
private:
// Weak.
IconLabelBubbleView* owner_;
DISALLOW_COPY_AND_ASSIGN(SeparatorView);
};
// Spacing between the image and the label. // Spacing between the image and the label.
int GetInternalSpacing() const; int GetInternalSpacing() const;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "chrome/test/views/chrome_views_test_base.h" #include "chrome/test/views/chrome_views_test_base.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/events/base_event_utils.h" #include "ui/events/base_event_utils.h"
#include "ui/events/gesture_detection/gesture_configuration.h" #include "ui/events/gesture_detection/gesture_configuration.h"
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
...@@ -54,7 +55,6 @@ class TestIconLabelBubbleView : public IconLabelBubbleView { ...@@ -54,7 +55,6 @@ class TestIconLabelBubbleView : public IconLabelBubbleView {
is_bubble_showing_(false) { is_bubble_showing_(false) {
GetImageView()->SetImageSize(gfx::Size(kImageSize, kImageSize)); GetImageView()->SetImageSize(gfx::Size(kImageSize, kImageSize));
SetLabel(base::ASCIIToUTF16("Label")); SetLabel(base::ASCIIToUTF16("Label"));
separator_view()->set_disable_animation_for_test(true);
} }
void SetCurrentAnimationValue(int value) { void SetCurrentAnimationValue(int value) {
...@@ -119,6 +119,9 @@ class TestIconLabelBubbleView : public IconLabelBubbleView { ...@@ -119,6 +119,9 @@ class TestIconLabelBubbleView : public IconLabelBubbleView {
} }
private: private:
std::unique_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_ =
std::make_unique<ui::ScopedAnimationDurationScaleMode>(
ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
int value_; int value_;
bool is_bubble_showing_; bool is_bubble_showing_;
DISALLOW_COPY_AND_ASSIGN(TestIconLabelBubbleView); DISALLOW_COPY_AND_ASSIGN(TestIconLabelBubbleView);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment