diff --git a/src/layouts.jl b/src/layouts.jl index c671bb8ba..c21f325d4 100644 --- a/src/layouts.jl +++ b/src/layouts.jl @@ -211,10 +211,28 @@ grid(args...; kw...) = GridLayout(args...; kw...) function GridLayout( dims...; parent = RootLayout(), - widths = zeros(dims[2]), - heights = zeros(dims[1]), + widths = nothing, + heights = nothing, kw..., ) + # Check the values for heights and widths if values are provided + if heights !== nothing && widths !== nothing + if sum(heights) != 1 + error("The sum of heights must be 1!") + end + if sum(widths) != 1 + error("The sum of widths must be 1!") + end + if all(x -> 0 < x < 1, widths) == false + error("Values for widths must be in the range (0, 1)!") + end + if all(x -> 0 < x < 1, heights) == false + error("Values for heights must be in the range (0, 1)!") + end + else + heights = zeros(dims[1]) + widths = zeros(dims[2]) + end grid = Matrix{AbstractLayout}(undef, dims...) layout = GridLayout( parent,