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

Increase control over plot widget inside of show method #2

Open
jbuckmccready opened this issue Jan 16, 2022 · 0 comments
Open

Increase control over plot widget inside of show method #2

jbuckmccready opened this issue Jan 16, 2022 · 0 comments

Comments

@jbuckmccready
Copy link

jbuckmccready commented Jan 16, 2022

I would like to be able to control as many aspects of the plot widget as possible from inside the Plot::show method to allow deciding whether to allow dragging or zooming based on the pointer position in the plot (and the event state, but that is already accessible from the PlotUi::ctx). See my original comment on this here: emilk/egui#759 (comment)

I have added allow_drag to the PlotUi structure which seems to be working good (although I need to test it more thoroughly for what I am wanting to do). I will look into adding the other viable control functions to it as well (e.g., allow_zoom, show_x, show_y, show_background, etc.), I am thinking that anything that is used after the call to the build_fn in the Plot::show method should be made available for consistency and flexibility. I will make a pull request when I've got everything added, cleaned up, and tested.

@emilk @EmbersArc Do you have any particular design input on this? The simplest non-breaking API change I can see is to just add each of the fields such as allow_drag, allow_zoom, etc. to the PlotUi structure (and add associated methods to mutate them), and default their values to match the fields on the Plot structure (so if they are only set on the Plot structure then it is honored), then in the build_fn they can be updated. This is somewhat awkward since there are then duplicate methods used to control the plot (one for the Plot structure and one for the PlotUi structure), would it be better to just move the fields and methods so they are only on the PlotUi structure (API breaking change)? Or maybe there's another better way to get at what I'm wanting to add?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant