egui icon indicating copy to clipboard operation
egui copied to clipboard

`Plot::items` fix bool setting of highlight

Open haricot opened this issue 2 years ago • 1 comments

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.

haricot avatar Dec 20 '22 23:12 haricot

otherwise I propose a branch with double booleans: If the first boolean is true, it highlights and the second boolean is its changing state.

haricot avatar Jan 08 '23 10:01 haricot

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?

emilk avatar Jan 23 '23 07:01 emilk

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.

haricot avatar Jan 23 '23 11:01 haricot

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.

haricot avatar Jan 23 '23 11:01 haricot

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.

haricot avatar Jan 26 '23 08:01 haricot

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.

haricot avatar Feb 10 '23 09:02 haricot