// render.h - UI scaling, colormaps, spectrogram texture generation, drawing #ifndef RENDER_H #define RENDER_H #include "spectrogram_types.h" // --- UI scaling & scaled text --- float GetUIScale(void); void DrawTextScaled(const char* text, float x, float y, float baseSize, Color color); float MeasureTextScaled(const char* text, float baseSize); // --- DPI-aware UI font --- // InitUIFont remembers the TTF path and bakes the first atlas; EnsureUIFont // rebuilds it (cheap no-op when unchanged) whenever the effective pixel density // (window UI scale * monitor DPI scale) shifts, keeping text crisp on any // display instead of thinning out on standard-DPI screens. Call EnsureUIFont // once per frame before drawing text. void InitUIFont(const char* path); void EnsureUIFont(void); // --- Colormaps --- void GenerateColormapTexture(void); const char* ColormapName(ColormapType type); // --- Spectrogram texture --- // GenerateSpectrogramTexture recomputes the synchrosqueezed reassignment (use // when the STFT changes). ColorizeSpectrogram only re-maps the cached // reassignment to colors (use for dB-floor / colormap changes). void GenerateSpectrogramTexture(StftResult* stft, Image* image, Texture2D* texture); void ColorizeSpectrogram(Image* image, Texture2D* texture); // --- Headless (no-GL) spectrogram + annotation rendering --- // BuildSpectrogramImageCPU fills `image` with the colorized spectrogram with no // texture upload, so it runs with no window / no X server. LoadFontCPU returns // a Font usable by ImageDrawTextEx without a GL context (glyphCount==0 on // failure). DrawAnnotationsToImage paints the mLnL overlay onto a full- // resolution spectrogram Image, honoring the kind filter and resting opacity. void BuildSpectrogramImageCPU(StftResult* stft, Image* image); Font LoadFontCPU(const char* path, int baseSize); void DrawAnnotationsToImage(Image* img, Font font); // --- On-screen drawing (operate on the global app state) --- void DrawSpectrogramGrid(Rectangle bounds, int numCellsX, int numCellsY, Color color); void DrawLabels(Rectangle bounds); void DrawSelection(Rectangle bounds); void DrawSelectionDrag(Rectangle bounds); void DrawCursorReadout(Rectangle bounds); void DrawMarkers(Rectangle bounds); void DrawSpectrumPanel(Rectangle bounds); void DrawPlayhead(Rectangle bounds); void DrawAnnotations(Rectangle bounds); // Annotation timeline lane. Updates app.hoveredTimelineEvent and // app.selectedAnnotation in response to mouse interaction in `lane`. void DrawTimeline(Rectangle lane); // Time-only annotation overlay rendered on top of the waveform scope. // Shares opacity/selection state with the spectrogram overlay. void DrawAnnotationsOnScope(Rectangle scopeBounds); #endif // RENDER_H