Undo and Redo Support

Bug #425460 reported by Martin G Miller
28
This bug affects 6 people
Affects Status Importance Assigned to Milestone
OpenShot Video Editor
Fix Released
High
Jonathan Thomas

Bug Description

I am using version 0.9.2 in ubuntu 9.04 32 bit.

I would like to see a multilevel "undo" feature, so If I make a mistake with something, I can go back to where I was. I tried using a few of the tools and suddenly lost a few tracks and other items, so I looked for the undo button and tried ctrl-z, but there was no way to go back, so I had to reload the project in an earlier saved state.

Tags: patch wishlist
Revision history for this message
Helen McCall (wildnfree) wrote :

Hello Martin,

Many thanks for your comments.

I have added these to our wishlist

Helen

tags: added: wishlist
Helen McCall (wildnfree)
Changed in openshot:
status: New → Confirmed
Andy Finch (fincha)
Changed in openshot:
importance: Undecided → Wishlist
Revision history for this message
hva (francesco-hermanitosverdes) wrote :

I have a working proof -of-concept implementation of a possible Undo/Redo or History funcionality.
Not finished yet. The good part of this approach is that it doesn't need huge changes in existing code base.

lp:~francesco-hermanitosverdes/openshot/francesco_undo_redo_test

Changed in openshot:
status: Confirmed → In Progress
Revision history for this message
Jonathan Thomas (jonoomph) wrote :

I updated the description of this bug to only talk about the undo/redo. The other items mentioned were already in our bug system.

Changed in openshot:
milestone: none → 1.1.0
description: updated
Revision history for this message
Jonathan Thomas (jonoomph) wrote :

I have not reviewed the code yet, but I did some research on comparing the speed of "copy.deepcopy" and "cPickle". Apparently cPickle is much faster than the copy method. So, it would seem that the cPickle approach might just work. =)

My only concern is if calling cPickle after many common actions will slow down OpenShot. I hope to review the code soon. Hopefully we can keep the hooks to this very simple...

For example:

# Add to history
history.log("Moved Clip")

Or something along those lines.

Thanks!
-Jonathan

summary: - feature request: undo and audio controls
+ Undo and Redo Support
Changed in openshot:
importance: Wishlist → High
Revision history for this message
hva (francesco-hermanitosverdes) wrote :

The trick I was using now for triggering the history recording of actions is based on the already existing project-is-modified notification function:

'project.set_project_modified(is_modified=True, refresh_xml=True)'

I thought that it could carry an extra argument to be used as a "switch" for the history system notification, and defaulting to None, like this:

'set_project_modified(self, is_modified=False, refresh_xml=False, type=None)'

So, in case of actions that we want to record in history stack, we just add the string describing the action as "type" argument, and the history system is activated, the string passed becomes the first arguent of a tuple containing also the StringIO object on which cPickle dumps the state pf the project, and the tuple is appended to the history stack. The first argument of the tuple is then used for describing the action in history tree-view.

I used this approach because it took advantage of the already existing hooks in the code, and besides this leaves us an easy way to fine-tune the system, deciding which action should be recorded in history whenever we want, using just one project-modified notification function.

For the tests I've made it seems that cPickle combined with cStringIO is rather fast, but it should probably be stress-tested on some huge project because this approach uses the project as some sort of state-machine, recording the whole state of it for every step.

Revision history for this message
Jonathan Thomas (jonoomph) wrote :

Francesco,
I have merged your branch into the trunk tonight. I made many small tweaks to the code, such as new Toolbar buttons for Undo/Redo, and added a few more history hooks where set_project_modified() was being called. Also, I have hidden the "History Tree" by default (available via View > History).

You should probably merge the trunk back into your branch, or create a new branch from the trunk at this point. =)

This is still "experimental", in that we need to do lots of testing on the speed of this approach. But so far it looks really good to me. Thanks for your help!

-Jonathan

Revision history for this message
Jonathan Thomas (jonoomph) wrote :

I fixed a few issues that were discovered with the Undo code and some of the history not being set when you drop new clips on the timeline. The fix is now in the trunk.

Changed in openshot:
status: In Progress → Fix Committed
Revision history for this message
Jonathan Thomas (jonoomph) wrote :

I am implementing the redo functionality and improving the History tree.

Changed in openshot:
assignee: nobody → Jonathan Thomas (jonoomph)
status: Fix Committed → In Progress
Revision history for this message
Jonathan Thomas (jonoomph) wrote :

The trunk now includes Redo functionality and an improved history tree.

Changed in openshot:
status: In Progress → Fix Committed
Revision history for this message
hva (francesco-hermanitosverdes) wrote :

I've made max_history_size customizable as user preference.
It defaults to 20 as it was hardcoded up to now.
here's the patch

Revision history for this message
Jonathan Thomas (jonoomph) wrote :

The max_history_size patch has been merged into the trunk. Thanks!

moimael (moimael)
Changed in openshot:
status: Fix Committed → Fix Released
tags: added: patch
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.