emilk / emilk/egui

Can't add two `Scene`'s side by side

Open
#7,141 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
30.6k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
72

Description

**Describe the bug**
Splitting the central panel evenly in two using `columns` and then adding a `Scene` with an image to both columns results in "incorrect" behavior. This "incorrect" behavior does not happen when adding a single `Scene` in the central panel directly. Some examples of this behavior:

1. Both images are shown on the right side when initialized.
2. Panning towards the left makes the image that should be on the left to pass the border (see image below). The right image is correctly clipped there.
3. Panning when zoomed in / out seems to have incorrect scaling. When zoomed in the panning is dampened and when zoomed out the panning is amplified.

![Image](https://github.com/user-attachments/assets/8f8e737d-3b3b-4e11-9393-4a36865c1131)

**To Reproduce**
Steps to reproduce the behavior:

1. Modify the `images` example with the following code:

```rust
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example

use eframe::egui;

fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 320.0]),
..Default::default()
};
eframe::run_native(
"Image Viewer",
options,
Box::new(|cc| {
// This gives us image support:
egui_extras::install_image_loaders(&cc.egui_ctx);
Ok(Box::::default())
}),
)
}

struct MyApp {
left_scene_rect: egui::Rect,
right_scene_rect: egui::Rect,
}

impl Default for MyApp {
fn default() -> Self {
Self {
left_scene_rect: egui::Rect::ZERO,
right_scene_rect: egui::Rect::ZERO,
}
}
}

impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.columns(2, |columns| {
columns[0].label("Left column");
columns[1].label("Right column");

egui::Scene::new().show(&mut columns[0], &mut self.left_scene_rect, |ui| {
ui.image(egui::include_image!("cat.webp"))
.on_hover_text_at_pointer("WebP");
});
egui::Scene::new().show(&mut columns[1], &mut self.right_scene_rect, |ui| {
ui.image(egui::include_image!("ferris.svg"))
.on_hover_text_at_pointer("SVG");
});
});
});
}
}
```

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

**Additional context**
This is my first time working with egui / eframe, so I hope I'm not making a stupid mistake 👼

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by modifying the images example with two columns and one egui::Scene per column, then reproduce the initialization, clipping, panning, and zoom behavior described. Compare it with a single Scene in the central panel; done means both images remain in their columns and each scene has correct clipping and pan/zoom scaling.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.