Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize screens as well when resizing scene #3093

Merged
merged 3 commits into from
Jul 25, 2023
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
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
Loading