+/*
+ * Slider
+ * -----------------------------------------------------------------------------
+ */
+
+static void ui_slider( ui_rect inout_panel, const char *str_label,
+ f32 min, f32 max, f32 *value, const char *format ){
+ ui_rect rect, label, box;
+ ui_standard_widget( inout_panel, rect, 1 );
+ ui_label( rect, str_label, k_ui_scale, 0, box );
+
+ f32 t;
+
+ enum ui_button_state
+ mask_using =
+ k_ui_button_holding_inside |
+ k_ui_button_holding_outside |
+ k_ui_button_click,
+ mask_brighter =
+ mask_using | k_ui_button_hover,
+ state = ui_colourbutton( box, k_ui_bg, k_ui_bg+2, k_ui_bg+3 );
+
+ if( state & mask_using ){
+ t = vg_clampf( (f32)(vg_ui.mouse[0] - box[0]) / (f32)( box[2] ),
+ 0.0f, 1.0f );
+ *value = vg_lerpf( min, max, t );
+ }
+ else
+ t = vg_clampf( (*value - min) / (max-min), 0.0f, 1.0f );
+
+ ui_rect line = { box[0], box[1], t * (f32)box[2], box[3] };
+ ui_fill( line, ui_colour(state&mask_brighter? k_ui_bg+4: k_ui_bg+2) );
+
+ ui_outline( box, 1, ui_colour(state? k_ui_fg+3: k_ui_bg+3), 0 );
+
+ /* TODO: replace this one day with our own function */
+ char buf[32];
+ snprintf( buf, sizeof(buf), format? format: "%.2f", *value );
+ ui_text( box, buf, 1, k_ui_align_middle_center, 0 );
+}
+