i'll just say it's better, and i ripped out the frontend for now.

This commit is contained in:
maksw committed 2025-11-23 20:49:24 +01:00
1 parent 97946c613a
commit 51c3f6bacc
14 files changed
+1111 -1358

No files matched your search

+28 -27
View File
@@ -1,7 +1,6 @@
// compositor.h
#ifndef COMPOSITOR_H
#define COMPOSITOR_H
#include <stdint.h>
#include <stdbool.h>
@@ -26,7 +25,6 @@ enum easing_t {
};
extern "C" {
typedef struct compositor_t compositor_t;
// Initialize compositor with given dimensions
@@ -37,33 +35,30 @@ void compositor_destroy(compositor_t* comp);
// Insert element, returns unique ID
uint32_t compositor_insert(compositor_t* comp,
const uint32_t* fb,
uint32_t fb_width,
uint32_t fb_height,
int32_t x, int32_t y,
int32_t z_order, float scale = 1.0f);
const uint32_t* fb,
uint32_t fb_width,
uint32_t fb_height,
int32_t x, int32_t y,
int32_t z_order, float scale = 1.0f);
// Remove element by ID
void compositor_remove(compositor_t* comp, uint32_t id);
// AIO Update element properties
void compositor_update(compositor_t* comp, uint32_t id,
int32_t x, int32_t y,
int32_t z_order, float scale,
bool visible); // holy clusterfuck
int32_t x, int32_t y,
int32_t z_order, float scale,
bool visible);
// Individual setters
void compositor_set_position(compositor_t* comp, uint32_t id,
int32_t x, int32_t y);
int32_t x, int32_t y);
void compositor_set_zorder(compositor_t* comp, uint32_t id,
int32_t z_order);
int32_t z_order);
void compositor_set_visible(compositor_t* comp, uint32_t id,
bool visible);
bool visible);
void compositor_set_scale(compositor_t* comp, uint32_t id,
float scale);
float scale);
// Advances all animations by a given time delta.
void compositor_tick(compositor_t* comp, float delta_time_sec);
@@ -71,20 +66,29 @@ void compositor_tick(compositor_t* comp, float delta_time_sec);
// Instantly sets the element-wide alpha.
void compositor_set_alpha(compositor_t* comp, uint32_t id, float alpha);
// Starts a "slide" animation on an element.
// Animation functions with queue parameter
void compositor_animate_move(compositor_t* comp, uint32_t id,
int32_t to_x, int32_t to_y,
float duration_sec, easing_t easing);
float duration_sec, easing_t easing, bool queue = false);
// Starts a "fade" or "dissolve" animation on an element.
void compositor_animate_fade(compositor_t* comp, uint32_t id,
float to_alpha,
float duration_sec, easing_t easing);
float duration_sec, easing_t easing, bool queue = false);
// Starts a "scale" animation on an element.
void compositor_animate_scale(compositor_t* comp, uint32_t id,
float to_scale,
float duration_sec, easing_t easing);
float duration_sec, easing_t easing, bool queue = false);
// Immediately complete all animations
void compositor_animation_complete(compositor_t* comp, uint32_t id);
void compositor_animation_complete_all(compositor_t* comp);
// Returns true if any element is animating or has queued animations.
bool compositor_is_animating(compositor_t * comp);
// Returns true if the specified element is animating or has queued animations.
bool compositor_is_element_animating(compositor_t* comp, uint32_t id);
// Compose all visible elements and return framebuffer pointer
const uint32_t* compositor_compose(compositor_t* comp);
@@ -93,9 +97,6 @@ void compositor_mark_content_dirty(compositor_t* comp, uint32_t id);
void compositor_mark_all_dirty(compositor_t* comp);
// Returns the last error message set for this compositor instance.
// Returns nullptr if no error has occurred.
const char* compositor_get_last_error(compositor_t* comp);
}
#endif // COMPOSITOR_H
#endif // COMPOSITOR_H
+3 -2
View File
@@ -5,10 +5,11 @@
#include <stdint.h>
extern "C" {
// Loads an image file as ARGB8888. Returns pointer to pixel data (free with image_free), sets width/height.
// Loads an image file as ARGB8888. Returns pointer to pixel data, sets width/height.
uint32_t* image_load(const char* filename, int* width, int* height);
// Loads and resizes an image file to desired dimensions as ARGB8888. Returns pointer to pixel data (free with image_free).
// Loads and resizes an image file to desired dimensions as ARGB8888. Returns pointer to pixel data.
uint32_t* image_load_resized(const char* filename, int desired_width, int desired_height);
// Frees image data.
void image_free(uint32_t* data);
}
+11 -5
View File
@@ -7,22 +7,28 @@
struct text_t;
extern "C" {
// initializes a new text renderer with given width and height
text_t* text_init(int width, int height);
// shares cache, prefer when using the same font to save memory
text_t* text_init_shared(text_t* source, int width, int height);
// destroys the text renderer and frees resources
void text_destroy(text_t* text);
// pushes new text buffer to be rendered, can be stacked
void text_push(text_t* text,
const char* str,
float size,
float speed,
const char* font_path,
bool outline);
// finish current text immediately
// load font and set as current font
void text_set_font(text_t* text, const char* font_path, float size);
// finish whole current text buffer immediately
void text_show_all_current(text_t* text);
// returns true if text is still animating
bool text_is_animating(text_t* text);
// advance, call every frame, returns false when done
// advance, call every frame, returns true when it touched the framebuffer
bool text_nextframe(text_t* text, float deltatime);
uint32_t* text_getfb(text_t* text);
// gets the framebuffer of the text renderer
const uint32_t* text_getfb(text_t* text);
// clears the text buffer and the frame buffer
void text_clear(text_t* text);
}
+7
View File
@@ -35,12 +35,19 @@ typedef struct window_t window_t;
#define KEY_0 39
extern "C" {
// creates a window with given width, height and title, title can be utf8
window_t* window_create(int width, int height, const char* title);
// destroys the window
void window_destroy(window_t* s);
// polls window events, returns true if the window should close
bool window_pollevent(window_t* s);
// blits the given framebuffer to the window. must be the same size as the window and ARGB8888 format
void window_blit(window_t* s, const uint32_t* framebuffer);
// returns true if the given key is currently held down
bool window_is_key_down(window_t* s, int key_scancode);
// returns true if the given mouse button is currently held down
bool window_is_mouse_button_down(window_t* s, int button_index);
// gets the current mouse position in window coordinates
void window_get_mouse_position(window_t* s, int* x, int* y);
}