Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Fix #316: the section eye stays while the pointer is on it

Claudea9cd761d525f
diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs
index d89a9ce32..907bae10d 100644
--- a/crates/ui-egui/src/widgets.rs
+++ b/crates/ui-egui/src/widgets.rs
@@ -270,8 +270,11 @@ pub fn section_header(ui: &mut Ui, id: &str, title: &str, open: bool, enabled: O
paint(p, chev, if open { Icon::ChevronDown } else { Icon::ChevronRight }, t.text_label);
p.text(pos2(r.left() + 44.0, r.center().y), Align2::LEFT_CENTER, title, t.semibold(14.0), t.text);
let mut toggled = None;
+ // shown while the pointer is anywhere on the header: `resp.hovered()` turns false as soon as the
+ // pointer is over the eye itself (the eye is on top), which hid the eye before it could be
+ // clicked (issue #316)
if let Some(on) = enabled
- && (resp.hovered() || !on)
+ && (ui.rect_contains_pointer(r) || !on)
{
let eye = Rect::from_center_size(pos2(r.right() - 34.0, r.center().y), vec2(18.0, 18.0));
let er = ui.interact(eye, ui.id().with(("eye", id)), Sense::click());