How to keep all gadget labels aligned between groups?

11 posts / 0 new
Last post
hypex
hypex's picture
Offline
Last seen: 2 months 2 weeks ago
Joined: 2011-09-09 16:20
How to keep all gadget labels aligned between groups?

Hi guys.

So I've been learning how to program a ReAction GUI and I'm seriously loving it! Well, not quite, LOL. Seriously spending the last week building up my new GUI, while getting over compiler errors, crashes and fixing faults. :-)

So I'm am quite happy with my progress after looking at example code and seeing how it's done. Unfortunately, the OS4 wiki has old examples that use older methods they don't recommend anymore, nor do they compile for me. Without the Trixie examples I'd be more lost.

So in my window I divided up an interface vertically into three named groups with a box. Inside the boxes are cycle gadgets or choosers as they are called in ReAction parlance. I finally got these displaying normally and added lables. I found labels to be quirky because they can't be added as part of the gadget tags, but added seperately to the layout, as if it was an afterthought. And then, not as simple text, but it needs to have text converted to an image. It's a useful toolkit obviously, being able to calculate layout of multiple groups, but it has a way of making a simple asset like label text slightly over complicated. It wants objects for everything which means it must all be stored and managed. And all the classes and gadgets must all be pre-opened by name.

My current issue is the gadgets look untidy because they are all in different spots. The labels are in different sizes so all the group choosers are offset in different positions. What I would like is for all the gadget lables to be in the same space, taking up the same width, like in a table. So all the gadgets align. But, it doesn't look like there is an easy way of doing so.

So, I found LAYOUT_LabelWidth and LAYOUT_AlignLabel, which looks like what I need. However, there are no examples of either I found, in the SDK or the net. One takes a width, so I would need to calculate the width of all the labels myself possibly, then find the longest and pass that. The other takes a layout and somehow needs to be linked to all groups in a way that isn't fully clear to me. Another option is to cheat and add space to the front of a label so it it's falsely bigger, but I tried that, and it doesn't work.

So, what would be the easiest way to solve it, while making use of the toolkit features? :-)

jabirulo
jabirulo's picture
Offline
Last seen: 12 hours 10 min ago
Joined: 2013-05-30 00:53
Re: How to keep all gadget labels aligned between groups?

Hi, can you post some image/grab to see what you have and maybe a mock up what you want to achive?

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

jabirulo
jabirulo's picture
Offline
Last seen: 12 hours 10 min ago
Joined: 2013-05-30 00:53
Re: How to keep all gadget labels aligned between groups?

LAYOUT_AlignLabels example attached.

  1. /* Set up inter-group label pagement. */
  2. IIntuition->SetAttrs( gadgets[GID_PAGELAY1], LAYOUT_AlignLabels, gadgets[GID_ALIGN1], TAG_DONE);
  3. IIntuition->SetAttrs( gadgets[GID_ALIGN1], LAYOUT_AlignLabels, gadgets[GID_ALIGN2], TAG_DONE);
  4. IIntuition->SetAttrs( gadgets[GID_ALIGN2], LAYOUT_AlignLabels, gadgets[GID_ALIGN3], TAG_DONE);

File attachments: 

AttachmentSize
File pageexample.lha2.62 KB

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

hypex
hypex's picture
Offline
Last seen: 2 months 2 weeks ago
Joined: 2011-09-09 16:20
Re: How to keep all gadget labels aligned between groups?

Hi. Thanks for replying! I see there is an example in the SDK. I don't know how I missed it as I searched again and it did come up. I also had read and ran the PageExample. But that was before I found my alignment issue.

So all the examples, being that and ReqTools, link the layouts after creating. Be good to do it as it's being created. But there is a dependence issue as first layout group cannot link to any other. Well as long as it works.

In the meantime my example GUI with odd placement. :-)

