mirror of
https://codeberg.org/armin/trommelkiste.git
synced 2026-09-01 04:10:46 +02:00
Add user preset save/load to the preset menu
This commit is contained in:
parent
ff96ab1a69
commit
143e0bac76
4 changed files with 212 additions and 28 deletions
|
|
@ -290,7 +290,7 @@ TrommelkisteEditor::TrommelkisteEditor(TrommelkisteProcessor& p)
|
|||
int id = presetCombo.getSelectedId();
|
||||
if (id >= 1)
|
||||
{
|
||||
proc.loadKit(id - 1);
|
||||
proc.loadPreset(id - 1);
|
||||
for (int i = 0; i < NUM_TRACKS; ++i)
|
||||
updateFileLabel(i);
|
||||
}
|
||||
|
|
@ -298,7 +298,7 @@ TrommelkisteEditor::TrommelkisteEditor(TrommelkisteProcessor& p)
|
|||
addAndMakeVisible(presetCombo);
|
||||
|
||||
presetPrevBtn.onClick = [this] {
|
||||
proc.prevKit();
|
||||
proc.prevPreset();
|
||||
refreshPresetCombo();
|
||||
for (int i = 0; i < NUM_TRACKS; ++i)
|
||||
updateFileLabel(i);
|
||||
|
|
@ -306,13 +306,36 @@ TrommelkisteEditor::TrommelkisteEditor(TrommelkisteProcessor& p)
|
|||
addAndMakeVisible(presetPrevBtn);
|
||||
|
||||
presetNextBtn.onClick = [this] {
|
||||
proc.nextKit();
|
||||
proc.nextPreset();
|
||||
refreshPresetCombo();
|
||||
for (int i = 0; i < NUM_TRACKS; ++i)
|
||||
updateFileLabel(i);
|
||||
};
|
||||
addAndMakeVisible(presetNextBtn);
|
||||
|
||||
presetSaveBtn.onClick = [this]
|
||||
{
|
||||
auto* aw = new juce::AlertWindow("Save Preset", "Enter a name for this preset:",
|
||||
juce::MessageBoxIconType::NoIcon);
|
||||
aw->addTextEditor("name", "", "Preset name");
|
||||
aw->addButton("Save", 1, juce::KeyPress(juce::KeyPress::returnKey));
|
||||
aw->addButton("Cancel", 0, juce::KeyPress(juce::KeyPress::escapeKey));
|
||||
aw->enterModalState(true, juce::ModalCallbackFunction::create(
|
||||
[this, aw](int result)
|
||||
{
|
||||
if (result == 1)
|
||||
{
|
||||
auto name = aw->getTextEditor("name")->getText().trim();
|
||||
if (name.isNotEmpty())
|
||||
{
|
||||
proc.saveUserPreset(name);
|
||||
refreshPresetCombo();
|
||||
}
|
||||
}
|
||||
}), true);
|
||||
};
|
||||
addAndMakeVisible(presetSaveBtn);
|
||||
|
||||
scaleCombo.addItemList({"100%", "125%", "150%", "175%", "200%"}, 1);
|
||||
scaleCombo.setSelectedId(3, dontSendNotification);
|
||||
scaleCombo.setColour(ComboBox::backgroundColourId, Colour(0xFF333333));
|
||||
|
|
@ -449,10 +472,10 @@ void TrommelkisteEditor::updateFileLabel(int idx)
|
|||
void TrommelkisteEditor::refreshPresetCombo()
|
||||
{
|
||||
presetCombo.clear(dontSendNotification);
|
||||
const int n = proc.getNumKits();
|
||||
const int n = proc.getNumPresets();
|
||||
for (int i = 0; i < n; ++i)
|
||||
presetCombo.addItem(proc.getKitList()[i].name, i + 1);
|
||||
presetCombo.setSelectedId(proc.currentKitIndex + 1, dontSendNotification);
|
||||
presetCombo.addItem(proc.getPresetName(i), i + 1);
|
||||
presetCombo.setSelectedId(proc.currentPresetIndex + 1, dontSendNotification);
|
||||
}
|
||||
|
||||
void TrommelkisteEditor::paint(Graphics& g)
|
||||
|
|
@ -606,7 +629,8 @@ void TrommelkisteEditor::resized()
|
|||
presetPrevBtn.setBounds(scaled(150), scaled(14), scaled(20), scaled(20));
|
||||
presetCombo.setBounds(scaled(172), scaled(14), scaled(100), scaled(20));
|
||||
presetNextBtn.setBounds(scaled(274), scaled(14), scaled(20), scaled(20));
|
||||
scaleCombo.setBounds(scaled(298), scaled(14), scaled(52), scaled(20));
|
||||
presetSaveBtn.setBounds(scaled(296), scaled(14), scaled(48), scaled(20));
|
||||
scaleCombo.setBounds(scaled(348), scaled(14), scaled(52), scaled(20));
|
||||
|
||||
// Header knobs
|
||||
const int hk = HDR_KNOB;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue