On Sat, 2007-07-28 at 08:51 +0530, Sameer Sahasrabuddhe wrote:
> Hello,
> 
> I was trying to figure out how to us Undo, and started with this article:
> 
> http://live.gnome.org/Dia/Undo
> 
> I wanted to follow up on how struct ReorderObjectsChange and the
> related functions are used. But the problem is can't really make out
> what is happening in code such as
> diagram_place_under_selected() in app/diagram.c

The tricky thing about diagram_place_under_selected() and its relatives
is that since you can move several objects, you need to keep the
original position of all of them in order to be able to undo.  The
easiest way to do this is to keep a copy of the whole object list.

Once we have the original object list, we take the selected objects out
(in the ordering they are in the layer, thus "sorted"), mark them all
for redrawing (object_add_updates_list()), then add them at the
beginning (bottom) of the object list.

The call to undo_reorder_list simply creates an undo object for the act
of changing the order of objects.  That call doesn't change the diagram.

Finally, we set the diagram modified, flush the diagram changes (to
force a redraw soon), and mark that this is the end of a user command by
setting an undo transaction point, meaning an undo command will undo
only until here.

Note that the undo_reorder_list call will merely stored the old and
current object lists (not the objects themselves), so it can switch back
and forth as it gets undone and redone.

-Lars

_______________________________________________
Dia-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia

Reply via email to