Dynamic number of child objects in Zune

dizzy · 1811

dizzy

  • Junior Member
  • **
    • Posts: 59
    • Karma: +60/-0
    • YouTube channel
on: January 08, 2019, 05:00:37 AM
Hello,

I've started to tinker with the arosx gamepad support after a break.

How could I implement dynamicly the gui buttons? Can I somehow add a for loop inside the window content?

I have now image objects as child, but I don't want to hardcode how many there are. I would like to have a row of button images corresponding to the gamepad buttons.
« Last Edit: January 08, 2019, 05:44:36 AM by dizzy »



magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #1 on: January 08, 2019, 07:23:55 AM
I have now image objects as child, but I don't want to hardcode how many there are. I would like to have a row of button images corresponding to the gamepad buttons.

In case you want the simplest solution then i would probably suggest to use a List. Neil just recently added support for rgb images with the special text escape.

But that is of course not a row but instead a (single) column (no idea if a list can be turned to display multiple columns in only a single row, perhaps listview does ?).

So afaik that leaves you with a group with either a custom Layouthook or using a single row (and multiple columns) or a combination of both the hook and row/columns

However, do note that using dynamic objects is not something that is easily to implement with MUI. You would have to make sure you have a clear indication (beforehand) on how many buttons there will be in order to make sure they will fit in the current dimensions of the used class (or suffer the consequence of a bunch of redraws/resizes). Unfortunately that is how most of MUI works (preferred is that things can only be added at init stage).

On the other hand, using a group does allows for dynamic creation with MUIM_Group_InitChange (ADDMEMBER/REMEMBER) and MUIM_Group_ExitChange. Problem is that i do not have any experience with it to know if it is workable for your situation (nor am i able to assist atm).

Just some thoughts as a suggestion in the hope it offers enough for you to be able to continue. If someone else has a more clear train of thoughts (or even better an exampe) then please let them speak their mind :)

PS: link to autodocs initchange.
« Last Edit: January 08, 2019, 07:52:17 AM by magorium »



dizzy

  • Junior Member
  • **
    • Posts: 59
    • Karma: +60/-0
    • YouTube channel
Reply #2 on: January 08, 2019, 07:51:44 AM
Thank you.

I don't yeat know how to decode the number of buttons from the xinput descriptor, but I can for now hardcode the basic set of buttons that should be there. These are known before the gui creation. On windows the number of buttons is different among different controllers so there should be a way of knowing the correct number.

As the gui creation is done with macros I thought I could interleave for loop between macro statements.

I'm at work at the moment but I'll try to find some way this evening.



o1i

  • Newbie
  • *
    • Posts: 41
    • Karma: +6/-0
Reply #3 on: January 08, 2019, 07:58:41 AM
 MUIM_Group_InitChange (ADDMEMBER/REMEMBER) and MUIM_Group_ExitChange should be fine.

Even if this seems to be against the MUI best practices, I usually don't build my guis at app initialization.

If you look at the janus-uae and janus-uae2 guis, both are built dynamically, not a single button there is hardcoded at window initialization.




magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #4 on: January 08, 2019, 10:20:28 PM
@o1i
I've just spent my first karma point for that   :) .

Thank you for the confirmation.