JV27LDDKKY57IEBWGBFPSHEARMOEGLBYGBJD27PDPTNWWYXA4T6AC
4GX6NAY4OD4RXA3UJKI3LLPU43ADGF3TDV2DHPNMSLXJPPXCXKOQC
RK2ASPN7A55RCEG2YRFZLFXNPSME2VKBE2ZXO257DYZPS5TPXC5QC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
I52S4E5FT6E6FHH3QEDJPWO7C6W7AIMAFDP2KQ5FEWXFQX7RY6CAC
5RUFNRJOK3PXQKJTPDEN5K5PI67MGB25QUA44WOCCH2O5KHXT45QC
FPSPT5TMWUJXWC4GYWRXHS3ZB6MBLRJACIRMGE3ACQI75CV72X4AC
VUF2SX7BSB6DYFUCIS24UAMIQB4F3FLYSDLS5UXDCKIKPTWH4WWQC
ZM7NOBRMD5HHA35Y4JDC76EOA2RD4KQOQCPURXYKXA6ABMKOJIGQC
VAVXKWZVOFJGWHCWYLTPDKSKKMSJEBKXNKXUW3T6IZAC3HE6HOIQC
UEG224LHBOPWSKOVXTKVAUEL47HET566LJF7ZSWVKMMLBSJWUHFAC
Selected_slider = nil
on_area = function(s, x,y)
if x < s.x then return end
if x > s.x+s.w then return end
if y < s.y then return end
if y > s.y+s.h then return end
return true
end
Settings_menu_area = {}
Foreground_color = {r=0, g=0, b=0}
Background_color = {r=1, g=1, b=1}
Settings_background_sliders = {}
Settings_foreground_sliders = {}
on_slider = function(slider, x,y)
if x < slider.x0 or x > slider.x1 then return end
if y < slider.y0-slider.h/2 or y > slider.y0+slider.h/2 then return end
return true
end
mouse_on_any_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
slider_value = function(slider, x)
local s = slider
if x < s.x0 then x = s.x0 end
if x > s.x1 then x = s.x1 end
s.x = x
s.value = s.lo + (s.x-s.x0)*(s.hi-s.lo)/(s.x1-s.x0)
return s.value
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
Settings_font_slider = {
name='font',
-- left extreme
x0=nil, y0=nil,
-- right extreme
x1=nil,
-- slider itself
x=nil, -- y=y0
w=nil, h=nil,
lo=20, hi=40,
}
-- draw a slider widget starting at x,y, extending right w pixels
-- position 'value' on the slider
-- the leftmost point on the slider will have value 'lo', and the rightmost will have 'hi'. In between the value will be linearly interpolated.
draw_slider = function(s)
love.graphics.line(s.x0, s.y0, s.x1, s.y0)
s.x = s.x0 + (s.x1-s.x0)*(s.value-s.lo)/(s.hi-s.lo)
love.graphics.rectangle('fill', s.x-s.h/2, s.y0-s.h/2, s.w,s.h)
end
draw_settings_menu = function()
App.color(Menu_background)
local w,h = 200, love.graphics.getFont():getHeight()*8
local x,y = Safe_width-30-w, Menu_bottom
Settings_menu_area = {x=x, y=y, w=w, h=h}
love.graphics.rectangle('fill', x,y, w,h)
App.color(Normal_color)
-- font size slider
love.graphics.print('font size', x+10,y+10)
y = y+10+Line_height
local sx = x+App.width('bg')+50 -- align all sliders
Settings_font_slider = {
name='font',
-- x limits
x0=sx+20, x1=Safe_width-30,
-- central y
y0=y+10,
-- slider knob dimensions
w=10, h=10,
-- extremes
lo=20, hi=40, -- font sizes
value=Current_pane.editor_state.font_height
}
draw_slider(Settings_font_slider)
y = y+10
-- colors
love.graphics.print('colors', x+10,y+10)
y = y+10+Line_height
-- colors/foreground
love.graphics.print('fg', x+20, y)
App.color(Foreground_color)
love.graphics.rectangle('fill', sx-20,y+5, 20,20)
Settings_foreground_sliders = {
r = {
name='fg/r',
x0 = sx+20, x1=Safe_width-30,
y0 = y,
w=10, h=10,
lo = 0, hi=1,
value = Foreground_color.r
},
g = {
name='fg/g',
x0 = sx+20, x1=Safe_width-30,
y0 = y+15,
w=10, h=10,
lo = 0, hi=1,
value = Foreground_color.g
},
b = {
name='fg/b',
x0 = sx+20, x1=Safe_width-30,
y0 = y+30,
w=10, h=10,
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+10+Line_height+10
-- colors/background
love.graphics.print('bg', x+20, y)
App.color(Background_color)
love.graphics.rectangle('fill', sx-20,y+5, 20,20)
App.color(Normal_color)
Settings_background_sliders = {
r = {
name='bg/r',
x0 = sx+20, x1=Safe_width-30,
y0 = y,
w=10, h=10,
lo = 0, hi=1,
value = Background_color.r
},
g = {
name='bg/g',
x0 = sx+20, x1=Safe_width-30,
y0 = y+15,
w=10, h=10,
lo = 0, hi=1,
value = Background_color.g
},
b = {
name='bg/b',
x0 = sx+20, x1=Safe_width-30,
y0 = y+30,
w=10, h=10,
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)
end
Show_settings =false
White = {r=1, g=1, b=1}