From: hgn Date: Wed, 6 Sep 2023 12:51:51 +0000 (+0100) Subject: api change X-Git-Url: https://harrygodden.com/git/?p=vg.git;a=commitdiff_plain;h=3b50c56358d80e59508d4335c1847e8d18d16135 api change --- diff --git a/vg_imgui.h b/vg_imgui.h index d107039..b624e7f 100644 --- a/vg_imgui.h +++ b/vg_imgui.h @@ -72,6 +72,10 @@ enum ui_scheme_colour{ k_ui_brighter = 8 }; +static ui_px k_ui_widget_height = 28, + k_ui_scale = 2, + k_ui_padding = 8; + typedef u32 ui_scheme[8*4]; #define UI_RGB( STDHEX ) 0xff000000 |\ @@ -1189,15 +1193,22 @@ static void ui_dev_colourview(void) } } +static void ui_standard_widget( ui_rect inout_panel, ui_rect out_rect ){ + ui_split( inout_panel, k_ui_axis_h, k_ui_widget_height*k_ui_scale, + k_ui_padding, out_rect, inout_panel ); +} + /* * checkbox * ----------------------------------------------------------------------------- */ -static int ui_checkbox( ui_rect rect, const char *str_label, int *data ){ - ui_rect label, box; +static int ui_checkbox( ui_rect inout_panel, const char *str_label, i32 *data ){ + ui_rect rect, label, box; + ui_standard_widget( inout_panel, rect ); + ui_split( rect, k_ui_axis_v, -rect[3], 0, label, box ); - ui_text( label, str_label, 1, k_ui_align_middle_left, 0 ); + ui_text( label, str_label, k_ui_scale, k_ui_align_middle_left, 0 ); int changed = ui_colourbutton( box, k_ui_bg )==1; if( changed ) @@ -1220,13 +1231,14 @@ static int ui_checkbox( ui_rect rect, const char *str_label, int *data ){ * unfortunately no return value since we only find out that event in the * postrender step. */ -static void ui_enum( ui_rect rect, const char *str_label, +static void ui_enum( ui_rect inout_panel, const char *str_label, struct ui_enum_opt *options, u32 len, i32 *value ) { - ui_rect label, box; - ui_split( rect, k_ui_axis_v, ui_text_line_width( str_label ) + 8, + ui_rect rect, label, box; + ui_standard_widget( inout_panel, rect ); + ui_split( rect, k_ui_axis_v, (ui_text_line_width( str_label )+8)*k_ui_scale, 0, label, box ); - ui_text( label, str_label, 1, k_ui_align_middle_left, 0 ); + ui_text( label, str_label, k_ui_scale, k_ui_align_middle_left, 0 ); const char *display = "OUT OF RANGE"; for( u32 i=0; i