Skip to content

Commit

Permalink
Add animated example for Checkbox (#4483)
Browse files Browse the repository at this point in the history
* Add animated example for `Checkbox`

* same mistake
  • Loading branch information
jkrumbiegel authored Oct 15, 2024
1 parent d7aafde commit 4279628
Showing 1 changed file with 60 additions and 16 deletions.
76 changes: 60 additions & 16 deletions docs/src/reference/blocks/checkbox.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Checkbox

```@figure backend=GLMakie
```@example checkbox
using GLMakie
using Random # hide
GLMakie.activate!() # hide
f = Figure()
gl = GridLayout(f[2, 1], tellwidth = false)
Expand All @@ -10,26 +15,65 @@ cb1 = Checkbox(subgl[1, 1], checked = false)
cb2 = Checkbox(subgl[2, 1], checked = true)
cb3 = Checkbox(subgl[3, 1], checked = true)
Label(subgl[1, 2], "Show grid", halign = :left)
Label(subgl[2, 2], "Show ticklabels", halign = :left)
Label(subgl[3, 2], "Show title", halign = :left)
Label(subgl[1, 2], "Dataset A", halign = :left)
Label(subgl[2, 2], "Dataset B", halign = :left)
Label(subgl[3, 2], "Dataset C", halign = :left)
rowgap!(subgl, 8)
colgap!(subgl, 8)
ax = Axis(
f[1, 1],
title = "Checkboxes",
xgridvisible = cb1.checked,
ygridvisible = cb1.checked,
xticklabelsvisible = cb2.checked,
yticklabelsvisible = cb2.checked,
xticksvisible = cb2.checked,
yticksvisible = cb2.checked,
titlevisible = cb3.checked,
alignmode = Outside(),
)
ax = Axis(f[1, 1])
Random.seed!(123) # hide
for cb in [cb1, cb2, cb3]
lines!(ax, cumsum(randn(1000)), alpha = @lift($(cb.checked) ? 1.0 : 0.1))
end
f
nothing # hide
```

```@setup checkbox
using ..FakeInteraction
evts = [
Wait(0.5),
Lazy() do fig
MouseTo(relative_pos(cb1, (0.7, 0.3)))
end,
Wait(0.2),
LeftClick(),
Wait(0.5),
Lazy() do fig
MouseTo(relative_pos(cb2, (0.5, 0.6)))
end,
Wait(0.2),
LeftClick(),
Wait(0.5),
Lazy() do fig
MouseTo(relative_pos(cb3, (0.4, 0.4)))
end,
Wait(0.2),
LeftClick(),
Wait(0.5),
Lazy() do fig
MouseTo(relative_pos(cb2, (0.6, 0.5)))
end,
Wait(0.2),
LeftClick(),
Wait(0.5),
Lazy() do fig
MouseTo(relative_pos(cb1, (0.3, 0.3)))
end,
Wait(0.2),
LeftClick(),
Wait(1.0),
]
interaction_record(f, "checkbox_example.mp4", evts)
```

```@raw html
<video autoplay loop muted playsinline src="./checkbox_example.mp4" width="600"/>
```

## Attributes
Expand Down

0 comments on commit 4279628

Please sign in to comment.