Skip to content

Commit

Permalink
restore old picture hover functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
markusdd committed Dec 30, 2024
1 parent edbf22d commit c31204f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ impl eframe::App for MyApp {
for url in imagevec {
let img = ui
.add(egui::Image::new(url).fit_to_exact_size(Vec2::new(200.0, 200.0)));
if img.hovered() {
if is_hover_rect(ui, img.rect) {
Window::new("")
.auto_sized()
.interactable(false)
Expand All @@ -494,8 +494,7 @@ impl eframe::App for MyApp {
.collapsible(false)
.show(ctx, |ui| {
ui.add(
egui::Image::new(url)
.fit_to_exact_size(Vec2::new(900.0, 900.0)),
egui::Image::new(url).fit_to_exact_size(Vec2::new(900.0, 900.0)),
);
});
}
Expand Down Expand Up @@ -569,6 +568,15 @@ impl eframe::App for MyApp {
}
}

pub fn is_hover_rect(ui: &egui::Ui, rect: egui::Rect) -> bool {
let pointer_pos = ui.input(|i| i.pointer.hover_pos());
let Some(pos) = pointer_pos else {
return false;
};

rect.contains(pos)
}

fn powered_by(ui: &mut egui::Ui) {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 0.0;
Expand Down

0 comments on commit c31204f

Please sign in to comment.