Skip to content

LayoutAndVectorAPIs.md

Noah Gibbs edited this page Oct 10, 2023 · 2 revisions

Layout and Vector APIs

When we bind to an underlying library (LibUI, GTK+, even HTML+CSS), they often have a drawable-layout based primary API. It's common to do layout with things like Stacks and Flows, or equivalent containers for various drawable libraries.

However, for pixel-exact placement or unusual shapes, it's common to have one or more fallback vector APIs that do drawing in a more dynamic way. In HTML this can mean the Canvas API or the SVG API. For LibUI, it's the Area API. For GTK+, it includes things like Cairo drawing areas.

Shoes also has this, with the animate/motion drawables.

It's possible to do "normal" layout-based Shoes with a vector backend, such as drawing a Shoes Para onto an HTML Canvas or a LibUI Area. But it makes it hard because we need to calculate sizes and layouts -- if you have a Stack with 3 Paras and then an image, you may have to calculate things like text wrapping to find out exactly how many pixels downward the image starts.

Where possible, it's nice to do layouts as layouts, and let the back-end library calculate them for us.