(bind-func Widget_slider2D_c
(lambda (label:i8* cb:[void,float,float]*)
(let ((lab (String label))
(slider_xpos .5)
(slider_ypos .5))
(lambda (widget:Widget* bounds:Rect*)
(let ((vg (GUI_context EXTEMPORE_GUI))
(click_p (gui_left_click_p bounds)))
;; toggle state
(if click_p
(begin (set! slider_xpos
(/ (- (gui_mouse_x) (tref bounds 0))
(tref bounds 2)))
(set! slider_ypos
(/ (- (gui_mouse_y) (tref bounds 1))
(tref bounds 3)))
(cb slider_xpos slider_ypos)))
;; draw background
(nvgBeginPath vg)
(nvgFillColor vg GUI_COLOR_ORANGE_D)
(gui_draw_rect bounds)
(nvgFill vg)
;; draw "marker"
(nvgBeginPath vg)
(if click_p
(nvgFillColor vg GUI_COLOR_ORANGE_L)
(nvgFillColor vg GUI_COLOR_ORANGE))
(gui_draw_circle (+ (* (tref bounds 2) slider_xpos)
(tref bounds 0))
(+ (* (tref bounds 3) slider_ypos)
(tref bounds 1))
10.)
(nvgFill vg)
(nvgFillColor vg GUI_COLOR_BG)
(nvgBeginPath vg)
(gui_draw_text_in_bounds bounds lab 30.)
(nvgFill vg))))))