mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-27 06:53:01 +00:00
add ability to move sub-songs
This commit is contained in:
parent
2da92b0433
commit
ddcd76328d
4 changed files with 77 additions and 19 deletions
1
TODO.md
1
TODO.md
|
@ -10,7 +10,6 @@
|
|||
- add another FM editor layout
|
||||
- if macros have release, note off should release them
|
||||
- add ability to move selection by dragging
|
||||
- add ability to move subsongs
|
||||
- find and replace
|
||||
- add mono/poly note preview button
|
||||
- (maybe) add default patch selection
|
||||
|
|
|
@ -827,6 +827,44 @@ bool DivEngine::removeSubSong(int index) {
|
|||
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() {
|
||||
BUSY_BEGIN;
|
||||
saveLock.lock();
|
||||
|
|
|
@ -825,6 +825,10 @@ class DivEngine {
|
|||
// remove subsong
|
||||
bool removeSubSong(int index);
|
||||
|
||||
// move subsong
|
||||
void moveSubSongUp(size_t index);
|
||||
void moveSubSongDown(size_t index);
|
||||
|
||||
// clear all subsong data
|
||||
void clearSubSongs();
|
||||
|
||||
|
|
|
@ -20,25 +20,42 @@ void FurnaceGUI::drawSubSongs() {
|
|||
snprintf(id,1023,"%d. %s",(int)e->getCurrentSubSong()+1,e->curSubSong->name.c_str());
|
||||
}
|
||||
if (ImGui::BeginCombo("##SubSong",id)) {
|
||||
for (size_t i=0; i<e->song.subsong.size(); i++) {
|
||||
if (e->song.subsong[i]->name.empty()) {
|
||||
snprintf(id,1023,"%d. <no name>",(int)i+1);
|
||||
} else {
|
||||
snprintf(id,1023,"%d. %s",(int)i+1,e->song.subsong[i]->name.c_str());
|
||||
}
|
||||
if (ImGui::Selectable(id,i==e->getCurrentSubSong())) {
|
||||
e->changeSongP(i);
|
||||
updateScroll(0);
|
||||
oldOrder=0;
|
||||
oldOrder1=0;
|
||||
oldRow=0;
|
||||
cursor.xCoarse=0;
|
||||
cursor.xFine=0;
|
||||
cursor.y=0;
|
||||
selStart=cursor;
|
||||
selEnd=cursor;
|
||||
curOrder=0;
|
||||
if (ImGui::BeginTable("SubSongSelection",2)) {
|
||||
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed);
|
||||
for (size_t i=0; i<e->song.subsong.size(); i++) {
|
||||
if (e->song.subsong[i]->name.empty()) {
|
||||
snprintf(id,1023,"%d. <no name>",(int)i+1);
|
||||
} else {
|
||||
snprintf(id,1023,"%d. %s",(int)i+1,e->song.subsong[i]->name.c_str());
|
||||
}
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable(id,i==e->getCurrentSubSong())) {
|
||||
e->changeSongP(i);
|
||||
updateScroll(0);
|
||||
oldOrder=0;
|
||||
oldOrder1=0;
|
||||
oldRow=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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue