From 9e374d04d0712d2957bdcfc76088750b3e9ab1b6 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Fri, 24 Dec 2021 13:08:45 +0100 Subject: [PATCH] :wrench: Make animation type configurable --- extension.js | 30 ++++++---- prefs.js | 7 +++ resources/ui/gtk4.ui | 59 +++++++++++++++++++ ...ell.extensions.burn-my-windows.gschema.xml | 12 ++++ src/extension/MatrixShader.js | 17 +++--- 5 files changed, 107 insertions(+), 18 deletions(-) diff --git a/extension.js b/extension.js index 675a1cd..06d77b6 100644 --- a/extension.js +++ b/extension.js @@ -131,17 +131,27 @@ class Extension { tweakTransition('scale-x', 1); tweakTransition('scale-y', 1); - // Instead, we add a cool shader to our window actor! - const shader = new MatrixShader(this._settings); - actor.add_effect(shader); + let shader = null; - // Update uniforms at each frame. - transition.connect('new-frame', (t) => { - shader.set_uniform_value('uProgress', t.get_progress()); - shader.set_uniform_value('uTime', 0.001 * t.get_elapsed_time()); - shader.set_uniform_value('uSizeX', actor.width); - shader.set_uniform_value('uSizeY', actor.height); - }); + // Add a cool shader to our window actor! + const mode = this._settings.get_enum('close-animation'); + if (mode == 1) { + shader = new FireShader(this._settings); + } else if (mode == 2) { + shader = new MatrixShader(this._settings); + } + + if (shader) { + actor.add_effect(shader); + + // Update uniforms at each frame. + transition.connect('new-frame', (t) => { + shader.set_uniform_value('uProgress', t.get_progress()); + shader.set_uniform_value('uTime', 0.001 * t.get_elapsed_time()); + shader.set_uniform_value('uSizeX', actor.width); + shader.set_uniform_value('uSizeY', actor.height); + }); + } }); } diff --git a/prefs.js b/prefs.js index cfb1e20..3d8db07 100644 --- a/prefs.js +++ b/prefs.js @@ -44,6 +44,7 @@ var PreferencesDialog = class PreferencesDialog { // Bind all properties. this._bindAdjustment('destroy-animation-time'); + this._bindCombobox('close-animation'); this._bindAdjustment('flame-movement-speed'); this._bindAdjustment('flame-scale'); this._bindColorButton('fire-color-1'); @@ -90,6 +91,12 @@ var PreferencesDialog = class PreferencesDialog { // ----------------------------------------------------------------------- private stuff + // Connects a Gtk.ComboBox (or anything else which has an 'active-id' property) to a + // settings key. It also binds the corresponding reset button. + _bindCombobox(settingsKey) { + this._bind(settingsKey, 'active-id'); + } + // Connects a Gtk.Adjustment (or anything else which has a 'value' property) to a // settings key. It also binds the corresponding reset button. _bindAdjustment(settingsKey) { diff --git a/resources/ui/gtk4.ui b/resources/ui/gtk4.ui index 01046c9..0073722 100644 --- a/resources/ui/gtk4.ui +++ b/resources/ui/gtk4.ui @@ -2,6 +2,23 @@ + + + + + + + + Fire + fire + + + Matrix + matrix + + + + never 200 @@ -42,6 +59,48 @@ + + + 0 + + + + + Close Window Animation + 0 + start + center + 1 + + + + + center + animation-mode-list + 1 + fire + + + + 0 + + + + + + + edit-clear-symbolic + Reset to Default Value + + + + + + + + 0 diff --git a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml index 6ff4329..7e1af3f 100644 --- a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml +++ b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml @@ -1,8 +1,20 @@ + + + + + + + "fire" + Close Animation + The animation used for window closing. + + + 2000 Destroy Animation Time diff --git a/src/extension/MatrixShader.js b/src/extension/MatrixShader.js index d6df16d..b4b8f8f 100644 --- a/src/extension/MatrixShader.js +++ b/src/extension/MatrixShader.js @@ -51,14 +51,14 @@ var MatrixShader = GObject.registerClass({Properties: {}, Signals: {}}, uniform sampler2D uFontTexture; // These may be configurable in the future. - const float EDGE_FADE = 30; - const float FADE_WIDTH = 150; - const float TRAIL_LENGTH = 0.2; - const float FINAL_FADE_START_TIME = 0.8; - const float LETTER_TILES = 16.0; - const float LETTER_SIZE = ${settings.get_int('matrix-scale')}; + const float EDGE_FADE = 30; + const float FADE_WIDTH = 150; + const float TRAIL_LENGTH = 0.2; + const float FINAL_FADE_START_TIME = 0.8; + const float LETTER_TILES = 16.0; + const float LETTER_SIZE = ${settings.get_int('matrix-scale')}; const float LETTER_FLICKER_SPEED = 2.0; - const float RANDOMNESS = ${settings.get_double('matrix-randomness')}; + const float RANDOMNESS = ${settings.get_double('matrix-randomness')}; // This returns a flickering grid of random letters. float getText(vec2 fragCoord) { @@ -117,7 +117,7 @@ var MatrixShader = GObject.registerClass({Properties: {}, Signals: {}}, vec3 tipColor = vec3(${tipColor.red / 255}, ${tipColor.green / 255}, ${tipColor.blue / 255}); - cogl_color_out.rgb += mix(trailColor, tipColor, pow(rainAlpha, 5)) * rainAlpha * text; + cogl_color_out.rgb += mix(trailColor, tipColor, min(1, pow(rainAlpha+0.1, 4))) * rainAlpha * text; // These are pretty useful for understanding how this works. // cogl_color_out = vec4(vec3(text), 1); @@ -127,6 +127,7 @@ var MatrixShader = GObject.registerClass({Properties: {}, Signals: {}}, `); }; + // This is overridden to bind the font texture for drawing. vfunc_paint_target(node, paint_context) { const pipeline = this.get_pipeline(); pipeline.set_layer_texture(1, this._fontTexture.get_texture());