ogallagher / fxgraph

A JavaFX graph editor
Do What The F*ck You Want To Public License
2 stars 0 forks source link

Mouse button customization for node translate vs viewport translate not finished #5

Closed ogallagher closed 2 years ago

ogallagher commented 2 years ago

As discussed in sirolf2009/fxgraph issue #7, the mouse buttons to use for node translation vs the button to use for viewport translation (panning) should be customizable.

However, the implementation is not yet complete, as setting both node translation and viewport pan to the same button causes behavior like so:

https://user-images.githubusercontent.com/17031438/129619546-38639f70-5a35-4d3c-83cb-c5558dde5794.mp4

ogallagher commented 2 years ago

I believe these sections are at least part of the issue:

https://github.com/ogallagher/fxgraph/blob/4643e37e5b4ff04c54180f2e20ce60073e57e9be/src/main/java/com/fxgraph/graph/NodeGestures.java#L54-L75

Above, in the case that the panning button and the node translation button are the same, then the panning has priority and the node is marked transparent.

https://github.com/ogallagher/fxgraph/blob/4643e37e5b4ff04c54180f2e20ce60073e57e9be/src/main/java/com/fxgraph/graph/NodeGestures.java#L77-L101

Above, when the drag is continued, the viewport pan no longer prevents a node from being dragged, even though NodeGestures.dragContext was never set.

ogallagher commented 2 years ago

I will attempt to solve this by prioritizing the node translation when the node is dragged, given that the node drag and viewport drag are set to trigger with the same mouse button.

ogallagher commented 2 years ago

The proposed changes fix cell vs viewport dragging, but cell resize handles (CellGestures) also need to be fixed to consume the drag event.

ogallagher commented 2 years ago

I believe custom mouse buttons for different drag interactions is complete. See demo below (only using left mouse button):

https://user-images.githubusercontent.com/17031438/129625123-43162f6c-f95f-4d0b-8021-76072b0ae14e.mp4