Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add animated example for Checkbox #4483

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading