Edit panel: the histogram clipping buttons stay clear of the hovered scroll bar (fixes #1640)

This commit is contained in:
Marco Arnulfo
2026-10-14 12:33:09 +02:00
parent a4b53b28cc
commit 0f398f6dba
2 changed files with 25 additions and 1 deletions
+8 -1
View File
@@ -679,8 +679,15 @@ fn histogram(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {
}
}
let (lo, hi) = h.clipping();
for (on, x, active) in [(lo > 0.003, plot.left() + 12.0, app.ui.show_clipping), (hi > 0.003, plot.right() - 12.0, app.ui.show_clipping)] {
// the panel's floating scroll bar widens over the right edge when hovered: both buttons keep
// clear of it, the left one too so they stay symmetric (#1640)
let scroll = ui.spacing().scroll;
let inset = 12.0 + scroll.bar_width + scroll.bar_outer_margin;
for (name, on, x, active) in
[("low", lo > 0.003, plot.left() + inset, app.ui.show_clipping), ("high", hi > 0.003, plot.right() - inset, app.ui.show_clipping)]
{
let tri = Rect::from_center_size(pos2(x, plot.top() + 10.0), vec2(14.0, 12.0));
register(ui.ctx(), format!("histogramClip:{name}"), tri);
p.rect_filled(tri, 2.0, if active { t.hover } else { Color32::from_gray(60) });
paint(p, tri.shrink(2.0), Icon::ChevronDown, if on { Color32::WHITE } else { Color32::from_gray(130) });
}
+17
View File
@@ -2365,3 +2365,20 @@ fn new_album_can_leave_the_selected_photos_out() {
confirm(&mut h);
assert!(photos(&h, "Nothing").is_empty());
}
#[test]
fn the_histogram_clipping_buttons_stay_clear_of_the_hovered_scroll_bar() {
// every section open: the Edit panel scrolls, so its scroll bar runs past the histogram
let h = demo(
[1400.0, 700.0],
json!({"view": "detail", "right": "edit", "histogram": true, "openSections": ["light", "color", "effects", "detail", "optics"]}),
);
let hist = widget(&h, "histogram");
let (low, high) = (widget(&h, "histogramClip:low"), widget(&h, "histogramClip:high"));
// a hovered floating scroll bar grows to its full width at the panel's right edge, over the content
let scroll = h.view.ctx.global_style().spacing.scroll;
let bar_left = hist.right() - scroll.bar_outer_margin - scroll.bar_width;
assert!(high.right() <= bar_left, "the highlight clipping button {high:?} is under the scroll bar (from x = {bar_left})");
// and the shadow one keeps the same inset from its edge
assert!(((low.left() - hist.left()) - (hist.right() - high.right())).abs() < 0.5, "{low:?} {high:?} in {hist:?}");
}