Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images in ScrollArea show weird behavior #3410

Open
swip3798 opened this issue Sep 28, 2023 · 3 comments
Open

Images in ScrollArea show weird behavior #3410

swip3798 opened this issue Sep 28, 2023 · 3 comments
Labels
bug Something is broken

Comments

@swip3798
Copy link

Describe the bug
When you take the image example from the egui repository and add the ferris.svg image multiple times in the ScrollArea, it shows up just once.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new project
  2. Add the following dependencies:
eframe = "0.23.0"
egui_extras = { version = "0.23.0", features = ["all_loaders"] }
  1. Add the ferris.svg file from the image example to the src folder
  2. Copy the following into your main.rs:
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
    let options = eframe::NativeOptions {
        initial_window_size: Some(egui::vec2(600.0, 800.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);
            Box::<MyApp>::default()
        }),
    )
}

#[derive(Default)]
struct MyApp {}

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            egui::ScrollArea::new([true, true]).show(ui, |ui| {
                ui.image(egui::include_image!("ferris.svg"));
                ui.image(egui::include_image!("ferris.svg"));
                ui.image(egui::include_image!("ferris.svg"));
            });
        });
    }
}

Expected behavior
I would expect to see the image appear multiple times. Weirdly enough the multiple images seem to have some effect, because the scrollbar show up and is able to scroll just so slightly, but still just one image appears. I've been able to get this in egui v0.22 but I was not able to build it in v0.23.

Desktop (please complete the following information):

  • OS: Linux, Debian, i3-wm
  • Version 0.23.0

Additional context

@swip3798 swip3798 added the bug Something is broken label Sep 28, 2023
@swip3798
Copy link
Author

I also verified that it also happens with the current git master

@swip3798
Copy link
Author

When doing the same thing with rasterized images such as pngs, it shows the image twice, one big version, one smaller, even though it's add three time to the ScrollArea.

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            egui::ScrollArea::new([true, true]).show(ui, |ui| {
                ui.image(egui::include_image!("screenshot.png"));
                ui.image(egui::include_image!("screenshot.png"));
                ui.image(egui::include_image!("screenshot.png"));
            });
        });
    }
}

Screenshot:

image

@VolkMilit
Copy link

Had the same problem with multiple images in frame containers in a ScrollArea container, but it was fixed by setting the image to a fixed size. Oddly enough, the solution was found in this issue, but I don't have any jitters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants