From 7b9f05ea0a4cb40d71ccd438689a8a9bc0f08a4a Mon Sep 17 00:00:00 2001 From: wukko Date: Thu, 17 Apr 2025 00:46:57 +0600 Subject: [PATCH] helium-ui: improve google's toast animation & positioning the toast is now smaller and positioned properly, in the top right corner of the web page. the animation is smooth and logical instead of a choppy laggy mess. --- patches/helium-ui/improve-toast.patch | 69 +++++++++++++++++++++++++++ patches/series | 1 + 2 files changed, 70 insertions(+) create mode 100644 patches/helium-ui/improve-toast.patch diff --git a/patches/helium-ui/improve-toast.patch b/patches/helium-ui/improve-toast.patch new file mode 100644 index 00000000..d78b06c9 --- /dev/null +++ b/patches/helium-ui/improve-toast.patch @@ -0,0 +1,69 @@ +--- a/chrome/browser/ui/toasts/toast_view.cc ++++ b/chrome/browser/ui/toasts/toast_view.cc +@@ -49,9 +49,8 @@ constexpr float kAnimationHeightScale = + + gfx::Transform GetScaleTransformation(gfx::Rect bounds) { + gfx::Transform transform; +- transform.Translate(0, +- bounds.CenterPoint().y() * (1 - kAnimationHeightScale)); +- transform.Scale(1, kAnimationHeightScale); ++ transform.Translate(bounds.CenterPoint().x(), 0); ++ transform.Scale(kAnimationHeightScale, kAnimationHeightScale); + return transform; + } + +@@ -119,8 +118,7 @@ ToastView::ToastView( + SetPaintClientToLayer(true); + SetShowCloseButton(false); + DialogDelegate::SetButtons(static_cast(ui::mojom::DialogButton::kNone)); +- set_corner_radius(ChromeLayoutProvider::Get()->GetDistanceMetric( +- DISTANCE_TOAST_BUBBLE_HEIGHT)); ++ set_corner_radius(8); + SetProperty(views::kElementIdentifierKey, kToastElementId); + set_close_on_deactivate(false); + SetProperty(views::kElementIdentifierKey, kToastViewId); +@@ -328,7 +326,7 @@ void ToastView::AnimateIn() { + + target_widget_bounds_ = GetWidget()->GetWindowBoundsInScreen(); + starting_widget_bounds_ = +- target_widget_bounds_ - gfx::Vector2d{0, kAnimationHeightOffset}; ++ target_widget_bounds_ - gfx::Vector2d{0, 0}; + height_animation_tween_ = gfx::Tween::ACCEL_5_70_DECEL_90; + height_animation_.SetDuration(base::Milliseconds(kAnimationEntryDuration)); + height_animation_.Start(); +@@ -410,13 +408,11 @@ gfx::Rect ToastView::GetBubbleBounds() { + const int width = + std::min(preferred_size.width(), + std::max(anchor_bounds.width() - 2 * minimum_margin, 0)); +- const int x = anchor_bounds.x() + ((anchor_bounds.width() - width) / 2); ++ const int x = anchor_bounds.x() + anchor_bounds.width() - width + 2 * minimum_margin; + + // Take bubble out of its original bounds to cross "line of death", unless in + // fullscreen mode where the top container isn't rendered. +- const int y = anchor_bounds.bottom() - (render_toast_over_web_contents_ +- ? views::BubbleBorder::kShadowBlur +- : (preferred_size.height() / 2)); ++ const int y = anchor_bounds.bottom() - 2 * minimum_margin; + return gfx::Rect(x, y, width, preferred_size.height()); + } + +@@ -448,7 +444,7 @@ void ToastView::AnimateOut(base::OnceClo + if (show_height_animation) { + starting_widget_bounds_ = GetWidget()->GetWindowBoundsInScreen(); + target_widget_bounds_ = +- starting_widget_bounds_ - gfx::Vector2d{0, kAnimationHeightOffset}; ++ starting_widget_bounds_ - gfx::Vector2d{0, 0}; + height_animation_tween_ = gfx::Tween::ACCEL_30_DECEL_20_85; + height_animation_.SetDuration(base::Milliseconds(kAnimationExitDuration)); + height_animation_.Start(); +--- a/chrome/browser/ui/views/chrome_layout_provider.cc ++++ b/chrome/browser/ui/views/chrome_layout_provider.cc +@@ -188,7 +188,7 @@ int ChromeLayoutProvider::GetDistanceMet + case DISTANCE_TOAST_BUBBLE_BETWEEN_LABEL_MENU_BUTTON_SPACING: + return 16; + case DISTANCE_TOAST_BUBBLE_HEIGHT: +- return 48; ++ return 36; + case DISTANCE_TOAST_BUBBLE_HEIGHT_ACTION_BUTTON: + return 36; + case DISTANCE_TOAST_BUBBLE_HEIGHT_CONTENT: diff --git a/patches/series b/patches/series index 9a63a068..19d88b1a 100644 --- a/patches/series +++ b/patches/series @@ -171,3 +171,4 @@ helium-ui/helium-logo-icons.patch helium-ui/settings-page-icons.patch helium-ui/square-ntp-monograms.patch helium-ui/set-gray-as-default-theme.patch +helium-ui/improve-toast.patch