Skip to content

Commit

Permalink
In contrast GUI, convert new contrast limit values to the right type …
Browse files Browse the repository at this point in the history
…and only update if the new values are different from the old values. (#309)

Prevents a crash when the contrast bars cross.
  • Loading branch information
jwahlstrand authored Jun 9, 2024
1 parent 91c93d6 commit cbf0b86
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/contrast_gui.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ function contrast_gui(enabled::Observable{Bool}, hist::Observable, clim::Observa
cmaxT = max(cmaxT, cmaxT+Δ)
end
mn, mx = minimum(rng), maximum(rng)
cmin, cmax = clamp(cminT, mn, mx), clamp(cmaxT, mn, mx)
cgui["slider_min"][] = (rng, cmin)
cgui["slider_max"][] = (rng, cmax)
cmin, cmax = T(clamp(cminT, mn, mx)), T(clamp(cmaxT, mn, mx))
if cmin != cgui["slider_min"][] || cmax != cgui["slider_max"][]
cgui["slider_min"][] = (rng, cmin)
cgui["slider_max"][] = (rng, cmax)
end
end
# Update the image contrast
clim[] = CLim(cmin, cmax)
Expand Down

0 comments on commit cbf0b86

Please sign in to comment.