Skip to content

Commit

Permalink
Relax align typing for Blocks (#2108)
Browse files Browse the repository at this point in the history
* relax alignment types to include numbers

* add test

* actually test

* add news
  • Loading branch information
jkrumbiegel committed Jul 3, 2022
1 parent 108aac9 commit 3a17241
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,5 +1,9 @@
# News

## master

- Fixed regression where `Block` alignments could not be specified as numbers anymore [#2108](https://github.com/JuliaPlots/Makie.jl/pull/2108).

## v0.17.7

- Improved `Menu` performance, now it should me much harder to reach the boundary of 255 scenes in GLMakie. `Menu` also takes a `default` keyword argument now and can be scrolled if there is too little space available.
Expand Down
4 changes: 2 additions & 2 deletions src/makielayout/blocks.jl
Expand Up @@ -332,8 +332,8 @@ function _block(T::Type{<:Block}, fig_or_scene::Union{Figure, Scene},
layout_height = Observable{Any}(nothing)
layout_tellwidth = Observable(true)
layout_tellheight = Observable(true)
layout_halign = Observable(:center)
layout_valign = Observable(:center)
layout_halign = Observable{Union{Symbol, Float64}}(:center)
layout_valign = Observable{Union{Symbol, Float64}}(:center)
layout_alignmode = Observable{Any}(Inside())

lobservables = LayoutObservables(
Expand Down
10 changes: 10 additions & 0 deletions test/makielayout.jl
Expand Up @@ -175,3 +175,13 @@ end
ax = Axis(f[1,1], xticks = 20:10:80)
scatter!(ax, 30:10:100, rand(Float64, 8), color = :red)
end

# issues 1958 and 2006
@testset "axislegend number align" begin
f = Figure()
ax = Axis(f[1,1], xticks = 20:10:80)
lines!(ax, 1:10, label = "A line")
leg = axislegend(ax, position = (0.4, 0.8))
@test leg.halign[] == 0.4
@test leg.valign[] == 0.8
end

0 comments on commit 3a17241

Please sign in to comment.