GUI: refactor the poly button

This commit is contained in:
tildearrow 2025-11-01 03:38:11 -05:00
parent a8a57342ed
commit 173f59dc78
3 changed files with 43 additions and 66 deletions

View file

@ -169,6 +169,20 @@ const bool mobileButtonPersist[32]={
false,
};
const char* noteInputModes[4]={
_N("Mono##PolyInput"),
_N("Poly##PolyInput"),
_N("Chord##PolyInput"),
// unused
_N("Of fuckin' course!##PolyInput")
};
#define CHANGE_NOTE_INPUT_MODE \
noteInputMode++; \
if (noteInputMode>GUI_NOTE_INPUT_CHORD) noteInputMode=GUI_NOTE_INPUT_MONO; \
if (noteInputMode==GUI_NOTE_INPUT_MONO) memset(multiIns,-1,7*sizeof(int)); \
e->setAutoNotePoly(noteInputMode!=GUI_NOTE_INPUT_MONO);
void FurnaceGUI::drawMobileControls() {
float timeScale=60.0*ImGui::GetIO().DeltaTime;
if (dragMobileMenu) {
@ -758,20 +772,9 @@ void FurnaceGUI::drawEditControls() {
}
ImGui::SameLine();
pushToggleColors(noteInputPoly);
if (ImGui::Button(noteInputPoly?(noteInputChord?(_("Chord##PolyInput")):(_("Poly##PolyInput"))):(_("Mono##PolyInput")))) {
if (noteInputPoly) {
if (noteInputChord) {
noteInputPoly=false;
noteInputChord=false;
} else {
noteInputChord=true;
}
} else {
noteInputPoly=true;
noteInputChord=false;
}
e->setAutoNotePoly(noteInputPoly);
pushToggleColors(noteInputMode!=GUI_NOTE_INPUT_MONO);
if (ImGui::Button(_(noteInputModes[noteInputMode&3]))) {
CHANGE_NOTE_INPUT_MODE;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_("Polyphony"));
@ -898,20 +901,9 @@ void FurnaceGUI::drawEditControls() {
unimportant(ImGui::Checkbox(_("Pattern"),&followPattern));
ImGui::SameLine();
pushToggleColors(noteInputPoly);
if (ImGui::Button(noteInputPoly?(noteInputChord?(_("Chord##PolyInput")):(_("Poly##PolyInput"))):(_("Mono##PolyInput")))) {
if (noteInputPoly) {
if (noteInputChord) {
noteInputPoly=false;
noteInputChord=false;
} else {
noteInputChord=true;
}
} else {
noteInputPoly=true;
noteInputChord=false;
}
e->setAutoNotePoly(noteInputPoly);
pushToggleColors(noteInputMode!=GUI_NOTE_INPUT_MONO);
if (ImGui::Button(_(noteInputModes[noteInputMode&3]))) {
CHANGE_NOTE_INPUT_MODE;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_("Polyphony"));
@ -1046,20 +1038,9 @@ void FurnaceGUI::drawEditControls() {
}
popToggleColors();
pushToggleColors(noteInputPoly);
if (ImGui::Button(noteInputPoly?(noteInputChord?(_("Chord##PolyInput")):(_("Poly##PolyInput"))):(_("Mono##PolyInput")))) {
if (noteInputPoly) {
if (noteInputChord) {
noteInputPoly=false;
noteInputChord=false;
} else {
noteInputChord=true;
}
} else {
noteInputPoly=true;
noteInputChord=false;
}
e->setAutoNotePoly(noteInputPoly);
pushToggleColors(noteInputMode!=GUI_NOTE_INPUT_MONO);
if (ImGui::Button(_(noteInputModes[noteInputMode&3]))) {
CHANGE_NOTE_INPUT_MODE;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_("Polyphony"));
@ -1156,20 +1137,9 @@ void FurnaceGUI::drawEditControls() {
popToggleColors();
ImGui::SameLine();
pushToggleColors(noteInputPoly);
if (ImGui::Button(noteInputPoly?(noteInputChord?(_("Chord##PolyInput")):(_("Poly##PolyInput"))):(_("Mono##PolyInput")))) {
if (noteInputPoly) {
if (noteInputChord) {
noteInputPoly=false;
noteInputChord=false;
} else {
noteInputChord=true;
}
} else {
noteInputPoly=true;
noteInputChord=false;
}
e->setAutoNotePoly(noteInputPoly);
pushToggleColors(noteInputMode!=GUI_NOTE_INPUT_MONO);
if (ImGui::Button(_(noteInputModes[noteInputMode&3]))) {
CHANGE_NOTE_INPUT_MODE;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_("Polyphony"));

View file

@ -1399,7 +1399,7 @@ void FurnaceGUI::noteInput(int num, int key, int vol, int chanOff) {
int tick=0;
int speed=0;
if (chanOff>0 && noteInputChord) {
if (chanOff>0 && noteInputMode==GUI_NOTE_INPUT_CHORD) {
ch=e->getViableChannel(ch,chanOff,curIns);
if ((!e->isPlaying() || !followPattern)) {
y-=editStep;
@ -1466,7 +1466,7 @@ void FurnaceGUI::noteInput(int num, int key, int vol, int chanOff) {
pat->newData[y][DIV_PAT_VOL]=-1;
}
}
if ((!e->isPlaying() || !followPattern) && (chanOff<1 || !noteInputChord)) {
if ((!e->isPlaying() || !followPattern) && (chanOff<1 || noteInputMode!=GUI_NOTE_INPUT_CHORD)) {
editAdvance();
}
makeUndo(GUI_UNDO_PATTERN_EDIT,UndoRegion(ord,ch,y,ord,ch,y));
@ -7657,7 +7657,7 @@ bool FurnaceGUI::init() {
initSystemPresets();
e->setAutoNotePoly(noteInputPoly);
e->setAutoNotePoly(noteInputMode!=GUI_NOTE_INPUT_MONO);
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER,"1");
#if SDL_VERSION_ATLEAST(2,0,17)
@ -8326,8 +8326,10 @@ void FurnaceGUI::syncState() {
orderLock=e->getConfBool("orderLock",false);
followOrders=e->getConfBool("followOrders",true);
followPattern=e->getConfBool("followPattern",true);
noteInputPoly=e->getConfBool("noteInputPoly",true);
noteInputChord=e->getConfBool("noteInputChord",false);
noteInputMode=e->getConfInt("noteInputMode",GUI_NOTE_INPUT_POLY);
if (noteInputMode!=GUI_NOTE_INPUT_MONO && noteInputMode!=GUI_NOTE_INPUT_POLY && noteInputMode!=GUI_NOTE_INPUT_CHORD) {
noteInputMode=GUI_NOTE_INPUT_POLY;
}
filePlayerSync=e->getConfBool("filePlayerSync",true);
audioExportOptions.loops=e->getConfInt("exportLoops",0);
if (audioExportOptions.loops<0) audioExportOptions.loops=0;
@ -8489,8 +8491,7 @@ void FurnaceGUI::commitState(DivConfig& conf) {
conf.set("followOrders",followOrders);
conf.set("followPattern",followPattern);
conf.set("orderEditMode",orderEditMode);
conf.set("noteInputPoly",noteInputPoly);
conf.set("noteInputChord",noteInputChord);
conf.set("noteInputMode",(int)noteInputMode);
conf.set("filePlayerSync",filePlayerSync);
if (settings.persistFadeOut) {
conf.set("exportLoops",audioExportOptions.loops);
@ -8665,8 +8666,7 @@ FurnaceGUI::FurnaceGUI():
preserveChanPos(false),
sysDupCloneChannels(true),
sysDupEnd(false),
noteInputPoly(true),
noteInputChord(false),
noteInputMode(GUI_NOTE_INPUT_POLY),
notifyWaveChange(false),
notifySampleChange(false),
recalcTimestamps(true),

View file

@ -1673,6 +1673,12 @@ struct CSDisAsmIns {
}
};
enum NoteInputModes: unsigned char {
GUI_NOTE_INPUT_MONO=0,
GUI_NOTE_INPUT_POLY,
GUI_NOTE_INPUT_CHORD
};
struct FurnaceCV;
class FurnaceGUI {
@ -1723,7 +1729,8 @@ class FurnaceGUI {
bool vgmExportDirectStream, displayInsTypeList, displayWaveSizeList;
bool portrait, injectBackUp, mobileMenuOpen, warnColorPushed;
bool wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu;
bool displayNew, displayExport, displayPalette, fullScreen, preserveChanPos, sysDupCloneChannels, sysDupEnd, noteInputPoly, noteInputChord;
bool displayNew, displayExport, displayPalette, fullScreen, preserveChanPos, sysDupCloneChannels, sysDupEnd;
unsigned char noteInputMode;
bool notifyWaveChange, notifySampleChange;
bool recalcTimestamps;
bool wantScrollListIns, wantScrollListWave, wantScrollListSample;