emilk/egui

`group` widgets ignore horizontal wrapping

RainbowCookie32 opened this issue · 5 comments

Describe the bug

When using ui.group() inside something like ui.horizontal_wrapped(), the widgets seem to ignore wrapping and just keep going well past screen boundaries. I went crazy trying to figure out why my UI was overflowing, until I removed the group and it started wrapping as expected.

To Reproduce

I put together this simple sample with eframe that triggers the issue:

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use eframe::egui;

#[derive(Default)]
struct DummyApp;

impl eframe::App for DummyApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, | ui | {
            ui.horizontal_wrapped(| ui | {
                for n in 0..500 {
                    ui.group(| ui | {
                        ui.strong(format!("Number {n}"));
                    });
                }
            });
        });
    }
}
fn main() {
    let app = DummyApp::default();
    let native_options = eframe::NativeOptions::default();

    eframe::run_native("wrap_test", native_options, Box::new(|_| Box::new(app)));
}

Expected behavior

The widgets don't overflow, and they keep going on a new row.

Screenshots
  • UI goes off-screen.

image


  • Wraps as expected without the group

image

Desktop (please complete the following information):

  • OS: Windows
  • Version: 10

Let me know if anything else is needed here :)

Also encountered this. There will also be a problem when using ui.vertical() instead of ui.group.

I have the same issue on egui v0.24, using eframe to build a native desktop application on windows 10.

I'm having the same problem, but also doesnt seem to work when using .horizontal(). with egui="0.26.2"

Same, the only way i was sort of able to fix this was by wrapping the group in ui.allocate_ui.
But this still caused the outer margins to be incorrect.

another way to fix it that I found was to use ui.add_sized. Like this you give it a size and then anything you put inside will kindof work