separate and fix note selector in find/replace

This commit is contained in:
Eknous-P 2025-09-24 13:55:22 +04:00
parent 2785625475
commit 4e97650488
3 changed files with 71 additions and 125 deletions

View file

@ -618,90 +618,14 @@ void FurnaceGUI::drawFindReplace() {
if ((i.noteMode==GUI_QUERY_RANGE || i.noteMode==GUI_QUERY_RANGE_NOT) && i.note>=120) {
i.note=0;
}
if (i.note==130) {
snprintf(tempID,1024,"%s##MREL",macroRelLabel);
} else if (i.note==129) {
snprintf(tempID,1024,"%s##NREL",noteRelLabel);
} else if (i.note==128) {
snprintf(tempID,1024,"%s##NOFF",noteOffLabel);
} else if (i.note>=-60 && i.note<120) {
snprintf(tempID,1024,"%c%c",noteNames[i.note+60][0],(noteNames[i.note+60][1]=='-')?' ':noteNames[i.note+60][1]);
} else {
snprintf(tempID,1024,"???");
i.note=0;
}
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2);
bool updateNote1=false;
int note1=i.note%12;
int oct1=i.note/12;
if (ImGui::BeginCombo("##NN1",tempID)) {
for (int j=0; j<12; j++) {
snprintf(tempID,1024,"%c%c",noteNames[j+72][0],(noteNames[j+72][1]=='-')?' ':noteNames[j+72][1]);
if (ImGui::Selectable(tempID,note1==j)) {
note1=j;
updateNote1=true;
}
}
if (i.noteMode!=GUI_QUERY_RANGE && i.noteMode!=GUI_QUERY_RANGE_NOT) {
if (ImGui::Selectable(noteOffLabel,note1==13)) {
i.note=128;
}
if (ImGui::Selectable(noteRelLabel,note1==14)) {
i.note=129;
}
if (ImGui::Selectable(macroRelLabel,note1==15)) {
i.note=130;
}
}
ImGui::EndCombo();
}
ImGui::SameLine();
if (i.note<128) {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2);
if (ImGui::InputScalar("##NNO1",ImGuiDataType_S32,&oct1)) {
if (oct1<-5) oct1=-5;
if (oct1>9) oct1=9;
updateNote1=true;
}
}
if (updateNote1) {
i.note=oct1*12+note1;
}
NoteSelector(&i.note, i.noteMode!=GUI_QUERY_RANGE && i.noteMode!=GUI_QUERY_RANGE_NOT);
}
ImGui::TableNextColumn();
if (SECOND_VISIBLE(i.noteMode)) {
if (i.noteMax<-60 || i.noteMax>=120) {
i.noteMax=0;
}
if (i.noteMax>=-60 && i.noteMax<120) {
snprintf(tempID,1024,"%c%c",noteNames[i.noteMax+60][0],(noteNames[i.noteMax+60][1]=='-')?' ':noteNames[i.noteMax+60][1]);
} else {
snprintf(tempID,1024,"???");
}
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2);
bool updateNote2=false;
int note2=i.noteMax%12;
int oct2=i.noteMax/12;
if (ImGui::BeginCombo("##NN2",tempID)) {
for (int j=0; j<12; j++) {
snprintf(tempID,1024,"%c%c",noteNames[j+72][0],(noteNames[j+72][1]=='-')?' ':noteNames[j+72][1]);
if (ImGui::Selectable(tempID,note2==j)) {
note2=j;
updateNote2=true;
}
}
ImGui::EndCombo();
}
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2);
if (ImGui::InputScalar("##NNO2",ImGuiDataType_S32,&oct2)) {
if (oct2<-5) oct2=-5;
if (oct2>9) oct2=9;
updateNote2=true;
}
if (updateNote2) {
i.noteMax=oct2*12+note2;
}
NoteSelector(&i.noteMax, false);
}
ImGui::TableNextRow();
@ -912,53 +836,7 @@ void FurnaceGUI::drawFindReplace() {
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
if (queryReplaceNoteMode==GUI_QUERY_REPLACE_SET) {
if (queryReplaceNote==130) {
snprintf(tempID,1024,"%s##MREL",macroRelLabel);
} else if (queryReplaceNote==129) {
snprintf(tempID,1024,"%s##NREL",noteRelLabel);
} else if (queryReplaceNote==128) {
snprintf(tempID,1024,"%s##NOFF",noteOffLabel);
} else if (queryReplaceNote>=-60 && queryReplaceNote<120) {
snprintf(tempID,1024,"%c%c",noteNames[queryReplaceNote+60][0],(noteNames[queryReplaceNote+60][1]=='-')?' ':noteNames[queryReplaceNote+60][1]);
} else {
snprintf(tempID,1024,"???");
queryReplaceNote=0;
}
bool updateNote=false;
int note1=queryReplaceNote%12;
int oct1=queryReplaceNote/12;
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2);
if (ImGui::BeginCombo("##NRValueC",tempID)) {
for (int i=0; i<12; i++) {
snprintf(tempID,1024,"%c%c",noteNames[i+72][0],(noteNames[i+72][1]=='-')?' ':noteNames[i+72][1]);
if (ImGui::Selectable(tempID,note1==i)) {
note1=i;
updateNote=true;
}
}
if (ImGui::Selectable(noteOffLabel,note1==13)) {
queryReplaceNote=128;
}
if (ImGui::Selectable(noteRelLabel,note1==14)) {
queryReplaceNote=129;
}
if (ImGui::Selectable(macroRelLabel,note1==15)) {
queryReplaceNote=130;
}
ImGui::EndCombo();
}
ImGui::SameLine();
if (queryReplaceNote<128) {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2);
if (ImGui::InputScalar("##NRValueCO",ImGuiDataType_S32,&oct1)) {
if (oct1<-5) oct1=-5;
if (oct1>9) oct1=9;
updateNote=true;
}
}
if (updateNote) {
queryReplaceNote=oct1*12+note1;
}
NoteSelector(&queryReplaceNote, true);
} else if (queryReplaceNoteMode==GUI_QUERY_REPLACE_ADD || queryReplaceNoteMode==GUI_QUERY_REPLACE_ADD_OVERFLOW) {
if (ImGui::InputInt("##NRValue",&queryReplaceNote,1,12)) {
if (queryReplaceNote<-180) queryReplaceNote=-180;