-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheckbox.lua
More file actions
47 lines (35 loc) · 1.22 KB
/
checkbox.lua
File metadata and controls
47 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
local ennui = require("ennui")
local Checkbox = ennui.Widgets.Checkbox
local StackPanel = ennui.Widgets.Stackpanel
local Text = ennui.Widgets.Text
local Window = ennui.Widgets.Window
local host = ennui.Widgets.Host()
:setSize(love.graphics.getDimensions())
local window = Window("Checkbox Example")
:setSize(350, 280)
:setPosition(100, 100)
local panel = StackPanel()
:setSpacing(10)
:setPadding(10)
:setSize(ennui.Size.fill(), ennui.Size.fill())
local basicCheckbox = Checkbox("Enable notifications")
local checkedCheckbox = Checkbox("Accept terms and conditions")
:setChecked(true)
local styledCheckbox = Checkbox("Big and green")
:setCheckColor(0.2, 1, 0.4)
:setBoxColor(0.6, 0.6, 0.6)
:setBoxSize(48)
local statusText = Text("Status: notifications disabled")
:setColor(0.7, 0.7, 0.7)
basicCheckbox:watch("checked", function(checked)
local status = checked and "enabled" or "disabled"
statusText:setText("Status: notifications " .. status)
end)
panel:addChild(Text("Basic Checkboxes:"):setColor(1, 1, 0.5))
panel:addChild(basicCheckbox)
panel:addChild(checkedCheckbox)
panel:addChild(styledCheckbox)
panel:addChild(statusText)
window:setContent(panel)
host:addChild(window)
return host