slider widget, tons of fixes and improvements for win32, reworked font loading.

This commit is contained in:
Patrick 2025-10-07 21:45:48 +02:00
commit 69f8a273f3
18 changed files with 452 additions and 90 deletions

View file

@ -34,6 +34,71 @@ void pgpl_gui_theme_configure(PGPL_GuiTheme *theme, PGPL_Color base_color,
theme->font = font;
}
void pgpl_gui_widget_adjust_event_params(PGPL_GuiWidget *widget,
PGPL_GuiTheme *theme, double *x,
double *y, double *max_width,
double *max_height) {
double width, height;
pgpl_gui_widget_max_content_size(widget, theme, &width, &height, *max_width,
*max_height);
widget->get_content_size(widget, theme, &width, &height, width, height);
if (!widget->expand_x) {
*max_width = width;
if (!widget->ignore_margin) {
*max_width += theme->margin.left + theme->margin.right;
}
if (!widget->ignore_border) {
*max_width += theme->border.left + theme->border.right;
}
if (!widget->ignore_padding) {
*max_width += theme->padding.left + theme->padding.right;
}
}
if (!widget->expand_y) {
*max_height = height;
if (!widget->ignore_margin) {
*max_height += theme->margin.top + theme->margin.bottom;
}
if (!widget->ignore_border) {
*max_height += theme->border.top + theme->border.bottom;
}
if (!widget->ignore_padding) {
*max_height += theme->padding.top + theme->padding.bottom;
}
}
if (!widget->ignore_margin) {
*x += theme->margin.left;
*y += theme->margin.top;
*max_width -= theme->margin.left + theme->margin.right;
*max_height -= theme->margin.top + theme->margin.bottom;
}
if (!widget->ignore_border) {
*x += theme->border.left;
*y += theme->border.top;
*max_width -= theme->border.left + theme->border.right;
*max_height -= theme->border.top + theme->border.bottom;
}
if (!widget->ignore_padding) {
*x += theme->padding.left;
*y += theme->padding.top;
*max_width -= theme->padding.left + theme->padding.right;
*max_height -= theme->padding.top + theme->padding.bottom;
}
*x += (*max_width - width) / 2;
*y += (*max_height - height) / 2;
}
void pgpl_gui_widget_max_content_size(PGPL_GuiWidget *widget,
PGPL_GuiTheme *theme, double *width,
double *height, double max_width,
@ -67,11 +132,13 @@ void pgpl_gui_widget_render_full(PGPL_GuiWidget *widget,
theme = &widget->theme_override;
}
x += +widget->offset_x;
y += +widget->offset_y;
x += widget->offset_x;
y += widget->offset_y;
widget->get_content_size(widget, theme, &width, &height, max_width,
max_height);
pgpl_gui_widget_max_content_size(widget, theme, &width, &height, max_width,
max_height);
widget->get_content_size(widget, theme, &width, &height, width, height);
if (!widget->expand_x) {
max_width = width;
@ -143,6 +210,13 @@ void pgpl_gui_widget_render_full(PGPL_GuiWidget *widget,
widget->render_content(widget, renderer, theme, x, y, max_width, max_height);
}
bool pgpl_gui_widget_within_area(double x, double y, double area_x,
double area_y, double area_width,
double area_height) {
return (x >= area_x && x <= (area_x + area_width)) &&
(y >= area_y && y <= (area_y + area_height));
}
bool pgpl_gui_widget_within_bounds(PGPL_GuiWidget *widget, PGPL_GuiTheme *theme,
double widget_x, double widget_y,
double max_width, double max_height,
@ -155,12 +229,8 @@ bool pgpl_gui_widget_within_bounds(PGPL_GuiWidget *widget, PGPL_GuiTheme *theme,
max_width -= theme->margin.left + theme->margin.right;
max_height -= theme->margin.top + theme->margin.bottom;
if ((x >= widget_x && x <= (widget_x + max_width)) &&
(y >= widget_y && y <= (widget_y + max_height))) {
return true;
}
return false;
return pgpl_gui_widget_within_area(x, y, widget_x, widget_y, max_width,
max_height);
}
void pgpl_gui_widget_configure(PGPL_GuiWidget *widget, double offset_x,