mirror of
https://github.com/morgan9e/helium
synced 2026-04-14 00:14:20 +09:00
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.
This commit is contained in:
69
patches/helium-ui/improve-toast.patch
Normal file
69
patches/helium-ui/improve-toast.patch
Normal file
@@ -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<int>(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:
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user