Conversation
Benchmark ResultsSHA: be101287e417eafeb69368562cb374b74f465303 Warning These results are subject to substantial noise because GitHub's CI runs on shared machines that are not ideally suited for benchmarking. |
perfectly safe, surely
|
I would probably make the Block infrastructure more like the plot infrastructure in this case, to make it behave more like the other recipe code does. Rename it even. Because when I wrote them first, I didn't consider blocks in a recursive way like they would work now, where a complex recipe by some user would use some predefined blocks (then complex recipes) internally. But I think the similarities to the complex recipe idea have shown that it should have worked more like that from the beginning. I just didn't see the similarity between a button, a slider an axis and something like a whole facet plot with a colorbar. |
What do you mean with that? Have
And what would you rename it to? I kind of like |
| f, b1 = Box(S.GridLayout()) | ||
| b2 = Box(f[1, 2], S.GridLayout()) | ||
| st = Makie.Stepper(f) | ||
| sync_step!(st) | ||
| b1[1] = S.GridLayout( | ||
| [ | ||
| S.Axis(; plots = [S.Lines(1:4; color = :black, linewidth = 5), S.Scatter(1:4; markersize = 20)]) | ||
| S.Axis3(; plots = [S.Scatter(Rect3f(Vec3f(0), Vec3f(1)); color = :red, markersize = 50)]) | ||
| ] | ||
| ) |
There was a problem hiding this comment.
BlockSpec and GridLayoutSpec can now be passed to a Block, either directly or through convert_arguments.
The way I set it up it's more or less irrelevant which block is used. If it doesn't implement an argument-catching initialize_block!(block, args...; kwargs...) and there is a BlockSpec or GridLayoutSpec present after convert_arguments it switches to SpecApi block construction. That then treats the block like a figure and defers to existing SpecApi code for GridLayoutSpec.
There was a problem hiding this comment.
Seems weird to me that something like Box(S.GridLayout()) works but I think that's fine if it's just a background quirk.
If it's useful to have some container block to pass a SpecApi GridLayoutSpec or BlockSpec to, then I think we should make a dedicated one. I think it could also be useful in general to have an empty placeholder block.
|
The |
|
Huh, still? I added a method to propagate update_state_before_display through nested blocks to fix this. Seems like that only works for |
|
The overload for gridlayout sides isn't implemented, yet: Label(b[1, 1:2, Top()], "Hello", font = :bold)ERROR: MethodError: no method matching getindex(::DualView, ::Int64, ::UnitRange{Int64}, ::Top) |
|
Thanks, found another one: Colorbar(b[end+1, :], vertical = false)ERROR: MethodError: no method matching axes(::DualView, ::Int64) |



Description
This is an alternative to #5454 which extends
@Blockinstead of@recipe. @jkrumbiegel suggested this because Blocks and complex recipes both fill the purpose of placing something in the layout.Changes relevant to existing Blocks
block.layoutcurrently always exists, but isn't always initializedProblems for existing Blocks
ComputeGraphbrokenotify(block.attribute)block.attr[] = block.attr[]setfield!,hasfield,getfieldfor attributes is broken since attributes aren't fields anymoreBlocks as complex recipes compared to
ComplexRecipefrom #5454DualView(f[1, 1], args...; attributes...)instead ofdualview(f[1, 1], args...; attributes...)currently can't be used without a GridPositioninitialize_block!(b::DualView, args...; kwargs...)instead ofplot!(cr::DualView)currently this means that arguments aren't automatically in the compute graph and noconvert_argumentsis used@Blocknow allows arguments and initialize_block will automatically apply argument conversions withinitialize_block!(block; kwargs...)defined (instead of theargs...version)@attributes begin ... endblock::DualViewinstead of::AbstractAxis, ::ComplexRecipeAxis(b[1, 1])andheatmap(b[1, 1], ...)work, including from outside the recipeb.blocksworks with the list generated on demandI decided to drop plots because it's rather confusing to have them withb.plotsworks with the list generated at init timeAxisBlockalso allows adding fields, which may be useful?Example
This is the example from #5454 rewritten with this pr:
TODO
Block()constructor that generates a figure and places the block atfig[1, 1]consider adding moredoesn't seem to be necessaryonany/map!/mapmethods forComputedinputs with N precedingObservableinputs. I'd be surprised if we don't run into issues with those...@Blockblock.layoutfor traditional blocksType of change
ComputeGraphbreakingsomeand similarlynotify()callsobs[] = obs[],setfield/hasfield/getfieldfor attributesChecklist