sokoban.love/0124-styled_button

24 lines
690 B
Plaintext

styled_button = function(name, x, y, onpress1, tooltip_text, fg)
local w = Font:getWidth(name)+10
button(Global_state, name, {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
icon = function(p)
if Active_button and Active_button.name == name and Active_button.expire > Current_time then
App.color(Highlighted_button_color)
else
App.color(fg or Normal_color)
end
love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
love.graphics.print(name, p.x+5,p.y+2)
end,
onpress1 = function()
onpress1()
Active_button = {
name=name,
expire=Current_time+0.1,
}
end,
tooltip = function(x,y)
show_tooltip(x,y+20, tooltip_text)
end,
})
end