From 073fb8b290c0c0cd597cd30bcd71137955e65e64 Mon Sep 17 00:00:00 2001 From: Jeremy Sagan Date: Tue, 29 Jan 2019 01:07:31 -0500 Subject: [PATCH] Add checks to wavetable popup menu --- .gitmodules | 1 + src/common/SurgeStorage.cpp | 17 +++++++++-------- src/common/gui/COscillatorDisplay.cpp | 18 +++++++++++------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.gitmodules b/.gitmodules index 07adea5768b..eecd75c2fcf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "vst3sdk"] path = vst3sdk url = https://github.com/steinbergmedia/vst3sdk.git + ignore = dirty \ No newline at end of file diff --git a/src/common/SurgeStorage.cpp b/src/common/SurgeStorage.cpp index 25ec114ebe4..05839fc338e 100644 --- a/src/common/SurgeStorage.cpp +++ b/src/common/SurgeStorage.cpp @@ -491,21 +491,22 @@ void SurgeStorage::refresh_wtlist() void SurgeStorage::perform_queued_wtloads() { + SurgePatch& patch = getPatch(); //Change here is for performance and ease of debugging, simply not calling getPatch so many times. Code should behave identically. for (int sc = 0; sc < 2; sc++) { for (int o = 0; o < n_oscs; o++) { - if (getPatch().scene[sc].osc[o].wt.queue_id != -1) + if (patch.scene[sc].osc[o].wt.queue_id != -1) { - load_wt(getPatch().scene[sc].osc[o].wt.queue_id, &getPatch().scene[sc].osc[o].wt); - getPatch().scene[sc].osc[o].wt.refresh_display = true; + load_wt(patch.scene[sc].osc[o].wt.queue_id, &patch.scene[sc].osc[o].wt); + patch.scene[sc].osc[o].wt.refresh_display = true; } - else if (getPatch().scene[sc].osc[o].wt.queue_filename[0]) + else if (patch.scene[sc].osc[o].wt.queue_filename[0]) { - getPatch().scene[sc].osc[o].queue_type = ot_wavetable; - getPatch().scene[sc].osc[o].wt.current_id = -1; - load_wt(getPatch().scene[sc].osc[o].wt.queue_filename, &getPatch().scene[sc].osc[o].wt); - getPatch().scene[sc].osc[o].wt.refresh_display = true; + patch.scene[sc].osc[o].queue_type = ot_wavetable; + patch.scene[sc].osc[o].wt.current_id = -1; + load_wt(patch.scene[sc].osc[o].wt.queue_filename, &patch.scene[sc].osc[o].wt); + patch.scene[sc].osc[o].wt.refresh_display = true; } } } diff --git a/src/common/gui/COscillatorDisplay.cpp b/src/common/gui/COscillatorDisplay.cpp index 3e7262c7f19..e6d3542d528 100644 --- a/src/common/gui/COscillatorDisplay.cpp +++ b/src/common/gui/COscillatorDisplay.cpp @@ -34,7 +34,6 @@ void COscillatorDisplay::draw(CDrawContext* dc) cdisurf->begin(); cdisurf->clear(0xffffffff); - int w = cdisurf->getWidth(); int h2 = cdisurf->getHeight(); int h = h2; assert(h < 512); @@ -268,12 +267,13 @@ CMouseEventResult COscillatorDisplay::onMouseDown(CPoint& where, const CButtonSt } else if (uses_wavetabledata(oscdata->type.val.i)) { + int id = oscdata->wt.current_id; if (rprev.pointInside(where)) { - int id = storage->getAdjacentWaveTable(oscdata->wt.current_id, false); + id = storage->getAdjacentWaveTable(oscdata->wt.current_id, false); if (id >= 0) oscdata->wt.queue_id = id; } else if (rnext.pointInside(where)) { - int id = storage->getAdjacentWaveTable(oscdata->wt.current_id, true); + id = storage->getAdjacentWaveTable(oscdata->wt.current_id, true); if (id >= 0) oscdata->wt.queue_id = id; } @@ -281,15 +281,15 @@ CMouseEventResult COscillatorDisplay::onMouseDown(CPoint& where, const CButtonSt { CRect menurect(0, 0, 0, 0); menurect.offset(where.x, where.y); - COptionMenu* contextMenu = new COptionMenu(menurect, 0, 0, 0, 0, COptionMenu::kNoDrawStyle); + COptionMenu* contextMenu = new COptionMenu(menurect, 0, 0, 0, 0, COptionMenu::kMultipleCheckStyle); for (auto c : storage->wtCategoryOrdering) { char name[NAMECHARS]; - COptionMenu* subMenu = new COptionMenu(getViewSize(), 0, c, 0, 0, COptionMenu::kNoDrawStyle); + COptionMenu* subMenu = new COptionMenu(getViewSize(), 0, c, 0, 0, COptionMenu::kMultipleCheckStyle); subMenu->setNbItemsPerColumn(32); int sub = 0; - int p; + for (auto p : storage->wtOrdering) { if (storage->wt_list[p].category == c) @@ -298,6 +298,8 @@ CMouseEventResult COscillatorDisplay::onMouseDown(CPoint& where, const CButtonSt auto actionItem = new CCommandMenuItem(CCommandMenuItem::Desc(name)); auto action = [this, p](CCommandMenuItem* item) { this->loadWavetable(p); }; + if (p == id) + actionItem->setChecked(true); actionItem->setActions(action, nullptr); subMenu->addEntry(actionItem); @@ -305,7 +307,9 @@ CMouseEventResult COscillatorDisplay::onMouseDown(CPoint& where, const CButtonSt } } strncpy(name, storage->wt_category[c].name.c_str(), NAMECHARS); - contextMenu->addEntry(subMenu, name); + CMenuItem *submenuItem = contextMenu->addEntry(subMenu, name); + if (id >= 0 && storage->wt_list[id].category == c) + submenuItem->setChecked(true); subMenu->forget(); // Important, so that the refcounter gets right }