12
12
// SPDX-FileCopyrightText: Simon Schneegans <[email protected] >
13
13
// SPDX-License-Identifier: GPL-3.0-or-later
14
14
15
+ // modified by Justin Garza <[email protected] >
16
+
15
17
'use strict' ;
16
18
17
19
import Gio from 'gi://Gio' ;
@@ -58,6 +60,9 @@ export default class Effect {
58
60
shader . _uScale = shader . get_uniform_location ( 'uScale' ) ;
59
61
shader . _uMovementSpeed = shader . get_uniform_location ( 'uMovementSpeed' ) ;
60
62
63
+ shader . _uRandomColor = shader . get_uniform_location ( 'uRandomColor' ) ;
64
+ shader . _uSeed = shader . get_uniform_location ( 'uSeed' ) ;
65
+
61
66
// And update all uniforms at the start of each animation.
62
67
shader . connect ( 'begin-animation' , ( shader , settings ) => {
63
68
for ( let i = 1 ; i <= 5 ; i ++ ) {
@@ -68,6 +73,8 @@ export default class Effect {
68
73
69
74
// clang-format off
70
75
shader . set_uniform_float ( shader . _u3DNoise , 1 , [ settings . get_boolean ( 'fire-3d-noise' ) ] ) ;
76
+ shader . set_uniform_float ( shader . _uRandomColor , 1 , [ settings . get_boolean ( 'fire-random-color' ) ] ) ;
77
+ shader . set_uniform_float ( shader . _uSeed , 1 , [ Math . random ( ) ] ) ;
71
78
shader . set_uniform_float ( shader . _uScale , 1 , [ settings . get_double ( 'fire-scale' ) ] ) ;
72
79
shader . set_uniform_float ( shader . _uMovementSpeed , 1 , [ settings . get_double ( 'fire-movement-speed' ) ] ) ;
73
80
// clang-format on
@@ -107,6 +114,7 @@ export default class Effect {
107
114
dialog . bindAdjustment ( 'fire-movement-speed' ) ;
108
115
dialog . bindAdjustment ( 'fire-scale' ) ;
109
116
dialog . bindSwitch ( 'fire-3d-noise' ) ;
117
+ dialog . bindSwitch ( 'fire-random-color' ) ;
110
118
dialog . bindColorButton ( 'fire-color-1' ) ;
111
119
dialog . bindColorButton ( 'fire-color-2' ) ;
112
120
dialog . bindColorButton ( 'fire-color-3' ) ;
@@ -129,6 +137,33 @@ export default class Effect {
129
137
// Initialize the fire-preset dropdown.
130
138
Effect . _createFirePresets ( dialog ) ;
131
139
}
140
+
141
+ // enables and disables the color buttons
142
+ function EnableDisableColorButtons ( dialog , state ) {
143
+
144
+ for ( let i = 1 ; i <= 5 ; i ++ ) {
145
+ dialog . getBuilder ( ) . get_object ( 'fire-color-' + i ) . set_sensitive ( ! state ) ;
146
+ }
147
+ }
148
+
149
+ const switchWidget = dialog . getBuilder ( ) . get_object ( 'fire-random-color' ) ;
150
+ if ( switchWidget ) {
151
+ // Connect to the "state-set" signal to update preferences dynamically based on
152
+ // the switch state.
153
+ switchWidget . connect ( 'state-set' , ( widget , state ) => {
154
+ EnableDisableColorButtons ( dialog ,
155
+ state ) ; // Update sensitivity when the state changes.
156
+ } ) ;
157
+
158
+ // Manually call the update function on startup, using the initial state of the
159
+ // switch.
160
+ const initialState =
161
+ switchWidget . get_active ( ) ; // Get the current state of the switch.
162
+ EnableDisableColorButtons ( dialog , initialState ) ;
163
+ } else {
164
+ // Log an error if the switch widget is not found in the UI.
165
+ log ( 'Error: \'fire-random-color\' switch widget not found.' ) ;
166
+ }
132
167
}
133
168
134
169
// ---------------------------------------------------------------- API for extension.js
0 commit comments