add ability to move sub-songs
This commit is contained in:
parent
2da92b0433
commit
ddcd76328d
1
TODO.md
1
TODO.md
|
@ -10,7 +10,6 @@
|
||||||
- add another FM editor layout
|
- add another FM editor layout
|
||||||
- if macros have release, note off should release them
|
- if macros have release, note off should release them
|
||||||
- add ability to move selection by dragging
|
- add ability to move selection by dragging
|
||||||
- add ability to move subsongs
|
|
||||||
- find and replace
|
- find and replace
|
||||||
- add mono/poly note preview button
|
- add mono/poly note preview button
|
||||||
- (maybe) add default patch selection
|
- (maybe) add default patch selection
|
||||||
|
|
|
@ -827,6 +827,44 @@ bool DivEngine::removeSubSong(int index) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivEngine::moveSubSongUp(size_t index) {
|
||||||
|
if (index<1 || index>=song.subsong.size()) return;
|
||||||
|
BUSY_BEGIN;
|
||||||
|
saveLock.lock();
|
||||||
|
|
||||||
|
if (index==curSubSongIndex) {
|
||||||
|
curSubSongIndex--;
|
||||||
|
} else if (index-1==curSubSongIndex) {
|
||||||
|
curSubSongIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
DivSubSong* prev=song.subsong[index-1];
|
||||||
|
song.subsong[index-1]=song.subsong[index];
|
||||||
|
song.subsong[index]=prev;
|
||||||
|
|
||||||
|
saveLock.unlock();
|
||||||
|
BUSY_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivEngine::moveSubSongDown(size_t index) {
|
||||||
|
if (index>=song.subsong.size()-1) return;
|
||||||
|
BUSY_BEGIN;
|
||||||
|
saveLock.lock();
|
||||||
|
|
||||||
|
if (index==curSubSongIndex) {
|
||||||
|
curSubSongIndex++;
|
||||||
|
} else if (index+1==curSubSongIndex) {
|
||||||
|
curSubSongIndex--;
|
||||||
|
}
|
||||||
|
|
||||||
|
DivSubSong* prev=song.subsong[index+1];
|
||||||
|
song.subsong[index+1]=song.subsong[index];
|
||||||
|
song.subsong[index]=prev;
|
||||||
|
|
||||||
|
saveLock.unlock();
|
||||||
|
BUSY_END;
|
||||||
|
}
|
||||||
|
|
||||||
void DivEngine::clearSubSongs() {
|
void DivEngine::clearSubSongs() {
|
||||||
BUSY_BEGIN;
|
BUSY_BEGIN;
|
||||||
saveLock.lock();
|
saveLock.lock();
|
||||||
|
|
|
@ -825,6 +825,10 @@ class DivEngine {
|
||||||
// remove subsong
|
// remove subsong
|
||||||
bool removeSubSong(int index);
|
bool removeSubSong(int index);
|
||||||
|
|
||||||
|
// move subsong
|
||||||
|
void moveSubSongUp(size_t index);
|
||||||
|
void moveSubSongDown(size_t index);
|
||||||
|
|
||||||
// clear all subsong data
|
// clear all subsong data
|
||||||
void clearSubSongs();
|
void clearSubSongs();
|
||||||
|
|
||||||
|
|
|
@ -20,25 +20,42 @@ void FurnaceGUI::drawSubSongs() {
|
||||||
snprintf(id,1023,"%d. %s",(int)e->getCurrentSubSong()+1,e->curSubSong->name.c_str());
|
snprintf(id,1023,"%d. %s",(int)e->getCurrentSubSong()+1,e->curSubSong->name.c_str());
|
||||||
}
|
}
|
||||||
if (ImGui::BeginCombo("##SubSong",id)) {
|
if (ImGui::BeginCombo("##SubSong",id)) {
|
||||||
for (size_t i=0; i<e->song.subsong.size(); i++) {
|
if (ImGui::BeginTable("SubSongSelection",2)) {
|
||||||
if (e->song.subsong[i]->name.empty()) {
|
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch);
|
||||||
snprintf(id,1023,"%d. <no name>",(int)i+1);
|
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed);
|
||||||
} else {
|
for (size_t i=0; i<e->song.subsong.size(); i++) {
|
||||||
snprintf(id,1023,"%d. %s",(int)i+1,e->song.subsong[i]->name.c_str());
|
if (e->song.subsong[i]->name.empty()) {
|
||||||
}
|
snprintf(id,1023,"%d. <no name>",(int)i+1);
|
||||||
if (ImGui::Selectable(id,i==e->getCurrentSubSong())) {
|
} else {
|
||||||
e->changeSongP(i);
|
snprintf(id,1023,"%d. %s",(int)i+1,e->song.subsong[i]->name.c_str());
|
||||||
updateScroll(0);
|
}
|
||||||
oldOrder=0;
|
ImGui::TableNextRow();
|
||||||
oldOrder1=0;
|
ImGui::TableNextColumn();
|
||||||
oldRow=0;
|
if (ImGui::Selectable(id,i==e->getCurrentSubSong())) {
|
||||||
cursor.xCoarse=0;
|
e->changeSongP(i);
|
||||||
cursor.xFine=0;
|
updateScroll(0);
|
||||||
cursor.y=0;
|
oldOrder=0;
|
||||||
selStart=cursor;
|
oldOrder1=0;
|
||||||
selEnd=cursor;
|
oldRow=0;
|
||||||
curOrder=0;
|
cursor.xCoarse=0;
|
||||||
|
cursor.xFine=0;
|
||||||
|
cursor.y=0;
|
||||||
|
selStart=cursor;
|
||||||
|
selEnd=cursor;
|
||||||
|
curOrder=0;
|
||||||
|
}
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::PushID(i);
|
||||||
|
if (ImGui::SmallButton(ICON_FA_ARROW_UP "##SubUp")) {
|
||||||
|
e->moveSubSongUp(i);
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::SmallButton(ICON_FA_ARROW_DOWN "##SubDown")) {
|
||||||
|
e->moveSubSongDown(i);
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue