What I learned designing a barebones UI engine

madebymohammed.com

58 points by teleforce 11 hours ago


cardanome - 3 hours ago

Immediate mode GUI is the way to go.

Retaining state is a pain and causes bugs. Trying to get fancy a la react and diffing the tree for changes makes not sense. That was a performance hack because changing the DOM in JS used to be slow as hell. You don't need that.

Just redraw the whole thing every frame. Great performance, simple, less bugs.

dazzawazza - 3 hours ago

> While it’s far from perfect, writing it taught me more about UI systems than I ever would have learned by sticking to established solutions alone.

This is a great attitude to have. Keep up the great work.

threetwoonezero - 3 hours ago

Had a similar itch during my game development with libgdx, and had almost same architecture eventually

I found that I have two different ways to construct UI layout , from top down, and from down to top, those could be contradictory, wonder how one could solve this, seems like common problem in all frameworks that I saw, like flutter just fail with error on screen if it can't solve restrictions in such conflict , others just show jiberish

giveexamples - 5 hours ago

rectcut is a good API for layout if you have a fixed viewport (eg eink display)

the API is a very simple one where you slice parts off an initial Rect. the only feature it provides is that it tracks (x, y, h, w) for you.

it doesn't work well with intrinsic sizes - it's more of a top down, fixed size thing.

mbmproductions - 8 hours ago

author here - thanks for posting :D would love to hear any thoughts or questions.