Tab views in GLMakie

I’d like to implement a tab view using GLMakie. By that I mean an area of a layout with a row of buttons that can select from a set of items (for example Axis objects) to display in the view. Since I’m not sure of the best way to do this I thought I’d ask if there is existing code somewhere that does something like this that I could use as an example.

If not is there a simple way to hide and unhide an object in GLMakie ? That would seem to be the basic primitive one would want to implement this. I would rather avoid having to delete and reconstruct objects as that may be costly.

Any other suggestions are welcome of course.

Right now we don’t have quite the infrastructure needed for that, I think (@sdanisch ?). There is a visible attribute for Scenes now, but it doesn’t proliferate to child scenes, so you can’t use it to hide a bunch of elements like Axis, Axis3, etc. which are all based on child scenes. In addition, if you were to hide a Scene you’d currently probably still catch all sorts of interaction events there, which you wouldn’t see but which would probably mess up your implemented logic in some way because of things interfering with each other.

I would rather avoid having to delete and reconstruct objects as that may be costly.

True, these objects are costly relative to the other options that aren’t available yet. But I think for normal assemblies it can be workable right now:

function panelA!(obj)
    Axis(obj[1, 1], title = "Panel A")
    lines!(cumsum(randn(1000)))
    Colorbar(obj[1, 2])
end

function panelB!(obj)
    Axis3(obj[1, 1], title = "Panel B")
    lines!(cumsum(randn(1000, 3), dims = 1))
    Colorbar(obj[2, 1], vertical = false)
end

begin
    f = Figure()
    buttongl = GridLayout(f[1, 1], tellwidth = false)
    ba = Button(buttongl[1, 1], label = "Panel A")
    bb = Button(buttongl[1, 2], label = "Panel B")
    panelgl = GridLayout(f[2, 1])
    
    function clear_panel!()
        clear!(x) = delete!(x)
        function clear!(x::GridLayout)
            for el in contents(x)
                clear!(el)
            end
        end
        clear!(panelgl)
        trim!(panelgl)
    end

    on(ba.clicks) do _
        clear_panel!()
        panelA!(panelgl)
    end
    on(bb.clicks) do _
        clear_panel!()
        panelB!(panelgl)
    end

    panelA!(panelgl)

    f
end