emilk / emilk/egui

`set_clip_rect` draws over `SidePanel` when children widgets exceed the available space

Open
#4,050 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
30.6k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
72

Description

**Describe the bug**

![issue](https://github.com/emilk/egui/assets/50304111/8cdd6502-747e-4ecb-9952-44e52027520e)
![image](https://github.com/emilk/egui/assets/50304111/a846732e-a8c0-431d-969b-89dd70d9274c)
![image](https://github.com/emilk/egui/assets/50304111/7cc3e3db-cea1-4a91-a7a0-f149075a2cca)

**To Reproduce**
Steps to reproduce the behavior:
Minimal reproduction project:
```rs
use eframe::egui::*;

fn main() -> Result<(), eframe::Error> {
let options = eframe::NativeOptions {
viewport: ViewportBuilder::default(),
..Default::default()
};

eframe::run_native(
"Image Cleanup",
options,
Box::new(|cc| Box::new(ImageCleanup {})),
)
}

struct ImageCleanup {}

impl eframe::App for ImageCleanup {
fn update(&mut self, ctx: &Context, _frame: &mut eframe::Frame) {
SidePanel::right("parameters").show(ctx, |ui| {
Grid::new("parameters")
.spacing([40.0, 4.0])
.striped(true)
.show(ui, |ui| {
ui.label("Hello world!");
ui.end_row();
});
});

SidePanel::left("preview_tools").show(ctx, |ui| {
Grid::new("preview_parameters")
.striped(true)
.show(ui, |ui| {
ui.label("Hello world!");
ui.end_row();
});
});

CentralPanel::default().show(ctx, |ui| {
ui.set_clip_rect(ui.available_rect_before_wrap());
ui.add(Button::new("Hi").min_size(
ui.available_size() * ((ctx.frame_nr() as f32 / 60.0).sin().abs() + 0.5),
));
ctx.request_repaint();
});
}
}
```

**Expected behavior**

Don't draw on top of the side panel, or if this is intended behavior, document it and describe
**Screenshots**

**Desktop (please complete the following information):**
- OS: Windows 11

Contributor guide

Open the contributing guide

Research direction

Start by running the minimal Rust reproduction with the referenced SidePanel, CentralPanel, and set_clip_rect calls, then inspect those APIs and their clipping behavior in egui. Done means overflowing CentralPanel children no longer draw over the side panels, or the intended behavior is documented; verify the result against the reproduction on Windows 11.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.