Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# New in 0.13

- 0.13.3: the legacy string-key shim on `ImageViewGUI` now routes unknown
keys to the `extras::Dict{Symbol,Any}` field instead of throwing
`ArgumentError`. This restores the pre-0.13 pattern of using the GUI
handle as a scratch space for downstream-defined keys (with a depwarn).
`Base.haskey(::ImageViewGUI, ::AbstractString)` is also defined.
- `imshow` now returns an `ImageDisplay` struct rather than a nested
`Dict{String,Any}`. The nested GUI and ROI groupings are exposed as
the structs `ImageViewGUI` (returned by `imshow_gui`) and `ImageROI`
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ImageView"
uuid = "86fae568-95e7-573e-a6b2-d8a6b900c9ef"
author = ["Tim Holy <tim.holy@gmail.com", "Jared Wahlstrand <jwahlstrand@gmail.com>"]
version = "0.13.2"
version = "0.13.3"

[deps]
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
Expand Down
5 changes: 5 additions & 0 deletions src/ImageView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export AnnotationText, AnnotationPoint, AnnotationPoints,
export CLim, annotate!, annotations, canvasgrid, imshow, imshow!, imshow_gui, imlink,
roi, scalebar, setup_contrast_popup!, slice2d

# Public-but-not-exported types that downstream packages dispatch on.
@static if VERSION >= v"1.11"
eval(Expr(:public, :ImageDisplay, :ImageViewGUI, :ImageROI))
end

const AbstractGray{T} = Color{T,1}
const GrayLike = Union{AbstractGray,Number}
const FixedColorant{T<:FixedPoint} = Colorant{T}
Expand Down
16 changes: 13 additions & 3 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,24 @@ function _legacy_get(g::ImageViewGUI, key::AbstractString)
key == "hoverinfo" && return getfield(g, :hoverinfo)
key == "zoomregion_info" && return getfield(g, :zoomregion_info)
key == "guidata" && return getfield(g, :extras)[:guidata]
throw(KeyError(key))
# Pre-0.13 callers used the GUI Dict as scratch space for arbitrary keys
# (e.g. stashing a `zoom_region` observable). Route those through `extras`.
return getfield(g, :extras)[Symbol(key)]
end
function _legacy_set!(g::ImageViewGUI, key::AbstractString, value)
key == "hoverinfo" && (g.hoverinfo = value; return value)
key == "zoomregion_info" && (g.zoomregion_info = value; return value)
key == "players" && (g.players = value; return value)
key == "guidata" && (g.extras[:guidata] = value; return value)
throw(ArgumentError("cannot assign legacy key \"$key\" on ImageViewGUI"))
getfield(g, :extras)[Symbol(key)] = value
return value
end

Base.haskey(g::ImageViewGUI, key::AbstractString) =
_legacy_haskey_known(g, key) || haskey(getfield(g, :extras), Symbol(key))

function _legacy_haskey_known(::ImageViewGUI, key::AbstractString)
return key in ("window", "vbox", "frame", "canvas", "status", "viewlabel",
"players", "hoverinfo", "zoomregion_info", "guidata")
end

function _legacy_get(r::ImageROI, key::AbstractString)
Expand Down
Loading