@@ -78,17 +78,17 @@ Rectangle<int> Patch::getBounds() const
7878
7979bool Patch::isDirty () const
8080{
81- return isPatchDirty. load () ;
81+ return isPatchDirty;
8282}
8383
8484bool Patch::canUndo () const
8585{
86- return canPatchUndo. load () ;
86+ return canPatchUndo;
8787}
8888
8989bool Patch::canRedo () const
9090{
91- return canPatchRedo. load () ;
91+ return canPatchRedo;
9292}
9393
9494void Patch::savePatch (URL const & locationURL)
@@ -144,20 +144,16 @@ bool Patch::isSubpatch()
144144 return false ;
145145}
146146
147- void Patch::updateUndoRedoState ()
147+ void Patch::updateUndoRedoState (SmallString undoName, SmallString redoName, bool dirty )
148148{
149- // TODO: maybe intercept this from Pd instead
150- if (auto patch = ptr.get <t_glist>()) {
151- canPatchUndo = pd::Interface::canUndo (patch.get ());
152- canPatchRedo = pd::Interface::canRedo (patch.get ());
153- isPatchDirty = patch->gl_dirty ;
154-
155- auto undoSize = pd::Interface::getUndoSize (patch.get ());
156- if (undoQueueSize != undoSize) {
157- undoQueueSize = undoSize;
158- updateUndoRedoString ();
159- }
160- }
149+ if (undoName == " props" ) undoName = " Change property" ;
150+ if (redoName == " props" ) redoName = " Change property" ;
151+
152+ canPatchUndo = undoName != " no" ;
153+ canPatchRedo = redoName != " no" ;
154+ lastUndoSequence = undoName.substring (0 , 1 ).toUpperCase () + undoName.substring (1 );
155+ lastRedoSequence = redoName.substring (0 , 1 ).toUpperCase () + redoName.substring (1 );
156+ isPatchDirty = dirty;
161157}
162158
163159void Patch::savePatch ()
@@ -563,7 +559,6 @@ void Patch::endUndoSequence(String const& name)
563559{
564560 if (auto patch = ptr.get <t_glist>()) {
565561 canvas_undo_add (patch.get (), UNDO_SEQUENCE_END, instance->generateSymbol (name)->s_name , nullptr );
566- updateUndoRedoState ();
567562 }
568563}
569564
@@ -575,7 +570,6 @@ void Patch::undo()
575570 glist_noselect (x);
576571
577572 pd::Interface::undo (patch.get ());
578- updateUndoRedoState ();
579573 }
580574}
581575
@@ -587,52 +581,9 @@ void Patch::redo()
587581 glist_noselect (x);
588582
589583 pd::Interface::redo (patch.get ());
590- updateUndoRedoString ();
591584 }
592585}
593586
594- void Patch::updateUndoRedoString ()
595- {
596- if (auto patch = ptr.get <t_glist>()) {
597- auto cnv = patch.get ();
598- auto currentUndo = canvas_undo_get (cnv)->u_last ;
599- auto undo = currentUndo;
600- auto redo = currentUndo->next ;
601-
602- #ifdef DEBUG_UNDO_QUEUE
603- auto undoDbg = undo;
604- auto redoDbg = redo;
605- #endif
606-
607- lastUndoSequence = " " ;
608- lastRedoSequence = " " ;
609-
610- // undo / redo list will contain pd undo events
611- while (undo) {
612- String undoName = String::fromUTF8 (undo->name );
613- if (undoName == " props" ) {
614- lastUndoSequence = " Change property" ;
615- break ;
616- } else if (undoName != " no" ) {
617- lastUndoSequence = undoName.substring (0 , 1 ).toUpperCase () + undoName.substring (1 );
618- break ;
619- }
620- undo = undo->prev ;
621- }
622-
623- while (redo) {
624- String redoName = String::fromUTF8 (redo->name );
625- if (redoName == " props" ) {
626- lastRedoSequence = " Change property" ;
627- break ;
628- } else if (redoName != " no" ) {
629- lastRedoSequence = redoName.substring (0 , 1 ).toUpperCase () + redoName.substring (1 );
630- break ;
631- }
632- redo = redo->next ;
633- }
634- }
635- }
636587
637588void Patch::updateTitle (SmallString const & newTitle)
638589{
0 commit comments