🔧 Add transiation tweaking
This commit is contained in:
+17
-29
@@ -24,7 +24,7 @@ const Me = imports.misc.extensionUtils.getCurrentExtension();
|
|||||||
const utils = Me.imports.src.utils;
|
const utils = Me.imports.src.utils;
|
||||||
const FireEffect = Me.imports.src.FireEffect.FireEffect;
|
const FireEffect = Me.imports.src.FireEffect.FireEffect;
|
||||||
|
|
||||||
const EFFECT_TYPES = [
|
const ALL_EFFECTS = [
|
||||||
Me.imports.src.FireEffect.FireEffect,
|
Me.imports.src.FireEffect.FireEffect,
|
||||||
Me.imports.src.MatrixEffect.MatrixEffect,
|
Me.imports.src.MatrixEffect.MatrixEffect,
|
||||||
Me.imports.src.TRexEffect.TRexEffect,
|
Me.imports.src.TRexEffect.TRexEffect,
|
||||||
@@ -136,39 +136,27 @@ class Extension {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's a transition in progress, we re-target these transitions so that the
|
// Choose a random effect.
|
||||||
// window is neither scaled nor faded.
|
const enabledEffects = [];
|
||||||
const tweakTransition = (property, value) => {
|
ALL_EFFECTS.forEach(Effect => {
|
||||||
const transition = actor.get_transition(property);
|
const [minMajor, minMinor] = Effect.getMinShellVersion();
|
||||||
if (transition) {
|
const prefix = Effect.getSettingsPrefix();
|
||||||
transition.set_to(value);
|
if (utils.shellVersionIsAtLeast(minMajor, minMinor) &&
|
||||||
transition.set_progress_mode(Clutter.AnimationMode.EASE_OUT_QUAD);
|
this._settings.get_boolean(`${prefix}-close-effect`)) {
|
||||||
transition.set_duration(1500);
|
enabledEffects.push(Effect);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
tweakTransition('opacity', 255);
|
if (enabledEffects.length == 0) {
|
||||||
tweakTransition('scale-x', 1);
|
return;
|
||||||
tweakTransition('scale-y', 1);
|
}
|
||||||
|
|
||||||
let shader = null;
|
const Effect = enabledEffects[Math.floor(Math.random() * enabledEffects.length)];
|
||||||
|
|
||||||
|
Effect.tweakTransitions(actor, this._settings);
|
||||||
|
|
||||||
// Add a cool shader to our window actor!
|
// Add a cool shader to our window actor!
|
||||||
// const mode = this._settings.get_enum('close-animation');
|
const shader = Effect.createShader(this._settings);
|
||||||
// if (mode == 1) {
|
|
||||||
shader = FireEffect.createShader(this._settings);
|
|
||||||
// } else if (mode == 2) {
|
|
||||||
// shader = new MatrixShader(this._settings);
|
|
||||||
// } else if (mode == 3) {
|
|
||||||
// shader = new TVEffectShader(this._settings);
|
|
||||||
// tweakTransition('scale-y', 0.5);
|
|
||||||
// } else if (mode == 4) {
|
|
||||||
// shader = new TRexShader(this._settings);
|
|
||||||
|
|
||||||
// const warp = 0.5 * this._settings.get_double('claw-scratch-warp');
|
|
||||||
// tweakTransition('scale-x', 1.0 + warp);
|
|
||||||
// tweakTransition('scale-y', 1.0 + warp);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (shader) {
|
if (shader) {
|
||||||
actor.add_effect(shader);
|
actor.add_effect(shader);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const ExtensionUtils = imports.misc.extensionUtils;
|
|||||||
const Me = imports.misc.extensionUtils.getCurrentExtension();
|
const Me = imports.misc.extensionUtils.getCurrentExtension();
|
||||||
const utils = Me.imports.src.utils;
|
const utils = Me.imports.src.utils;
|
||||||
|
|
||||||
const EFFECT_TYPES = [
|
const ALL_EFFECTS = [
|
||||||
Me.imports.src.FireEffect.FireEffect,
|
Me.imports.src.FireEffect.FireEffect,
|
||||||
Me.imports.src.MatrixEffect.MatrixEffect,
|
Me.imports.src.MatrixEffect.MatrixEffect,
|
||||||
Me.imports.src.TRexEffect.TRexEffect,
|
Me.imports.src.TRexEffect.TRexEffect,
|
||||||
@@ -57,10 +57,10 @@ var PreferencesDialog = class PreferencesDialog {
|
|||||||
stack.add_titled(
|
stack.add_titled(
|
||||||
this._builder.get_object('general-prefs'), 'general', 'General Options');
|
this._builder.get_object('general-prefs'), 'general', 'General Options');
|
||||||
|
|
||||||
EFFECT_TYPES.forEach(Type => {
|
ALL_EFFECTS.forEach(Effect => {
|
||||||
const [minMajor, minMinor] = Type.getMinShellVersion();
|
const [minMajor, minMinor] = Effect.getMinShellVersion();
|
||||||
if (utils.shellVersionIsAtLeast(minMajor, minMinor)) {
|
if (utils.shellVersionIsAtLeast(minMajor, minMinor)) {
|
||||||
Type.initPreferences(this);
|
Effect.initPreferences(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -107,11 +107,11 @@ var PreferencesDialog = class PreferencesDialog {
|
|||||||
|
|
||||||
const menu = this._builder.get_object('close-effect-menu');
|
const menu = this._builder.get_object('close-effect-menu');
|
||||||
|
|
||||||
EFFECT_TYPES.forEach(Type => {
|
ALL_EFFECTS.forEach(Effect => {
|
||||||
const [minMajor, minMinor] = Type.getMinShellVersion();
|
const [minMajor, minMinor] = Effect.getMinShellVersion();
|
||||||
if (utils.shellVersionIsAtLeast(minMajor, minMinor)) {
|
if (utils.shellVersionIsAtLeast(minMajor, minMinor)) {
|
||||||
const prefix = Type.getSettingsPrefix();
|
const prefix = Effect.getSettingsPrefix();
|
||||||
const label = Type.getLabel();
|
const label = Effect.getLabel();
|
||||||
|
|
||||||
const action = this._settings.create_action(`${prefix}-close-effect`);
|
const action = this._settings.create_action(`${prefix}-close-effect`);
|
||||||
group.add_action(action);
|
group.add_action(action);
|
||||||
|
|||||||
@@ -215,6 +215,24 @@ var FireEffect = class FireEffect {
|
|||||||
return new FireShader(settings);
|
return new FireShader(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there's a transition in progress, we re-target these transitions so that the
|
||||||
|
// window is neither scaled nor faded.
|
||||||
|
static tweakTransitions(actor, settings) {
|
||||||
|
const animationTime = settings.get_int('fire-animation-time');
|
||||||
|
|
||||||
|
const tweakTransition = (property, value) => {
|
||||||
|
const transition = actor.get_transition(property);
|
||||||
|
if (transition) {
|
||||||
|
transition.set_to(value);
|
||||||
|
transition.set_duration(animationTime);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tweakTransition('opacity', 255);
|
||||||
|
tweakTransition('scale-x', 1);
|
||||||
|
tweakTransition('scale-y', 1);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- private stuff
|
// ----------------------------------------------------------------------- private stuff
|
||||||
|
|
||||||
// This populates the preset dropdown menu for the fire options.
|
// This populates the preset dropdown menu for the fire options.
|
||||||
|
|||||||
@@ -190,4 +190,22 @@ var MatrixEffect = class MatrixEffect {
|
|||||||
static createShader(settings) {
|
static createShader(settings) {
|
||||||
return new MatrixShader(settings);
|
return new MatrixShader(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there's a transition in progress, we re-target these transitions so that the
|
||||||
|
// window is neither scaled nor faded.
|
||||||
|
static tweakTransitions(actor, settings) {
|
||||||
|
const animationTime = settings.get_int('matrix-animation-time');
|
||||||
|
|
||||||
|
const tweakTransition = (property, value) => {
|
||||||
|
const transition = actor.get_transition(property);
|
||||||
|
if (transition) {
|
||||||
|
transition.set_to(value);
|
||||||
|
transition.set_duration(animationTime);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tweakTransition('opacity', 255);
|
||||||
|
tweakTransition('scale-x', 1);
|
||||||
|
tweakTransition('scale-y', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -201,4 +201,24 @@ var TRexEffect = class TRexEffect {
|
|||||||
static createShader(settings) {
|
static createShader(settings) {
|
||||||
return new TRexShader(settings);
|
return new TRexShader(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there's a transition in progress, we re-target these transitions so that the
|
||||||
|
// window is neither scaled nor faded.
|
||||||
|
static tweakTransitions(actor, settings) {
|
||||||
|
const animationTime = settings.get_int('trex-animation-time');
|
||||||
|
|
||||||
|
const tweakTransition = (property, value) => {
|
||||||
|
const transition = actor.get_transition(property);
|
||||||
|
if (transition) {
|
||||||
|
transition.set_to(value);
|
||||||
|
transition.set_duration(animationTime);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const warp = 0.5 * settings.get_double('claw-scratch-warp');
|
||||||
|
|
||||||
|
tweakTransition('opacity', 255);
|
||||||
|
tweakTransition('scale-x', 1.0 + warp);
|
||||||
|
tweakTransition('scale-y', 1.0 + warp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -130,4 +130,22 @@ var TVEffect = class TVEffect {
|
|||||||
static createShader(settings) {
|
static createShader(settings) {
|
||||||
return new TVEffectShader(settings);
|
return new TVEffectShader(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there's a transition in progress, we re-target these transitions so that the
|
||||||
|
// window is neither scaled nor faded.
|
||||||
|
static tweakTransitions(actor, settings) {
|
||||||
|
const animationTime = settings.get_int('tv-animation-time');
|
||||||
|
|
||||||
|
const tweakTransition = (property, value) => {
|
||||||
|
const transition = actor.get_transition(property);
|
||||||
|
if (transition) {
|
||||||
|
transition.set_to(value);
|
||||||
|
transition.set_duration(animationTime);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tweakTransition('opacity', 255);
|
||||||
|
tweakTransition('scale-x', 1);
|
||||||
|
tweakTransition('scale-y', 0.5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user