IMAGE(https://os4coding.net/sites/default/files/commentsfiles/test.png)

File attachments: 

AttachmentSize
Image icon test.png26.23 KB
hypex
hypex's picture
Offline
Last seen: 2 months 2 weeks ago
Joined: 2011-09-09 16:20
Re: How to keep all gadget labels aligned between groups?

Okay I've tried linking layouts to each other in order. But I cannot get it fully to work. The file gadget refuses to budge. I wonder if I'm missing more tags. Think I might need to get label widths then reset each layout width to match. Though I thought this would be easier.

IMAGE(https://os4coding.net/sites/default/files/commentsfiles/test2.png)

File attachments: 

AttachmentSize
Image icon test2.png45.29 KB
trixie
trixie's picture
Offline
Last seen: 6 months 11 hours ago
Joined: 2011-02-03 13:58
Re: How to keep all gadget labels aligned between groups?

@hypex

The file gadget refuses to budge.

It's possible that there's a bug in the getfile.gadget, and the gadget's GM_LAYOUT method doesn't cooperate with LAYOUT_AlignLabel.

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

hypex
hypex's picture
Offline
Last seen: 2 months 2 weeks ago
Joined: 2011-09-09 16:20
Re: How to keep all gadget labels aligned between groups?

@trixie

It's possible that there's a bug in the getfile.gadget, and the gadget's GM_LAYOUT method doesn't cooperate with LAYOUT_AlignLabel.

Yes I suppose that is possible. I worked around it by adding another gadget to the group. Though that doesn't help by itself.

I may have laid it out in a quirky way or with too many layout gadgets. As you can see I also added a tab though it's redundant in my test interface. So, I have a main layout, with a clicktab, containing a page group, from which a page is added with another layout, to which contain three more layout groups with bevel and title you can see, which finallly contain the gadgets.

I've really laid it out this time! :-P

jabirulo
jabirulo's picture
Offline
Last seen: 12 hours 10 min ago
Joined: 2013-05-30 00:53
Re: How to keep all gadget labels aligned between groups?

And if you add another gadget to the "File:" group (Layout). Does it align correctly (both or only one)?

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

hypex
hypex's picture
Offline
Last seen: 2 months 2 weeks ago
Joined: 2011-09-09 16:20
Re: How to keep all gadget labels aligned between groups?

@jabirulo

Yes it aligns correctly. Both labels match up. Aligned with other group labels.

trixie
trixie's picture
Offline
Last seen: 6 months 11 hours ago
Joined: 2011-02-03 13:58
Re: How to keep all gadget labels aligned between groups?

@hypex

So, I have a main layout, with a clicktab, containing a page group, from which a page is added with another layout

Depending on your particular GUI, the latter may not be needed because a page gadget is in fact a variant of the layout gadget. So it will lay out, vertically or horizontally, whatever you have within the page group.

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

hypex
hypex's picture
Offline
Last seen: 2 months 2 weeks ago
Joined: 2011-09-09 16:20
Re: How to keep all gadget labels aligned between groups?

@trixie

Depending on your particular GUI, the latter may not be needed because a page gadget is in fact a variant of the layout gadget. So it will lay out, vertically or horizontally, whatever you have within the page group.

It did look a bit convoluted. I was following the page example posted above. I find the "page.gadget" a bit confusing. So, it it can't be referenced with a class pointer, but must be opened for every use by name. It's part of layout gadget but you can't open it from the layout gadget. I'm not sure why it was made so complicated. Why not just let layout gadget handle it with some extra tags?

  1. LAYOUT_AddChild, gadgets[GID_CLICKTAB] = IIntuition->NewObject(NULL, "clicktab.gadget",
  2. GA_ID, GID_CLICKTAB,
  3. GA_RelVerify, TRUE,
  4. GA_Text, tablabels,
  5.  
  6. CLICKTAB_PageGroup, gadgets[GID_PAGE] = IIntuition->NewObject(NULL, "page.gadget",
  7. LAYOUT_DeferLayout, TRUE,
  8.  
  9. PAGE_Add, gadgets[GID_PAGELAY1] = IIntuition->NewObject(NULL, "layout.gadget",
  10. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  11. LAYOUT_SpaceOuter, TRUE,
  12. LAYOUT_SpaceInner, TRUE,
Log in or register to post comments