Skip to content

Commit

Permalink
Add checks to wavetable popup menu
Browse files Browse the repository at this point in the history
  • Loading branch information
sagantech committed Jan 29, 2019
1 parent e5b546f commit 073fb8b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "vst3sdk"]
path = vst3sdk
url = https://github.com/steinbergmedia/vst3sdk.git
ignore = dirty
17 changes: 9 additions & 8 deletions src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
18 changes: 11 additions & 7 deletions src/common/gui/COscillatorDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -268,28 +267,29 @@ 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;
}
else if (rmenu.pointInside(where))
{
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)
Expand All @@ -298,14 +298,18 @@ 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);

sub++;
}
}
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
}
Expand Down

0 comments on commit 073fb8b

Please sign in to comment.