(bind-func Widget_button_c
(lambda (label:i8* cb:[void]*)
(let ((lab (String label))
(click_p:i1 0)
(prev_click_p:i1 0))
(lambda (widget:Widget* bounds:Rect*)
(let ((vg (GUI_context EXTEMPORE_GUI)))
;; toggle state
(set! click_p (gui_left_click_p bounds))
(if (and click_p (not prev_click_p))
;; fire callback
(cb))
(set! prev_click_p click_p)
;; call the callback
;; draw background
(nvgBeginPath vg)
(cond (click_p
(nvgFillColor vg GUI_COLOR_EMPH))
((gui_inbounds_p bounds)
(nvgFillColor vg GUI_COLOR_HL))
(else
(nvgFillColor vg GUI_COLOR_BG)))
(gui_draw_rect bounds)
(nvgFill vg)
;; draw text
(nvgBeginPath vg)
(if click_p
(nvgFillColor vg GUI_COLOR_BG)
(nvgFillColor vg GUI_COLOR_FG))
(gui_draw_text_in_bounds bounds lab 30.)
(nvgFill vg))))))