MakieLayout.jl
MakieLayout.jl copied to clipboard
Togglable button
We were discussing this at some point in slack but unfortunately it got lost. I think a great option for the standard button is a "togglable" setting, that makes the button "on" when it is clicked, and then "off" when it is clicked again. I know there is the Toggle struct, but I find it nicer having a button, and I also prefer having the text on the thing I toggle.
I have a code working for this button:
runbutton = LButton(scene, label = Observable("run"),
buttoncolor = Observable(RGBf0(0.8, 0.8, 0.8)),
buttoncolor_hover = Observable(RGBf0(0.7, 0.7, 0.9)),
buttoncolor_active = Observable(RGBf0(0.6, 0.6, 1.0)),
labelcolor = Observable((RGBf0(0,0,0))),
labelcolor_active = Observable((RGBf0(1,1,1))),
height = 40, width = 70,
)
# Functionality that CREATES the play/stop button
# TODO: will be deleted once MakieLayout has togglable button
on(runbutton.clicks) do n
t = runbutton.label[] == "run" ? "stop" : "run"
runbutton.label[] = t
for (s1, s2) in ((:buttoncolor, :buttoncolor_active), (:labelcolor, :labelcolor_active))
getproperty(runbutton, s1)[], getproperty(runbutton, s2)[] =
getproperty(runbutton, s2)[], getproperty(runbutton, s1)[]
end
runbutton.labelcolor_hover[] = runbutton.labelcolor[]
end
but I am not sure how I could incorporate this in a PR. If you guide me I would gladly contribute that (but also feel free to use any part of the code).