Skip to content

Commit 301371d

Browse files
committed
box in textwithbox() adapts to axis changes correctly
Thanks @jkrumbiegel for the workaround. See also MakieOrg/Makie.jl#4632.
1 parent 95b51a7 commit 301371d

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/recipes/textwithbox.jl

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ function Makie.plot!(p::TextWithBox)
1414

1515
padding = get(p.poly, :padding, nothing)
1616

17-
# XXX: ignores many observable updates, like the text itself or axis properties
18-
# see https://github.com/MakieOrg/Makie.jl/issues/4632
19-
rect = @lift @p let
20-
boundingbox2d(t, :pixel)
21-
@set __.origin .+= $(tattrs.offset)
22-
isnothing(padding) ? __ : dilate(__, $padding)
23-
end
24-
poly!(p, pattrs, rect)
17+
# solution by Julius Krumbiegel (jkrumbiegel) on slack
18+
scene = Makie.get_scene(p)
19+
glyphcolls = t.plots[1][1]
20+
bboxes = lift(glyphcolls, scene.camera.projectionview, scene.viewport, padding) do glyphcolls, _, _, padding
21+
transformed = Makie.apply_transform(t.transformation.transform_func[], t[1][])
22+
pos = Makie.project.(Ref(scene.camera), t.space[], t.markerspace[], transformed)
23+
24+
map(glyphcolls, pos) do glyphcoll, pos
25+
rect = Rect2f(Makie.unchecked_boundingbox(glyphcoll, pos, Makie.to_rotation(t.rotation[])))
26+
isnothing(padding) ? rect : dilate(rect, padding)
27+
end
28+
end
29+
poly!(p, pattrs, bboxes)
2530

2631
reverse!(p.plots)
2732
return p

0 commit comments

Comments
 (0)