mirror of
https://github.com/elementary/gala.git
synced 2024-11-22 10:12:35 +03:00
AnimationSettings: Introduce get_animation_duration (#2106)
Co-authored-by: Leo <lenemter@gmail.com>
This commit is contained in:
parent
f5cfb7fe43
commit
b2bfe28062
@ -22,4 +22,11 @@ namespace AnimationsSettings {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
|
||||
opacity = 0;
|
||||
|
||||
save_easing_state ();
|
||||
set_easing_duration (AnimationsSettings.get_enable_animations () ? 200 : 0);
|
||||
set_easing_duration (AnimationsSettings.get_animation_duration (200));
|
||||
opacity = 255;
|
||||
restore_easing_state ();
|
||||
}
|
||||
@ -150,7 +150,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
|
||||
public override void hide () {
|
||||
opacity = 255;
|
||||
|
||||
var duration = AnimationsSettings.get_enable_animations () ? 200 : 0;
|
||||
var duration = AnimationsSettings.get_animation_duration (200);
|
||||
save_easing_state ();
|
||||
set_easing_duration (duration);
|
||||
opacity = 0;
|
||||
@ -172,7 +172,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
|
||||
#else
|
||||
public override bool enter_event (Clutter.CrossingEvent event) {
|
||||
#endif
|
||||
var duration = AnimationsSettings.get_enable_animations () ? 300 : 0;
|
||||
var duration = AnimationsSettings.get_animation_duration (300);
|
||||
|
||||
close_button.save_easing_state ();
|
||||
close_button.set_easing_duration (duration);
|
||||
@ -192,7 +192,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
|
||||
#else
|
||||
public override bool leave_event (Clutter.CrossingEvent event) {
|
||||
#endif
|
||||
var duration = AnimationsSettings.get_enable_animations () ? 300 : 0;
|
||||
var duration = AnimationsSettings.get_animation_duration (300);
|
||||
|
||||
close_button.save_easing_state ();
|
||||
close_button.set_easing_duration (duration);
|
||||
@ -314,7 +314,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
|
||||
}
|
||||
|
||||
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 ();
|
||||
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_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 ();
|
||||
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 () {
|
||||
off_screen = false;
|
||||
|
||||
var duration = AnimationsSettings.get_enable_animations () ? 300 : 0;
|
||||
var duration = AnimationsSettings.get_animation_duration (300);
|
||||
|
||||
save_easing_state ();
|
||||
set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK);
|
||||
|
@ -165,7 +165,7 @@ namespace Gala {
|
||||
if (animate) {
|
||||
icon.save_easing_state ();
|
||||
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.restore_easing_state ();
|
||||
|
||||
|
@ -871,7 +871,7 @@ namespace Gala {
|
||||
|
||||
dock.save_easing_state ();
|
||||
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.restore_easing_state ();
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
public bool active {
|
||||
set {
|
||||
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.restore_easing_state ();
|
||||
}
|
||||
@ -399,7 +399,7 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
return;
|
||||
}
|
||||
|
||||
var duration = AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0;
|
||||
var duration = AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION);
|
||||
|
||||
save_easing_state ();
|
||||
set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
|
||||
@ -484,7 +484,7 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
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.set_easing_mode (Clutter.AnimationMode.LINEAR);
|
||||
@ -506,7 +506,7 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
#else
|
||||
public override bool leave_event (Clutter.CrossingEvent event) {
|
||||
#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.set_easing_mode (Clutter.AnimationMode.LINEAR);
|
||||
@ -642,7 +642,7 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
active_shape.hide ();
|
||||
|
||||
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.save_easing_state ();
|
||||
@ -700,8 +700,8 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
|
||||
var scale = hovered ? 0.4 : 1.0;
|
||||
var opacity = hovered ? 0 : 255;
|
||||
var duration = hovered && insert_thumb != null ? insert_thumb.delay : 100;
|
||||
duration = AnimationsSettings.get_enable_animations () ? duration : 0;
|
||||
uint duration = hovered && insert_thumb != null ? insert_thumb.delay : 100;
|
||||
duration = AnimationsSettings.get_animation_duration (duration);
|
||||
|
||||
window_icon.save_easing_state ();
|
||||
|
||||
@ -809,7 +809,7 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
get_parent ().remove_child (this);
|
||||
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.save_easing_state ();
|
||||
|
@ -146,7 +146,7 @@ namespace Gala {
|
||||
|
||||
new_icon.save_easing_state ();
|
||||
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 ();
|
||||
|
||||
if (icon == null) {
|
||||
|
@ -414,7 +414,7 @@ public class Gala.WindowSwitcher : CanvasActor {
|
||||
}
|
||||
|
||||
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;
|
||||
restore_easing_state ();
|
||||
}
|
||||
|
@ -387,13 +387,13 @@ namespace Gala {
|
||||
|
||||
save_easing_state ();
|
||||
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);
|
||||
restore_easing_state ();
|
||||
|
||||
background.save_easing_state ();
|
||||
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.restore_easing_state ();
|
||||
};
|
||||
@ -463,13 +463,13 @@ namespace Gala {
|
||||
|
||||
save_easing_state ();
|
||||
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);
|
||||
restore_easing_state ();
|
||||
|
||||
background.save_easing_state ();
|
||||
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.restore_easing_state ();
|
||||
};
|
||||
|
@ -82,7 +82,7 @@ public class Gala.WorkspaceInsertThumb : Clutter.Actor {
|
||||
private new void transform (bool expand) {
|
||||
save_easing_state ();
|
||||
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) {
|
||||
remove_transition ("pulse");
|
||||
|
Loading…
Reference in New Issue
Block a user