Reaction GUI and vertical layouts

9 posts / 0 new
Last post
Hans
Hans's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2010-12-09 22:04
Reaction GUI and vertical layouts

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

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
- I also tried just adding a


- I also tried just adding a label.image object (which does support multi-line labels) to the layout, but that simply isn't rendered

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.

Hans
Hans's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2010-12-09 22:04
Re: Reaction GUI and vertical layouts

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.

I completely overlooked that tag. Thanks for that. The labels are now aligned properly.

Hans

Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work

trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Reaction GUI and vertical layouts

@salass00

Did you use LAYOUT_AddImage or LAYOUT_AddChild to this?

I was just going to ask the same question :-) It's a common mistake.

LAYOUT_AddChild is a confusing misnomer because images are children as well, aren't they? So why do we have two different tags for the same thing (= adding a BOOPSI object)? It only reveals how brainless the original ClassAct/ReAction implementation was. Ideally, children objects should be added via a single tag regardless of type, and the layout should recognize internally whether it's a gadget or an image.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
and the layout should

and the layout should recognize internally whether it's a gadget or an image

How?

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
and the layout should



and the layout should recognize internally whether it's a gadget or an image

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.

trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Reaction GUI and vertical layouts

@thomas

How?

Don't know, I'm talking about how things should have been implemented, ideally. If a BOOPSI class cannot be identified other way than by associating it with a specific tag (LAYOUT_AddImage or LAYOUT_AddChild) then there's room for improvement in the BOOPSI system, too.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

Hans
Hans's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2010-12-09 22:04
Re: Reaction GUI and vertical layouts

@trixie

Don't know, I'm talking about how things should have been implemented, ideally. If a BOOPSI class cannot be identified other way than by associating it with a specific tag (LAYOUT_AddImage or LAYOUT_AddChild) then there's room for improvement in the BOOPSI system, too.

Since I also got tripped up by the confusing LAYOUT_AddChild/LAYOUT_AddImage combo, I agree that LAYOUT_AddChild should be able to handle everything. This wasted quite a bit of my time, and makes the learning curve just that little bit steeper.

I see no reason why BOOPSI couldn't determine if something is an image or a gadget. After all, each class has to be able to call the methods of the parent class, so there has to be a pointer to the parent class somewhere.

Hans

Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work

trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Reaction GUI and vertical layouts

@Hans

LAYOUT_AddChild should be able to handle everything.

The LAYOUT_AddImage tag would of course have to stay for backwards compatibility but it would 1) be clearly marked as deprecated in the docs, and 2) would only work as a placeholder calling the now-made-universal LAYOUT_AddChild code. In a dream at least :-)

I see no reason why BOOPSI couldn't determine if something is an image or a gadget.

100% agreed. There must be a way.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

Log in or register to post comments