window_get_mouse_position returns a struct, claude wrote me a state machine for main.cpp, compositor queues animations on type instead of one queue, change from uint32_t to *_handle_t, improve compositor performance, generic raii wrapper in main.cpp over multiple structs.
This commit is contained in:
1 parent
a12c9a3e8f
commit
02b5bc8b52
7 files changed
+748
-490
No files matched your search
+9
-8
@@ -12,6 +12,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct audio_t audio_t;
|
||||
typedef uint32_t audio_stream_id_t;
|
||||
|
||||
// If the return type is bool, false means failure.
|
||||
|
||||
@@ -34,7 +35,7 @@ void audio_free_data(uint8_t* data);
|
||||
// data must remain valid until the stream ends or is stopped
|
||||
// loop: if true, the stream restarts on EOF
|
||||
// 0 means failure, valid IDs start from 1
|
||||
uint32_t audio_play(audio_t* audio,
|
||||
audio_stream_id_t audio_play(audio_t* audio,
|
||||
const uint8_t* data,
|
||||
int size,
|
||||
int channels,
|
||||
@@ -42,22 +43,22 @@ uint32_t audio_play(audio_t* audio,
|
||||
bool loop);
|
||||
|
||||
// Stop and remove stream by ID
|
||||
bool audio_stop(audio_t* audio, uint32_t id);
|
||||
bool audio_stop(audio_t* audio, audio_stream_id_t id);
|
||||
|
||||
bool audio_pause(audio_t* audio, uint32_t id);
|
||||
bool audio_resume(audio_t* audio, uint32_t id);
|
||||
bool audio_pause(audio_t* audio, audio_stream_id_t id);
|
||||
bool audio_resume(audio_t* audio, audio_stream_id_t id);
|
||||
|
||||
// Returns true if the stream is active (playing or paused)
|
||||
bool audio_is_active(audio_t* audio, uint32_t id);
|
||||
bool audio_is_active(audio_t* audio, audio_stream_id_t id);
|
||||
|
||||
// Returns true if the stream is currently playing (not paused, not stopped)
|
||||
bool audio_is_playing(audio_t* audio, uint32_t id);
|
||||
bool audio_is_playing(audio_t* audio, audio_stream_id_t id);
|
||||
|
||||
// Per-stream volume, immediate effect, range [0.0, 1.0]
|
||||
bool audio_set_volume(audio_t* audio, uint32_t id, float volume);
|
||||
bool audio_set_volume(audio_t* audio, audio_stream_id_t id, float volume);
|
||||
|
||||
// Animate per-stream volume linearly over time, driven by audio_tick()
|
||||
bool audio_animate_volume(audio_t* audio, uint32_t id,
|
||||
bool audio_animate_volume(audio_t* audio, audio_stream_id_t id,
|
||||
float to_volume, float duration_sec);
|
||||
|
||||
// Global volume, immediate effect, range [0.0, 1.0]
|
||||
|
||||
+18
-23
@@ -41,6 +41,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct compositor_t compositor_t;
|
||||
typedef uint32_t element_handle_t;
|
||||
|
||||
// If the return type is bool, false means failure.
|
||||
|
||||
@@ -55,7 +56,7 @@ void compositor_destroy(compositor_t* comp);
|
||||
// FB format is ARGB8888 and it always will be
|
||||
// The compositor takes a reference, caller must keep alive until removed
|
||||
// 0 means failure, valid IDs start from 1
|
||||
uint32_t compositor_insert(compositor_t* comp,
|
||||
element_handle_t compositor_insert(compositor_t* comp,
|
||||
const uint32_t* fb,
|
||||
uint32_t fb_width,
|
||||
uint32_t fb_height,
|
||||
@@ -64,24 +65,18 @@ uint32_t compositor_insert(compositor_t* comp,
|
||||
anchor_point_t anchor);
|
||||
|
||||
// Remove element by ID
|
||||
bool compositor_remove(compositor_t* comp, uint32_t id);
|
||||
bool compositor_remove(compositor_t* comp, element_handle_t id);
|
||||
|
||||
// AIO Update element properties, immediate effect
|
||||
bool compositor_update(compositor_t* comp, uint32_t id,
|
||||
int32_t x, int32_t y,
|
||||
int32_t z_order, float scale,
|
||||
bool visible, float alpha);
|
||||
|
||||
// Individual setters, immediate effect
|
||||
bool compositor_set_position(compositor_t* comp, uint32_t id,
|
||||
// Setters, immediate effect
|
||||
bool compositor_set_position(compositor_t* comp, element_handle_t id,
|
||||
int32_t x, int32_t y);
|
||||
bool compositor_set_zorder(compositor_t* comp, uint32_t id,
|
||||
bool compositor_set_zorder(compositor_t* comp, element_handle_t id,
|
||||
int32_t z_order);
|
||||
bool compositor_set_scale(compositor_t* comp, uint32_t id,
|
||||
bool compositor_set_scale(compositor_t* comp, element_handle_t id,
|
||||
float scale);
|
||||
bool compositor_set_visible(compositor_t* comp, uint32_t id,
|
||||
bool compositor_set_visible(compositor_t* comp, element_handle_t id,
|
||||
bool visible);
|
||||
bool compositor_set_alpha(compositor_t* comp, uint32_t id,
|
||||
bool compositor_set_alpha(compositor_t* comp, element_handle_t id,
|
||||
float alpha);
|
||||
|
||||
// Advances all animations by a given time delta.
|
||||
@@ -91,31 +86,31 @@ void compositor_tick(compositor_t* comp, float delta_time_sec);
|
||||
// Queue means the animation will start after the previous animation completed
|
||||
// Not queueing will play the animation alongside any current animation
|
||||
// You cannot stack the same type of animation without queueing, the second call will cancel the first call.
|
||||
bool compositor_animate_move(compositor_t* comp, uint32_t id,
|
||||
bool compositor_animate_move(compositor_t* comp, element_handle_t id,
|
||||
int32_t to_x, int32_t to_y,
|
||||
float duration_sec, easing_t easing, bool queue);
|
||||
bool compositor_animate_fade(compositor_t* comp, uint32_t id,
|
||||
float duration_sec, easing_t easing, bool queue, bool parallel);
|
||||
bool compositor_animate_fade(compositor_t* comp, element_handle_t id,
|
||||
float to_alpha,
|
||||
float duration_sec, easing_t easing, bool queue);
|
||||
bool compositor_animate_scale(compositor_t* comp, uint32_t id,
|
||||
float duration_sec, easing_t easing, bool queue, bool parallel);
|
||||
bool compositor_animate_scale(compositor_t* comp, element_handle_t id,
|
||||
float to_scale,
|
||||
float duration_sec, easing_t easing, bool queue);
|
||||
float duration_sec, easing_t easing, bool queue, bool parallel);
|
||||
|
||||
// Immediately finish all animations on a specific object (optionally only N queued, 0 = all), or every object.
|
||||
bool compositor_animation_finish_element(compositor_t* comp, uint32_t id, int num_queued /*0=all*/);
|
||||
bool compositor_animation_finish_element(compositor_t* comp, element_handle_t id, int num_queued /*0=all*/);
|
||||
void compositor_animation_finish_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);
|
||||
bool compositor_is_element_animating(compositor_t* comp, element_handle_t id);
|
||||
|
||||
// Compose all visible elements and return framebuffer pointer
|
||||
const uint32_t* compositor_compose(compositor_t* comp);
|
||||
|
||||
// Mark an element's content as dirty for redrawing
|
||||
bool compositor_mark_content_dirty(compositor_t* comp, uint32_t id);
|
||||
bool compositor_mark_content_dirty(compositor_t* comp, element_handle_t id);
|
||||
void compositor_mark_all_dirty(compositor_t* comp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+3
-1
@@ -53,6 +53,8 @@ extern "C" {
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
typedef struct { int x, y; } mouse_pos_t;
|
||||
|
||||
// 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
|
||||
@@ -66,7 +68,7 @@ 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);
|
||||
mouse_pos_t window_get_mouse_position(window_t* s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user