Commit a377b773 authored by Alexey Baskakov's avatar Alexey Baskakov Committed by Commit Bot

Revert "Implement pop in and out animations for stacked notification icons"

This reverts commit 70df16a3.

Reason for revert: This is a culprit CL which fails
UnifiedMessageCenter ash_unittests 

Example:
https://ci.chromium.org/p/chromium/builders/ci/linux-chromeos-dbg/15343

Original change's description:
> Implement pop in and out animations for stacked notification icons
> 
> Bug: 1025050
> Change-Id: I5073cb6f54036b86f1bf455e89f29d529ad25a4e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1918038
> Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#716782}

TBR=xiyuan@chromium.org,tengs@chromium.org,amehfooz@chromium.org

Change-Id: I366f50b2c2e1e1468178bd137fb5d5d8d7b559ed
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1025050
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925842Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716887}
parent 75c4ac5e
...@@ -13,11 +13,8 @@ ...@@ -13,11 +13,8 @@
#include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tray_popup_utils.h"
#include "ash/system/unified/rounded_label_button.h" #include "ash/system/unified/rounded_label_button.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/interpolated_transform.h"
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
#include "ui/message_center/public/cpp/message_center_constants.h" #include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/message_center/vector_icons.h" #include "ui/message_center/vector_icons.h"
...@@ -123,108 +120,14 @@ class StackingBarLabelButton : public views::LabelButton { ...@@ -123,108 +120,14 @@ class StackingBarLabelButton : public views::LabelButton {
} // namespace } // namespace
class StackedNotificationBar::StackedNotificationBarIcon class StackedNotificationBar::StackedNotificationBarIcon
: public views::ImageView, : public views::ImageView {
public ui::LayerAnimationObserver {
public: public:
StackedNotificationBarIcon(StackedNotificationBar* notification_bar, StackedNotificationBarIcon(const std::string& id)
const std::string& id) : views::ImageView(), id_(id) {}
: views::ImageView(), notification_bar_(notification_bar), id_(id) {
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
}
void AnimateIn() {
DCHECK(!is_animating_out());
std::unique_ptr<ui::InterpolatedTransform> scale =
std::make_unique<ui::InterpolatedScale>(
gfx::Point3F(kNotificationIconAnimationScaleFactor,
kNotificationIconAnimationScaleFactor, 1),
gfx::Point3F(1, 1, 1));
std::unique_ptr<ui::InterpolatedTransform> scale_about_pivot =
std::make_unique<ui::InterpolatedTransformAboutPivot>(
GetLocalBounds().CenterPoint(), std::move(scale));
scale_about_pivot->SetChild(std::make_unique<ui::InterpolatedTranslation>(
gfx::PointF(0, kNotificationIconAnimationLowPosition),
gfx::PointF(0, kNotificationIconAnimationHighPosition)));
std::unique_ptr<ui::LayerAnimationElement> scale_and_move_up =
ui::LayerAnimationElement::CreateInterpolatedTransformElement(
std::move(scale_about_pivot),
base::TimeDelta::FromMilliseconds(
kNotificationIconAnimationUpDurationMs));
scale_and_move_up->set_tween_type(gfx::Tween::EASE_IN);
std::unique_ptr<ui::LayerAnimationElement> move_down =
ui::LayerAnimationElement::CreateInterpolatedTransformElement(
std::make_unique<ui::InterpolatedTranslation>(
gfx::PointF(0, kNotificationIconAnimationHighPosition),
gfx::PointF(0, 0)),
base::TimeDelta::FromMilliseconds(
kNotificationIconAnimationDownDurationMs));
std::unique_ptr<ui::LayerAnimationSequence> sequence =
std::make_unique<ui::LayerAnimationSequence>();
sequence->AddElement(std::move(scale_and_move_up));
sequence->AddElement(std::move(move_down));
layer()->GetAnimator()->StartAnimation(sequence.release());
}
void AnimateOut() {
layer()->GetAnimator()->StopAnimating();
std::unique_ptr<ui::InterpolatedTransform> scale =
std::make_unique<ui::InterpolatedScale>(
gfx::Point3F(1, 1, 1),
gfx::Point3F(kNotificationIconAnimationScaleFactor,
kNotificationIconAnimationScaleFactor, 1));
std::unique_ptr<ui::InterpolatedTransform> scale_about_pivot =
std::make_unique<ui::InterpolatedTransformAboutPivot>(
gfx::Point(bounds().width() * 0.5, bounds().height() * 0.5),
std::move(scale));
scale_about_pivot->SetChild(std::make_unique<ui::InterpolatedTranslation>(
gfx::PointF(0, 0),
gfx::PointF(0, kNotificationIconAnimationLowPosition)));
std::unique_ptr<ui::LayerAnimationElement> scale_and_move_down =
ui::LayerAnimationElement::CreateInterpolatedTransformElement(
std::move(scale_about_pivot),
base::TimeDelta::FromMilliseconds(
kNotificationIconAnimationOutDurationMs));
scale_and_move_down->set_tween_type(gfx::Tween::EASE_IN);
std::unique_ptr<ui::LayerAnimationSequence> sequence =
std::make_unique<ui::LayerAnimationSequence>();
sequence->AddElement(std::move(scale_and_move_down));
sequence->AddObserver(this);
layer()->GetAnimator()->StartAnimation(sequence.release());
set_animating_out();
}
// ui::LayerAnimationObserver:
void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override {
notification_bar_->OnIconAnimatedOut(this);
// Note |this| is deleted after this point.
}
void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override {}
void OnLayerAnimationScheduled(
ui::LayerAnimationSequence* sequence) override {}
const std::string& id() const { return id_; } const std::string& id() const { return id_; }
bool is_animating_out() const { return animating_out_; }
void set_animating_out() { animating_out_ = true; }
private: private:
StackedNotificationBar* notification_bar_;
std::string id_; std::string id_;
bool animating_out_ = false;
}; };
StackedNotificationBar::StackedNotificationBar( StackedNotificationBar::StackedNotificationBar(
...@@ -335,7 +238,7 @@ void StackedNotificationBar::AddNotificationIcon( ...@@ -335,7 +238,7 @@ void StackedNotificationBar::AddNotificationIcon(
message_center::Notification* notification, message_center::Notification* notification,
bool at_front) { bool at_front) {
views::ImageView* icon_view_ = views::ImageView* icon_view_ =
new StackedNotificationBarIcon(this, notification->id()); new StackedNotificationBarIcon(notification->id());
if (at_front) if (at_front)
notification_icons_container_->AddChildViewAt(icon_view_, 0); notification_icons_container_->AddChildViewAt(icon_view_, 0);
else else
...@@ -354,26 +257,8 @@ void StackedNotificationBar::AddNotificationIcon( ...@@ -354,26 +257,8 @@ void StackedNotificationBar::AddNotificationIcon(
} }
} }
void StackedNotificationBar::OnIconAnimatedOut(views::View* icon) {
delete icon;
Layout();
}
StackedNotificationBar::StackedNotificationBarIcon*
StackedNotificationBar::GetFrontIcon() {
const auto i = std::find_if(
notification_icons_container_->children().cbegin(),
notification_icons_container_->children().cend(), [](const auto* v) {
return !static_cast<const StackedNotificationBarIcon*>(v)
->is_animating_out();
});
return (i == notification_icons_container_->children().cend()
? nullptr
: static_cast<StackedNotificationBarIcon*>(*i));
}
const StackedNotificationBar::StackedNotificationBarIcon* const StackedNotificationBar::StackedNotificationBarIcon*
StackedNotificationBar::GetIconFromId(const std::string& id) const { StackedNotificationBar::GetIconFromId(const std::string& id) {
for (auto* v : notification_icons_container_->children()) { for (auto* v : notification_icons_container_->children()) {
const StackedNotificationBarIcon* icon = const StackedNotificationBarIcon* icon =
static_cast<const StackedNotificationBarIcon*>(v); static_cast<const StackedNotificationBarIcon*>(v);
...@@ -391,20 +276,10 @@ void StackedNotificationBar::ShiftIconsLeft( ...@@ -391,20 +276,10 @@ void StackedNotificationBar::ShiftIconsLeft(
kStackedNotificationBarMaxIcons); kStackedNotificationBarMaxIcons);
// Remove required number of icons from the front. // Remove required number of icons from the front.
// Only animate if we're removing one icon. for (int i = 0; i < removed_icons_count; i++) {
if (removed_icons_count == 1) { delete notification_icons_container_->children().front();
StackedNotificationBarIcon* icon = GetFrontIcon();
if (icon) {
icon->AnimateOut();
}
} else {
for (int i = 0; i < removed_icons_count; i++) {
StackedNotificationBarIcon* icon = GetFrontIcon();
if (icon) {
delete icon;
}
}
} }
// Add icons to the back if there was a backfill. // Add icons to the back if there was a backfill.
int backfill_start = kStackedNotificationBarMaxIcons - removed_icons_count; int backfill_start = kStackedNotificationBarMaxIcons - removed_icons_count;
int backfill_end = int backfill_end =
...@@ -431,10 +306,6 @@ void StackedNotificationBar::ShiftIconsRight( ...@@ -431,10 +306,6 @@ void StackedNotificationBar::ShiftIconsRight(
true /*at_front*/); true /*at_front*/);
++stacked_notification_count_; ++stacked_notification_count_;
} }
// Animate in the first stacked notification icon.
StackedNotificationBarIcon* icon = GetFrontIcon();
if (icon)
GetFrontIcon()->AnimateIn();
} }
void StackedNotificationBar::UpdateStackedNotifications( void StackedNotificationBar::UpdateStackedNotifications(
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "ash/system/message_center/message_center_scroll_bar.h" #include "ash/system/message_center/message_center_scroll_bar.h"
#include "ash/system/message_center/unified_message_center_view.h" #include "ash/system/message_center/unified_message_center_view.h"
#include "ash/system/message_center/unified_message_list_view.h" #include "ash/system/message_center/unified_message_list_view.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/gfx/animation/animation_delegate.h" #include "ui/gfx/animation/animation_delegate.h"
#include "ui/message_center/message_center_observer.h" #include "ui/message_center/message_center_observer.h"
#include "ui/views/background.h" #include "ui/views/background.h"
...@@ -51,9 +50,6 @@ class StackedNotificationBar : public views::View, ...@@ -51,9 +50,6 @@ class StackedNotificationBar : public views::View,
// Set notification bar state to expanded. // Set notification bar state to expanded.
void SetExpanded(); void SetExpanded();
// Clean up icon view after it's removal animation is complete.
void OnIconAnimatedOut(views::View* icon);
// views::View: // views::View:
void OnPaint(gfx::Canvas* canvas) override; void OnPaint(gfx::Canvas* canvas) override;
const char* GetClassName() const override; const char* GetClassName() const override;
...@@ -70,12 +66,9 @@ class StackedNotificationBar : public views::View, ...@@ -70,12 +66,9 @@ class StackedNotificationBar : public views::View,
class StackedNotificationBarIcon; class StackedNotificationBarIcon;
friend class UnifiedMessageCenterViewTest; friend class UnifiedMessageCenterViewTest;
// Get the first icon which is not animating out.
StackedNotificationBarIcon* GetFrontIcon();
// Search for a icon view in the stacked notification bar based on a provided // Search for a icon view in the stacked notification bar based on a provided
// notification id. // notification id.
const StackedNotificationBarIcon* GetIconFromId(const std::string& id) const; const StackedNotificationBarIcon* GetIconFromId(const std::string& id);
// Set visibility based on number of stacked notifications or animation state. // Set visibility based on number of stacked notifications or animation state.
void UpdateVisibility(); void UpdateVisibility();
......
...@@ -135,12 +135,6 @@ constexpr gfx::Insets kStackedNotificationIconsContainerPadding(1, 16, 0, 8); ...@@ -135,12 +135,6 @@ constexpr gfx::Insets kStackedNotificationIconsContainerPadding(1, 16, 0, 8);
constexpr int kStackedNotificationBarMaxIcons = 3; constexpr int kStackedNotificationBarMaxIcons = 3;
constexpr int kStackedNotificationBarIconSpacing = 6; constexpr int kStackedNotificationBarIconSpacing = 6;
constexpr int kStackedNotificationIconSize = 18; constexpr int kStackedNotificationIconSize = 18;
constexpr int kNotificationIconAnimationLowPosition = 7;
constexpr int kNotificationIconAnimationHighPosition = -3;
constexpr double kNotificationIconAnimationScaleFactor = 0.77;
constexpr int kNotificationIconAnimationUpDurationMs = 50;
constexpr int kNotificationIconAnimationDownDurationMs = 17;
constexpr int kNotificationIconAnimationOutDurationMs = 67;
// Constants used in FeaturePodsView of UnifiedSystemTray. // Constants used in FeaturePodsView of UnifiedSystemTray.
constexpr gfx::Size kUnifiedFeaturePodIconSize(48, 48); constexpr gfx::Size kUnifiedFeaturePodIconSize(48, 48);
......
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