emilk/egui

Sliders not getting wrapped correctly

placuszek15 opened this issue · 0 comments

Describe the bug
Using ui.horizontal_wrapped() to ui.add() sliders does not seem to wrap them correctly.

To Reproduce
Example code from eframe default app

impl eframe::App for TemplateApp {
    /// Called by the frame work to save state before shutdown.
    fn save(&mut self, storage: &mut dyn eframe::Storage) {
        eframe::set_value(storage, eframe::APP_KEY, self);
    }

    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        let Self { label, value } = self;
        egui::CentralPanel::default().show(ctx, |ui| {
            ui.horizontal_wrapped(|ui| {
                for num in 0..100 {
                let resp = ui.add(egui::Slider::new(&mut self.value, 0.0..=9999.0).text(format!("label nr: {:?}",num )));
            }

            });
            // The central panel the region left after adding TopPanel's and SidePanel's
            egui::warn_if_debug_build(ui);
        });
        }
    }

Expected behavior
If add is changed to add_sized with nearly any size it wraps correctly.

Screenshots

Regular add:
image

add_sized with rough approximates of add's response's rect.max- rect.min:
image

Desktop (please complete the following information):

  • OS: Fedora 6.1.14-100.fc36.x86_64 w/ KDE Plasma

Additional context
I somehow managed to do https://media.discordapp.net/attachments/904461220592119849/1081683278706262116/image.png while trying to massage add_sized with ui.set_max_size(egui::Vec2{x:800.0, y:600.0}) but im unable to reproduce it :/, might be related to incorrect sizes