RE: [Inkscape-devel] shift+click to select broken

On Fri, 2003-12-19 at 04:25, bulia byak wrote:
Fixed, please test. I had to make use of
sp_document_partial_items_in_box()
for this, which was in the code but never used, and fixed a bug in it so
it
could actually work.
Hrm, I still can't get shift+click (versus shift+drag) to work. :/
That was a bad solution anyway. It just used bounding box, so objects with holes etc. were treated as opaque rectangles. Now a much better solution is checked in. I had to dig into the arena code (something I was trying to avoid) but I think I succeeded. Please test now.
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.
The same approach can be used for ctrl-clicking to select within group. Mental, if you think this approach is acceptable, I'll go on and try to implement ctrl-click.
_________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2f...

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
participants (2)
-
bulia byak
-
MenTaLguY