X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmainundo.C;h=a0aec63baf641caeef00ca699c33b61757faa89c;hb=60f8df69db9ddd8148bfc41a17bb0955b52a45e6;hp=98b864c80df5450700bbd9d66468b86e2dd5a710;hpb=21c2e6b36d6a96c2f662a89459d607b5a387f4eb;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/mainundo.C b/cinelerra-5.1/cinelerra/mainundo.C index 98b864c8..a0aec63b 100644 --- a/cinelerra-5.1/cinelerra/mainundo.C +++ b/cinelerra-5.1/cinelerra/mainundo.C @@ -164,125 +164,95 @@ void MainUndo::update_undo_after(const char *description, } -int MainUndo::undo() +UndoStackItem *MainUndo::next_undo() { - UndoStackItem *current = undo_stack->current; - char after_description[BCTEXTLEN]; - after_description[0] = 0; + return undo_stack->get_current_undo(); +} - mwindow->undo_commercial(); +UndoStackItem *MainUndo::next_redo() +{ + return undo_stack->get_current_redo(); +} -//printf("MainUndo::undo 1\n"); -//dump(); +int MainUndo::undo_load_flags() +{ + UndoStackItem *item = next_undo(); + return item ? item->get_flags() : 0; +} -// Rewind to an after entry - if(current && !(undo_stack->number_of(current) % 2)) - { - current = PREVIOUS; - } +int MainUndo::redo_load_flags() +{ + UndoStackItem *item = next_redo(); + return item ? item->get_flags() : 0; +} -// Rewind to a before entry - if(current && (undo_stack->number_of(current) % 2)) - { - strcpy(after_description, current->get_description()); - current = PREVIOUS; - } -// Now have an even number - if(current) - { - undo_stack->current = current; +int MainUndo::undo() +{ + mwindow->undo_commercial(); + UndoStackItem *current = undo_stack->current; + if( current ) { + undo_stack->current = next_undo(); + if( undo_stack->number_of(current) % 2 ) + current = PREVIOUS; // Now have an even number + } + if( current ) { // Set the redo text to the current description - if(mwindow->gui) - mwindow->gui->mainmenu->redo->update_caption( - after_description); - + if( mwindow->gui ) { + UndoStackItem *next = NEXT; + mwindow->gui->mainmenu->redo-> + update_caption(next ? next->get_description() : ""); + } FileXML file; char *current_data = current->get_data(); - if(current_data) - { + if( current_data ) { file.read_from_string(current_data); load_from_undo(&file, current->get_flags()); //printf("MainUndo::undo %d %s\n", __LINE__, current->get_filename()); mwindow->set_filename(current->get_filename()); delete [] current_data; -// move current entry back one step - undo_stack->pull(); - - - if(mwindow->gui) - { + if( mwindow->gui ) { // Now update the menu with the after entry - current = PREVIOUS; -// Must be a previous entry to perform undo - if(current) - mwindow->gui->mainmenu->undo->update_caption( - current->get_description()); - else - mwindow->gui->mainmenu->undo->update_caption(""); + UndoStackItem *prev = PREVIOUS; + mwindow->gui->mainmenu->undo-> + update_caption(prev ? prev->get_description() : ""); } } } - -//dump(); reset_creators(); + mwindow->reset_caches(); return 0; } + int MainUndo::redo() { - UndoStackItem *current = undo_stack->current; -//printf("MainUndo::redo 1\n"); -//dump(); - -// Get 1st entry - if(!current) current = undo_stack->first; - -// Advance to a before entry - if(current && (undo_stack->number_of(current) % 2)) - { - current = NEXT; - } - -// Advance to an after entry - if(current && !(undo_stack->number_of(current) % 2)) - { - current = NEXT; - } - - if(current) - { - FileXML file; - char *current_data = current->get_data(); + UndoStackItem *current = next_redo(); + if( current ) { undo_stack->current = current; - - if(current_data) - { + char *current_data = current->get_data(); + if( current_data ) { + FileXML file; mwindow->set_filename(current->get_filename()); file.read_from_string(current_data); load_from_undo(&file, current->get_flags()); delete [] current_data; - if(mwindow->gui) - { + if( mwindow->gui ) { // Update menu - mwindow->gui->mainmenu->undo->update_caption(current->get_description()); - + mwindow->gui->mainmenu->undo-> + update_caption(current->get_description()); // Get next after entry - current = NEXT; - if(current) - current = NEXT; - - if(current) - mwindow->gui->mainmenu->redo->update_caption(current->get_description()); - else - mwindow->gui->mainmenu->redo->update_caption(""); + if( (current=NEXT) ) current = NEXT; + mwindow->gui->mainmenu->redo-> + update_caption(current ? current->get_description() : ""); } } } reset_creators(); + mwindow->reset_caches(); //dump(); return 0; } @@ -291,6 +261,8 @@ int MainUndo::redo() // Here the master EDL loads int MainUndo::load_from_undo(FileXML *file, uint32_t load_flags) { + if( load_flags & LOAD_SESSION ) + mwindow->close_mixers(); mwindow->edl->load_xml(file, load_flags); for(Asset *asset = mwindow->edl->assets->first; asset; @@ -306,6 +278,8 @@ int MainUndo::load_from_undo(FileXML *file, uint32_t load_flags) } mwindow->mainindexes->start_build(); mwindow->update_plugin_guis(1); + if( load_flags & LOAD_SESSION ) + mwindow->open_mixers(); return 0; }