-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathPatchView.h
158 lines (117 loc) · 5.11 KB
/
PatchView.h
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
/*
Copyright (c) 2020 Christof Ruch. All rights reserved.
Dual licensed: Distributed under Affero GPL license by default, an MIT license is available for purchase
*/
#pragma once
#include "JuceHeader.h"
#include "Librarian.h"
#include "MidiController.h"
#include "Logger.h"
#include "Patch.h"
#include "Synth.h"
#include "SynthHolder.h"
#include "PatchButtonPanel.h"
#include "SplitteredComponent.h"
#include "CategoryButtons.h"
#include "CurrentPatchDisplay.h"
#include "CollapsibleContainer.h"
#include "PatchListTree.h"
#include "RecycleBin.h"
#include "PatchDatabase.h"
#include "PatchHolder.h"
#include "AutomaticCategory.h"
#include "ImportFromSynthDialog.h"
#include "SynthBankPanel.h"
#include "PatchHistoryPanel.h"
#include <map>
class PatchDiff;
class PatchSearchComponent;
class PatchView : public Component,
public DragAndDropContainer,
private ChangeListener
{
public:
PatchView(midikraft::PatchDatabase &database, std::vector<midikraft::SynthHolder> const &synths);
virtual ~PatchView() override;
void resized() override;
// React on synth or patch changed
virtual void changeListenerCallback(ChangeBroadcaster* source) override;
void retrieveFirstPageFromDatabase();
std::shared_ptr<midikraft::PatchList> retrieveListFromDatabase(midikraft::ListInfo const& info);
void loadSynthBankFromDatabase(std::shared_ptr<midikraft::Synth> synth, MidiBankNumber bank, std::string const& bankId);
void retrieveBankFromSynth(std::shared_ptr<midikraft::Synth> synth, MidiBankNumber bank, std::function<void()> finishedHandler);
void sendBankToSynth(std::shared_ptr<midikraft::SynthBank> bankToSend, bool ignoreDirty, std::function<void()> finishedHandler);
void selectPatch(midikraft::PatchHolder& patch, bool alsoSendToSynth);
// Macro controls triggered by the MidiKeyboard
void hideCurrentPatch();
void favoriteCurrentPatch();
void selectPreviousPatch();
void selectNextPatch();
void retrieveEditBuffer();
// Protected functions that are potentially dangerous and are only called via the main menu
void retrievePatches();
void bulkRenamePatches();
void receiveManualDump();
void deletePatches();
void reindexPatches();
void loadPatches();
void exportPatches();
void exportBank();
void createPatchInterchangeFile();
void showPatchDiffDialog();
// Additional functions for the auto thumbnailer
int totalNumberOfPatches();
void selectFirstPatch();
// Hand through from PatchSearch
midikraft::PatchFilter currentFilter();
// Special functions
void bulkImportPIP(File directory);
// New for bank management
midikraft::PatchFilter bankFilter(std::shared_ptr<midikraft::Synth> synth, std::string const& listID);
void copyBankPatchNamesToClipboard();
private:
friend class PatchSearchComponent;
friend class SimplePatchGrid;
std::vector<CategoryButtons::Category> predefinedCategories();
int getTotalCount();
void loadPage(int skip, int limit, midikraft::PatchFilter const& filter, std::function<void(std::vector<midikraft::PatchHolder>)> callback);
std::vector<midikraft::PatchHolder> autoCategorize(std::vector<midikraft::PatchHolder> const &patches);
// TODO These should go into a more general library
std::vector<MidiProgramNumber> patchIsInSynth(midikraft::PatchHolder& patch);
static bool isSynthConnected(std::shared_ptr<midikraft::Synth> synth);
static std::vector<MidiMessage> buildSelectBankAndProgramMessages(MidiProgramNumber program, midikraft::PatchHolder& patch);
// Helper functions
void sendProgramChangeMessagesForPatch(std::shared_ptr<midikraft::MidiLocationCapability> midiLocation, MidiProgramNumber program, midikraft::PatchHolder& patch);
static void sendPatchAsSysex(midikraft::PatchHolder& patch);
void updateLastPath();
void mergeNewPatches(std::vector<midikraft::PatchHolder> patchesLoaded);
void saveCurrentPatchCategories();
void setSynthBankFilter(std::shared_ptr<midikraft::Synth> synth, MidiBankNumber bank);
void setUserBankFilter(std::shared_ptr<midikraft::Synth> synth, std::string const& listId);
void setImportListFilter(String filter);
void setUserListFilter(String filter);
void deleteSomething(nlohmann::json const &infos);
void fillList(std::shared_ptr<midikraft::PatchList> list, CreateListDialog::TFillParameters fillParameters, std::function<void()> finishedCallback);
void showBank();
PatchListTree patchListTree_;
std::string sourceFilterID_; // This is the old "import" combo box in new
std::string listFilterID_;
std::unique_ptr<SplitteredComponent> splitters_;
TabbedComponent rightSideTab_;
RecycleBin recycleBin_;
Label patchLabel_;
std::unique_ptr<PatchSearchComponent> patchSearch_;
std::unique_ptr<PatchButtonPanel> patchButtons_;
std::unique_ptr<CurrentPatchDisplay> currentPatchDisplay_;
std::unique_ptr<SynthBankPanel> synthBank_;
std::unique_ptr<PatchHistoryPanel> patchHistory_;
std::unique_ptr<ImportFromSynthDialog> importDialog_;
std::unique_ptr<PatchDiff> diffDialog_;
midikraft::Librarian librarian_;
std::vector<midikraft::SynthHolder> synths_;
int currentLayer_;
midikraft::PatchHolder compareTarget_;
midikraft::PatchDatabase &database_;
std::string lastPathForPIF_;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PatchView)
};