GUI: allow use of octave up/down whn fil pick open

issue #1895
This commit is contained in:
tildearrow 2024-10-17 16:22:04 -05:00
parent 5eae36f092
commit 9fbb7df674

View file

@ -1472,7 +1472,6 @@ void FurnaceGUI::orderInput(int num) {
void FurnaceGUI::keyDown(SDL_Event& ev) { void FurnaceGUI::keyDown(SDL_Event& ev) {
if (introPos<11.0 && !shortIntro) return; if (introPos<11.0 && !shortIntro) return;
if (ImGuiFileDialog::Instance()->IsOpened()) return;
if (aboutOpen) return; if (aboutOpen) return;
if (cvOpen) return; if (cvOpen) return;
@ -1490,162 +1489,102 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
mapped|=FURKMOD_SHIFT; mapped|=FURKMOD_SHIFT;
} }
if (bindSetActive) { if (!ImGuiFileDialog::Instance()->IsOpened()) {
if (!ev.key.repeat) { if (bindSetActive) {
switch (ev.key.keysym.sym) { if (!ev.key.repeat) {
case SDLK_LCTRL: case SDLK_RCTRL: switch (ev.key.keysym.sym) {
case SDLK_LALT: case SDLK_RALT: case SDLK_LCTRL: case SDLK_RCTRL:
case SDLK_LGUI: case SDLK_RGUI: case SDLK_LALT: case SDLK_RALT:
case SDLK_LSHIFT: case SDLK_RSHIFT: case SDLK_LGUI: case SDLK_RGUI:
bindSetPending=false; case SDLK_LSHIFT: case SDLK_RSHIFT:
actionKeys[bindSetTarget][bindSetTargetIdx]=(mapped&(~FURK_MASK))|0xffffff; bindSetPending=false;
break; actionKeys[bindSetTarget][bindSetTargetIdx]=(mapped&(~FURK_MASK))|0xffffff;
default: break;
actionKeys[bindSetTarget][bindSetTargetIdx]=mapped; default:
actionKeys[bindSetTarget][bindSetTargetIdx]=mapped;
// de-dupe with an n^2 algorithm that will never ever be a problem (...but for real though) // de-dupe with an n^2 algorithm that will never ever be a problem (...but for real though)
for (size_t i=0; i<actionKeys[bindSetTarget].size(); i++) { for (size_t i=0; i<actionKeys[bindSetTarget].size(); i++) {
for (size_t j=i+1; j<actionKeys[bindSetTarget].size(); j++) { for (size_t j=i+1; j<actionKeys[bindSetTarget].size(); j++) {
if (actionKeys[bindSetTarget][i]==actionKeys[bindSetTarget][j]) { if (actionKeys[bindSetTarget][i]==actionKeys[bindSetTarget][j]) {
actionKeys[bindSetTarget].erase(actionKeys[bindSetTarget].begin()+j); actionKeys[bindSetTarget].erase(actionKeys[bindSetTarget].begin()+j);
}
} }
} }
}
bindSetActive=false; bindSetActive=false;
bindSetPending=false; bindSetPending=false;
bindSetTarget=0; bindSetTarget=0;
bindSetTargetIdx=0; bindSetTargetIdx=0;
bindSetPrevValue=0; bindSetPrevValue=0;
parseKeybinds(); parseKeybinds();
break; break;
}
} }
return;
} }
return;
}
if (latchTarget) { if (latchTarget) {
if (mapped==SDLK_DELETE || mapped==SDLK_BACKSPACE) { if (mapped==SDLK_DELETE || mapped==SDLK_BACKSPACE) {
switch (latchTarget) {
case 1:
latchIns=-1;
break;
case 2:
latchVol=-1;
break;
case 3:
latchEffect=-1;
break;
case 4:
latchEffectVal=-1;
break;
}
} else {
auto it=valueKeys.find(ev.key.keysym.sym);
if (it!=valueKeys.cend()) {
int num=it->second;
switch (latchTarget) { switch (latchTarget) {
case 1: // instrument case 1:
changeLatch(latchIns); latchIns=-1;
break; break;
case 2: // volume case 2:
changeLatch(latchVol); latchVol=-1;
break; break;
case 3: // effect case 3:
changeLatch(latchEffect); latchEffect=-1;
break; break;
case 4: // effect value case 4:
changeLatch(latchEffectVal); latchEffectVal=-1;
break; break;
} }
} else {
auto it=valueKeys.find(ev.key.keysym.sym);
if (it!=valueKeys.cend()) {
int num=it->second;
switch (latchTarget) {
case 1: // instrument
changeLatch(latchIns);
break;
case 2: // volume
changeLatch(latchVol);
break;
case 3: // effect
changeLatch(latchEffect);
break;
case 4: // effect value
changeLatch(latchEffectVal);
break;
}
}
} }
return;
} }
return;
}
if (sampleMapWaitingInput) { if (sampleMapWaitingInput) {
switch (sampleMapColumn) { switch (sampleMapColumn) {
case 0: { case 0: {
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) { if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
alterSampleMap(0,-1); alterSampleMap(0,-1);
return;
}
auto it=valueKeys.find(ev.key.keysym.sym);
if (it!=valueKeys.cend()) {
int num=it->second;
if (num<10) {
alterSampleMap(0,num);
return; return;
} }
auto it=valueKeys.find(ev.key.keysym.sym);
if (it!=valueKeys.cend()) {
int num=it->second;
if (num<10) {
alterSampleMap(0,num);
return;
}
}
break;
} }
break; case 1: {
} if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
case 1: { alterSampleMap(1,-1);
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
alterSampleMap(1,-1);
return;
}
auto it=noteKeys.find(ev.key.keysym.scancode);
if (it!=noteKeys.cend()) {
int key=it->second;
int num=12*curOctave+key;
if (num<-60) num=-60; // C-(-5)
if (num>119) num=119; // B-9
alterSampleMap(1,num);
return;
}
break;
}
case 2: {
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
alterSampleMap(2,-1);
return;
}
auto it=valueKeys.find(ev.key.keysym.sym);
if (it!=valueKeys.cend()) {
int num=it->second;
if (num<10) {
alterSampleMap(2,num);
return; return;
} }
}
break;
}
case 3: {
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
alterSampleMap(3,-1);
return;
}
auto it=valueKeys.find(ev.key.keysym.sym);
if (it!=valueKeys.cend()) {
int num=it->second;
if (num<16) {
alterSampleMap(3,num);
return;
}
}
break;
}
}
}
// PER-WINDOW KEYS
switch (curWindow) {
case GUI_WINDOW_PATTERN: {
auto actionI=actionMapPat.find(mapped);
if (actionI!=actionMapPat.cend()) {
int action=actionI->second;
if (action>0) {
doAction(action);
return;
}
}
// pattern input otherwise
if (mapped&(FURKMOD_ALT|FURKMOD_CTRL|FURKMOD_META|FURKMOD_SHIFT)) break;
if (!ev.key.repeat || settings.inputRepeat) {
if (cursor.xFine==0) { // note
auto it=noteKeys.find(ev.key.keysym.scancode); auto it=noteKeys.find(ev.key.keysym.scancode);
if (it!=noteKeys.cend()) { if (it!=noteKeys.cend()) {
int key=it->second; int key=it->second;
@ -1654,86 +1593,148 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
if (num<-60) num=-60; // C-(-5) if (num<-60) num=-60; // C-(-5)
if (num>119) num=119; // B-9 if (num>119) num=119; // B-9
if (edit) { alterSampleMap(1,num);
noteInput(num,key); return;
} }
break;
}
case 2: {
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
alterSampleMap(2,-1);
return;
} }
} else if (edit) { // value
auto it=valueKeys.find(ev.key.keysym.sym); auto it=valueKeys.find(ev.key.keysym.sym);
if (it!=valueKeys.cend()) { if (it!=valueKeys.cend()) {
int num=it->second; int num=it->second;
valueInput(num); if (num<10) {
alterSampleMap(2,num);
return;
}
}
break;
}
case 3: {
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
alterSampleMap(3,-1);
return;
}
auto it=valueKeys.find(ev.key.keysym.sym);
if (it!=valueKeys.cend()) {
int num=it->second;
if (num<16) {
alterSampleMap(3,num);
return;
}
}
break;
}
}
}
// PER-WINDOW KEYS
switch (curWindow) {
case GUI_WINDOW_PATTERN: {
auto actionI=actionMapPat.find(mapped);
if (actionI!=actionMapPat.cend()) {
int action=actionI->second;
if (action>0) {
doAction(action);
return;
} }
} }
} // pattern input otherwise
break; if (mapped&(FURKMOD_ALT|FURKMOD_CTRL|FURKMOD_META|FURKMOD_SHIFT)) break;
} if (!ev.key.repeat || settings.inputRepeat) {
case GUI_WINDOW_ORDERS: { if (cursor.xFine==0) { // note
auto actionI=actionMapOrders.find(mapped); auto it=noteKeys.find(ev.key.keysym.scancode);
if (actionI!=actionMapOrders.cend()) { if (it!=noteKeys.cend()) {
int action=actionI->second; int key=it->second;
if (action>0) { int num=12*curOctave+key;
doAction(action);
return; if (num<-60) num=-60; // C-(-5)
if (num>119) num=119; // B-9
if (edit) {
noteInput(num,key);
}
}
} else if (edit) { // value
auto it=valueKeys.find(ev.key.keysym.sym);
if (it!=valueKeys.cend()) {
int num=it->second;
valueInput(num);
}
}
} }
break;
} }
// order input otherwise case GUI_WINDOW_ORDERS: {
if (mapped&(FURKMOD_ALT|FURKMOD_CTRL|FURKMOD_META|FURKMOD_SHIFT)) break; auto actionI=actionMapOrders.find(mapped);
if (orderEditMode!=0) { if (actionI!=actionMapOrders.cend()) {
auto it=valueKeys.find(ev.key.keysym.sym); int action=actionI->second;
if (it!=valueKeys.cend()) { if (action>0) {
int num=it->second; doAction(action);
orderInput(num); return;
}
} }
} // order input otherwise
break; if (mapped&(FURKMOD_ALT|FURKMOD_CTRL|FURKMOD_META|FURKMOD_SHIFT)) break;
} if (orderEditMode!=0) {
case GUI_WINDOW_SAMPLE_EDIT: { auto it=valueKeys.find(ev.key.keysym.sym);
auto actionI=actionMapSample.find(mapped); if (it!=valueKeys.cend()) {
if (actionI!=actionMapSample.cend()) { int num=it->second;
int action=actionI->second; orderInput(num);
if (action>0) { }
doAction(action);
return;
} }
break;
} }
break; case GUI_WINDOW_SAMPLE_EDIT: {
} auto actionI=actionMapSample.find(mapped);
case GUI_WINDOW_INS_LIST: { if (actionI!=actionMapSample.cend()) {
auto actionI=actionMapInsList.find(mapped); int action=actionI->second;
if (actionI!=actionMapInsList.cend()) { if (action>0) {
int action=actionI->second; doAction(action);
if (action>0) { return;
doAction(action); }
return;
} }
break;
} }
break; case GUI_WINDOW_INS_LIST: {
} auto actionI=actionMapInsList.find(mapped);
case GUI_WINDOW_WAVE_LIST: { if (actionI!=actionMapInsList.cend()) {
auto actionI=actionMapWaveList.find(mapped); int action=actionI->second;
if (actionI!=actionMapWaveList.cend()) { if (action>0) {
int action=actionI->second; doAction(action);
if (action>0) { return;
doAction(action); }
return;
} }
break;
} }
break; case GUI_WINDOW_WAVE_LIST: {
} auto actionI=actionMapWaveList.find(mapped);
case GUI_WINDOW_SAMPLE_LIST: { if (actionI!=actionMapWaveList.cend()) {
auto actionI=actionMapSampleList.find(mapped); int action=actionI->second;
if (actionI!=actionMapSampleList.cend()) { if (action>0) {
int action=actionI->second; doAction(action);
if (action>0) { return;
doAction(action); }
return;
} }
break;
} }
break; case GUI_WINDOW_SAMPLE_LIST: {
auto actionI=actionMapSampleList.find(mapped);
if (actionI!=actionMapSampleList.cend()) {
int action=actionI->second;
if (action>0) {
doAction(action);
return;
}
}
break;
}
default:
break;
} }
default:
break;
} }
// GLOBAL KEYS // GLOBAL KEYS
@ -1741,6 +1742,9 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
if (actionI!=actionMapGlobal.cend()) { if (actionI!=actionMapGlobal.cend()) {
int action=actionI->second; int action=actionI->second;
if (action>0) { if (action>0) {
if (ImGuiFileDialog::Instance()->IsOpened()) {
if (action!=GUI_ACTION_OCTAVE_UP && action!=GUI_ACTION_OCTAVE_DOWN) return;
}
doAction(action); doAction(action);
return; return;
} }