GUI: prepare for more UX improvements

- add "temporary instrument" to DivEngine
- prepare for two things:
  - instrument preview on file picker (at least built-in one)
  - instrument selector for banks (#364)
This commit is contained in:
tildearrow 2022-04-25 18:23:12 -05:00
parent 2e52a2855c
commit b3f1935f2b
3 changed files with 16 additions and 1 deletions

View file

@ -739,6 +739,7 @@ String DivEngine::getWarnings() {
}
DivInstrument* DivEngine::getIns(int index, DivInstrumentType fallbackType) {
if (index==-2 && tempIns!=NULL) return tempIns;
if (index<0 || index>=song.insLen) {
switch (fallbackType) {
case DIV_INS_OPLL:
@ -1363,6 +1364,15 @@ int DivEngine::addInstrumentPtr(DivInstrument* which) {
return song.insLen;
}
void DivEngine::loadTempIns(DivInstrument* which) {
BUSY_BEGIN;
if (tempIns==NULL) {
tempIns=new DivInstrument;
}
memcpy(tempIns,which,sizeof(DivInstrument));
BUSY_END;
}
void DivEngine::delInstrument(int index) {
BUSY_BEGIN;
saveLock.lock();

View file

@ -302,6 +302,7 @@ class DivEngine {
public:
DivSong song;
DivInstrument* tempIns;
DivSystem sysOfChan[DIV_MAX_CHANS];
int dispatchOfChan[DIV_MAX_CHANS];
int dispatchChanOfChan[DIV_MAX_CHANS];
@ -525,6 +526,9 @@ class DivEngine {
// if the returned vector is empty then there was an error.
std::vector<DivInstrument*> instrumentFromFile(const char* path);
// load temporary instrument
void loadTempIns(DivInstrument* which);
// delete instrument
void delInstrument(int index);
@ -798,6 +802,7 @@ class DivEngine {
metroAmp(0.0f),
metroVol(1.0f),
totalProcessed(0),
tempIns(NULL),
oscBuf{NULL,NULL},
oscSize(1),
oscReadPos(0),

View file

@ -2419,7 +2419,7 @@ bool FurnaceGUI::loop() {
}
}
wantCaptureKeyboard=ImGui::GetIO().WantCaptureKeyboard;
wantCaptureKeyboard=ImGui::GetIO().WantTextInput;
while (true) {
midiLock.lock();