[Lazarus] Undo/Redo in Form Designer

Martin lazarus at mfriebe.de
Sun Dec 16 15:08:22 CET 2012


On 16/12/2012 08:51, Juha Manninen wrote:
> I am still thinking of the most important case: undo for delete operation.
> It is also the most difficult one. Anchors and alignment depend on the
> order of creation. It is not enough to just insert a deleted control
> back. Maybe the whole form must be recreated. Maybe there must be a
> snapshot history of the form.
>
> I guess Mattias must comment on your code at some point. I cannot say
> whether it fits the big picture when undo for delete is implemented.
>

While I have never looked at the designer code, I think this can be 
broken down into  individual parts:

1) Monitor all properties/ property editors. This allows to detect 
changes to individual properties, made by the user. Such as name height, 
caption, align, options....

This is not complete. Some properties may have side effects. hanging 
anchors, can change positions. Setting an option may clear another 
published property.
Yet for step 1 those can be ignored. This is a huge topic and needs a 
discussion off its own. Afaik the only way to detect those changes, is 
to stream the entire form.

2) creation of new controls

3) deletion of controls (bringing it back, even with the wrong order is 
already a step, but only if the code allows to fix that later)

4) change Baseclass

5) change z-order (afaik also creation order)

6) .... (I am sure there is more)

----
Then it must record, whenever it makes changes to the editor. So they 
can be undone too.

And eventually, when it makes changes to the editor, it must register 
there, so the editor can send an event, if that change is undone by the 
editors undo system (or redone).






More information about the Lazarus mailing list