News for hackers. Stuff that matters.
Re:Egui – An immediate mode GUI written in Rust by delifue on Thursday December 26, 2024 @01:04AM (#42513439)
A common problem of immediate mode GUI is how to make the parent component's size dynamically determined by child component's content (2-phase dynamic layout). Does Egui solve this issue?
Re:Egui – An immediate mode GUI written in Rust by jgoertler on Thursday December 26, 2024 @02:01AM (#42513588)
You can instruct egui to discard a frame. That way you can perform this two phase layout across two frames without showing an unfinished UI.

This mechanism can get you there most of the time.

Re:Egui – An immediate mode GUI written in Rust by chrismorgan on Thursday December 26, 2024 @02:12AM (#42513615)
Take the Code Example demo initially opened: drag age up to 120, then press the Increment button, and watch the label “Arthur is 120” briefly blip to “Arthur is 121” (while the DragValue still shows 120!) before being dragged back down to 120 presumably by rerendering and egui::DragValue::new(age).range(0..=120) clamping it.

That’s… eww. It probably doesn’t often cause real problems—though it surely could, as it’s allowing temporary rendering with out-of-bounds values that a developer might have expected to be clamped—but it’s still very eww, the idea that mutating data leads to parts of a frame being rendered with different data.

Re:Egui – An immediate mode GUI written in Rust by jgoertler on Thursday December 26, 2024 @02:49AM (#42513743)
I’m currently on mobile, where I couldn’t reproduce this.

I agree, that shouldn’t happen and it might be a bug, because the input is handled after drawing the initial frame and should be clamped before starting to draw the next frame. Drag events are tricky though, because they come with a frame delay by default (you have to recognize the drag).

Does this reproduce reliably on desktop? If so then I can create an issue for this.