bento_examples
Some examples for the Bento library
A set of C example programs showing how to build resizable panel layouts, like sidebars and splitters, with the Bento layout library.
This repository is a collection of example programs written in C that demonstrate how to use the Bento library. Bento is a layout library, a tool that helps you arrange panels and regions on screen, similar to how you would divide a window into a sidebar on the left and a main content area on the right.
The examples walk through progressively more complex layout scenarios. A two-panel layout example shows how to set up a sidebar with a fixed width next to a main panel that fills the remaining space. A three-panel layout example adds a splitter between the panels, a draggable divider that lets the user resize the sections at runtime. There is also a more complex demo called ImBento that integrates Bento with Dear ImGui, a popular immediate-mode graphical interface library, demonstrating a multi-region layout with top, bottom, left, right, and center panels, each with their own sizing rules and nested splitters.
The C code in the examples uses Bento's API directly, declaring layout elements with sizing parameters that control whether a panel has a fixed size, fills available space, or grows and shrinks proportionally. The project is built with CMake, and the README includes commands to generate a Visual Studio 2022 solution for building on Windows.
Where it fits
- Learn how to build a two-panel sidebar and main content layout with the Bento library.
- See how draggable splitters let users resize panels at runtime.
- Study how Bento integrates with Dear ImGui to build a multi-region editor layout.
- Use these examples as a starting point for a custom C UI layout system.