YrXtals/include/yr_xtals.h

101 lines
4.3 KiB
C

#ifndef YR_XTALS_H
#define YR_XTALS_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct ViewportHandle ViewportHandle;
/// Owns the iOS view's wgpu surface, iced renderer, and App state.
struct ViewportHandle *viewport_create(void *uiview, float width, float height, float scale);
void viewport_destroy(struct ViewportHandle *handle);
void viewport_render(struct ViewportHandle *handle);
void viewport_resize(struct ViewportHandle *handle, float width, float height, float scale);
/// pushes a single-pointer touch event with implicit-Left button into the iced runtime.
void viewport_touch_event(struct ViewportHandle *handle,
float x,
float y,
bool pressed,
bool moved);
void viewport_key_event(struct ViewportHandle *handle,
uint32_t key,
uint32_t modifiers,
bool pressed,
const char *text);
/// drains the pending-picker flag (0 none, 1 folder, 2 file) and returns the prior value.
uint8_t viewport_take_pending_pick(struct ViewportHandle *handle);
/// drains the pending playback-capture action flag (0 idle, 1 start, 2 stop).
uint8_t viewport_take_pending_capture_action(struct ViewportHandle *handle);
void viewport_apply_picked_folder(struct ViewportHandle *handle, const char *path);
void viewport_apply_picked_file(struct ViewportHandle *handle, const char *path);
void viewport_apply_picked_files(struct ViewportHandle *handle,
const char *const *paths,
size_t count);
/// drives the import progress bar, cleared by total=0.
void viewport_set_library_progress(struct ViewportHandle *handle,
uint32_t current,
uint32_t total);
/// shows the modal coordinator-wait overlay with a UTF-8 message; null pointer clears.
void viewport_set_coordinating_message(struct ViewportHandle *handle, const char *msg);
/// pushes parallel arrays of placeholder titles and track-number tags (0 = unknown) into the sidebar.
void viewport_set_pending_titles(struct ViewportHandle *handle,
const char *const *titles,
const uint32_t *track_numbers,
size_t count);
/// fills in the file path of a pending track once export finishes.
void viewport_set_track_path(struct ViewportHandle *handle,
size_t idx,
const char *path);
/// pushes JPEG/PNG artwork bytes for a track through the art decode thread.
void viewport_set_track_art(struct ViewportHandle *handle,
size_t idx,
const uint8_t *bytes,
size_t len);
/// switches the top-level playback mode: 0 = Local file playback, 1 = Playback capture from the OS.
void viewport_set_playback_mode(struct ViewportHandle *handle, uint32_t mode);
/// pushes a chunk of interleaved f32 PCM captured by the shell into the playback-capture pipeline.
void viewport_push_capture_pcm(struct ViewportHandle *handle,
const float *samples,
size_t sample_count,
uint32_t sample_rate,
uint32_t channels);
/// updates the now-playing metadata for Playback capture mode. clears fields on null pointers.
void viewport_set_capture_metadata(struct ViewportHandle *handle,
const char *title,
const char *artist,
uint64_t position_ms,
uint64_t duration_ms);
/// serializes both settings slots as a JSON string. caller frees via viewport_free_string.
char *viewport_get_settings_json(struct ViewportHandle *handle);
/// applies a JSON settings blob loaded by the shell at startup. silent no-op on parse failure.
void viewport_set_settings_json(struct ViewportHandle *handle, const char *json);
/// drains the pending-persist flag set after a settings change.
bool viewport_take_pending_persist_settings(struct ViewportHandle *handle);
void viewport_free_string(char *s);
#endif