Undo, redo

From Buzztard

Jump to: navigation, search

The editor app. needs undo/redo. As a side effect handling undo/redo makes it easy to detect when the song has been changed. If there is nothing to undo since last save (load), it has not been changed ;).

Contents

[edit] Existing implementations

[edit] GUndo

GUndo manages a sequence of actions. Echo action has callbacks for undo/redo and free. One can link toolbar/menu items to the sequence and the allow to go back and forth.

Everytime we add an action, we would need to pack the data + some context into a struct. When an action is added, it refs all related objects.

The GUndoSequence is a default implementation of the GUndoHistory Iface. We could have our own (GUndoSequence subclass?) that also write the history to a log file. This can be used for crash recovery. We can use the BtPersistence Iface to serialize the data objects. Maybe we just need two more callback for a new action (serialize/deserialize). It could store/restore the context and use BtPersistence for the objects.

[edit] Examples

[edit] add a machine

bt_setup_add_machine(setup, machine)

  • object: machine
  • parent: setup
  • undo: bt_setup_remove_machine(setup, machine)
  • redo: bt_setup_add_machine(setup, machine)
  • free: g_object_unref(machine)

[edit] remove a machine

bt_setup_remove_machine(setup, machine)

  • object: machine
  • parent: setup
  • undo: bt_setup_add_machine(setup, machine)
  • redo: bt_setup_remove_machine(setup, machine)
  • free: g_object_unref(machine)

[edit] entering something in a pattern

bt_pattern_set_global_event(pattern, tick, param, value)

  • object: value, old_value, tick, param
  • parent: pattern
  • undo: bt_pattern_set_global_event(patter, tick, param, old_value)
  • redo: bt_pattern_set_global_event(patter, tick, param, value)
  • free: ...

[edit] Links

Undo/Redo Links

Personal tools
collaboration

SourceForge Logo

GStreamer Logo

Become a Friend of GNOME

Linux Sound Logo

MediaWiki

Valgrind

GNU Library Public Licence

GNU Free Documentation License 1.2