Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A very hacky undo redo implementation #531

Closed
wants to merge 1 commit into from

Conversation

mbfraga
Copy link
Collaborator

@mbfraga mbfraga commented Mar 24, 2021

Summary / How this PR fixes the problem?

Implement a very hacky undo redo using existing serialization methods

Should serve as a proof of concept...and even if it gets implemented like this (with major cleanup and fixes), it would serve as a way to start adding the right events in the right place. And also see any reworks that may need to happen.

Known Issues / Things To Do

Super hacks--if this is the direction initial undo/redo takes, then serialization / deserialization needs to be refactored correctly.

This PR fixes/implements the following bugs/features:

  • Fixes Implement History Manager #263 - sorta, kinda, not really--but it's a working prototype that may be good to merge (after time spent to do it the right way) if only to test things

Should serve as a proof of concept...and even if it gets implemented
like this (with major cleanup and fixes), it would serve as a way
to start adding the right events in the right place. And also
see any reworks that may need to happen.
@mbfraga mbfraga changed the title A ~1.5 hr, very hacky undo redo implementation A very hacky undo redo implementation Mar 24, 2021



public class Akira.Lib.Managers.UndoManager : Object {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call this HistoryManager since it will handle both undos and redos.

}

while (to_delete.get_length () != 0) {
canvas.window.event_bus.request_delete_item (to_delete.pop_head());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to collect the images as the request_delete_item will remove those automatically.
Just artboards and free items.
Here we could also make this method async and use multi threading to prevent UI freeze when clearing a very busy canvas.

Comment on lines +39 to +40
clear_canvas(canvas);
Akira.FileFormat.JsonLoader.inner_load_content(canvas, obj);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this, it seems a bit extreme.
With this if we move an item and we want to revert to its previous position, we're clearing the canvas and reloading everything. That seems expensive.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If clearing and reloading is expensive, we have bigger issues than undo/redo. There is no reason the view should be expensive to regenerate.

I'm open to new ideas, but am cautious about an alternative that doesn't require cleaning the slate. They tend to be rather brittle and crash or artifact prone approaches.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, the current implementation of clearing and reloading is not efficient, but that's a different story.

@Alecaddd
Copy link
Member

@mbfraga wanna close this as it's gonna be invalid with the components refactor you're doing?

@Alecaddd
Copy link
Member

Alecaddd commented Jul 4, 2021

@mbfraga can we close this since it doesn't fit with the component refactor you're doing?

@Alecaddd Alecaddd closed this Jul 14, 2021
@Alecaddd Alecaddd deleted the wip/mbfraga/hacky_undo_redo branch July 16, 2021 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement History Manager
2 participants