Revert "add undo to instrument editor (check for diffs on the current DivInstrument in insEdit, record them in a stack)"

This reverts commit 5c9fd69ac1.
This commit is contained in:
tildearrow 2024-08-19 02:49:14 -05:00
parent f1de0bf2b7
commit d3af810462
8 changed files with 55 additions and 307 deletions

View file

@ -605,7 +605,7 @@ void FurnaceGUI::drawDebug() {
}
if (ImGui::TreeNode("Recent Files")) {
ImGui::Text("Items: %d - Max: %d",(int)recentFile.size(),settings.maxRecentFile);
ImGui::Text("readPos: %d - writePos: %d",(int)recentFile.readPos,(int)recentFile.writePos());
ImGui::Text("readPos: %d - writePos: %d",(int)recentFile.readPos,(int)recentFile.writePos);
ImGui::Indent();
for (size_t i=0; i<recentFile.size(); i++) {
ImGui::Text("%d: %s",(int)i,recentFile[i].c_str());

View file

@ -73,8 +73,6 @@ void FurnaceGUI::doAction(int what) {
case GUI_ACTION_UNDO:
if (curWindow==GUI_WINDOW_SAMPLE_EDIT) {
doUndoSample();
} else if (curWindow==GUI_WINDOW_INS_EDIT) {
doUndoInstrument();
} else {
doUndo();
}
@ -82,8 +80,6 @@ void FurnaceGUI::doAction(int what) {
case GUI_ACTION_REDO:
if (curWindow==GUI_WINDOW_SAMPLE_EDIT) {
doRedoSample();
} else if (curWindow==GUI_WINDOW_INS_EDIT) {
doRedoInstrument();
} else {
doRedo();
}

View file

@ -8310,7 +8310,6 @@ FurnaceGUI::FurnaceGUI():
localeRequiresChineseTrad(false),
localeRequiresKorean(false),
prevInsData(NULL),
cachedCurInsPtr(NULL),
pendingLayoutImport(NULL),
pendingLayoutImportLen(0),
pendingLayoutImportStep(0),

View file

@ -2256,8 +2256,6 @@ class FurnaceGUI {
std::vector<ImWchar> localeExtraRanges;
DivInstrument* prevInsData;
DivInstrument cachedCurIns;
DivInstrument* cachedCurInsPtr;
unsigned char* pendingLayoutImport;
size_t pendingLayoutImportLen;
@ -2924,9 +2922,6 @@ class FurnaceGUI {
void doUndoSample();
void doRedoSample();
void doUndoInstrument();
void doRedoInstrument();
void play(int row=0);
void setOrder(unsigned char order, bool forced=false);
void stop();

View file

@ -5250,7 +5250,6 @@ void FurnaceGUI::drawInsEdit() {
ImGui::SetNextWindowSizeConstraints(ImVec2(440.0f*dpiScale,400.0f*dpiScale),ImVec2(canvasW,canvasH));
}
if (ImGui::Begin("Instrument Editor",&insEditOpen,globalWinFlags|(settings.allowEditDocking?0:ImGuiWindowFlags_NoDocking),_("Instrument Editor"))) {
DivInstrument* ins=nullptr;
if (curIns==-2) {
ImGui::SetCursorPosY(ImGui::GetCursorPosY()+(ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y)*0.5f);
CENTER_TEXT(_("waiting..."));
@ -5278,7 +5277,6 @@ void FurnaceGUI::drawInsEdit() {
curIns=i;
wavePreviewInit=true;
updateFMPreview=true;
ins = e->song.ins[curIns];
}
}
ImGui::EndCombo();
@ -5301,7 +5299,7 @@ void FurnaceGUI::drawInsEdit() {
ImGui::EndTable();
}
} else {
ins=e->song.ins[curIns];
DivInstrument* ins=e->song.ins[curIns];
if (updateFMPreview) {
renderFMPreview(ins);
updateFMPreview=false;
@ -7740,51 +7738,7 @@ void FurnaceGUI::drawInsEdit() {
ImGui::EndPopup();
}
if (ins) {
bool insChanged = ins != cachedCurInsPtr;
bool delayDiff = ImGui::IsMouseDown(ImGuiMouseButton_Left) || ImGui::IsMouseDown(ImGuiMouseButton_Right) || ImGui::GetIO().WantCaptureKeyboard;
// check against the last cached to see if diff -- note that modifications to instruments happen outside
// drawInsEdit (e.g. cursor inputs are processed and can directly modify macro data)
if (!insChanged && !delayDiff) {
ins->recordUndoStepIfChanged(e->processTime, &cachedCurIns);
}
if (insChanged || !delayDiff) {
cachedCurIns = *ins;
}
cachedCurInsPtr = ins;
} else {
cachedCurInsPtr = nullptr;
}
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_INS_EDIT;
ImGui::End();
}
void FurnaceGUI::doUndoInstrument() {
if (!insEditOpen) return;
if (curIns<0 || curIns>=(int)e->song.ins.size()) return;
DivInstrument* ins=e->song.ins[curIns];
// is locking the engine necessary? copied from doUndoSample
e->lockEngine([this,ins]() {
ins->undo();
cachedCurInsPtr=ins;
cachedCurIns=*ins;
});
}
void FurnaceGUI::doRedoInstrument() {
if (!insEditOpen) return;
if (curIns<0 || curIns>=(int)e->song.ins.size()) return;
DivInstrument* ins=e->song.ins[curIns];
// is locking the engine necessary? copied from doRedoSample
e->lockEngine([this,ins]() {
ins->redo();
cachedCurInsPtr=ins;
cachedCurIns=*ins;
});
}