allow moving ins/wave/samples up or down

This commit is contained in:
tildearrow 2022-01-11 03:52:11 -05:00
parent 020d278f00
commit 4c5fbc252b
3 changed files with 76 additions and 8 deletions

View file

@ -2719,6 +2719,66 @@ void DivEngine::moveOrderDown() {
isBusy.unlock(); isBusy.unlock();
} }
bool DivEngine::moveInsUp(int which) {
if (which<1 || which>=(int)song.ins.size()) return false;
isBusy.lock();
DivInstrument* prev=song.ins[which];
song.ins[which]=song.ins[which-1];
song.ins[which-1]=prev;
isBusy.unlock();
return true;
}
bool DivEngine::moveWaveUp(int which) {
if (which<1 || which>=(int)song.wave.size()) return false;
isBusy.lock();
DivWavetable* prev=song.wave[which];
song.wave[which]=song.wave[which-1];
song.wave[which-1]=prev;
isBusy.unlock();
return true;
}
bool DivEngine::moveSampleUp(int which) {
if (which<1 || which>=(int)song.sample.size()) return false;
isBusy.lock();
DivSample* prev=song.sample[which];
song.sample[which]=song.sample[which-1];
song.sample[which-1]=prev;
isBusy.unlock();
return true;
}
bool DivEngine::moveInsDown(int which) {
if (which<0 || which>=((int)song.ins.size())-1) return false;
isBusy.lock();
DivInstrument* prev=song.ins[which];
song.ins[which]=song.ins[which+1];
song.ins[which+1]=prev;
isBusy.unlock();
return true;
}
bool DivEngine::moveWaveDown(int which) {
if (which<0 || which>=((int)song.wave.size())-1) return false;
isBusy.lock();
DivWavetable* prev=song.wave[which];
song.wave[which]=song.wave[which+1];
song.wave[which+1]=prev;
isBusy.unlock();
return true;
}
bool DivEngine::moveSampleDown(int which) {
if (which<0 || which>=((int)song.sample.size())-1) return false;
isBusy.lock();
DivSample* prev=song.sample[which];
song.sample[which]=song.sample[which+1];
song.sample[which+1]=prev;
isBusy.unlock();
return true;
}
void DivEngine::noteOn(int chan, int ins, int note, int vol) { void DivEngine::noteOn(int chan, int ins, int note, int vol) {
isBusy.lock(); isBusy.lock();
pendingNotes.push(DivNoteEvent(chan,ins,note,vol,true)); pendingNotes.push(DivNoteEvent(chan,ins,note,vol,true));

View file

@ -349,6 +349,16 @@ class DivEngine {
// move order down // move order down
void moveOrderDown(); void moveOrderDown();
// move thing up
bool moveInsUp(int which);
bool moveWaveUp(int which);
bool moveSampleUp(int which);
// move thing down
bool moveInsDown(int which);
bool moveWaveDown(int which);
bool moveSampleDown(int which);
// play note // play note
void noteOn(int chan, int ins, int note, int vol=-1); void noteOn(int chan, int ins, int note, int vol=-1);

View file

@ -511,11 +511,11 @@ void FurnaceGUI::drawInsList() {
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::ArrowButton("InsUp",ImGuiDir_Up)) { if (ImGui::ArrowButton("InsUp",ImGuiDir_Up)) {
// TODO if (e->moveInsUp(curIns)) curIns--;
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::ArrowButton("InsDown",ImGuiDir_Down)) { if (ImGui::ArrowButton("InsDown",ImGuiDir_Down)) {
// TODO if (e->moveInsDown(curIns)) curIns++;
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(ICON_FA_TIMES "##InsDelete")) { if (ImGui::Button(ICON_FA_TIMES "##InsDelete")) {
@ -582,8 +582,6 @@ const char* ssgEnvTypes[8]={
"Down Down Down", "Down.", "Down Up Down Up", "Down UP", "Up Up Up", "Up.", "Up Down Up Down", "Up DOWN" "Down Down Down", "Down.", "Down Up Down Up", "Down UP", "Up Up Up", "Up.", "Up Down Up Down", "Up DOWN"
}; };
// TODO: BUTTONS TO SELECT BETWEEN 15 AND 31
// AND DUTY TOO
void FurnaceGUI::drawInsEdit() { void FurnaceGUI::drawInsEdit() {
if (!insEditOpen) return; if (!insEditOpen) return;
if (ImGui::Begin("Instrument Editor",&insEditOpen,ImGuiWindowFlags_NoDocking)) { if (ImGui::Begin("Instrument Editor",&insEditOpen,ImGuiWindowFlags_NoDocking)) {
@ -1006,11 +1004,11 @@ void FurnaceGUI::drawWaveList() {
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::ArrowButton("WaveUp",ImGuiDir_Up)) { if (ImGui::ArrowButton("WaveUp",ImGuiDir_Up)) {
// TODO if (e->moveWaveUp(curWave)) curWave--;
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::ArrowButton("WaveDown",ImGuiDir_Down)) { if (ImGui::ArrowButton("WaveDown",ImGuiDir_Down)) {
// TODO if (e->moveWaveDown(curWave)) curWave++;
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(ICON_FA_TIMES "##WaveDelete")) { if (ImGui::Button(ICON_FA_TIMES "##WaveDelete")) {
@ -1117,11 +1115,11 @@ void FurnaceGUI::drawSampleList() {
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::ArrowButton("SampleUp",ImGuiDir_Up)) { if (ImGui::ArrowButton("SampleUp",ImGuiDir_Up)) {
// TODO if (e->moveSampleUp(curSample)) curSample--;
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::ArrowButton("SampleDown",ImGuiDir_Down)) { if (ImGui::ArrowButton("SampleDown",ImGuiDir_Down)) {
// TODO if (e->moveSampleDown(curSample)) curSample++;
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(ICON_FA_TIMES "##SampleDelete")) { if (ImGui::Button(ICON_FA_TIMES "##SampleDelete")) {