🔧 Make animation type configurable

This commit is contained in:
Simon Schneegans
2021-12-24 13:08:45 +01:00
parent 32a57cc523
commit 9e374d04d0
5 changed files with 107 additions and 18 deletions
+20 -10
View File
@@ -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);
});
}
});
}
+7
View File
@@ -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) {
+59
View File
@@ -2,6 +2,23 @@
<interface domain="desktop-cube">
<requires lib="gtk" version="4.0" />
<object class="GtkListStore" id="animation-mode-list">
<columns>
<column type="gchararray" />
<column type="gchararray" />
</columns>
<data>
<row>
<col id="0">Fire</col>
<col id="1">fire</col>
</row>
<row>
<col id="0">Matrix</col>
<col id="1">matrix</col>
</row>
</data>
</object>
<object class="GtkScrolledWindow" id="settings-widget">
<property name="hscrollbar-policy">never</property>
<property name="min-content-height">200</property>
@@ -42,6 +59,48 @@
</style>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Close Window Animation</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkComboBox" id="close-animation">
<property name="valign">center</property>
<property name="model">animation-mode-list</property>
<property name="id_column">1</property>
<property name="active_id">fire</property>
<child>
<object class="GtkCellRendererText" />
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="reset-close-animation">
<property name="icon-name">edit-clear-symbolic</property>
<property name="tooltip-text">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
@@ -1,8 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<enum id='org.gnome.shell.extensions.burn-my-windows.AnimationType'>
<value value='1' nick='fire' />
<value value='2' nick='matrix' />
</enum>
<schema path="/org/gnome/shell/extensions/burn-my-windows/" id="org.gnome.shell.extensions.burn-my-windows">
<key name="close-animation" enum="org.gnome.shell.extensions.burn-my-windows.AnimationType">
<default>"fire"</default>
<summary>Close Animation</summary>
<description>The animation used for window closing.</description>
</key>
<key name="destroy-animation-time" type="i">
<default>2000</default>
<summary>Destroy Animation Time</summary>
+9 -8
View File
@@ -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());