egui
egui copied to clipboard
`Plot::items` fix bool setting of highlight
While working on a proposal for feature additions for the Plot widget, I realized that the Plot: items were not reacting with the parameter highlight function.
I take this opportunity to propose BoolState
which will make it a little clearer than the double boolean necessary for its operation, it seems to me. ~~Also the same case repeats itself if we want to add this functionality with allow_hover~~ , which I would like to propose soon among others.
otherwise I propose a branch with double booleans: If the first boolean is true, it highlights and the second boolean is its changing state.
Can you expand a bit on the problem? I would expect .highlight(true)
to highlight the given item this frame. What is the difference between init
and state
?
In fact, the highlight function doesn't seem to work without the two booleans. in Plot::Items:
pub fn highlight(mut self, highlight: bool) -> Self {
self.highlight = highlight;
self
}
~~And personally, I don't see any point in disabling it (since PR #2558 allow_hover)~~ , so another possibility is to remove those chunks if you don't want to give the option to enable or disable highlighting in setting.
What is the difference between init and state?
if init is false
and highlight becomes true (state = true) then it will not be highlighted.
if init is true
and highlight becomes true (state = true) then it will be highlighted.
I understood my mistake in what I expected from the highlight function.
what I was proposing here is to be able to authorize or not highlight in the plot and when hovering over the legend of the plot.
For example if a plot item has allow_hover = false
we could expect it to also be in the plot legend.
I close this PR because it seems more necessary to me and should be named Default_highlight if necessary because it allows elements not to be highlighted when hovering in the legend of the plot.