AnimationSettings: Introduce get_animation_duration (#2106)

Co-authored-by: Leo <lenemter@gmail.com>
This commit is contained in:
Leonhard 2024-11-07 14:22:47 +01:00 committed by GitHub
parent f5cfb7fe43
commit b2bfe28062
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 31 additions and 24 deletions

View File

@ -22,4 +22,11 @@ namespace AnimationsSettings {
return enable_animations; return enable_animations;
} }
/**
* Utility that returns the given duration or 0 if animations are disabled.
*/
public uint get_animation_duration (uint duration) {
return get_enable_animations () ? duration : 0;
}
} }

View File

@ -142,7 +142,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
opacity = 0; opacity = 0;
save_easing_state (); save_easing_state ();
set_easing_duration (AnimationsSettings.get_enable_animations () ? 200 : 0); set_easing_duration (AnimationsSettings.get_animation_duration (200));
opacity = 255; opacity = 255;
restore_easing_state (); restore_easing_state ();
} }
@ -150,7 +150,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
public override void hide () { public override void hide () {
opacity = 255; opacity = 255;
var duration = AnimationsSettings.get_enable_animations () ? 200 : 0; var duration = AnimationsSettings.get_animation_duration (200);
save_easing_state (); save_easing_state ();
set_easing_duration (duration); set_easing_duration (duration);
opacity = 0; opacity = 0;
@ -172,7 +172,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
#else #else
public override bool enter_event (Clutter.CrossingEvent event) { public override bool enter_event (Clutter.CrossingEvent event) {
#endif #endif
var duration = AnimationsSettings.get_enable_animations () ? 300 : 0; var duration = AnimationsSettings.get_animation_duration (300);
close_button.save_easing_state (); close_button.save_easing_state ();
close_button.set_easing_duration (duration); close_button.set_easing_duration (duration);
@ -192,7 +192,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
#else #else
public override bool leave_event (Clutter.CrossingEvent event) { public override bool leave_event (Clutter.CrossingEvent event) {
#endif #endif
var duration = AnimationsSettings.get_enable_animations () ? 300 : 0; var duration = AnimationsSettings.get_animation_duration (300);
close_button.save_easing_state (); close_button.save_easing_state ();
close_button.set_easing_duration (duration); close_button.set_easing_duration (duration);
@ -314,7 +314,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
} }
private void on_close_click_clicked () { private void on_close_click_clicked () {
var duration = AnimationsSettings.get_enable_animations () ? FADE_OUT_TIMEOUT : 0; var duration = AnimationsSettings.get_animation_duration (FADE_OUT_TIMEOUT);
save_easing_state (); save_easing_state ();
set_easing_duration (duration); set_easing_duration (duration);
@ -448,7 +448,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
var screen_limit_start_y = SCREEN_MARGIN + monitor_y; var screen_limit_start_y = SCREEN_MARGIN + monitor_y;
var screen_limit_end_y = monitor_height + monitor_y - SCREEN_MARGIN - height; var screen_limit_end_y = monitor_height + monitor_y - SCREEN_MARGIN - height;
var duration = AnimationsSettings.get_enable_animations () ? 300 : 0; var duration = AnimationsSettings.get_animation_duration (300);
save_easing_state (); save_easing_state ();
set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK); set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK);
@ -461,7 +461,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
private bool place_window_off_screen () { private bool place_window_off_screen () {
off_screen = false; off_screen = false;
var duration = AnimationsSettings.get_enable_animations () ? 300 : 0; var duration = AnimationsSettings.get_animation_duration (300);
save_easing_state (); save_easing_state ();
set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK); set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK);

View File

@ -165,7 +165,7 @@ namespace Gala {
if (animate) { if (animate) {
icon.save_easing_state (); icon.save_easing_state ();
icon.set_easing_mode (Clutter.AnimationMode.LINEAR); icon.set_easing_mode (Clutter.AnimationMode.LINEAR);
icon.set_easing_duration (AnimationsSettings.get_enable_animations () ? 200 : 0); icon.set_easing_duration (AnimationsSettings.get_animation_duration (200));
icon.opacity = 0; icon.opacity = 0;
icon.restore_easing_state (); icon.restore_easing_state ();

View File

@ -871,7 +871,7 @@ namespace Gala {
dock.save_easing_state (); dock.save_easing_state ();
dock.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); dock.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
dock.set_easing_duration (AnimationsSettings.get_enable_animations () ? ANIMATION_DURATION : 0); dock.set_easing_duration (AnimationsSettings.get_animation_duration (ANIMATION_DURATION));
dock.y = target_y; dock.y = target_y;
dock.restore_easing_state (); dock.restore_easing_state ();
}; };

View File

@ -47,7 +47,7 @@ public class Gala.WindowClone : Clutter.Actor {
public bool active { public bool active {
set { set {
active_shape.save_easing_state (); active_shape.save_easing_state ();
active_shape.set_easing_duration (AnimationsSettings.get_enable_animations () ? FADE_ANIMATION_DURATION : 0); active_shape.set_easing_duration (AnimationsSettings.get_animation_duration (FADE_ANIMATION_DURATION));
active_shape.opacity = value ? 255 : 0; active_shape.opacity = value ? 255 : 0;
active_shape.restore_easing_state (); active_shape.restore_easing_state ();
} }
@ -399,7 +399,7 @@ public class Gala.WindowClone : Clutter.Actor {
return; return;
} }
var duration = AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0; var duration = AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION);
save_easing_state (); save_easing_state ();
set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
@ -484,7 +484,7 @@ public class Gala.WindowClone : Clutter.Actor {
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
var duration = AnimationsSettings.get_enable_animations () ? FADE_ANIMATION_DURATION : 0; var duration = AnimationsSettings.get_animation_duration (FADE_ANIMATION_DURATION);
close_button.save_easing_state (); close_button.save_easing_state ();
close_button.set_easing_mode (Clutter.AnimationMode.LINEAR); close_button.set_easing_mode (Clutter.AnimationMode.LINEAR);
@ -506,7 +506,7 @@ public class Gala.WindowClone : Clutter.Actor {
#else #else
public override bool leave_event (Clutter.CrossingEvent event) { public override bool leave_event (Clutter.CrossingEvent event) {
#endif #endif
var duration = AnimationsSettings.get_enable_animations () ? FADE_ANIMATION_DURATION : 0; var duration = AnimationsSettings.get_animation_duration (FADE_ANIMATION_DURATION);
close_button.save_easing_state (); close_button.save_easing_state ();
close_button.set_easing_mode (Clutter.AnimationMode.LINEAR); close_button.set_easing_mode (Clutter.AnimationMode.LINEAR);
@ -642,7 +642,7 @@ public class Gala.WindowClone : Clutter.Actor {
active_shape.hide (); active_shape.hide ();
var scale = window_icon.width / clone.width; var scale = window_icon.width / clone.width;
var duration = AnimationsSettings.get_enable_animations () ? FADE_ANIMATION_DURATION : 0; var duration = AnimationsSettings.get_animation_duration (FADE_ANIMATION_DURATION);
clone.get_transformed_position (out abs_x, out abs_y); clone.get_transformed_position (out abs_x, out abs_y);
clone.save_easing_state (); clone.save_easing_state ();
@ -700,8 +700,8 @@ public class Gala.WindowClone : Clutter.Actor {
var scale = hovered ? 0.4 : 1.0; var scale = hovered ? 0.4 : 1.0;
var opacity = hovered ? 0 : 255; var opacity = hovered ? 0 : 255;
var duration = hovered && insert_thumb != null ? insert_thumb.delay : 100; uint duration = hovered && insert_thumb != null ? insert_thumb.delay : 100;
duration = AnimationsSettings.get_enable_animations () ? duration : 0; duration = AnimationsSettings.get_animation_duration (duration);
window_icon.save_easing_state (); window_icon.save_easing_state ();
@ -809,7 +809,7 @@ public class Gala.WindowClone : Clutter.Actor {
get_parent ().remove_child (this); get_parent ().remove_child (this);
prev_parent.insert_child_at_index (this, prev_index); prev_parent.insert_child_at_index (this, prev_index);
var duration = AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0; var duration = AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION);
clone.set_pivot_point (0.0f, 0.0f); clone.set_pivot_point (0.0f, 0.0f);
clone.save_easing_state (); clone.save_easing_state ();

View File

@ -146,7 +146,7 @@ namespace Gala {
new_icon.save_easing_state (); new_icon.save_easing_state ();
new_icon.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); new_icon.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
new_icon.set_easing_duration (AnimationsSettings.get_enable_animations () ? 500 : 0); new_icon.set_easing_duration (AnimationsSettings.get_animation_duration (500));
new_icon.restore_easing_state (); new_icon.restore_easing_state ();
if (icon == null) { if (icon == null) {

View File

@ -414,7 +414,7 @@ public class Gala.WindowSwitcher : CanvasActor {
} }
save_easing_state (); save_easing_state ();
set_easing_duration (AnimationsSettings.get_enable_animations () ? ANIMATION_DURATION : 0); set_easing_duration (AnimationsSettings.get_animation_duration (ANIMATION_DURATION));
opacity = show ? 255 : 0; opacity = show ? 255 : 0;
restore_easing_state (); restore_easing_state ();
} }

View File

@ -387,13 +387,13 @@ namespace Gala {
save_easing_state (); save_easing_state ();
set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
set_easing_duration (AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0); set_easing_duration (AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION));
set_x (target_x); set_x (target_x);
restore_easing_state (); restore_easing_state ();
background.save_easing_state (); background.save_easing_state ();
background.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); background.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
background.set_easing_duration (AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0); background.set_easing_duration (AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION));
background.set_scale (scale, scale); background.set_scale (scale, scale);
background.restore_easing_state (); background.restore_easing_state ();
}; };
@ -463,13 +463,13 @@ namespace Gala {
save_easing_state (); save_easing_state ();
set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
set_easing_duration (AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0); set_easing_duration (AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION));
set_x (target_x); set_x (target_x);
restore_easing_state (); restore_easing_state ();
background.save_easing_state (); background.save_easing_state ();
background.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); background.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
background.set_easing_duration (AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0); background.set_easing_duration (AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION));
background.set_scale (1, 1); background.set_scale (1, 1);
background.restore_easing_state (); background.restore_easing_state ();
}; };

View File

@ -82,7 +82,7 @@ public class Gala.WorkspaceInsertThumb : Clutter.Actor {
private new void transform (bool expand) { private new void transform (bool expand) {
save_easing_state (); save_easing_state ();
set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
set_easing_duration (AnimationsSettings.get_enable_animations () ? 200 : 0); set_easing_duration (AnimationsSettings.get_animation_duration (200));
if (!expand) { if (!expand) {
remove_transition ("pulse"); remove_transition ("pulse");