Skip to content

Commit

Permalink
Introduce isclosed(scene), conditionally use Bonito.LargeUpdate (#4569
Browse files Browse the repository at this point in the history
)

* try large update for Samplers (e.g. heatmap data update)

* introduce isclosed + conditionally use Bonito.LargeUpdate

* fix tests

* add changelog

* allow new Bonito versions
  • Loading branch information
SimonDanisch authored Nov 5, 2024
1 parent 88746d9 commit bf76264
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Introduce `isclosed(scene)`, conditionally use `Bonito.LargeUpdate` [#4569](https://github.com/MakieOrg/Makie.jl/pull/4569).
- Allow plots to move between scenes in SpecApi [#4132](https://github.com/MakieOrg/Makie.jl/pull/4132).
- Added empty constructor to all backends for `Screen` allowing `display(Makie.current_backend().Screen(), fig)` [#4561](https://github.com/MakieOrg/Makie.jl/pull/4561).
- Added `subsup` and `left_subsup` functions that offer stacked sub- and superscripts for `rich` text which means this style can be used with arbitrary fonts and is not limited to fonts supported by MathTeXEngine.jl [#4489](https://github.com/MakieOrg/Makie.jl/pull/4489).
Expand Down
3 changes: 3 additions & 0 deletions GLMakie/test/unit_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ end
# assure we correctly close screen and remove it from plot
@test getscreen(ax.scene) === nothing
@test !events(ax.scene).window_open[]
# Because of on(scene.events.window_open) in scene, we need to free all scenes first
# to have 0 listeners
empty!(fig)
@test isempty(events(ax.scene).window_open.listeners)

# Test singleton screen replacement
Expand Down
2 changes: 1 addition & 1 deletion WGLMakie/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ShaderAbstractions = "65257c39-d410-5151-9873-9b3e5be5013e"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[compat]
Bonito = "3.2.4"
Bonito = "3.2.4, 4"
Colors = "0.11, 0.12, 0.13"
FileIO = "1.1"
FreeTypeAbstraction = "0.10"
Expand Down
5 changes: 3 additions & 2 deletions WGLMakie/src/serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,13 @@ function register_geometry_updates(@nospecialize(plot), update_buffer::Observabl
end

function uniform_updater(@nospecialize(plot), uniforms::Dict)
updater = Observable(Any[:none, []])
updater = Observable{Any}(Any[:none, []])
for (name, value) in uniforms
if value isa Sampler
on(plot, ShaderAbstractions.updater(value).update) do (f, args)
if f === ShaderAbstractions.update!
updater[] = [name, [Int32[size(value.data)...], serialize_three(args[1])]]
update = [name, [Int32[size(value.data)...], serialize_three(args[1])]]
updater[] = isdefined(Bonito, :LargeUpdate) ? Bonito.LargeUpdate(update) : update
end
return
end
Expand Down
12 changes: 10 additions & 2 deletions src/scenes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ mutable struct Scene <: AbstractScene
cycler::Cycler

conversions::DimConversions
isclosed::Bool

function Scene(
parent::Union{Nothing, Scene},
Expand Down Expand Up @@ -131,13 +132,21 @@ mutable struct Scene <: AbstractScene
convert(Vector{AbstractLight}, lights),
deregister_callbacks,
Cycler(),
DimConversions()
DimConversions(),
false
)
on(scene, events.window_open) do open
if !open
scene.isclosed = true
end
end
finalizer(free, scene)
return scene
end
end

isclosed(scene::Scene) = scene.isclosed

# on & map versions that deregister when scene closes!
function Observables.on(@nospecialize(f), @nospecialize(scene::Union{Plot,Scene}), @nospecialize(observable::Observable); update=false, priority=0)
to_deregister = on(f, observable; update=update, priority=priority)::Observables.ObserverFunction
Expand Down Expand Up @@ -538,7 +547,6 @@ end
# return
# end


function move_to!(plot::Plot, scene::Scene)
if plot.parent === scene
return
Expand Down

0 comments on commit bf76264

Please sign in to comment.