- include/kry_math.h: Vector2 math and KryTransform2D (compose/point/camera) - include/scene_tree.h + src/scene/scene_tree.c: KryScene/KryNode retained node tree with array arena, parent/child links, world-transform update, lifecycle vtable (ready/process/physics_process/draw), KrySceneTick/ PhysicsTick/Draw driver - include/node2d_props.h: Camera2DProps, Sprite2DProps - Rename UI Sprite widget to Picture (raylib owns Image as a struct): ui_sprite.h -> ui_picture.h, SpriteProps -> PictureProps, UISpriteFit -> UIPictureFit, UI_SPRITE_FIT_* -> UI_PICTURE_FIT_*, Sprite() -> Picture(); extract shared texture cache to src/ui/ui_picture_cache.c (KryLoadPictureTexture, KryPictureFitRect) shared by the Picture widget and the upcoming Sprite2D scene node - Migrate example, docs, node registry to the Picture name
49 lines
1.4 KiB
C
49 lines
1.4 KiB
C
#ifndef UI_PICTURE_H
|
|
#define UI_PICTURE_H
|
|
|
|
/*
|
|
* UI picture widget + shared picture texture cache.
|
|
*
|
|
* The immediate-mode UI Picture widget (Picture/PictureProps) and the retained
|
|
* Sprite2D scene node both load textures through KryLoadPictureTexture so a
|
|
* path is loaded at most once regardless of which tree draws it. Named
|
|
* "Picture" rather than "Image" because raylib already owns `Image` as a
|
|
* decoded-image-in-memory struct type.
|
|
*/
|
|
|
|
#include "kryon_compat.generated.h"
|
|
|
|
#define KRY_PICTURE_CACHE_MAX 128
|
|
|
|
typedef enum UIPictureFit {
|
|
UI_PICTURE_FIT_STRETCH,
|
|
UI_PICTURE_FIT_CONTAIN,
|
|
UI_PICTURE_FIT_COVER
|
|
} UIPictureFit;
|
|
|
|
typedef struct PictureProps {
|
|
const char *asset_path;
|
|
Rectangle bounds;
|
|
Rectangle source;
|
|
Vector2 origin;
|
|
float rotation;
|
|
Color tint;
|
|
UIPictureFit fit;
|
|
} PictureProps;
|
|
|
|
/*
|
|
* Load (or return cached) texture for `path`. The path may be a runtime file or
|
|
* an embedded asset name. Returns a zero-id texture on failure. The returned
|
|
* texture is owned by the cache; callers must not UnloadTexture it.
|
|
*/
|
|
Texture2D KryLoadPictureTexture(const char *path);
|
|
|
|
/*
|
|
* Compute the destination rectangle for a picture given its fit mode and the
|
|
* source texture dimensions. STRETCH/CONTAIN/COVER behavior is shared by the
|
|
* UI Picture widget and the Sprite2D scene node so both draw identically.
|
|
*/
|
|
Rectangle KryPictureFitRect(PictureProps picture, Texture2D texture);
|
|
|
|
#endif
|