1
- use iced:: { Column , Element , Length , Row , Text , Align } ;
1
+ use iced:: { Align , Column , Element , Length , Row , Text } ;
2
2
3
- use iced_audio:: { knob, ModulationRange , FloatRange , Knob ,
4
- mod_range_input, ModRangeInput , h_slider, HSlider , v_slider, VSlider } ;
3
+ use iced_audio:: {
4
+ h_slider, knob, mod_range_input, v_slider, FloatRange , HSlider , Knob ,
5
+ ModRangeInput , ModulationRange , VSlider ,
6
+ } ;
5
7
6
8
use crate :: { style, Step } ;
7
9
@@ -84,18 +86,20 @@ impl Default for ModRanges {
84
86
. modulation_range ( mod_range) ,
85
87
86
88
auto_input1_state : mod_range_input:: State :: new (
87
- float_range_bipolar. create_param_default ( ModRangesID :: ModRangeInput1 ) ,
89
+ float_range_bipolar
90
+ . create_param_default ( ModRangesID :: ModRangeInput1 ) ,
88
91
) ,
89
-
92
+
90
93
knob_auto1_state : knob:: State :: new (
91
94
float_range. create_param_default ( ModRangesID :: ModKnob1 ) ,
92
95
)
93
96
. modulation_range ( ModulationRange :: default ( ) ) ,
94
97
95
98
auto_input2_state : mod_range_input:: State :: new (
96
- float_range_bipolar. create_param_default ( ModRangesID :: ModRangeInput2 ) ,
99
+ float_range_bipolar
100
+ . create_param_default ( ModRangesID :: ModRangeInput2 ) ,
97
101
) ,
98
-
102
+
99
103
knob_auto2_state : knob:: State :: new (
100
104
float_range. create_param_default ( ModRangesID :: ModKnob2 ) ,
101
105
)
@@ -197,28 +201,30 @@ impl ModRanges {
197
201
if let Some ( mod_range) =
198
202
& mut self . knob_auto1_state . modulation_range
199
203
{
200
- let auto_value = self . float_range_bipolar
204
+ let auto_value = self
205
+ . float_range_bipolar
201
206
. to_value ( self . auto_input1_state . param . normal ) ;
202
207
203
- mod_range. start = self . knob_auto1_state . param . normal ;
204
- mod_range. end = ( mod_range. start . value ( ) +
205
- auto_value) . into ( ) ;
208
+ mod_range. start =
209
+ self . knob_auto1_state . param . normal ;
210
+ mod_range. end =
211
+ ( mod_range. start . value ( ) + auto_value) . into ( ) ;
206
212
}
207
213
}
208
214
ModRangesID :: ModRangeInput1 => {
209
- let auto_value = self . float_range_bipolar
215
+ let auto_value = self
216
+ . float_range_bipolar
210
217
. to_value ( self . auto_input1_state . param . normal ) ;
211
218
212
- self . output_text = crate :: info_text_f32 (
213
- id,
214
- auto_value,
215
- ) ;
219
+ self . output_text = crate :: info_text_f32 ( id, auto_value) ;
216
220
217
221
if let Some ( mod_range) =
218
222
& mut self . knob_auto1_state . modulation_range
219
223
{
220
- mod_range. end = ( self . knob_auto1_state . param . normal . value ( ) +
221
- auto_value) . into ( ) ;
224
+ mod_range. end =
225
+ ( self . knob_auto1_state . param . normal . value ( )
226
+ + auto_value)
227
+ . into ( ) ;
222
228
}
223
229
}
224
230
@@ -232,28 +238,30 @@ impl ModRanges {
232
238
if let Some ( mod_range) =
233
239
& mut self . knob_auto2_state . modulation_range
234
240
{
235
- let auto_value = self . float_range_bipolar
241
+ let auto_value = self
242
+ . float_range_bipolar
236
243
. to_value ( self . auto_input2_state . param . normal ) ;
237
244
238
- mod_range. start = self . knob_auto2_state . param . normal ;
239
- mod_range. end = ( mod_range. start . value ( ) +
240
- auto_value) . into ( ) ;
245
+ mod_range. start =
246
+ self . knob_auto2_state . param . normal ;
247
+ mod_range. end =
248
+ ( mod_range. start . value ( ) + auto_value) . into ( ) ;
241
249
}
242
250
}
243
251
ModRangesID :: ModRangeInput2 => {
244
- let auto_value = self . float_range_bipolar
252
+ let auto_value = self
253
+ . float_range_bipolar
245
254
. to_value ( self . auto_input2_state . param . normal ) ;
246
255
247
- self . output_text = crate :: info_text_f32 (
248
- id,
249
- auto_value,
250
- ) ;
256
+ self . output_text = crate :: info_text_f32 ( id, auto_value) ;
251
257
252
258
if let Some ( mod_range) =
253
259
& mut self . knob_auto2_state . modulation_range
254
260
{
255
- mod_range. end = ( self . knob_auto2_state . param . normal . value ( ) +
256
- auto_value) . into ( ) ;
261
+ mod_range. end =
262
+ ( self . knob_auto2_state . param . normal . value ( )
263
+ + auto_value)
264
+ . into ( ) ;
257
265
}
258
266
}
259
267
}
@@ -270,19 +278,18 @@ impl ModRanges {
270
278
271
279
let knob_end = Knob :: new ( & mut self . knob_end_state , Message :: KnobMoved ) ;
272
280
273
- let knob1 =
274
- Knob :: new ( & mut self . knob1_state , Message :: KnobMoved )
275
- . style ( style:: KnobCustomArc ) ;
276
-
281
+ let knob1 = Knob :: new ( & mut self . knob1_state , Message :: KnobMoved )
282
+ . style ( style:: KnobCustomArc ) ;
283
+
277
284
let auto_input1 =
278
285
ModRangeInput :: new ( & mut self . auto_input1_state , Message :: KnobMoved )
279
286
. size ( Length :: from ( 10 ) )
280
287
. style ( style:: ModRangeInputCustom ) ;
281
-
288
+
282
289
let knob_auto1 =
283
290
Knob :: new ( & mut self . knob_auto1_state , Message :: KnobMoved )
284
291
. style ( style:: KnobCustomStyleCircle ) ;
285
-
292
+
286
293
let h_slider1 =
287
294
HSlider :: new ( & mut self . h_slider1_state , Message :: KnobMoved )
288
295
. style ( style:: HSliderRectStyle ) ;
@@ -291,55 +298,63 @@ impl ModRanges {
291
298
VSlider :: new ( & mut self . v_slider1_state , Message :: KnobMoved )
292
299
. width ( Length :: from ( Length :: Units ( 30 ) ) )
293
300
. style ( style:: VSliderRectStyle ) ;
294
-
301
+
295
302
let auto_input2 =
296
303
ModRangeInput :: new ( & mut self . auto_input2_state , Message :: KnobMoved )
297
304
. size ( Length :: from ( 15 ) )
298
305
. style ( mod_range_input:: DefaultInvisible ) ;
299
-
306
+
300
307
let knob_auto2 =
301
308
Knob :: new ( & mut self . knob_auto2_state , Message :: KnobMoved )
302
309
. style ( style:: KnobCustomStyleCircle ) ;
303
310
304
311
// push the widgets into rows
305
- let knob_row = Row :: new ( ) . spacing ( 20 ) . push (
306
- Column :: new ( )
307
- . max_width ( 125 )
308
- . spacing ( 10 )
309
- . push ( Text :: new ( "Range Start" ) )
310
- . push ( knob_start)
311
- . push ( Text :: new ( "Range End" ) )
312
- . push ( knob_end)
313
- )
314
- . push ( Column :: new ( )
315
- . max_width ( 125 )
316
- . max_height ( 250 )
317
- . align_items ( Align :: Center )
312
+ let knob_row = Row :: new ( )
318
313
. spacing ( 20 )
319
- . push ( knob1)
320
- . push ( h_slider1)
321
- . push ( v_slider1)
322
- )
323
- . push ( Column :: new ( )
324
- . width ( Length :: Fill )
325
- . spacing ( 10 )
326
- . push ( Column :: new ( )
327
- . width ( Length :: Fill )
328
- . spacing ( 10 )
329
- . align_items ( Align :: Center )
330
- . push ( Text :: new ( "Custom Style with ModRangeInput" ) )
331
- . push ( auto_input1)
332
- . push ( knob_auto1) ,
314
+ . push (
315
+ Column :: new ( )
316
+ . max_width ( 125 )
317
+ . spacing ( 10 )
318
+ . push ( Text :: new ( "Range Start" ) )
319
+ . push ( knob_start)
320
+ . push ( Text :: new ( "Range End" ) )
321
+ . push ( knob_end) ,
333
322
)
334
- . push ( Column :: new ( )
335
- . width ( Length :: Fill )
336
- . spacing ( 0 )
337
- . align_items ( Align :: Center )
338
- . push ( Text :: new ( "Custom Style with invisible ModRangeInput" ) )
339
- . push ( auto_input2)
340
- . push ( knob_auto2) ,
323
+ . push (
324
+ Column :: new ( )
325
+ . max_width ( 125 )
326
+ . max_height ( 250 )
327
+ . align_items ( Align :: Center )
328
+ . spacing ( 20 )
329
+ . push ( knob1)
330
+ . push ( h_slider1)
331
+ . push ( v_slider1) ,
341
332
)
342
- ) ;
333
+ . push (
334
+ Column :: new ( )
335
+ . width ( Length :: Fill )
336
+ . spacing ( 10 )
337
+ . push (
338
+ Column :: new ( )
339
+ . width ( Length :: Fill )
340
+ . spacing ( 10 )
341
+ . align_items ( Align :: Center )
342
+ . push ( Text :: new ( "Custom Style with ModRangeInput" ) )
343
+ . push ( auto_input1)
344
+ . push ( knob_auto1) ,
345
+ )
346
+ . push (
347
+ Column :: new ( )
348
+ . width ( Length :: Fill )
349
+ . spacing ( 0 )
350
+ . align_items ( Align :: Center )
351
+ . push ( Text :: new (
352
+ "Custom Style with invisible ModRangeInput" ,
353
+ ) )
354
+ . push ( auto_input2)
355
+ . push ( knob_auto2) ,
356
+ ) ,
357
+ ) ;
343
358
344
359
let content = Column :: new ( )
345
360
. spacing ( 20 )
0 commit comments