mii_emu/ui_gl/mii_mui_utils.c
Michel Pollet 11cdb8b209 Version 1.9: See Changelog for details
List is too long...

Signed-off-by: Michel Pollet <buserror@gmail.com>
2024-05-13 16:40:51 +01:00

71 lines
2.0 KiB
C

#include "mii_mui_utils.h"
int
mii_mui_fileselect_widget( //
mii_mui_file_select_t *out,
mui_window_t *w,
c2_rect_t *where,
const char *enclosing_box_title,
const char *button_title,
const char *checkbox_title)
{
mui_t *ui = w->ui;
float base_size = mui_font_find(ui, "main")->size;
float icons_size = mui_font_find(ui, "icon_small")->size;
float margin = base_size * 0.7;
mui_control_t * c = NULL;
c2_rect_t cf;
c2_rect_t cp = *where;
cp.b = cp.t + base_size * 2.3;
where->b = cp.b;
const int but_width = 100;
cp.r = where->r - margin * 2 - but_width;
c2_rect_set(&cf, margin, (margin / 2),
c2_rect_width(&w->frame) - margin - but_width,
(margin/2) + base_size);
out->box = c = mui_groupbox_new(w, cp,
enclosing_box_title, MUI_CONTROL_TEXTBOX_FRAME);
c2_rect_bottom_of(&cf, cp.t, base_size);
c2_rect_right_of(&cf, cp.l, margin * 0.5);
cf.b = cf.t + icons_size;
cf.r = cf.l + icons_size;
out->icon = c = mui_textbox_new(w, cf,
MUI_ICON_FILE, "icon_small",
MUI_TEXT_ALIGN_MIDDLE | MUI_TEXT_ALIGN_CENTER | 0);
c->state = MUI_CONTROL_STATE_DISABLED;
cf.l = cf.r;
cf.r = cp.r - margin * 0.5;
out->fname = c = mui_textbox_new(w, cf,
"Click \"Select\" to pick a file", NULL,
MUI_TEXT_ALIGN_MIDDLE);
c->state = MUI_CONTROL_STATE_DISABLED;
c2_rect_right_of(&cf, cp.r, margin);
cf.r = where->r - margin * 0.5;
c2_rect_inset(&cf, -4,-4);
out->button = c = mui_button_new(w,
cf, MUI_BUTTON_STYLE_NORMAL,
button_title , 0);
if (checkbox_title) {
c2_rect_bottom_of(&cf, cp.b, margin * 0.4);
cf.l = cp.l + (margin * 0.7);
cf.r = cf.l + 200;
cf.b = cf.t + base_size;
where->b = cf.b;
out->checkbox = c = mui_button_new(w,
cf, MUI_BUTTON_STYLE_CHECKBOX,
checkbox_title, 0);
c2_rect_right_of(&cf, cf.r, margin * 0.5);
cf.r = c2_rect_width(&w->frame) - margin * 1.2;
out->warning = c = mui_textbox_new(w, cf,
"", NULL,
MUI_TEXT_ALIGN_MIDDLE|MUI_TEXT_ALIGN_RIGHT);
}
return 0;
}