Hi there, I’m wondering if there’s been any discussion around a composable layer above the widget API. I believe the vast majority of UI elements can be built with a relatively short list of components, stacks & callbacks - rectangles, circles, text, on_drag, on_hover etc.
Curious to know people’s thoughts - I think a composable API might be very nice to have in iced!
Oh, nice! I read through that discussion, my thoughts might be in the same vein.
My ideas on this came from reading the discussion around animation. If I remember correctly, one of the troubles with adding animation was that every widget is responsible for it’s own (relatively low level) rendering. The way to add new capabilities (such as interpolation) was to update every single widget.
Based on that - I think an API that provides a set of fundamental units could allow things to scale differently. Any capabilities added to the units could inherently be available to the widget which composes them.
The quick and dirty implementation I was messing around with was a widget that takes a set of “unit” elements like a stack would, draws them, & optionally handles some callbacks like ‘on_hover’ or ‘on_press’.
The definition of a custom widget with this approach looks something like this