Skip to content

Commit

Permalink
Resize screens as well when resizing scene (#3093)
Browse files Browse the repository at this point in the history
* Resize screens as well when resizing scene

* fix other backends
  • Loading branch information
SimonDanisch authored Jul 25, 2023
1 parent 9f317ce commit d85ca14
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CairoMakie/src/screen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,6 @@ end
is_vector_backend(ctx::Cairo.CairoContext) = is_vector_backend(ctx.surface)
is_vector_backend(surf::Cairo.CairoSurface) = is_vector_backend(get_render_type(surf))
is_vector_backend(rt::RenderType) = rt in (PDF, EPS, SVG)

# no need for resizing screen, since we need to redisplay anyways!
Base.resize!(screen::Screen, w, h) = nothing
3 changes: 3 additions & 0 deletions WGLMakie/src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ mutable struct Screen <: Makie.MakieScreen
end
end

# Resizing the scene is enough for WGLMakie
Base.resize!(::WGLMakie.Screen, w, h) = nothing

function Base.isopen(screen::Screen)
three = get_three(screen)
return !isnothing(three) && isopen(three.session)
Expand Down
4 changes: 2 additions & 2 deletions src/figures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const CURRENT_FIGURE_LOCK = Base.ReentrantLock()
"""
current_figure()
Returns the current active figure (or the last figure created).
Returns the current active figure (or the last figure created).
Returns `nothing` if there is no current active figure.
"""
current_figure() = lock(()-> CURRENT_FIGURE[], CURRENT_FIGURE_LOCK)
Expand Down Expand Up @@ -202,4 +202,4 @@ end
Resizes the given `Figure` to the resolution given by `width` and `height`.
If you want to resize the figure to its current layout content, use `resize_to_layout!(fig)` instead.
"""
Makie.resize!(figure::Figure, args...) = resize!(figure.scene, args...)
Makie.resize!(figure::Figure, width::Integer, height::Integer) = resize!(figure.scene, width, height)
5 changes: 5 additions & 0 deletions src/scenes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@ end
Base.resize!(scene::Scene, x::Number, y::Number) = resize!(scene, (x, y))
function Base.resize!(scene::Scene, rect::Rect2)
pixelarea(scene)[] = rect
if isroot(scene)
for screen in scene.current_screens
resize!(screen, widths(rect)...)
end
end
end

# Just indexing into a scene gets you plot 1, plot 2 etc
Expand Down

0 comments on commit d85ca14

Please sign in to comment.