I'm working on a small GUI, and I want to have a vertical fuel-gauge gadget with a 2-line label centred above it. This sounds like it should be simple, but I just cannot get it aligned right.
Here are the problems I have encountered so far:
- The layout gadget only allows labels to be to the left or right of gadgets, so putting labels above or below a gadget isn't natively supported
- The documentation suggests using the layout gadget's own label field, but it doesn't support multi-line labels. Putting a '\n' in it, results in an ugly box being printed instead of starting a new line
- I cannot use a string gadget, because it doesn't provide full control over its border style
- I tried using a read-only button gadget, but it also doesn't support multi-line labels
- I also tried just adding a label.image object (which does support multi-line labels) to the layout, but that simply isn't rendered
- I have had the best success by putting a label.image inside a read-only button gadget, but the label is shifted 5 pixels or so to the right
So, what would be the best way of getting a properly centred multi-line label above a fuelgauge gadget (or any other gadget type)? It seems like I really need to jump through hoops to get things to look the way that I want them to.
Hans
Did you use LAYOUT_AddImage or LAYOUT_AddChild to this? LAYOUT_AddChild won't work as label.image is a subclass of imageclass and not gadgetclass.
How?
An OM_GET attribute could be added in gadgetclass, imageclass and datatypeclass that returns an appropriate value in each case.
Edit: This wouldn't work with non-BOOPSI gadgets and images though, but existing tags could always be used for those cases. An idea might be to rename current LAYOUT_AddChild to LAYOUT_AddGadget and add a new tag LAYOUT_AddChild tag that only works with BOOPSI objects.