Well, in new Espruino firmwares (cutting edge, or 2v11 when released) you can actually put a binary image inside a text string like this, and alignment and newlines are handled correctly. There's a new 'stringMetrics' too which gives you width/height of a string (even including inline images) and I'll move the layout over to using that soon.
So in a way, you can actually do the 'simple' option right now - just set the label to the "\0" plus the image. If you want text under, do "\0"+image+"\nMy Label".
However probably one big use case is going to be toggle buttons - so press once and the image changes to 'on', again for 'off', so probably something that allows you to change the image easily is better.
So yeah, maybe we just look for a c in the button object containing a single layout, and if so we make the size whatever the size of the layout object is inside it, plus some padding? It shouldn't need much in the way of code changes at all.
You can still do the 'quick' image icon, or can do it properly
© Espruino, powered by microcosm.
Report a problem