Increase control over plot widget inside of show method
jbuckmccready opened this issue · 0 comments
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?