Skip to main content

Getting started

Start by building and running the demo. For build or runtime errors, see Troubleshooting.

Build and run the demo​

You need CMake 3.23+ and a C11 compiler. raylib is downloaded automatically if it isn't installed.

cmake -S . -B build
cmake --build build
./build/examples/ccompose_demo # Windows: build\examples\Debug\ccompose_demo.exe
ctest --test-dir build --output-on-failure # run the tests

Close the window to quit.

See Building for platform packages, vcpkg, cross-compiling, headless builds, and CMake options. See Web (WASM) for browser builds.

Your first program​

#include "ccompose.h"

int main(void) {
CC_SetWindow(960, 640, "My first ccompose app");
CC_SetBackground(Color(18, 18, 20, 255));
CC_Init();

while (CC_Running()) {
CC_Begin();

Column("Root",
.layout = { .sizing = { Grow(), Grow() },
.padding = PadAll(24),
.childGap = 12 }) {

Text("Hello, ccompose!",
.textColor = Color(236, 236, 236, 255),
.fontSize = 32);

Row("Toolbar",
.layout = { .childGap = 8,
.childAlignment = { .y = AlignYCenter() } }) {
Text("File", .textColor = Color(200,200,200,255), .fontSize = 14);
Text("Edit", .textColor = Color(200,200,200,255), .fontSize = 14);
Text("View", .textColor = Color(200,200,200,255), .fontSize = 14);
}
}

CC_End();
}

CC_Shutdown();
return 0;
}

Link against the ccompose::ccompose CMake target:

add_subdirectory(third_party/ccompose)
target_link_libraries(my_app PRIVATE ccompose::ccompose)

Building also covers find_package(ccompose) after an install.

Next steps​

  • Lifecycle: CC_Init, CC_Begin, CC_End, fonts, error handlers
  • Containers: Column, Row, Box, Element and how they nest
  • Interaction: add clickable Buttons with hover feedback
  • Progress: show a progress bar or ring, with a value or animated