Ciao,
   Well, I've got basic undo/redo support implemented in Nova.  Now we 
just have to go through and implement all the commands.  First, a little 
explanation though.

   Any command that is going to support undo/redo has to be implemented 
in a class that derives from QUndoCommand, which just has two methods, 
undo() and redo().  When you execute a command you need to create one of 
these objects, with any information it will need to successfully perform 
undo and redo in the future, such as object position, type-string etc., 
and you need to push it onto a QUndoStack.  This is a fancy stack that 
automatically manages your commands and handles the calling of undo/redo 
when activated from the menu.  (I've added those to the gui as well...) 
  Since each patch window will have it's own undo stack, which is 
typical for a document oriented program, there is another layer above 
this called the QUndoGroup.  This groups all the undo stacks in the 
program into 1 place.  Using the undo group means you just have to call 
stack.activate anytime you change focus, and then if the user types in a 
hot key to undo or redo it will execute the next command from the 
correct stack.  I still need to figure out how to get the focus change 
event to call activate, but that should be in the Qt docs somewhere.

I implemented a single command so far, which is when a new object is 
created in a patch canvas.  The infrastructure seems to work correctly, 
but I'm missing something with the undo functionality, which should just 
delete the object from the canvas.  It looks like I have to schedule a 
removal, which communicates to the engine and then waits for a callback 
that finally removes it.  Something is being missed though, because it 
doesn't always remove.  Maybe if you take a look Tim you will know what 
I missed.  Otherwise I'll track it down.

In general I think it would be nice to separate some of the 
functionality that is together in the gui code.  Basically, take the 
logical operations outside of the actual gui management.  So basically 
have some of the code that manages object state and communication with 
the engine, which then just calls methods on a very dumb gui layer that 
purely knows how to paint nice things to the screen.  This will make it 
easier to debug, and also to support gui plugins, alternative guis (like 
an opengl based 3D versions, which is what we plan on doing in the 
future).

Things look good though, I'm getting my feet wet and making progress. 
Once I have undo/redo working for all the current operations possible 
I'd like to implement a DSP object, so I can get a feel for how that 
part of things works.  Maybe another week away.  Do you have anything 
that is sort of next on the list that I could start looking into while 
I'm in lazy code reading mode? :-)

peace,
Jeff

P.S.  I published my git repository, and you can checkout the latest 
patches in the web interface here:

http://code.lifeisagraph.net/?p=nova.git;a=summary

_______________________________________________
nova-dev mailing list
[email protected]
http://klingt.org/cgi-bin/mailman/listinfo/nova-dev
http://tim.klingt.org/nova

Reply via email to