aboutsummaryrefslogtreecommitdiff
path: root/src/saffron_widget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/saffron_widget.c')
-rw-r--r--src/saffron_widget.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/saffron_widget.c b/src/saffron_widget.c
index 850d1b8..8612557 100644
--- a/src/saffron_widget.c
+++ b/src/saffron_widget.c
@@ -4,6 +4,7 @@
#include <saffron.h>
void saffron_widget_init(SaffronWidget* widget) {
+ /* This function is a generic primitive for initializing widgets. You wouldn't want to do this manually unless you're a lunatic. It is meant to be wrapped around by other functions that change the default parameters, for example, what sane person makes a widget 0x0x0x0? you LUNATIC! */
widget->x = 0;
widget->y = 0;
widget->w = 0;
@@ -15,10 +16,14 @@ void saffron_widget_init(SaffronWidget* widget) {
widget->parent = NULL;
widget->children = NULL;
widget->child_count = 0;
+
+ widget->width_mode = SAFFRON_SIZE_FIXED;
+ widget->height_mode = SAFFRON_SIZE_FIXED;
+ widget->pixel_perfect = false;
}
SaffronWidget* saffron_widget_new(void) {
- /* This function is a generic primitive for creating widgets. You wouldn't want to do this manually unless you're a lunatic. It is meant to be wrapped around by other functions that change the default parameters, for example, what sane person makes a widget 0x0x0x0? you LUNATIC! */
+ /* also generic primitive, refer to above comment in saffron_widget_init */
SaffronWidget* widget = malloc(sizeof(SaffronWidget));
if (widget) {
saffron_widget_init(widget);
@@ -63,21 +68,21 @@ void saffron_widget_add_child(SaffronWidget *parent, SaffronWidget *child) {
SaffronWidget* saffron_widget_hit_test(SaffronWidget* widget, int x, int y) {
if (!widget) {
- printf("[saffron] hit test: widget is NULL!\n");
+ printf("[Saffron] hit test: widget is NULL!\n");
return NULL;
}
if (x < widget->x || x > widget->x + widget->w) {
- printf("[saffron] hit test: widget failed X bounds check!\n");
+ printf("[Saffron] hit test: widget failed X bounds check!\n");
return NULL;
}
if (y < widget->y || y > widget->y + widget->h) {
- printf("[saffron] hit test: widget failed Y bounds check!\n");
+ printf("[Saffron] hit test: widget failed Y bounds check!\n");
return NULL;
}
// check children front to back
for (int i = widget->child_count - 1; i >= 0; i--) {
- printf("[saffron] recursing to child (%i)\n", i);
+ printf("[Saffron] recursing to child (%i)\n", i);
SaffronWidget* hit = saffron_widget_hit_test(widget->children[i], x, y);
if (hit) return hit;
}