diff options
| -rw-r--r-- | include/saffron_widget.h | 1 | ||||
| -rw-r--r-- | meson.build | 33 | ||||
| -rw-r--r-- | src/saffron_layout.c | 4 | ||||
| -rw-r--r-- | src/saffron_widget.c | 1 | ||||
| -rw-r--r-- | src/saffron_window.c | 4 |
5 files changed, 39 insertions, 4 deletions
diff --git a/include/saffron_widget.h b/include/saffron_widget.h index 8e7ad12..1383bd5 100644 --- a/include/saffron_widget.h +++ b/include/saffron_widget.h @@ -30,6 +30,7 @@ typedef struct SaffronWidget { SaffronWidgetType type; void (*free)(struct SaffronWidget* self); SaffronTheme* theme; + void (*on_resize)(struct SaffronWidget* self); } SaffronWidget; #endif diff --git a/meson.build b/meson.build index 14aa2f0..46be2e1 100644 --- a/meson.build +++ b/meson.build @@ -16,11 +16,28 @@ sources = [ 'src/saffron_event_hooks.c', ] -saffron_lib = static_library('saffron', sources, include_directories: inc, dependencies: deps) +saffron_lib = static_library('saffron', + sources, + include_directories: inc, + dependencies: deps, + install: true, + install_dir: 'lib' +) -test_deps = [] +install_headers( + 'include/saffron.h', + 'include/saffron_api.h', + 'include/saffron_button.h', + 'include/saffron_layout.h', + 'include/saffron_text.h', + 'include/saffron_theme.h', + 'include/saffron_widget.h', + 'include/saffron_window.h', + 'include/saffron_event_hooks.h', + subdir: 'saffron' +) -# demonstrate how we can statically link SDL and saffron into an application easily +test_deps = [] test_deps += dependency('sdl3', static: true) test_deps += dependency('sdl3-ttf', static: true) saffron_dep = declare_dependency(link_with: saffron_lib, include_directories: inc, dependencies: deps) @@ -28,3 +45,13 @@ test_deps += saffron_dep executable('saffron_test', 'tests/test_main.c', dependencies: test_deps) executable('saffron_hooks_test', 'tests/test_hooks.c', dependencies: test_deps) + +pkg = import('pkgconfig') +pkg.generate(saffron_lib, + subdirs: 'saffron', + version: '0.1', + name: 'saffron', + filebase: 'saffron', + description: 'Lightweight UI framework built on top of SDL3', + requires: ['sdl3', 'sdl3-ttf'], +) diff --git a/src/saffron_layout.c b/src/saffron_layout.c index 72d915c..4601e83 100644 --- a/src/saffron_layout.c +++ b/src/saffron_layout.c @@ -58,6 +58,10 @@ void saffron_box_layout(SaffronBox* box) { child->y = y_offset; y_offset += child->h + box->spacing; } + + if (child->on_resize) { + child->on_resize(child); + } if (child->type == SAFFRON_WIDGET_BOX) { saffron_box_layout((SaffronBox*)child); diff --git a/src/saffron_widget.c b/src/saffron_widget.c index 6cb1664..ac5e300 100644 --- a/src/saffron_widget.c +++ b/src/saffron_widget.c @@ -26,6 +26,7 @@ void saffron_widget_init(SaffronWidget* widget) { widget->type = SAFFRON_WIDGET_UNKNOWN; widget->free = NULL; widget->theme = NULL; + widget->on_resize = NULL; } SaffronWidget* saffron_widget_new(void) { diff --git a/src/saffron_window.c b/src/saffron_window.c index 34da341..6c89c50 100644 --- a/src/saffron_window.c +++ b/src/saffron_window.c @@ -7,6 +7,8 @@ #include <SDL3/SDL.h> #include <SDL3_ttf/SDL_ttf.h> #include <saffron.h> +#include <SDL3/SDL_egl.h> +#include <SDL3/SDL_opengles2.h> SaffronWindow* saffron_window_new(const char* title, int w, int h) { SaffronWindow* window = malloc(sizeof(SaffronWindow)); @@ -17,7 +19,7 @@ SaffronWindow* saffron_window_new(const char* title, int w, int h) { memset(window->hooks, 0, sizeof(window->hooks)); window->hook_count = 0; - Uint32 flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY; + Uint32 flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_OPENGL; window->sdl_window = SDL_CreateWindow(title, w, h, flags); window->renderer = SDL_CreateRenderer(window->sdl_window, NULL); window->root->theme = SF_MACRO_DEFAULT_THEME; |
