js: Use implicit animations for animatable properties
We now have everything in place to replace Tweener for all animatable properties with implicit animations, which has the following benefits: - they run entirely in C, while Tweener requires context switches to JS each frame - they are more reliable, as Tweener only detects when an animation is overwritten with another Tween, while Clutter considers any property change https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/22
This commit is contained in:
@ -10,7 +10,6 @@ const System = imports.system;
|
||||
const History = imports.misc.history;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const ShellEntry = imports.ui.shellEntry;
|
||||
const Tweener = imports.ui.tweener;
|
||||
const Main = imports.ui.main;
|
||||
const JsParse = imports.misc.jsParse;
|
||||
|
||||
@ -37,6 +36,8 @@ var AUTO_COMPLETE_DOUBLE_TAB_DELAY = 500;
|
||||
var AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION = 200;
|
||||
var AUTO_COMPLETE_GLOBAL_KEYWORDS = _getAutoCompleteGlobalKeywords();
|
||||
|
||||
const LG_ANIMATION_TIME = 500;
|
||||
|
||||
function _getAutoCompleteGlobalKeywords() {
|
||||
const keywords = ['true', 'false', 'null', 'new'];
|
||||
// Don't add the private properties of window (i.e., ones starting with '_')
|
||||
@ -419,9 +420,12 @@ var ObjInspector = class ObjInspector {
|
||||
this.actor.show();
|
||||
if (sourceActor) {
|
||||
this.actor.set_scale(0, 0);
|
||||
Tweener.addTween(this.actor, { scale_x: 1, scale_y: 1,
|
||||
transition: 'easeOutQuad',
|
||||
time: 0.2 });
|
||||
this.actor.ease({
|
||||
scale_x: 1,
|
||||
scale_y: 1,
|
||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||
time: 200
|
||||
});
|
||||
} else {
|
||||
this.actor.set_scale(1, 1);
|
||||
}
|
||||
@ -941,7 +945,7 @@ var LookingGlass = class LookingGlass {
|
||||
this._completionActor.set_text(completions.join(', '));
|
||||
|
||||
// Setting the height to -1 allows us to get its actual preferred height rather than
|
||||
// whatever was last given in set_height by Tweener.
|
||||
// whatever was last set when animating
|
||||
this._completionActor.set_height(-1);
|
||||
let [, naturalHeight] = this._completionActor.get_preferred_height(this._resultsArea.get_width());
|
||||
|
||||
@ -950,28 +954,32 @@ var LookingGlass = class LookingGlass {
|
||||
this._completionActor.height = naturalHeight;
|
||||
} else {
|
||||
let settings = St.Settings.get();
|
||||
let duration = AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION / settings.slow_down_factor;
|
||||
this._completionActor.show();
|
||||
Tweener.removeTweens(this._completionActor);
|
||||
Tweener.addTween(this._completionActor, { time: AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION / (1000 * settings.slow_down_factor),
|
||||
transition: 'easeOutQuad',
|
||||
height: naturalHeight,
|
||||
opacity: 255
|
||||
});
|
||||
this._completionActor.remove_all_transitions();
|
||||
this._completionActor.ease({
|
||||
height: naturalHeight,
|
||||
opacity: 255,
|
||||
duration,
|
||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_hideCompletions() {
|
||||
if (this._completionActor) {
|
||||
let settings = St.Settings.get();
|
||||
Tweener.removeTweens(this._completionActor);
|
||||
Tweener.addTween(this._completionActor, { time: AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION / (1000 * settings.slow_down_factor),
|
||||
transition: 'easeOutQuad',
|
||||
height: 0,
|
||||
opacity: 0,
|
||||
onComplete: () => {
|
||||
this._completionActor.hide();
|
||||
}
|
||||
});
|
||||
let duration = AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION / settings.slow_down_factor;
|
||||
this._completionActor.remove_all_transitions();
|
||||
this._completionActor.ease({
|
||||
height: 0,
|
||||
opacity: 0,
|
||||
duration,
|
||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||
onComplete: () => {
|
||||
this._completionActor.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1080,15 +1088,16 @@ var LookingGlass = class LookingGlass {
|
||||
this._open = true;
|
||||
this._history.lastItem();
|
||||
|
||||
Tweener.removeTweens(this.actor);
|
||||
this.actor.remove_all_transitions();
|
||||
|
||||
// We inverse compensate for the slow-down so you can change the factor
|
||||
// through LookingGlass without long waits.
|
||||
let settings = St.Settings.get();
|
||||
Tweener.addTween(this.actor, { time: 0.5 / settings.slow_down_factor,
|
||||
transition: 'easeOutQuad',
|
||||
y: this._targetY
|
||||
});
|
||||
let duration = LG_ANIMATION_TIME / St.Settings.get().slow_down_factor;
|
||||
this.actor.ease({
|
||||
y: this._targetY,
|
||||
duration,
|
||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD
|
||||
});
|
||||
}
|
||||
|
||||
close() {
|
||||
@ -1098,20 +1107,21 @@ var LookingGlass = class LookingGlass {
|
||||
this._objInspector.actor.hide();
|
||||
|
||||
this._open = false;
|
||||
Tweener.removeTweens(this.actor);
|
||||
this.actor.remove_all_transitions();
|
||||
|
||||
this.setBorderPaintTarget(null);
|
||||
|
||||
Main.popModal(this._entry);
|
||||
|
||||
let settings = St.Settings.get();
|
||||
Tweener.addTween(this.actor, { time: Math.min(0.5 / settings.slow_down_factor, 0.5),
|
||||
transition: 'easeOutQuad',
|
||||
y: this._hiddenY,
|
||||
onComplete: () => {
|
||||
this.actor.hide();
|
||||
}
|
||||
});
|
||||
let duration = Math.min(LG_ANIMATION_TIME / settings.slow_down_factor,
|
||||
LG_ANIMATION_TIME);
|
||||
this.actor.ease({
|
||||
y: this._hiddenY,
|
||||
duration,
|
||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||
onComplete: () => this.actor.hide()
|
||||
});
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(LookingGlass.prototype);
|
||||
|
Reference in New Issue
Block a user