Skip to content

Commit

Permalink
add backend and update_state kwargs to show (#4558)
Browse files Browse the repository at this point in the history
* add backend kwarg to show

* added CHANGELOG entry

* add minimal test

* add kwarg to update state or not

* fix CHANGELOG

* add test

* refactor per ffreyer's review

* fix test

---------

Co-authored-by: Frederic Freyer <[email protected]>
Co-authored-by: Simon <[email protected]>
  • Loading branch information
3 people authored Dec 6, 2024
1 parent 71593af commit db8c78c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## [0.21.17] - 2024-12-05

- Added `backend` and `update` kwargs to `show` [#4558](https://github.com/MakieOrg/Makie.jl/pull/4558)
- Disabled unit prefix conversions for compound units (e.g. `u"m/s"`) to avoid generating incorrect units. [#4583](https://github.com/MakieOrg/Makie.jl/pull/4583)
- Added kwarg to rotate Toggle [#4445](https://github.com/MakieOrg/Makie.jl/pull/4445)
- Fixed orientation of environment light textures in RPRMakie [#4629](https://github.com/MakieOrg/Makie.jl/pull/4629).
Expand Down
5 changes: 2 additions & 3 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,16 @@ function Base.show(io::IO, m::MIME"text/markdown", fig::FigureLike)
throw(MethodError(show, io, m, fig))
end

function Base.show(io::IO, m::MIME, figlike::FigureLike)
function Base.show(io::IO, m::MIME, figlike::FigureLike; backend = current_backend(), update=true)
if ALWAYS_INLINE_PLOTS[] == false && m isa MIME_TO_TRICK_VSCODE
# We use this mime to display the figure in a window here.
# See declaration of MIME_TO_TRICK_VSCODE for more info
display(figlike)
return () # this is a diagnostic vscode mime, so we can just return nothing
end
scene = get_scene(figlike)
backend = current_backend()
# get current screen the scene is already displayed on, or create a new screen
update_state_before_display!(figlike)
update && update_state_before_display!(figlike)
screen = getscreen(backend, scene, Dict(:visible=>false), io, m)
backend_show(screen, io, m, scene)
return screen
Expand Down
7 changes: 7 additions & 0 deletions test/figures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,10 @@ end
@test_throws ArgumentError lines(f[1, 1], 1:10, axis = (aspect = DataAspect()))
@test_throws ArgumentError lines(f[1, 1][2, 2], 1:10, axis = (aspect = DataAspect()))
end

@testset "show with a backend" begin
fig = Figure()
io = IOBuffer()
# if there were no show method with backend and update kwargs then MethodError would be thrown instead
@test_throws ErrorException show(io, MIME"text/plain"(), fig, backend=missing, update=false)
end

12 comments on commit db8c78c

@SimonDanisch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir=MakieCore

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/120809

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a MakieCore-v0.8.11 -m "<description of version>" db8c78c36f17ab0f229266ddb69502098888387e
git push origin MakieCore-v0.8.11

@SimonDanisch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/120812

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.21.17 -m "<description of version>" db8c78c36f17ab0f229266ddb69502098888387e
git push origin v0.21.17

@SimonDanisch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir=GLMakie

@SimonDanisch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir=WGLMakie

@SimonDanisch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir=CairoMakie

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/120813

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a GLMakie-v0.10.17 -m "<description of version>" db8c78c36f17ab0f229266ddb69502098888387e
git push origin GLMakie-v0.10.17

@SimonDanisch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir=RPRMakie

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/120814

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a WGLMakie-v0.10.17 -m "<description of version>" db8c78c36f17ab0f229266ddb69502098888387e
git push origin WGLMakie-v0.10.17

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/120815

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a CairoMakie-v0.12.17 -m "<description of version>" db8c78c36f17ab0f229266ddb69502098888387e
git push origin CairoMakie-v0.12.17

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/120816

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a RPRMakie-v0.7.17 -m "<description of version>" db8c78c36f17ab0f229266ddb69502098888387e
git push origin RPRMakie-v0.7.17

Please sign in to comment.