Skip to content

SidePanel::exact_width does not product a panel of that size #3006

@al2me6

Description

@al2me6

Describe the bug

Side panels are wider than the given exact_width.

To Reproduce

struct App;

impl eframe::App for App {
    fn update(&mut self, ctx: &eframe::egui::Context, _frame: &mut eframe::Frame) {
        eframe::egui::SidePanel::right("panel")
            .exact_width(150.)
            .show(ctx, |ui| {
                ui.horizontal_wrapped(|ui| {
                    ui.label("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.");
                });
                ui.separator();
            });
    }
}

fn main() -> eframe::Result<()> {
    eframe::run_native(
        "ExactWidth",
        eframe::NativeOptions::default(),
        Box::new(|_cc| Box::new(App)),
    )
}

Expected behavior

The panel is exactly 150 px wide.

Screenshots

Observe that the panel is in fact 166 px wide:

image

Thus, if the panel is on the right side, UI elements are clipped beyond the window:

image

Desktop:

  • OS: Windows 10
  • Browser: Firefox, Chromium-derived
  • Version eframe 0.21.3

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions