Butter: Bug 463, the Undo Manager

Bug 463 is about implementing an undo/redo backend in Butter using the command pattern. The progress of what’s completed so far is here.

Currently

  • Control-z is undo, and control-shift-z is redo.
  • Only track events that are added can be undone and redone.

In src/timeline/media.js, adding a track event, before the UndoManager was implemented looked like this:

      var trackEvent = track.addTrackEvent({
        popcornOptions: {
          start: start,
          end: start + 1,
          target: defaultTarget.elementID
        },
        type: type
      });

With the UndoManager in place, it now looks like this:

      var trackEvent = butter.addTrackEvent({
        track: track,
        type: type,
        popcornOptions: {
          start: start,
          end: start + 1,
          target: defaultTarget.elementID
        }
      });

It remains largely the same, except that behind the scenes, butter.addTrackEvent creates the command object and registers it with the UndoManager. After this is done, control-z can be used to undo, and contol-shift-z can be used to redo the action. The commands are placed on an undo and redo stack as appropriate, and currently there are no restrictions on how many commands can be undone/redone.

Having the UndoManager in place will provide Butter with many benefits. Some of them are

  • Creating macro commands.
  • A simplified user interface: The UI only needs to know to call the command’s execute function.
  • Loosely coupled design.

I will be getting feedback and fixing the design in the coming weeks, and we will, piece by piece, change all undoable actions in Butter to make use of the commands and undo manager.

Advertisements
This entry was posted in Open Source. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s