On Fri, 2003-12-19 at 17:41, bulia byak wrote:
Here's what I did: in document.cpp, a new function sp_document_item_at_point() was added, to complement items_in_box and partial_items_in_box. It calls nr_arena_item_invoke_pick() on all items to find those that are pickable at the given point, and returns the topmost of them. Now select-context.cpp simply uses sp_document_item_at_point() in its root_handler when shift-clicked and does selection toggle. This means we can do without the item that was passed on from the arena code - if we have mouse coordinates, we can always find out the item under mouse. This was necessary in this case because I do shift-rubberband in root_handler, and I must process shift-click in it too, and root_handler does not get an item as an argument.
Well... I think you have the right idea -- I'm just not quite it's the right place to do it from. Selection is a per-desktop thing, and multiple desktops can be associated with a single document.
The thing is, SPItem::desktop is a _linked list_ of SPItemViews, one for each SPDesktop (or plain SPSVGView).
Right now, sp_document_item_at_point() always takes the first in the list, regardless of which SPDesktop the selection is happening on.
Although it appears to work right now, I will guarantee you that it will fail under some circumstances where (for an obvious example) an SPItem is displayed on some desktops, but not others.
So, I guess at minimum sp_document_item_at_point() also needs to take the NRArena the selection is happening on, to know which SPItemView (if any) applies (check to see if NRArenaItem::arena is the right NRArena).
So, to keep this programmer-friendly, I think basically what you need is an sp_desktop_item_at_point() that figures out what NRArena to use, and calls sp_document_item_at_point().
To get the NRArena for a desktop, you can use ((SPCanvasArena *)SP_DT_ACETATE (desktop))->arena.
-mental