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

image in ScrollArea jitters #3455

Open
GaN8373 opened this issue Oct 11, 2023 · 5 comments
Open

image in ScrollArea jitters #3455

GaN8373 opened this issue Oct 11, 2023 · 5 comments
Labels
bug Something is broken egui

Comments

@GaN8373
Copy link

GaN8373 commented Oct 11, 2023

[dependencies]
egui = "0.23.0"
eframe = { version = "0.23.0", default-features = false, features = [
    "accesskit",    
    "default_fonts",
    "glow",          
    "persistence",   
] }
egui_extras = { version = "0.23.0",features = ["all_loaders"] }
image = { version = "0.24", features = ["jpeg", "png"] }
fn gen_image<'a>() -> Image<'a> {
    Image::new("file://assets/icon-256.png")
        .max_width(42.0)
        .rounding(10.0)
}
pub(crate) fn default(app: &mut TemplateApp, ctx: &Context) -> InnerResponse<()> {
    egui::SidePanel::left("left_panel_1")
        .width_range(Rangef::new(20.0, 50.0))
        .show(ctx, |ui| {
            egui::ScrollArea::vertical().show(ui, |ui| {
                ui.add(gen_image()).on_hover_text("item 1");
                ui.add(gen_image()).on_hover_text("item 2");
                ui.add(gen_image()).on_hover_text("item 3");
                ui.add(gen_image()).on_hover_text("item 4");
                ui.add(gen_image()).on_hover_text("item 5");
                ui.add(gen_image()).on_hover_text("item 6");
                ui.add(gen_image()).on_hover_text("item 7");
                ui.add(gen_image()).on_hover_text("item 8");
                ui.add(gen_image()).on_hover_text("item 9");
                ui.add(gen_image()).on_hover_text("item 10");
                ui.add(gen_image()).on_hover_text("item 11");
                ui.add(gen_image()).on_hover_text("item 12");
                ui.add(gen_image()).on_hover_text("item 13");
                ui.add(gen_image()).on_hover_text("item 14");
                ui.add(gen_image()).on_hover_text("item 15");
            });
        })
}
eframe.template.2023-10-11.15-51-35.mp4

Desktop (please complete the following information):

  • OS: windows11
  • Browser edge 117.0.2045.41
  • Version egui 0.23.0
@GaN8373 GaN8373 added the bug Something is broken label Oct 11, 2023
@GaN8373
Copy link
Author

GaN8373 commented Oct 11, 2023

I fixed it by setting the image to a fixed size, if you think this is not a bug, please just close the issue

@AHeimberger
Copy link

AHeimberger commented Oct 12, 2023

I am facing the same issue. I am currently working through the example section of egui.
https://github.com/emilk/egui/blob/master/examples/images/src/main.rs

Desktop (please complete the following information):
OS: ubuntu 22.04
Version egui: 0.23.0

@GaN8373
Copy link
Author

GaN8373 commented Oct 13, 2023

I am facing the same issue. I am currently working through the example section of egui. https://github.com/emilk/egui/blob/master/examples/images/src/main.rs

Desktop (please complete the following information): OS: ubuntu 22.04 Version egui: 0.23.0

you can use Image::new("file://assets/icon-256.png").fit_to_exact_size(Vec2::new(42.0, 42.0))
Fixed image size avoids this problem

@Coffee-Nerd
Copy link

This happens with ScrollArea in general, not just images in ScrollArea. I've been having issues with this for text as well. I thought it was tied to scroll_to_bottom, but it may not be... I saw another issue here where the scrollbar can go beyond its intended bounds, #3734, which may be tied to this issue as well.

@lucasmerlin
Copy link
Collaborator

I think this is caused by the following feedback loop:

  1. the content is larger than the scroll area
  2. the scrollbar is shown
  3. the content resizes (because the scrollbar takes some width)
  4. the content is now smaller than the scroll area
  5. the scrollbar is hidden
  6. the content resizes (because now there is more space without the scroll area)
  7. repeat at step 1

So any of the following things could work:

  • set the content to a fixed width (as mentioned by @GaN601)
  • update the ScrollBarVisibility to AlwaysVisible
  • change the scrollbar type to floating

I think to fix this in egui we'd need some way to detect if this flickering is currently occuring and then decide to either show or hide the scrollbar until the content or scroll area size changes again.

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

No branches or pull requests

4 participants