emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
21.57k stars 1.56k forks source link

demo app: Changing text size via slider causes severe flickering (fantom input - redraw loop) #2540

Open ngortheone opened 1 year ago

ngortheone commented 1 year ago

Changing text size via slider causes severe flickering, while doing the same via the button works fine.

My best guess is that there is an unintentional input-redraw loop:

Interestingly doing the same via button widget, that does not care about knob/mouse relation has no such problem. The bigger question is whether this is considered to be egui bug or simply poorly designed UI. One could make an argument that egui does what it is supposed to do. On the other hand such cases are probably common. Should slider behave more like that button (care less about mouse to knob relation?) Should such widgets "remember" their original position until user release the mouse?

Anyway video with demonstration is attached:

egui.webm

parasyte commented 1 year ago

Yep, this is a bug in the settings window on the demo app. I'm not sure if this is something that can be fixed in the general case. The "least effort" solution is defensive coding; don't allow any interactive region to be changed while the user is interacting with it.

I believe your analysis is correct. When the Sense (or Response?) rect is changed relative to the cursor and there is a temporal relationship between events (like a drag, pinch gesture, even a double click, etc.), you will get unexpected results.

This is true for both position and size. Imagine if the slider changed its width based on how the "marker" is dragged.