Author Topic: Dynamic number of child objects in Zune  (Read 472 times)

dizzy

  • Newbie
  • *
  • Posts: 40
  • Karma: +0/-0
Dynamic number of child objects in Zune
« on: January 08, 2019, 12:00:37 PM »
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, 12:44:36 PM by dizzy »

magorium

  • Member
  • ***
  • Posts: 108
  • Karma: +0/-0
  • Convicted non contributor
Re: Dynamic number of child objects in Zune
« Reply #1 on: January 08, 2019, 02:23:55 PM »
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, 02:52:17 PM by magorium »

dizzy

  • Newbie
  • *
  • Posts: 40
  • Karma: +0/-0
Re: Dynamic number of child objects in Zune
« Reply #2 on: January 08, 2019, 02:51:44 PM »
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: 23
  • Karma: +1/-0
Re: Dynamic number of child objects in Zune
« Reply #3 on: January 08, 2019, 02:58:41 PM »
 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

  • Member
  • ***
  • Posts: 108
  • Karma: +0/-0
  • Convicted non contributor
Re: Dynamic number of child objects in Zune
« Reply #4 on: January 09, 2019, 05:20:28 AM »
@o1i
I've just spent my first karma point for that   :) .

Thank you for the confirmation.