-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathBackendApplicationCommands.cpp
3530 lines (2698 loc) · 113 KB
/
BackendApplicationCommands.cpp
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
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ===========================================================================
*
* This file is part of HISE.
* Copyright 2016 Christoph Hart
*
* HISE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HISE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*
* Commercial licenses for using HISE in an closed source project are
* available on request. Please visit the project's website to get more
* information about commercial licensing:
*
* http://www.hise.audio/
*
* HISE is based on the JUCE library,
* which must be separately licensed for closed source applications:
*
* http://www.juce.com
*
* ===========================================================================
*/
#define toggleVisibility(x) {x->setVisible(!x->isVisible()); owner->setComponentShown(info.commandID, x->isVisible());}
#define SET_COMMAND_TARGET(result, name, active, ticked, shortcut) { result.setInfo(name, name, "Target", 0); \\
result.setActive(active); \\
result.setTicked(ticked); \\
result.addDefaultKeypress(shortcut, ModifierKeys::commandModifier); }
#define ADD_MENU_ITEM(x) jassert(checkSanity(x)); p.addCommandItem(mainCommandManager, x);
namespace hise { using namespace juce;
BackendCommandTarget::BackendCommandTarget(BackendProcessor *owner_):
owner(owner_),
currentColumnMode(OneColumn)
{
CopyPasteTargetHandler* h = this;
handlerFunction.f = [h](Component*)
{
return h;
};
CopyPasteTarget::setHandlerFunction(&handlerFunction);
createMenuBarNames();
}
void BackendCommandTarget::setEditor(BackendRootWindow *editor)
{
bpe = dynamic_cast<BackendRootWindow*>(editor);
mainCommandManager = owner->getCommandManager();
mainCommandManager->registerAllCommandsForTarget(this);
mainCommandManager->getKeyMappings()->resetToDefaultMappings();
updater = new Updater(*this);
bpe->addKeyListener(mainCommandManager->getKeyMappings());
mainCommandManager->setFirstCommandTarget(this);
mainCommandManager->commandStatusChanged();
}
void BackendCommandTarget::getAllCommands(Array<CommandID>& commands)
{
const CommandID id[] = {
Settings,
WorkspaceScript,
WorkspaceSampler,
WorkspaceCustom,
MenuSnippetFileNew,
MenuSnippetClose,
MenuNewFile,
MenuOpenFile,
MenuSaveFile,
MenuSaveFileAs,
MenuSaveFileXmlBackup,
MenuSaveFileAsXmlBackup,
MenuOpenXmlBackup,
MenuProjectNew,
MenuProjectLoad,
MenuFileBrowseExamples,
MenuFileCreateRecoveryXml,
MenuProjectShowInFinder,
MenuFileShowHiseAppDataFolder,
MenuFileShowProjectAppDataFolder,
MenuFileSettings,
MenuExportCleanBuildDirectory,
MenuToolsCreateThirdPartyNode,
MenuFileExtractEmbeddeSnippetFiles,
MenuFileImportSnippet,
MenuExportSetupWizard,
MenuExportFileAsPlugin,
MenuExportFileAsEffectPlugin,
MenuExportFileAsMidiFXPlugin,
MenuExportFileAsStandaloneApp,
MenuExportProjectAsExpansion,
MenuExportFileAsSnippet,
MenuExportSampleDataForInstaller,
MenuExportCompileFilesInPool,
MenuExportCompileNetworksAsDll,
MenuToolsWavetablesToMonolith,
MenuFileQuit,
MenuEditUndo,
MenuEditRedo,
MenuEditCopy,
MenuEditPaste,
MenuEditMoveUp,
MenuEditMoveDown,
MenuEditCreateScriptVariable,
MenuEditCreateBase64State,
MenuEditCloseAllChains,
MenuEditPlotModulator,
MenuToolsEditShortcuts,
MenuToolsRecompile,
MenuViewClearConsole,
MenuToolsCheckCyclicReferences,
MenuExportCheckPluginParameters,
MenuToolsConvertSVGToPathData,
MenuToolsBroadcasterWizard,
MenuExportRestoreToDefault,
MenuExportValidateUserPresets,
MenuExportCheckAllSampleMaps,
MenuExportCheckUnusedImages,
MenuExportCleanDspNetworkFiles,
MenuToolsForcePoolSearch,
MenuToolsConvertSampleMapToWavetableBanks,
MenuToolsConvertAllSamplesToMonolith,
MenuToolsUpdateSampleMapIdsBasedOnFileName,
MenuToolsConvertSfzToSampleMaps,
MenuExportUnloadAllSampleMaps,
MenuExportUnloadAllAudioFiles,
MenuToolsRecordOneSecond,
MenuToolsImportArchivedSamples,
MenuToolsCreateRSAKeys,
MenuToolsCreateDummyLicenseFile,
MenuToolsApplySampleMapProperties,
MenuToolsSimulateChangingBufferSize,
MenuToolsShowDspNetworkDllInfo,
MenuToolsCreateRnboTemplate,
MenuToolsCreateGlobalCableCppCode,
MenuViewResetLookAndFeel,
MenuViewReset,
MenuViewRotate,
MenuViewEnableGlobalLayoutMode,
MenuViewAddFloatingWindow,
MenuViewToggleSnippetBrowser,
MenuViewGotoUndo,
MenuViewGotoRedo,
MenuHelpShowAboutPage,
MenuHelpCheckVersion,
MenuHelpShowDocumentation
};
commands.addArray(id, numElementsInArray(id));
commands.sort();
}
void BackendCommandTarget::setCopyPasteTarget(CopyPasteTarget* newTarget)
{
if (currentCopyPasteTarget.get() != nullptr)
{
currentCopyPasteTarget->deselect();
}
else
{
mainCommandManager->setFirstCommandTarget(this);
}
currentCopyPasteTarget = newTarget;
updateCommands();
}
void BackendCommandTarget::createMenuBarNames()
{
menuNames.clear();
menuNames.add("File");
menuNames.add("Edit " + (currentCopyPasteTarget.get() == nullptr ? "" : currentCopyPasteTarget->getObjectTypeName()));
menuNames.add("Export");
menuNames.add("Tools");
menuNames.add("View");
menuNames.add("Help");
jassert(menuNames.size() == numMenuNames);
}
void BackendCommandTarget::getCommandInfo(CommandID commandID, ApplicationCommandInfo &result)
{
#if JUCE_WINDOWS
static const String fileBrowserName = "Explorer";
#elif JUCE_MAC
static const String fileBrowserName = "Finder";
#else
static const String fileBrowserName = "File Browser";
#endif
result.categoryName = "Hidden";
switch (commandID)
{
case HamburgerMenu:
setCommandTarget(result, "Show Menu", true, false, 'X', false);
break;
case Settings:
#if IS_STANDALONE_APP
setCommandTarget(result, "Show Audio Device Settings", true, false, 'X', false);
#else
setCommandTarget(result, "Show Audio Device Settings (disabled for plugins)", false, bpe->currentDialog == nullptr, '8');
#endif
break;
case WorkspaceScript:
{
setCommandTarget(result, "Show Scripting Workspace", true, bpe->getCurrentWorkspace() == WorkspaceScript, 'X', false);
result.categoryName = "View";
break;
}
case WorkspaceSampler:
{
setCommandTarget(result, "Show Sampler Workspace", true, bpe->getCurrentWorkspace() == WorkspaceSampler, 'X', false);
result.categoryName = "View";
break;
}
case WorkspaceCustom:
{
setCommandTarget(result, "Show Custom Workspace", true, bpe->getCurrentWorkspace() == WorkspaceCustom, 'X', false);
result.categoryName = "View";
break;
}
case MenuSnippetFileNew:
setCommandTarget(result, "Show snippet browser", true, false, 'X', false);
result.categoryName = "File";
break;
case MenuSnippetClose:
setCommandTarget(result, "Close this window", true, false, 'X', false);
result.categoryName = "File";
break;
case MenuNewFile:
setCommandTarget(result, "New", true, false, 'N');
result.categoryName = "File";
break;
case MenuOpenFile:
setCommandTarget(result, "Open Archive", true, false, 'X', false);
result.categoryName = "File";
break;
case MenuSaveFile: {
setCommandTarget(result, "Save Archive", true, false, 'S', false);
auto k = TopLevelWindowWithKeyMappings::getFirstKeyPress(bpe, FloatingTileKeyPressIds::save_hip);
result.addDefaultKeypress(k.getKeyCode(), k.getModifiers());
result.categoryName = "File";
break; }
case MenuSaveFileAs:
setCommandTarget(result, "Save As Archive", true, false, 'X', false);
result.categoryName = "File";
break;
case MenuSaveFileXmlBackup: {
setCommandTarget(result, "Save XML", GET_PROJECT_HANDLER(bpe->getMainSynthChain()).isActive(), false, 'S', false);
auto k = TopLevelWindowWithKeyMappings::getFirstKeyPress(bpe, FloatingTileKeyPressIds::save_xml);
result.addDefaultKeypress(k.getKeyCode(), k.getModifiers());
result.categoryName = "File";
break; }
case MenuSaveFileAsXmlBackup:
setCommandTarget(result, "Save as XML", GET_PROJECT_HANDLER(bpe->getMainSynthChain()).isActive(), false, 'X', false);
result.categoryName = "File";
break;
case MenuOpenXmlBackup:
setCommandTarget(result, "Open XML", GET_PROJECT_HANDLER(bpe->getMainSynthChain()).isActive(), false, 'O');
result.categoryName = "File";
break;
case MenuFileBrowseExamples:
setCommandTarget(result, "Browse example snippets", true, false, 'x', false);
result.categoryName = "Help";
break;
case MenuProjectNew:
setCommandTarget(result, "Create new Project", true, false, 'X', false);
result.categoryName = "File";
break;
case MenuProjectLoad:
setCommandTarget(result, "Load Project", true, false, 'X', false);
result.categoryName = "File";
break;
case MenuFileExtractEmbeddeSnippetFiles:
setCommandTarget(result, "Copy snippet script files to current project", GET_PROJECT_HANDLER(bpe->getMainSynthChain()).isActive(), false, 'X', false);
result.categoryName = "File";
break;
case MenuProjectShowInFinder:
setCommandTarget(result, "Show Project folder in " + fileBrowserName,
GET_PROJECT_HANDLER(bpe->getMainSynthChain()).isActive(), false, 'X', false);
result.categoryName = "File";
break;
case MenuFileShowHiseAppDataFolder:
setCommandTarget(result, "Show HISE App data folder in " + fileBrowserName,
GET_PROJECT_HANDLER(bpe->getMainSynthChain()).isActive(), false, 'X', false);
result.categoryName = "File";
break;
case MenuFileShowProjectAppDataFolder:
setCommandTarget(result, "Show Project App Data folder in " + fileBrowserName,
GET_PROJECT_HANDLER(bpe->getMainSynthChain()).isActive(), false, 'X', false);
result.categoryName = "File";
break;
case MenuToolsCreateThirdPartyNode:
setCommandTarget(result, "Create C++ third party node template", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuExportSetupWizard:
setCommandTarget(result, "Setup Export Wizard", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuExportFileAsPlugin:
setCommandTarget(result, "Export as Instrument (VSTi / AUi) plugin", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuExportFileAsEffectPlugin:
setCommandTarget(result, "Export as FX plugin", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuExportFileAsStandaloneApp:
setCommandTarget(result, "Export as Standalone Application", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuExportProjectAsExpansion:
setCommandTarget(result, "Export Project as Full Expansion", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuExportFileAsMidiFXPlugin:
setCommandTarget(result, "Export as MIDI FX plugin", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuExportFileAsSnippet:
setCommandTarget(result, "Export as HISE Snippet", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuExportCompileNetworksAsDll:
setCommandTarget(result, "Compile DSP networks as dll", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuFileCreateRecoveryXml:
setCommandTarget(result, "Create recovery XML from Archive", true, false, 'x', false);
result.categoryName = "File";
break;
case MenuExportSampleDataForInstaller:
setCommandTarget(result, "Package sample monolith files", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuToolsWavetablesToMonolith:
setCommandTarget(result, "Export Wavetables to monolith", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuExportCompileFilesInPool:
setCommandTarget(result, "Export Pooled Files to Binary Resource", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuFileSettings:
setCommandTarget(result, "Settings", true, false, 'X', false);
result.categoryName = "File";
break;
case MenuExportCleanBuildDirectory:
setCommandTarget(result, "Clean Build directory", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuExportCleanDspNetworkFiles:
setCommandTarget(result, "Clean DSP network files", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuFileImportSnippet:
setCommandTarget(result, "Import HISE Snippet", true, false, 'V', true, ModifierKeys::commandModifier | ModifierKeys::shiftModifier);
result.categoryName = "File";
break;
case MenuFileQuit:
setCommandTarget(result, "Quit", true, false, 'X', false);
result.categoryName = "File";
break;
case MenuEditUndo:
setCommandTarget(result, "Undo: " + bpe->owner->getControlUndoManager()->getUndoDescription(), bpe->owner->getControlUndoManager()->canUndo(), false, 'Z', true, ModifierKeys::commandModifier);
result.categoryName = "Edit";
break;
case MenuEditRedo:
setCommandTarget(result, "Redo: " + bpe->owner->getControlUndoManager()->getRedoDescription(), bpe->owner->getControlUndoManager()->canRedo(), false, 'Y', true, ModifierKeys::commandModifier);
result.categoryName = "Edit";
break;
case MenuEditCopy:
setCommandTarget(result, "Copy", currentCopyPasteTarget.get() != nullptr, false, 'C');
result.categoryName = "Edit";
break;
case MenuEditPaste:
setCommandTarget(result, "Paste", currentCopyPasteTarget.get() != nullptr, false, 'V');
result.categoryName = "Edit";
break;
case MenuEditMoveUp:
setCommandTarget(result, "Move up", currentCopyPasteTarget.get() != nullptr, false, 'X', false);
result.categoryName = "Edit";
result.addDefaultKeypress(KeyPress::upKey, ModifierKeys::ctrlModifier);
break;
case MenuToolsEditShortcuts:
setCommandTarget(result, "Edit Shortcuts", true, false, 'x', false);
result.categoryName = "File";
break;
case MenuEditMoveDown:
setCommandTarget(result, "Move down", currentCopyPasteTarget.get() != nullptr, false, 'X', false);
result.categoryName = "Edit";
result.addDefaultKeypress(KeyPress::downKey, ModifierKeys::ctrlModifier);
break;
case MenuEditCreateScriptVariable:
setCommandTarget(result, "Create script variable", currentCopyPasteTarget.get() != nullptr, false, 'C', true, ModifierKeys::commandModifier | ModifierKeys::shiftModifier);
result.categoryName = "Edit";
break;
case MenuEditCreateBase64State:
setCommandTarget(result, "Create Base64 encoded state", currentCopyPasteTarget.get() != nullptr, false, 'C', false);
result.categoryName = "Edit";
break;
case MenuEditPlotModulator:
{
ProcessorEditor * editor = dynamic_cast<ProcessorEditor*>(currentCopyPasteTarget.get());
bool active = false;
bool ticked = false;
if(editor != nullptr)
{
auto mod = dynamic_cast<Modulation*>(editor->getProcessor());
if(mod != nullptr)
{
active = true;
ticked = mod->isPlotted();
}
}
setCommandTarget(result, "Plot Modulator", active, ticked, 'P');
result.categoryName = "Edit";
break;
}
case MenuEditCloseAllChains:
setCommandTarget(result, "Close all chains", clipBoardNotEmpty(), false, 'X', false);
result.categoryName = "Edit";
break;
case MenuToolsRecompile:
setCommandTarget(result, "Recompile all scripts", true, false, 'X', false);
result.addDefaultKeypress(KeyPress::F5Key, ModifierKeys::shiftModifier);
result.categoryName = "Tools";
break;
case MenuToolsCheckCyclicReferences:
setCommandTarget(result, "Check Javascript objects for cyclic references", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsSimulateChangingBufferSize:
setCommandTarget(result, "Simulate varying audio buffer size", true, bpe->getBackendProcessor()->isUsingDynamicBufferSize(), 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsBroadcasterWizard:
setCommandTarget(result, "Show Broadcaster Wizard", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsCreateExternalScriptFile:
setCommandTarget(result, "Create external script file", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuExportValidateUserPresets:
setCommandTarget(result, "Validate user presets", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuExportCheckAllSampleMaps:
setCommandTarget(result, "Validate sample maps", GET_PROJECT_HANDLER(bpe->getMainSynthChain()).isActive(), false, 'X', false);
result.categoryName = "Export";
break;
case MenuExportCheckPluginParameters:
setCommandTarget(result, "Validate plugin parameters", GET_PROJECT_HANDLER(bpe->getMainSynthChain()).isActive(), false, 'X', false);
result.categoryName = "Export";
break;
case MenuToolsImportArchivedSamples:
setCommandTarget(result, "Import archived samples", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsShowDspNetworkDllInfo:
setCommandTarget(result, "Show DSP Network DLL info", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuExportCheckUnusedImages:
setCommandTarget(result, "Collect unreferenced images", GET_PROJECT_HANDLER(bpe->getMainSynthChain()).isActive(), false, 'X', false);
result.categoryName = "Export";
break;
case MenuToolsForcePoolSearch:
setCommandTarget(result, "Force duplicate search in pool when loading samples", true, bpe->getBackendProcessor()->getSampleManager().getModulatorSamplerSoundPool()->isPoolSearchForced(), 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsConvertAllSamplesToMonolith:
setCommandTarget(result, "Convert all samples to Monolith + Samplemap", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsCreateRnboTemplate:
setCommandTarget(result, "Create C++ template for RNBO patch", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsConvertSampleMapToWavetableBanks:
setCommandTarget(result, "Show Wavetable Creator", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsUpdateSampleMapIdsBasedOnFileName:
setCommandTarget(result, "Update SampleMap Ids based on file names", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsConvertSfzToSampleMaps:
setCommandTarget(result, "Convert SFZ files to SampleMaps", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuExportUnloadAllSampleMaps:
setCommandTarget(result, "Unload all Samplemaps", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuToolsApplySampleMapProperties:
setCommandTarget(result, "Apply sample map properties to sample files", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuExportUnloadAllAudioFiles:
setCommandTarget(result, "Unload all audio files", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuToolsEnableDebugLogging:
setCommandTarget(result, "Enable Debug Logger", true, bpe->owner->getDebugLogger().isLogging(), 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsRecordOneSecond:
setCommandTarget(result, "Render HISE output to disk", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsCreateRSAKeys:
setCommandTarget(result, "Create RSA Key pair", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsCreateGlobalCableCppCode:
setCommandTarget(result, "Create C++ code for global cables", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuToolsConvertSVGToPathData:
setCommandTarget(result, "Show SVG to Path Converter", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuExportRestoreToDefault:
setCommandTarget(result, "Reset UI controls to default values", true, false, 'X', false);
result.categoryName = "Export";
break;
case MenuToolsCreateDummyLicenseFile:
setCommandTarget(result, "Create Dummy License File", true, false, 'X', false);
result.categoryName = "Tools";
break;
case MenuViewResetLookAndFeel:
setCommandTarget(result, "Reset custom Look and Feel", true, false, 'X', false);
result.categoryName = "View";
break;
case MenuViewToggleSnippetBrowser:
setCommandTarget(result, "Toggle Snippet Browser", true, false, 'X', false);
result.categoryName = "View";
break;
case MenuViewReset:
setCommandTarget(result, "Reset Workspaces", true, false, 'X', false);
result.categoryName = "View";
break;
case MenuViewGotoUndo:
case MenuViewGotoRedo:
{
auto isUndo = commandID == MenuViewGotoUndo;
auto l = bpe->getBackendProcessor()->getLocationUndoManager();
auto shortcutId = isUndo ? TextEditorShortcuts::goto_undo : TextEditorShortcuts::goto_redo;
String name;
if(isUndo)
{
name << "Go back to ";
name << l->getUndoDescription();
}
else
name << "Goto next location";
result.setInfo(name, name, "Unused", 0);
result.setActive(true);
result.categoryName = "View";
result.defaultKeypresses.add(TopLevelWindowWithKeyMappings::getFirstKeyPress(bpe, shortcutId));
break;
}
case MenuViewRotate:
setCommandTarget(result, "Vertical Layout", true, bpe->isRotated(), 'X', false);
result.categoryName = "View";
break;
case MenuViewEnableGlobalLayoutMode:
setCommandTarget(result, "Enable Layout Mode", true, bpe->getRootFloatingTile()->isLayoutModeEnabled(), 'X', false);
result.categoryName = "View";
break;
case MenuViewAddFloatingWindow:
setCommandTarget(result, "Add floating window", true, false, 'x', false);
result.categoryName = "View";
break;
case MenuViewClearConsole:
setCommandTarget(result, "Clear Console", true, false, 'X', false);
result.categoryName = "View";
break;
case MenuHelpShowAboutPage:
setCommandTarget(result, "About HISE", true, false, 'X', false);
result.categoryName = "Help";
break;
case MenuHelpShowDocumentation:
setCommandTarget(result, "Show Documentation", true, false, 'X', false);
result.addDefaultKeypress(KeyPress::F1Key, ModifierKeys::noModifiers);
result.categoryName = "Help";
break;
case MenuHelpCheckVersion:
setCommandTarget(result, "Check for newer version", true, false, 'X', false);
result.categoryName = "Help";
break;
default: jassertfalse; return;
}
}
bool BackendCommandTarget::perform(const InvocationInfo &info)
{
switch (info.commandID)
{
case HamburgerMenu: Actions::showMainMenu(bpe); return true;
case Settings: bpe->showSettingsWindow(); return true;
case WorkspaceScript:
case WorkspaceSampler:
case WorkspaceCustom: bpe->showWorkspace(info.commandID); updateCommands(); return true;
case MenuViewToggleSnippetBrowser: bpe->toggleSnippetBrowser(); return true;
case MenuSnippetClose: bpe->deleteThisSnippetInstance(false); return true;
case MenuNewFile: Actions::newFile(bpe); return true;
case MenuOpenFile: Actions::openFile(bpe); return true;
case MenuSaveFile: Actions::saveFile(bpe, false); updateCommands(); return true;
case MenuSaveFileAs: Actions::saveFile(bpe, true); updateCommands(); return true;
case MenuSaveFileXmlBackup: Actions::saveFileXml(bpe); updateCommands(); return true;
case MenuSaveFileAsXmlBackup: Actions::saveFileAsXml(bpe); updateCommands(); return true;
case MenuOpenXmlBackup: { FileChooser fc("Select XML file to load",
GET_PROJECT_HANDLER(bpe->getMainSynthChain()).getSubDirectory(ProjectHandler::SubDirectories::XMLPresetBackups), "*.xml", true);
if (fc.browseForFileToOpen()) Actions::openFileFromXml(bpe, fc.getResult()); return true;}
case MenuProjectNew: Actions::createNewProject(bpe); updateCommands(); return true;
case MenuProjectLoad: Actions::loadProject(bpe); updateCommands(); return true;
case MenuProjectShowInFinder: Actions::showProjectInFinder(bpe); return true;
case MenuFileShowProjectAppDataFolder: Actions::showAppDataFolder(bpe, true); return true;
case MenuFileShowHiseAppDataFolder: Actions::showAppDataFolder(bpe, false); return true;
case MenuFileBrowseExamples: Actions::showExampleBrowser(bpe); return true;
case MenuFileCreateRecoveryXml: Actions::createRecoveryXml(bpe); return true;
case MenuFileSettings: Actions::showFileProjectSettings(bpe); return true;
case MenuExportCleanBuildDirectory: Actions::cleanBuildDirectory(bpe); return true;
case MenuToolsCreateThirdPartyNode: Actions::createThirdPartyNode(bpe); return true;
case MenuFileImportSnippet: Actions::replaceWithClipboardContent(bpe); return true;
case MenuFileExtractEmbeddeSnippetFiles: Actions::extractEmbeddedFilesFromSnippet(bpe); return true;
case MenuFileQuit: if (PresetHandler::showYesNoWindow("Quit Application", "Do you want to quit?"))
JUCEApplicationBase::quit(); return true;
case MenuEditUndo: bpe->owner->getControlUndoManager()->undo(); updateCommands(); return true;
case MenuEditRedo: bpe->owner->getControlUndoManager()->redo(); updateCommands(); return true;
case MenuEditCopy: if (currentCopyPasteTarget) currentCopyPasteTarget->copyAction(); return true;
case MenuEditPaste: if (currentCopyPasteTarget) currentCopyPasteTarget->pasteAction(); return true;
case MenuEditMoveUp: if (currentCopyPasteTarget) Actions::moveModule(currentCopyPasteTarget, true); return true;
case MenuEditMoveDown: if (currentCopyPasteTarget) Actions::moveModule(currentCopyPasteTarget, false); return true;
case MenuEditCreateScriptVariable: Actions::createScriptVariableDeclaration(currentCopyPasteTarget); return true;
case MenuEditCreateBase64State: Actions::createBase64State(currentCopyPasteTarget.get()); return true;
case MenuEditPlotModulator: Actions::plotModulator(currentCopyPasteTarget.get()); updateCommands(); return true;
case MenuEditCloseAllChains: Actions::closeAllChains(bpe); return true;
case MenuToolsRecompile: Actions::recompileAllScripts(bpe); return true;
case MenuToolsCheckCyclicReferences:Actions::checkCyclicReferences(bpe); return true;
case MenuToolsCreateExternalScriptFile: Actions::createExternalScriptFile(bpe); updateCommands(); return true;
case MenuExportValidateUserPresets: Actions::validateUserPresets(bpe); return true;
case MenuExportRestoreToDefault: Actions::restoreToDefault(bpe); return true;
case MenuExportCheckUnusedImages: Actions::checkUnusedImages(bpe); return true;
case MenuExportSetupWizard: Actions::setupExportWizard(bpe); return true;
case MenuToolsShowDspNetworkDllInfo: Actions::showNetworkDllInfo(bpe); return true;
case MenuToolsForcePoolSearch: Actions::toggleForcePoolSearch(bpe); updateCommands(); return true;
case MenuToolsConvertSampleMapToWavetableBanks: Actions::convertSampleMapToWavetableBanks(bpe); return true;
case MenuToolsConvertAllSamplesToMonolith: Actions::convertAllSamplesToMonolith(bpe); return true;
case MenuToolsUpdateSampleMapIdsBasedOnFileName: Actions::updateSampleMapIds(bpe); return true;
case MenuToolsConvertSfzToSampleMaps: Actions::convertSfzFilesToSampleMaps(bpe); return true;
case MenuExportUnloadAllSampleMaps: Actions::removeAllSampleMaps(bpe); return true;
case MenuToolsSimulateChangingBufferSize: bpe->getBackendProcessor()->toggleDynamicBufferSize(); return true;
case MenuExportUnloadAllAudioFiles: Actions::unloadAllAudioFiles(bpe); return true;
case MenuToolsCreateRSAKeys: Actions::createRSAKeys(bpe); return true;
case MenuToolsCreateDummyLicenseFile: Actions::createDummyLicenseFile(bpe); return true;
case MenuExportCheckAllSampleMaps: Actions::checkAllSamplemaps(bpe); return true;
case MenuExportCheckPluginParameters: Actions::checkPluginParameterSanity(bpe); return true;
case MenuExportCleanDspNetworkFiles: Actions::cleanDspNetworkFiles(bpe); return true;
case MenuToolsCreateRnboTemplate: Actions::createRnboTemplate(bpe); return true;
case MenuToolsImportArchivedSamples: Actions::importArchivedSamples(bpe); return true;
case MenuToolsRecordOneSecond: Actions::exportAudio(bpe); return true;
case MenuToolsEnableDebugLogging: bpe->owner->getDebugLogger().toggleLogging(); updateCommands(); return true;
case MenuToolsApplySampleMapProperties: Actions::applySampleMapProperties(bpe); return true;
case MenuToolsConvertSVGToPathData: Actions::convertSVGToPathData(bpe); return true;
case MenuToolsBroadcasterWizard:
{
auto s = new multipage::library::EncodedBroadcasterWizard(bpe);//multipage::library::BroadcasterWizard(bpe);
s->setModalBaseWindowComponent(bpe);
return true;
}
case MenuToolsEditShortcuts: Actions::editShortcuts(bpe); return true;
case MenuViewReset: bpe->resetInterface(); updateCommands(); return true;
case MenuViewRotate:
bpe->toggleRotate();
updateCommands();
return true;
case MenuViewEnableGlobalLayoutMode: bpe->toggleLayoutMode(); updateCommands(); return true;
case MenuViewAddFloatingWindow: bpe->addFloatingWindow(); return true;
case MenuViewGotoUndo: bpe->getBackendProcessor()->getLocationUndoManager()->undo(); updateCommands(); return true;
case MenuViewGotoRedo: bpe->getBackendProcessor()->getLocationUndoManager()->redo(); updateCommands(); return true;
case MenuExportFileAsPlugin:
Actions::exportProject(bpe, (int)CompileExporter::BuildOption::AllPluginFormatsInstrument);
return true;
case MenuExportFileAsEffectPlugin:
Actions::exportProject(bpe, (int)CompileExporter::BuildOption::AllPluginFormatsFX);
return true;
case MenuExportFileAsStandaloneApp:
Actions::exportProject(bpe, (int)CompileExporter::BuildOption::StandaloneLinux);
return true;
case MenuExportFileAsMidiFXPlugin:
Actions::exportProject(bpe, (int)CompileExporter::BuildOption::AllPluginFormatsMidiFX);
return true;
case MenuExportCompileNetworksAsDll: Actions::compileNetworksToDll(bpe); return true;
case MenuExportFileAsSnippet: Actions::exportFileAsSnippet(bpe); return true;
case MenuExportProjectAsExpansion: Actions::exportHiseProject(bpe); return true;
case MenuExportSampleDataForInstaller: Actions::exportSampleDataForInstaller(bpe); return true;
case MenuToolsWavetablesToMonolith: Actions::exportWavetablesToMonolith(bpe); return true;
case MenuToolsCreateGlobalCableCppCode: Actions::createGlobalCableCppCode(bpe); return true;
case MenuExportCompileFilesInPool: Actions::exportCompileFilesInPool(bpe); return true;
case MenuViewResetLookAndFeel: Actions::resetLookAndFeel(bpe); return true;
case MenuViewClearConsole: owner->getConsoleHandler().clearConsole(); return true;
case MenuHelpShowAboutPage: Actions::showAboutPage(bpe); return true;
case MenuHelpCheckVersion: Actions::checkVersion(bpe); return true;
case MenuHelpShowDocumentation: Actions::showDocWindow(bpe); return true;
}
return false;
}
void BackendCommandTarget::updateCommands()
{
mainCommandManager->commandStatusChanged();
createMenuBarNames();
menuItemsChanged();
}
PopupMenu BackendCommandTarget::getMenuForIndex(int topLevelMenuIndex, const String &menuName)
{
MenuNames m = (MenuNames)topLevelMenuIndex;
auto isSnippetBrowser = bpe->getBackendProcessor()->isSnippetBrowser();
auto categoryIds = mainCommandManager->getCommandsInCategory(menuName.upToFirstOccurrenceOf(" ", false, false));
jassert(!categoryIds.isEmpty());
#if JUCE_DEBUG
int lastMenuId = 0;
bool allowCheck = true;//
auto checkSanity = [&](MainToolbarCommands x)
{
if(!allowCheck)
return true;
// If this hits, then you need to make sure
// that the category from getCommandInfo() matches the menu name
jassert(categoryIds.contains(x));
auto prev = (MainToolbarCommands)lastMenuId;
// If this hits, then the order of the command menu definition
// is not correct and needs to be shuffled in the enum definition
// to match the menu order
jassert(prev < x);
ignoreUnused(prev);
lastMenuId = x;
return true;
};
#endif
PopupMenu p;
switch (m)
{
case BackendCommandTarget::FileMenu: {
if(isSnippetBrowser)
{
ADD_MENU_ITEM(MenuNewFile);
ADD_MENU_ITEM(MenuFileImportSnippet);
ADD_MENU_ITEM(MenuFileExtractEmbeddeSnippetFiles);
ADD_MENU_ITEM(MenuSnippetClose);
}
else
{
p.addSectionHeader("Project Management");
ADD_MENU_ITEM(MenuProjectNew);
ADD_MENU_ITEM(MenuProjectLoad);
PopupMenu recentProjects;
#if HISE_IOS
Array<File> results;
File userDataDirectory = File::getSpecialLocation(File::userDocumentsDirectory);
userDataDirectory.findChildFiles(results, File::findDirectories, false);
String currentProject = GET_PROJECT_HANDLER(bpe->getMainSynthChain()).getWorkDirectory().getFullPathName();
const String menuTitle = "Available Projects";
for (int i = 0; i < results.size(); i++)
{
recentProjects.addItem(MenuProjectRecentOffset + i, results[i].getFileName(), true, results[i].getFullPathName() == currentProject);
}
#else
StringArray recentProjectDirectories = GET_PROJECT_HANDLER(bpe->getMainSynthChain()).getRecentWorkDirectories();
const String menuTitle = "Recent Projects";
String currentProject = GET_PROJECT_HANDLER(bpe->getMainSynthChain()).getWorkDirectory().getFullPathName();
for (int i = 0; i < recentProjectDirectories.size(); i++)
{
recentProjects.addItem(MenuProjectRecentOffset + i, recentProjectDirectories[i], true, currentProject == recentProjectDirectories[i]);
}
#endif
p.addSubMenu(menuTitle, recentProjects);
p.addSeparator();
ADD_MENU_ITEM(MenuProjectShowInFinder);
ADD_MENU_ITEM(MenuFileShowHiseAppDataFolder);
ADD_MENU_ITEM(MenuFileShowProjectAppDataFolder);
p.addSeparator();
p.addSectionHeader("File Management");
ADD_MENU_ITEM(MenuNewFile);
ADD_MENU_ITEM(MenuOpenXmlBackup);
ADD_MENU_ITEM(MenuSaveFileXmlBackup);
ADD_MENU_ITEM(MenuSaveFileAsXmlBackup);
PopupMenu xmlBackups;
Array<File> xmlBackupFiles = GET_PROJECT_HANDLER(bpe->getMainSynthChain()).getFileList(ProjectHandler::SubDirectories::XMLPresetBackups);
for (int i = 0; i < xmlBackupFiles.size(); i++)
{
xmlBackups.addItem(i + MenuFileXmlBackupMenuOffset, xmlBackupFiles[i].getFileName());
}
p.addSubMenu("Open recent XML", xmlBackups);
p.addSeparator();
ADD_MENU_ITEM(MenuOpenFile);
ADD_MENU_ITEM(MenuSaveFile);
PopupMenu filesInProject;
if (GET_PROJECT_HANDLER(bpe->getMainSynthChain()).isActive())
{
recentFileList = GET_PROJECT_HANDLER(bpe->getMainSynthChain()).getFileList(ProjectHandler::SubDirectories::Presets, true);
for (int i = 0; i < recentFileList.size(); i++)
{
filesInProject.addItem(MenuOpenFileFromProjectOffset+i, recentFileList[i].getFileNameWithoutExtension(), true, false);
}
}
p.addSubMenu("Open recent Archive", filesInProject, filesInProject.getNumItems() != 0);
p.addSeparator();
ADD_MENU_ITEM(MenuFileImportSnippet);
ADD_MENU_ITEM(MenuFileCreateRecoveryXml);
#if HISE_IOS
#else
p.addSeparator();
ADD_MENU_ITEM(MenuFileSettings);
ADD_MENU_ITEM(MenuToolsEditShortcuts);
p.addSeparator();
ADD_MENU_ITEM(MenuFileQuit);
#endif
}
break;
}
case BackendCommandTarget::EditMenu:
{
ADD_MENU_ITEM(MenuEditUndo);
ADD_MENU_ITEM(MenuEditRedo);
p.addSeparator();
if(dynamic_cast<JavascriptCodeEditor*>(bpe->currentCopyPasteTarget.get()))
{
dynamic_cast<JavascriptCodeEditor*>(bpe->currentCopyPasteTarget.get())->addPopupMenuItems(p, nullptr);
}
else
{
ADD_MENU_ITEM(MenuEditCopy);
ADD_MENU_ITEM(MenuEditPaste);
p.addSeparator();
ADD_MENU_ITEM(MenuEditCreateScriptVariable);
ADD_MENU_ITEM(MenuEditCreateBase64State);
}
}
break;
case BackendCommandTarget::ExportMenu:
{
if(isSnippetBrowser)
{
ADD_MENU_ITEM(MenuExportFileAsSnippet);
}
else
{
ADD_MENU_ITEM(MenuExportSetupWizard);
p.addSectionHeader("Export As");
ADD_MENU_ITEM(MenuExportFileAsPlugin);
ADD_MENU_ITEM(MenuExportFileAsEffectPlugin);
ADD_MENU_ITEM(MenuExportFileAsMidiFXPlugin);
ADD_MENU_ITEM(MenuExportFileAsStandaloneApp);
p.addSeparator();
ADD_MENU_ITEM(MenuExportFileAsSnippet);
ADD_MENU_ITEM(MenuExportProjectAsExpansion);
p.addSeparator();
p.addSectionHeader("Validation Tools");
ADD_MENU_ITEM(MenuExportCheckAllSampleMaps);
ADD_MENU_ITEM(MenuExportCheckPluginParameters);
ADD_MENU_ITEM(MenuExportValidateUserPresets);
ADD_MENU_ITEM(MenuExportCheckUnusedImages);
p.addSeparator();
p.addSectionHeader("Cleanup Tools");