From d52c27228e2343832f9539fd10bff5c7f5714367 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 23 Jan 2023 12:57:24 +0100 Subject: [PATCH] :wrench: Port TV Glitch to GNOME --- extension.js | 1 + prefs.js | 1 + resources/ui/adw/TVGlitch.ui | 171 ++++++++++ resources/ui/gtk3/TVGlitch.ui | 297 ++++++++++++++++++ resources/ui/gtk4/TVGlitch.ui | 249 +++++++++++++++ ...ell.extensions.burn-my-windows.gschema.xml | 47 +++ src/TVGlitch.js | 29 +- 7 files changed, 781 insertions(+), 14 deletions(-) create mode 100644 resources/ui/adw/TVGlitch.ui create mode 100644 resources/ui/gtk3/TVGlitch.ui create mode 100644 resources/ui/gtk4/TVGlitch.ui diff --git a/extension.js b/extension.js index 4498a13..ead3dbe 100644 --- a/extension.js +++ b/extension.js @@ -69,6 +69,7 @@ class Extension { new Me.imports.src.SnapOfDisintegration.SnapOfDisintegration(), new Me.imports.src.TRexAttack.TRexAttack(), new Me.imports.src.TVEffect.TVEffect(), + new Me.imports.src.TVGlitch.TVGlitch(), new Me.imports.src.Wisps.Wisps(), ]; diff --git a/prefs.js b/prefs.js index dc2b818..fc64ba1 100644 --- a/prefs.js +++ b/prefs.js @@ -65,6 +65,7 @@ var PreferencesDialog = class PreferencesDialog { new Me.imports.src.SnapOfDisintegration.SnapOfDisintegration(), new Me.imports.src.TRexAttack.TRexAttack(), new Me.imports.src.TVEffect.TVEffect(), + new Me.imports.src.TVGlitch.TVGlitch(), new Me.imports.src.Wisps.Wisps(), ]; diff --git a/resources/ui/adw/TVGlitch.ui b/resources/ui/adw/TVGlitch.ui new file mode 100644 index 0000000..84539a3 --- /dev/null +++ b/resources/ui/adw/TVGlitch.ui @@ -0,0 +1,171 @@ + + + + + + + + + + + Animation Time [ms] + + + center + 1 + 0 + left + 300 + + + 2000 + 100 + 1 + 100 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Scale + + + center + 1 + 2 + left + 300 + + + 10 + 0.1 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Strength + + + center + 1 + 2 + left + 300 + + + 10 + 0.1 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Speed + + + center + 1 + 2 + left + 300 + + + 10 + 0.1 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Color + tv-glitch-color + + + center + 250 + 0 + 1 + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + \ No newline at end of file diff --git a/resources/ui/gtk3/TVGlitch.ui b/resources/ui/gtk3/TVGlitch.ui new file mode 100644 index 0000000..122177f --- /dev/null +++ b/resources/ui/gtk3/TVGlitch.ui @@ -0,0 +1,297 @@ + + + + + + + + 2000 + 100 + 1 + 100 + + + + 10 + 0.1 + 0.01 + 0.1 + + + + 10 + 0.1 + 0.01 + 0.1 + + + + 10 + 0.1 + 0.01 + 0.1 + + + + vertical + + + + + + none + + + + + 10 + 10 + 10 + 10 + 0 + + + 8 + + + Animation Time [ms] + 0 + start + center + 1 + + + + + end + center + 1 + 0 + left + 300 + tv-glitch-animation-time + + + + + + + edit-clear-symbolic + 1 + + + Reset to Default Value + + + + + + + + + + + 10 + 10 + 10 + 10 + 0 + + + 8 + + + Scale + 0 + start + center + 1 + + + + + end + center + 1 + 2 + left + 300 + tv-glitch-scale + + + + + + + edit-clear-symbolic + 1 + + + Reset to Default Value + + + + + + + + + + + 10 + 10 + 10 + 10 + 0 + + + 8 + + + Strength + 0 + start + center + 1 + + + + + end + center + 1 + 2 + left + 300 + tv-glitch-strength + + + + + + + edit-clear-symbolic + 1 + + + Reset to Default Value + + + + + + + + + + + 10 + 10 + 10 + 10 + 0 + + + 8 + + + Speed + 0 + start + center + 1 + + + + + end + center + 1 + 2 + left + 300 + tv-glitch-speed + + + + + + + edit-clear-symbolic + 1 + + + Reset to Default Value + + + + + + + + + + + 10 + 10 + 10 + 10 + 0 + + + + + Color + 0 + start + center + 1 + + + + + 0 + 1 + + + + + + + edit-clear-symbolic + 1 + + + Reset to Default Value + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/ui/gtk4/TVGlitch.ui b/resources/ui/gtk4/TVGlitch.ui new file mode 100644 index 0000000..f10fa9c --- /dev/null +++ b/resources/ui/gtk4/TVGlitch.ui @@ -0,0 +1,249 @@ + + + + + + + + vertical + + + + + + none + 1 + + + + + 0 + + + + + Animation Time [ms] + 0 + start + center + 1 + + + + + end + center + 1 + 0 + left + 300 + + + 2000 + 100 + 1 + 100 + + + + + + + edit-clear-symbolic + Reset to Default Value + + + + + + + + + + + 0 + + + + + Scale + 0 + start + center + 1 + + + + + end + center + 1 + 2 + left + 300 + + + 10 + 0.1 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + Reset to Default Value + + + + + + + + + + + 0 + + + + + Strength + 0 + start + center + 1 + + + + + end + center + 1 + 2 + left + 300 + + + 10 + 0.1 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + Reset to Default Value + + + + + + + + + + + 0 + + + + + Speed + 0 + start + center + 1 + + + + + end + center + 1 + 2 + left + 300 + + + 10 + 0.1 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + Reset to Default Value + + + + + + + + + + + 0 + + + + + Color + 0 + start + center + 1 + + + + + 0 + 1 + + + + + edit-clear-symbolic + Reset to Default Value + + + + + + + + + + + + + + + + + \ No newline at end of file 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 e0e2604..ffb8800 100644 --- a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml +++ b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml @@ -688,6 +688,53 @@ SPDX-License-Identifier: CC0-1.0 The color of the effect. + + + + + + + false + TV Glitch Close Effect + Use the Glitch effect for window closing. + + + + false + TV Glitch Open Effect + Use the Glitch effect for window opening. + + + + 750 + TV Glitch Animation Time + The time the Glitch effect takes. + + + + 1.0 + TV Glitch Scale + The size of the effect. + + + + 2.0 + TV Glitch Strength + The intensity of the effect. + + + + 2.0 + TV Glitch Speed + The speed of the effect. + + + + "rgb(100, 160, 255)" + TV Glitch Color + The color of the effect. + + diff --git a/src/TVGlitch.js b/src/TVGlitch.js index dda3bba..8510535 100644 --- a/src/TVGlitch.js +++ b/src/TVGlitch.js @@ -24,13 +24,14 @@ const utils = Me.imports.src.utils; const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory; ////////////////////////////////////////////////////////////////////////////////////////// -// This effect applies some intentional graphics issues to your windows. // +// This effect combines the Glitch and the TV Effect. Credits go to Kurt Wilson // +// (https://github.com/Kurtoid) for this idea! // ////////////////////////////////////////////////////////////////////////////////////////// // The effect class can be used to get some metadata (like the effect's name or supported // GNOME Shell versions), to initialize the respective page of the settings dialog, as // well as to create the actual shader for the effect. -var Glitch = class { +var TVGlitch = class { // The constructor creates a ShaderFactory which will be used by extension.js to create // shader instances for this effect. The shaders will be automagically created using the @@ -52,7 +53,7 @@ var Glitch = class { // Write all uniform values at the start of each animation. shader.connect('begin-animation', (shader, settings) => { - const c = Clutter.Color.from_string(settings.get_string('glitch-color'))[1]; + const c = Clutter.Color.from_string(settings.get_string('tv-glitch-color'))[1]; // If we are performing an integration tests, we use a fixed seed. const testMode = settings.get_boolean('test-mode'); @@ -60,9 +61,9 @@ var Glitch = class { // clang-format off shader.set_uniform_float(shader._uSeed, 1, [testMode ? 0 : Math.random()]); shader.set_uniform_float(shader._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]); - shader.set_uniform_float(shader._uScale, 1, [settings.get_double('glitch-scale')]); - shader.set_uniform_float(shader._uStrength, 1, [settings.get_double('glitch-strength')]); - shader.set_uniform_float(shader._uSpeed, 1, [settings.get_double('glitch-speed')]); + shader.set_uniform_float(shader._uScale, 1, [settings.get_double('tv-glitch-scale')]); + shader.set_uniform_float(shader._uStrength, 1, [settings.get_double('tv-glitch-strength')]); + shader.set_uniform_float(shader._uSpeed, 1, [settings.get_double('tv-glitch-speed')]); // clang-format on }); }); @@ -80,13 +81,13 @@ var Glitch = class { // effect is enabled currently (e.g. '*-close-effect'), and its animation time // (e.g. '*-animation-time'). getNick() { - return 'tvglitch'; + return 'tv-glitch'; } // This will be shown in the sidebar of the preferences dialog as well as in the // drop-down menus where the user can choose the effect. getLabel() { - return _('TVGlitch'); + return _('TV Glitch'); } // -------------------------------------------------------------------- API for prefs.js @@ -99,14 +100,14 @@ var Glitch = class { dialog.getBuilder().add_from_resource(`/ui/${utils.getUIDir()}/TVGlitch.ui`); // Bind all properties. - dialog.bindAdjustment('glitch-animation-time'); - dialog.bindAdjustment('glitch-scale'); - dialog.bindAdjustment('glitch-speed'); - dialog.bindAdjustment('glitch-strength'); - dialog.bindColorButton('glitch-color'); + dialog.bindAdjustment('tv-glitch-animation-time'); + dialog.bindAdjustment('tv-glitch-scale'); + dialog.bindAdjustment('tv-glitch-speed'); + dialog.bindAdjustment('tv-glitch-strength'); + dialog.bindColorButton('tv-glitch-color'); // Finally, return the new settings page. - return dialog.getBuilder().get_object('tvglitch-prefs'); + return dialog.getBuilder().get_object('tv-glitch-prefs'); } // ---------------------------------------------------------------- API for extension.js