Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for click-style pan tools #14033

Merged
merged 1 commit into from
Aug 23, 2024
Merged

Conversation

mattpap
Copy link
Contributor

@mattpap mattpap commented Aug 20, 2024

This PR adds rudimentary support for left, right, up and down pan tools (also with NSWE aliases), implemented as a single ClickPanTool. For now no keyboard support was added, because we don't have any implementation for action tools. It would be convenient to arrange respective tool buttons in a group, but that will have to wait for PR #13571. I'm tentatively marking this as a part of CZI R6, but this will be more relevant when we will start working on keyboard support.

Screencast.from.20.08.2024.16.02.45.webm
Code
import numpy as np

from bokeh.models import BoxSelectTool, ClickPanTool
from bokeh.plotting import figure, show

N = 4000
x = np.random.random(size=N) * 100
y = np.random.random(size=N) * 100
radii = np.random.random(size=N) * 1.5
colors = np.array([(r, g, 150) for r, g in zip(50+2*x, 30+2*y)], dtype="uint8")

TOOLS="pan_left,pan_right,pan_up,pan_down,pan,box_select"

p = figure(tools=TOOLS, width=400, height=400)

p.circle(x, y, radius=radii, fill_color=colors, fill_alpha=0.6, line_color=None)

p.select_one(BoxSelectTool).persistent = True
p.select(ClickPanTool).factor = 0.2

show(p)

@bryevdv
Copy link
Member

bryevdv commented Aug 21, 2024

cc @bokeh/dev thoughts on the arrow sense? I understand why they are why they are but it was contrary to my expectations. I.e. in order to "pan left" you have to "drag right" and I expected the buttons to indicate the "drag" direction, not "pan" direction.

@Azaya89
Copy link
Member

Azaya89 commented Aug 21, 2024

Yes, it was a bit counter-intuitive to me.

@mattpap
Copy link
Contributor Author

mattpap commented Aug 21, 2024

This behavior is consistent with arrow key function in google maps, leaflet and other. Left arrow reveals more of what's on the left of the plot. Pan gesture that achieves the same function is drag to the right. Perhaps it would have been more clear if I used a map based example, e.g.:

Screencast.from.21.08.2024.21.55.04.webm

@bryevdv
Copy link
Member

bryevdv commented Aug 22, 2024

This behavior is consistent with arrow key function

Well that's actually interesting, I would expect the behavior exactly as shown WASD or arrow keys. I think the difference for me comes down to mouse vs. keyboard, where using the mouse to click the arrows just really suggests the operation is analogous to a drag, also with the mouse. i.e. click a right arrow with a mouse ~ move to the right with a mouse (i.e. "pan left")

I won't hold up the PR but I would like to know if the eventual plan is that keyboard navigation will work without having the toolbar icons present at all? Frankly, adding four icons to the toolbar is "alot", especially if there are even a few other usual tools present. I can't actually imagine that users will truly want these cluttering the toolbar in most cases.

@mattpap
Copy link
Contributor Author

mattpap commented Aug 23, 2024

I won't hold up the PR but I would like to know if the eventual plan is that keyboard navigation will work without having the toolbar icons present at all? Frankly, adding four icons to the toolbar is "alot", especially if there are even a few other usual tools present. I can't actually imagine that users will truly want these cluttering the toolbar in most cases.

The next step will be to add keyboard support, but that's quite a bit of work because we have to add focus management for plots (so that arrow keys only work when plots are in focus) and coordinate key handling with other tools.

I don't expect users to add all four buttons a toolbar like in the examples. I would expect they would use buttons like that when their plots pan only in one direction (equivalent to e.g. PanTool(dimensions="width")). Whereas if they need both dimensions, then they would arrange buttons in a cross layout within the frame area, though that will require further work to allow full customization of tool buttons and related controls, and their positioning (so something that goes beyond what PR #13571 tries to achieve).

@mattpap mattpap merged commit 496611f into branch-3.6 Aug 23, 2024
21 of 22 checks passed
@mattpap mattpap deleted the mattpap/click_pan_tool branch August 23, 2024 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants