It now looks a lot like button.lua.
OC4P6P36KEBO2FIYTKXUQOP6VSQRFONDCLSZDGN7ZNYN23UMNH7AC
WYTWSZR3D6HIXT43YUIOFYSYWE66XOKYG25OQIQAO3LEFS62GDAQC
LEE7TNZMRETHPOO52OJGLN6X6VMORXZO2SM3VVTU336NFZ4DKCYQC
LR4HHCRHSRNJHD625BE5ERN73NBHLWI2IHMFUFCB3Y2AGEDFSXSAC
W4EQ6IW4KVNJDAN32RUK7BLGWJB3TKZIE27PLIIGU5ARJPBMVS6QC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
JV27LDDKKY57IEBWGBFPSHEARMOEGLBYGBJD27PDPTNWWYXA4T6AC
PUXFYOQ4VNORZQANT2QRXQDFSPWXRTRFMEVMPWL4LWMAPSOSC3EQC
ZOGPQR4SBN6CHYKE2SZOYNXN3XDFOBXUFNQCZ53DAQSRKP7DZKPQC
QIG72BFJB2ZXK6APGH3K4MFHXBSJDV6VIZFY32G6LBP5P5T4BN6QC
NVZTMKERX3NCKNKRYOTAHNVT7CDVHQW3KMVLH35USH5D3TCIQOXQC
ZM7NOBRMD5HHA35Y4JDC76EOA2RD4KQOQCPURXYKXA6ABMKOJIGQC
IP4LD33DQFWQ4654YPNJRKQ3CNYSHRZPX6U6ZPY7OLE744XX3MEQC
VAVXKWZVOFJGWHCWYLTPDKSKKMSJEBKXNKXUW3T6IZAC3HE6HOIQC
FIUQJVL2MCC4VKKX7JBT6377TWIGPTUC5NXMUABV5JILB3ZDWZFAC
BQTHWI4ATNV7Q7K2Y3BV2MVFUNVNQGAU3QU6EZ54LATEREOKC6CQC
UEG224LHBOPWSKOVXTKVAUEL47HET566LJF7ZSWVKMMLBSJWUHFAC
LGIEVJE6W72DAIY7NEWDIMPSI6K5GR2M4BREPQ4TYFWCZYGA6MHQC
select_settings_slider = function(x,y, mouse_button)
local result = false
if on_slider(Settings_font_slider, x,y) then
Selected_slider = Settings_font_slider.name
result = true
end
for color,slider in pairs(Settings_foreground_sliders) do
if on_slider(slider, x,y) then
Selected_slider = slider.name
result = true
end
end
for color,slider in pairs(Settings_background_sliders) do
if on_slider(slider, x,y) then
Selected_slider = slider.name
result = true
end
end
return result
end
update_any_sliders = function(x,y)
if Selected_slider == Settings_font_slider.name then
update_font_settings(slider_value(Settings_font_slider, x))
return true
end
for color,slider in pairs(Settings_foreground_sliders) do
if Selected_slider == slider.name then
Foreground_color[color] = slider_value(slider, x)
return true
end
end
for color,slider in pairs(Settings_background_sliders) do
if Selected_slider == slider.name then
Background_color[color] = slider_value(slider, x)
return true
end
end
end
mouse_press_consumed_by_any_slider = function(State, x, y)
for name, slider in pairs(State.slider_handlers) do
if on_slider(slider, x,y) then
State.selected_slider = name -- used by update across frames; slider_handlers is recreated every frame
return true
end
end
end
update_sliders = function(State, x)
for name, slider in pairs(State.slider_handlers) do
if State.selected_slider == name then
slider.update(slider_value(slider, x))
break
end
end
end
slider = function(State, name, params)
draw_slider(params)
State.slider_handlers[name] = params
end
local prev = Settings_font_slider
Settings_foreground_sliders = {
r = {
name='fg/r',
local prev = Global_state.slider_handlers.font
for _,color in ipairs{'r', 'g', 'b'} do
slider(Global_state, 'fg/'..color, {
fg=Normal_color,
value=Foreground_color.r,
},
g = {
name='fg/g',
x0=prev.x0, x1=prev.x1,
y0=y+15,
w=prev.w, h=prev.h,
lo=0, hi=1,
value=Foreground_color.g,
},
b = {
name='fg/b',
x0=prev.x0, x1=prev.x1,
y0=y+30,
w=prev.w, h=prev.h,
lo=0, hi=1,
value=Foreground_color.b,
},
}
App.color(Normal_color)
draw_slider(Settings_foreground_sliders.r)
draw_slider(Settings_foreground_sliders.g)
draw_slider(Settings_foreground_sliders.b)
y = y+50
value=Foreground_color[color],
update=function(v) Foreground_color[color] = v end,
})
y = y+15
end
y = y+5
value=Background_color.g
},
b = {
name='bg/b',
x0 = prev.x0, x1=prev.x1,
y0 = y+30,
w=prev.w, h=prev.h,
lo = 0, hi=1,
value = Background_color.b
},
}
App.color(Normal_color)
draw_slider(Settings_background_sliders.r)
draw_slider(Settings_background_sliders.g)
draw_slider(Settings_background_sliders.b)
value=Background_color[color],
update=function(v) Background_color[color] = v end,
})
y = y+15
end
if Selected_slider then
update_any_sliders(App.mouse_x(), App.mouse_y())
end
-- main area
update_sliders(Global_state, App.mouse_x())
-- == main area