gled 2.28.5

gled is an application for creating animations and effects on artnet or dmx installations
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
use super::{
    UiAction, apply_palette_action, location_by_target, scene_effect_by_target,
    scene_instance_by_target, set_scene_opacity, update_animation,
};
use crate::{
    app::{App, svg::Svg},
    input::{artnet::ARTNET_CONFIG, event::InputEvent},
    pipeline::group::Group,
    storage::asset::{
        Asset,
        animation::{
            argument::{Argument, ArgumentKind},
            config::float_value::FloatValue,
        },
        curve::multiplied_curve::MultipliedCurve,
    },
};
use notify_rust::Notification;
use std::sync::Arc;

impl App {
    #[cfg_attr(feature = "profiling", profiling::function)]
    pub fn handle_ui_actions(&mut self) {
        loop {
            let Ok(Some(action)) = self.ui_action_receiver.try_recv() else {
                return;
            };
            tracing::trace!("Handling ui action: {action:?}");

            if let Some(project) = &mut self.project
                && apply_palette_action(
                    project,
                    self.selected_scene_instance,
                    &self.collections,
                    &action,
                )
            {
                continue;
            }

            match (&mut self.project, action) {
                (Some(project), UiAction::AddScene(pos, scene)) => {
                    project.add_scene(pos, scene, &self.collections);
                }
                (Some(project), UiAction::DeleteSceneInstance { location }) => {
                    project.remove_scene_instance(location);
                }
                (Some(project), UiAction::DeleteSceneInstancePath(path)) => {
                    if let Some(location) =
                        location_by_target(project, path, self.selected_scene_instance)
                    {
                        project.remove_scene_instance(location);
                    }
                }
                (Some(project), UiAction::CloneSceneInstance(location)) => {
                    if let Some(scene_instance) = project
                        .get_scenes_instance(&location)
                        .map(|scene_instance| scene_instance.cloned_with_new_id(&self.collections))
                    {
                        let target = project.next_empty_grid_location(location);
                        project.add_scene_instance(target, scene_instance);
                    }
                }
                (Some(project), UiAction::CloneSceneInstancePath(path)) => {
                    if let Some(location) =
                        location_by_target(project, path, self.selected_scene_instance)
                        && let Some(scene_instance) =
                            project
                                .get_scenes_instance(&location)
                                .map(|scene_instance| {
                                    scene_instance.cloned_with_new_id(&self.collections)
                                })
                    {
                        let target = project.next_empty_grid_location(location);
                        project.add_scene_instance(target, scene_instance);
                    }
                }
                (Some(project), UiAction::ReloadShaderCode(animation)) => {
                    project.reload_shader_code(animation, &self.collections);
                    self.windows
                        .scenes
                        .reload_shader_code(animation, &mut self.collections);
                }
                (Some(project), UiAction::SendPositions) => {
                    project.send_positions();
                }
                (Some(project), UiAction::SetSvg(svg)) => {
                    project.svg = svg;
                    project.remove_nonexistant_groups();
                }
                (Some(project), UiAction::SetSceneOpacity(path, opacity)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        set_scene_opacity(scene_instance, opacity);
                    }
                }
                (Some(project), UiAction::SetMainDimmer(dimmer)) => {
                    project.main_dimmer = dimmer;
                }
                (Some(project), UiAction::SetProjectArtnetControlActive(active)) => {
                    project.artnet_control_config(|config| config.active = active);
                }
                (Some(project), UiAction::SetProjectArtnetControlUniverse(universe)) => {
                    project.artnet_control_config(|config| config.universe = universe);
                }
                (Some(project), UiAction::SetProjectOscActive(active)) => {
                    project.osc_config.active = active;
                    let osc_config = project.osc_config;
                    self.apply_osc_config(osc_config);
                }
                (Some(project), UiAction::SetProjectOscPort(port)) => {
                    project.osc_config.port = port;
                    let osc_config = project.osc_config;
                    self.apply_osc_config(osc_config);
                }
                (Some(project), UiAction::SetProjectGroup(group_index, group_name)) => {
                    project.groups.insert(group_index, Group(group_name));
                }
                (Some(project), UiAction::RemoveProjectGroup(group_index)) => {
                    project.groups.remove(group_index);
                }
                (Some(project), UiAction::ClearProjectGroups) => {
                    project.groups.clear();
                }
                (Some(project), UiAction::AddProjectTapInputArtnet(channel)) => {
                    project.tap_input_events.insert(InputEvent::Artnet(channel));
                }
                (Some(project), UiAction::RemoveProjectTapInputArtnet(channel)) => {
                    project
                        .tap_input_events
                        .remove(&InputEvent::Artnet(channel));
                }
                (Some(project), UiAction::ClearProjectTapInput) => {
                    project.tap_input_events.clear();
                }
                (Some(project), UiAction::AddProjectBlackoutInputArtnet(channel)) => {
                    project
                        .blackout_input_events
                        .insert(InputEvent::Artnet(channel));
                }
                (Some(project), UiAction::RemoveProjectBlackoutInputArtnet(channel)) => {
                    project
                        .blackout_input_events
                        .remove(&InputEvent::Artnet(channel));
                }
                (Some(project), UiAction::ClearProjectBlackoutInput) => {
                    project.blackout_input_events.clear();
                }
                (Some(project), UiAction::AddProjectBlackoutHoldInputArtnet(channel)) => {
                    project
                        .blackout_hold_input_events
                        .insert(InputEvent::Artnet(channel));
                }
                (Some(project), UiAction::RemoveProjectBlackoutHoldInputArtnet(channel)) => {
                    project
                        .blackout_hold_input_events
                        .remove(&InputEvent::Artnet(channel));
                }
                (Some(project), UiAction::ClearProjectBlackoutHoldInput) => {
                    project.blackout_hold_input_events.clear();
                }
                (Some(project), UiAction::AddProjectHalfInputArtnet(channel)) => {
                    project
                        .half_input_events
                        .insert(InputEvent::Artnet(channel));
                }
                (Some(project), UiAction::RemoveProjectHalfInputArtnet(channel)) => {
                    project
                        .half_input_events
                        .remove(&InputEvent::Artnet(channel));
                }
                (Some(project), UiAction::ClearProjectHalfInput) => {
                    project.half_input_events.clear();
                }
                (Some(project), UiAction::AddProjectDoubleInputArtnet(channel)) => {
                    project
                        .double_input_events
                        .insert(InputEvent::Artnet(channel));
                }
                (Some(project), UiAction::RemoveProjectDoubleInputArtnet(channel)) => {
                    project
                        .double_input_events
                        .remove(&InputEvent::Artnet(channel));
                }
                (Some(project), UiAction::ClearProjectDoubleInput) => {
                    project.double_input_events.clear();
                }
                (Some(project), UiAction::ToggleSceneActive(location)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, location, self.selected_scene_instance)
                    {
                        scene_instance.active = !scene_instance.active;
                    }
                }
                (Some(project), UiAction::SetSceneActive(location, active)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, location, self.selected_scene_instance)
                    {
                        scene_instance.active = active;
                    }
                }
                (Some(project), UiAction::SetSceneFlash(location, flash)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, location, self.selected_scene_instance)
                    {
                        scene_instance.flash = flash;
                    }
                }
                (Some(project), UiAction::SelectScene(location)) => {
                    if let Some(pos) =
                        location_by_target(project, location, self.selected_scene_instance)
                    {
                        self.set_selected_scene_instance(pos);
                    }
                }
                (Some(project), UiAction::SelectSceneByLocation(location)) => {
                    if project.scenes_instances_grid.contains_key(&location) {
                        self.set_selected_scene_instance(location);
                    }
                }
                (Some(project), UiAction::SetAudioDevice(device_id)) => {
                    project.audio_input_device = device_id.clone();
                    self.audio_pool.selected_device = device_id;
                    self.audio_pool.restart_fft();
                }
                (Some(project), UiAction::SwapScenes(from, to)) => {
                    let to_item = project.remove_scene_instance(to);
                    let from_item = project.remove_scene_instance(from);
                    if let Some(from_item) = from_item {
                        project.add_scene_instance(to, from_item);
                    }
                    if let Some(to_item) = to_item {
                        project.add_scene_instance(from, to_item);
                    }
                    self.set_selected_scene_instance(to);
                }
                (Some(project), UiAction::SetSceneName(path, name)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.name = name;
                    }
                }
                (Some(project), UiAction::SetSceneColor(path, color)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.color = color;
                    }
                }
                (Some(project), UiAction::SetSceneInputDimmer(path, dimmer)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.input_dimmer = dimmer;
                    }
                }
                (Some(project), UiAction::SetSceneIgnoreMainDimmer(path, ignore)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.ignore_main_dimmer = ignore;
                    }
                }
                (Some(project), UiAction::SetSceneBeatOffset(path, beat_offset)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.beat_progression_offset =
                            MultipliedCurve::new_multiplier(beat_offset);
                    }
                }
                (Some(project), UiAction::SetSceneOpacityMultiplier(path, value)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.opacity.set_multiplier(value);
                    }
                }
                (Some(project), UiAction::SetSceneOpacityCurve(path, curve)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.opacity.set_curve(curve);
                    }
                }
                (Some(project), UiAction::SetSceneBeatOffsetMultiplier(path, value)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.beat_progression_offset.set_multiplier(value);
                    }
                }
                (Some(project), UiAction::SetSceneBeatOffsetCurve(path, curve)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.beat_progression_offset.set_curve(curve);
                    }
                }
                (Some(project), UiAction::SetSceneSetOffsetOnFlash(path, set_offset_on_flash)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.set_offset_on_flash = set_offset_on_flash;
                    }
                }
                (Some(project), UiAction::SetSceneActivationInput(path, input_event)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.activation_input = input_event;
                    }
                }
                (Some(project), UiAction::SetSceneFlashInput(path, input_event)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.flash_input = input_event;
                    }
                }
                (Some(project), UiAction::SetSceneDimmerInput(path, input_event)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.dimmer_input = input_event;
                    }
                }
                (Some(project), UiAction::ClearSceneGroupsOverwrite(path)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        scene_instance.groups_overwrite = None;
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneGroupsOverwriteEntry(path, group_index, group_name),
                ) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                    {
                        let groups = scene_instance.groups_overwrite.get_or_insert_default();
                        groups.insert(group_index, Group(group_name));
                    }
                }
                (Some(project), UiAction::RemoveSceneGroupsOverwriteEntry(path, group_index)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, path, self.selected_scene_instance)
                        && let Some(groups) = scene_instance.groups_overwrite.as_mut()
                    {
                        groups.remove(group_index);
                        if groups.is_empty() {
                            scene_instance.groups_overwrite = None;
                        }
                    }
                }
                (Some(project), UiAction::SetSceneEffectOpacity(target, effect_index, opacity)) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.opacity = MultipliedCurve::new_multiplier(opacity);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectOpacityMultiplier(target, effect_index, value),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.opacity.set_multiplier(value);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectOpacityCurve(target, effect_index, curve),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.opacity.set_curve(curve);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectColorShift(target, effect_index, color_shift),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.color_shift = MultipliedCurve::new_multiplier(color_shift);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectColorShiftMultiplier(target, effect_index, value),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.color_shift.set_multiplier(value);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectColorShiftCurve(target, effect_index, curve),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.color_shift.set_curve(curve);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectBeatProgression(target, effect_index, beat_progression),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.beat_progression = MultipliedCurve::new_multiplier(beat_progression);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectBeatProgressionMultiplier(target, effect_index, value),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.beat_progression.set_multiplier(value);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectBeatProgressionCurve(target, effect_index, curve),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.beat_progression.set_curve(curve);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectBeatOffset(target, effect_index, beat_offset),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.beat_progression_offset =
                            MultipliedCurve::new_multiplier(beat_offset);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectBeatOffsetMultiplier(target, effect_index, value),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.beat_progression_offset.set_multiplier(value);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectBeatOffsetCurve(target, effect_index, curve),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.beat_progression_offset.set_curve(curve);
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectSpeedExponent(target, effect_index, speed_exponent),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.speed_exponent = speed_exponent;
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectGroupIndex(target, effect_index, group_index),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.group_index = group_index;
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectAnimation(target, effect_index, animation),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) {
                        effect.animation = animation;
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectAnimationConfigU32(
                        target,
                        effect_index,
                        config_index,
                        value,
                    ),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) && let Some(config) = effect.animation_config.u32(config_index)
                    {
                        *config = value;
                    }
                }
                (
                    Some(project),
                    UiAction::SetSceneEffectAnimationConfigF32(
                        target,
                        effect_index,
                        config_index,
                        value,
                    ),
                ) => {
                    if let Some(effect) = scene_effect_by_target(
                        project,
                        target,
                        self.selected_scene_instance,
                        effect_index,
                    ) && let Some(config) = effect.animation_config.float(config_index)
                    {
                        *config = FloatValue::F32(value);
                    }
                }
                (Some(project), UiAction::AddSceneEffect(target)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, target, self.selected_scene_instance)
                    {
                        scene_instance
                            .scene
                            .add_effect(Default::default(), &self.collections);
                    }
                }
                (Some(project), UiAction::RemoveSceneEffect(target, effect_index)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, target, self.selected_scene_instance)
                    {
                        scene_instance.scene.remove_effect(effect_index);
                    }
                }
                (Some(project), UiAction::CloneSceneEffect(target, effect_index)) => {
                    if let Some(scene_instance) =
                        scene_instance_by_target(project, target, self.selected_scene_instance)
                        && let Some(effect) = scene_instance.scene.effect(effect_index).cloned()
                    {
                        scene_instance.scene.add_effect(effect, &self.collections);
                    }
                }
                (_, UiAction::SetAnimationShaderCode(animation_id, shader_code)) => {
                    update_animation(&mut self.collections, animation_id, |animation| {
                        animation.shader_code = shader_code;
                    });
                }
                (_, UiAction::AddAnimationArgument(animation_id)) => {
                    update_animation(&mut self.collections, animation_id, |animation| {
                        animation.arguments.push(Argument::default());
                    });
                }
                (_, UiAction::RemoveAnimationArgument(animation_id, argument_index)) => {
                    update_animation(&mut self.collections, animation_id, |animation| {
                        if argument_index < animation.arguments.len() {
                            animation.arguments.remove(argument_index);
                        }
                    });
                }
                (_, UiAction::SetAnimationArgumentName(animation_id, argument_index, name)) => {
                    update_animation(&mut self.collections, animation_id, |animation| {
                        if let Some(argument) = animation.arguments.get_mut(argument_index) {
                            argument.name = name;
                        }
                    });
                }
                (_, UiAction::SetAnimationArgumentKind(animation_id, argument_index, kind)) => {
                    update_animation(&mut self.collections, animation_id, |animation| {
                        if let Some(argument) = animation.arguments.get_mut(argument_index) {
                            argument.kind = ArgumentKind::from(kind);
                        }
                    });
                }
                (_, UiAction::Tap) => {
                    self.timing.tap(&self.persistent_state);
                }
                (_, UiAction::SpeedAdd(delta)) => {
                    self.timing.add_speed(delta, &self.persistent_state);
                }
                (_, UiAction::SpeedMultiply(multiplier)) => {
                    self.timing
                        .multiply_speed(multiplier, &self.persistent_state);
                }
                (_, UiAction::SetBlackout(blackout)) => {
                    self.blackout = blackout;
                }
                (_, UiAction::SetProject(project)) => {
                    if let Some(project) = Asset::get(project, &self.collections) {
                        self.persistent_state.set_last_project_id(project.id);
                        self.persistent_state.save();

                        self.project_id = Some(project.id);
                        let project = Arc::unwrap_or_clone(project).data;
                        self.set_selected_scene_instance(
                            project
                                .all_scene_instance_locations()
                                .next()
                                .copied()
                                .unwrap_or_default(),
                        );
                        self.extract_output.routings = project.output_routings.clone();
                        *ARTNET_CONFIG.lock() = project.artnet_config.clone();
                        self.apply_osc_config(project.osc_config);
                        project.channel_overwrites.clone().set();
                        self.audio_pool.selected_device = project.audio_input_device.clone();
                        self.audio_pool.restart_fft();
                        self.project = Some(project);
                        UiAction::ReloadShaderCode(None).enqueue();
                    } else {
                        self.windows.external_device_settings.close();
                        self.windows.output_routings.close();
                        self.windows.shortcuts.close();
                        self.project.take();
                        self.project_id.take();
                    };
                    Svg::reset();
                }
                (_, UiAction::CloseWindow(viewport_id)) => {
                    self.other_main_windows.remove(&viewport_id);
                }
                (_, UiAction::OpenGitConfigWindow) => {
                    self.windows.git_config.open();
                }
                (_, UiAction::MidiOutputActive(active)) => {
                    self.midi_output_active = active;
                }
                (
                    Some(_),
                    UiAction::SetProjectPaletteFromAsset(_)
                    | UiAction::SetProjectPalettePrimary(_)
                    | UiAction::SetProjectPaletteSecondary(_)
                    | UiAction::SetProjectPaletteGradient(_, _)
                    | UiAction::SetScenePaletteOverwriteFromAsset(_, _)
                    | UiAction::SetScenePaletteOverwritePrimary(_, _)
                    | UiAction::SetScenePaletteOverwriteSecondary(_, _)
                    | UiAction::SetScenePaletteOverwriteGradient(_, _, _),
                ) => {}

                (_, UiAction::Error(error)) => {
                    tracing::error!("{error}");

                    if let Err(err) = Notification::new()
                        .summary("Error")
                        .body(&error)
                        .icon("application-gled")
                        .show()
                    {
                        tracing::error!("Could not show notification: {err:?}");
                    }

                    self.windows.errors.entries.push(error);
                }
                (None, _) => tracing::trace!("Ingoring ui action which needs a loaded project"),
            }
        }
    }
}