Cumulative Undo/Redo :More than one stroke at a time

The last feature I did for Krita was to implement a Cumulative Undo/Redo feature. Since its been almost 3 months since my last contribution to Krita — I thought this was the one of the very first things I had to do from a rather clogged pipeline.

ALPHA 1: unnamed - test.kra [modified] – Krita_002

The Cumulative Undo/Redo feature basically enables the artist to undo/redo several strokes in one go. How it works is that it groups several of the strokes together as one Undo Command based on the time-stamp on it. The grouping parameters are configurable by the artist and define as to how many strokes should be kept individual (undoable) before the grouping starts taking place. Further more, the user can also define how much time-gap should be between each individual stroke and the time-span across the first and last stroke of the group for the commands to be merged.

Selection_001

As shown in the screenshot — several commands have been merged into the top few commands ( You can view this by going to Settings -> Dockers -> Undo History ). The last commands however will remain unmerged as the last N strokes are supposed to remain individual. The parameters can be set by right-clicking on the docker.

The use for such a feature is when the artist is making something as deft as grass and then realizes that the brush size is wrong or the color is a shade lighter. So, instead of undoing every blade of grass — he or she can use this feature and get rid of the grass entirely.

Now, for the details. We implemented this by putting an empty linked list structures in each of the KUndo2Command objects used in the Undo Stacks. These linked lists worked like mini-undo stacks themselves. So whenever merging occurred based on the timestamp – the KUndo2Command objects are appended to the Head command (chronologically first command in the group) and removed from the main Undo-Stack itself. So whenever somebody wants to undo the entire set of commands in the merged commands — the undo starts happening from the last command itself ( Tail of the List ) and works its way upto the Head of the List. The Redo command works exactly the opposite. It starts from the Head and works its way down the list to the chronologically last command in the group.

So that was one thing out of the pipeline. Hopefully, I’ll start contributing to Krita again and keep the pipe clean  or for a need of a better phrase — manage my time better.

Advertisements
Cumulative Undo/Redo :More than one stroke at a time

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