Skip to content

Commit

Permalink
Acc Bugs; Reset storage state when resetting init patch
Browse files Browse the repository at this point in the history
The init patch updated prefs but not the in memory image.
Oops! Closes surge-synthesizer#5637

Also initialize storage in Switch; and add the key handlers
for MultiSwitch. Addresses surge-synthesizer#4616
  • Loading branch information
baconpaul committed Dec 16, 2021
1 parent bfd8736 commit 19c350d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ void SurgeGUIEditor::controlBeginEdit(Surge::GUI::IComponentTagValue *control)
}
else
{
jassert(false);
// jassert(false);
}
}

Expand All @@ -2088,7 +2088,7 @@ void SurgeGUIEditor::controlEndEdit(Surge::GUI::IComponentTagValue *control)
}
else
{
jassert(false);
// jassert(false);
}
}

Expand Down
30 changes: 30 additions & 0 deletions src/surge-xt/gui/widgets/MultiSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,36 @@ void MultiSwitch::mouseWheelMove(const juce::MouseEvent &event,
}
}

bool MultiSwitch::keyPressed(const juce::KeyPress &key)
{
if (!Surge::GUI::allowKeyboardEdits(storage))
return false;

bool got{false};
int dir = 1;
if (key.getKeyCode() == juce::KeyPress::leftKey || key.getKeyCode() == juce::KeyPress::downKey)
{
got = true;
dir = -1;
}
if (key.getKeyCode() == juce::KeyPress::rightKey || key.getKeyCode() == juce::KeyPress::upKey)
{
got = true;
}

if (got)
{
auto iv = limit_range(getIntegerValue() + dir, 0, rows * columns - 1);

setValue(1.f * iv / (rows * columns - 1));
notifyBeginEdit();
notifyValueChanged();
notifyEndEdit();
repaint();
}
return got;
}

#if SURGE_JUCE_ACCESSIBLE

struct MultiSwitchRadioButton : public juce::Component
Expand Down
1 change: 1 addition & 0 deletions src/surge-xt/gui/widgets/MultiSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct MultiSwitch : public juce::Component, public WidgetBaseMixin<MultiSwitch>
endHover();
repaint();
}
bool keyPressed(const juce::KeyPress &key) override;
Surge::GUI::WheelAccumulationHelper wheelHelper;
void mouseWheelMove(const juce::MouseEvent &event,
const juce::MouseWheelDetails &wheel) override;
Expand Down
7 changes: 7 additions & 0 deletions src/surge-xt/gui/widgets/PatchSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,13 @@ void PatchSelector::showClassicMenu(bool single_category)
Surge::Storage::updateUserDefaultValue(
storage, Surge::Storage::InitialPatchCategoryType,
storage->patch_category[current_category].isFactory ? "Factory" : "User");

storage->initPatchName = Surge::Storage::getUserDefaultValue(
storage, Surge::Storage::InitialPatchName, "Init Saw");
storage->initPatchCategory = Surge::Storage::getUserDefaultValue(
storage, Surge::Storage::InitialPatchCategory, "Templates");
storage->initPatchCategoryType = Surge::Storage::getUserDefaultValue(
storage, Surge::Storage::InitialPatchCategoryType, "Factory");
});

contextMenu.addSeparator();
Expand Down
2 changes: 1 addition & 1 deletion src/surge-xt/gui/widgets/Switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct Switch : public juce::Component, public WidgetBaseMixin<Switch>
repaint();
}

SurgeStorage *storage;
SurgeStorage *storage{nullptr};
void setStorage(SurgeStorage *s) { storage = s; }

Surge::GUI::WheelAccumulationHelper wheelHelper;
Expand Down

0 comments on commit 19c350d

Please sign in to comment.