Custom drawing
Draw creates a container whose final position and size are handed to your callback, so you can draw anything with raylib inside a box that ccompose lays out.
Example
static void paint_bars(CC_BoundingBox bb, void *user) {
const float *values = user; // your own data
float w = bb.width / 3;
for (int i = 0; i < 3; ++i) {
float h = bb.height * values[i];
DrawRectangle((int)(bb.x + i * w), (int)(bb.y + bb.height - h),
(int)w - 4, (int)h, SKYBLUE);
}
}
static float values[3] = { 0.3f, 0.8f, 0.5f };
static void chart(void) {
Draw("Chart", paint_bars, values,
.layout = { .sizing = { Grow(), Fixed(120) } }) {}
}
Reference
| Name | Form | What it does | Page |
|---|---|---|---|
Draw | Draw("id", CC_DrawFn fn, void *user, .field = ...) { } | A Column whose final bounding box is passed to your callback, so you can draw into it with raylib. | Custom drawing |
DrawRow | DrawRow("id", fn, user, ...) { } | Same, with children flowing left to right. | Custom drawing |
DrawColumn | DrawColumn("id", fn, user, ...) { } | Same as Draw. | Custom drawing |
CC_DrawFn | void (*)(CC_BoundingBox bb, void *user) | Callback type. bb is in screen pixels. | Custom drawing |
CC_AcquireDrawSlot | CC_DrawSlot *(CC_DrawFn fn, void *user) | Pool call behind the macros. Use it to attach a callback to Element or another container. Returns NULL when the 128-entry pool is full. | Custom drawing |
CC_DrawSlot | struct | Pool entry. Don't fill it yourself. | Custom drawing |