3 buttons, 3 panels, and lots of potential scripting...
-
I have 3 buttons and 3 panels. The panels are stacked on top of each other. If you click button 1 then Panel 1 disappears and the other two panels move up. If you click button 2 then Panel 2 disappears and Panel 3 moves up. Button 3 just makes Panel 3 disappear.
But I'm getting into trouble trying to figure out a method of combining button presses and before I dive in and start writing a bunch of if / else statements I thought I'd see if anyone had come across something similar before. Any help much appreciated!
HiseSnippet 1043.3ocsW0saaaCElxIJHRacXcXWrKExUN.oo1TccEHnndwIYvXKodycEq2r.FIZahHQJHQ2Nis.rmi8DsGm9F3cnDkkbhr7OESWX3y4vuC+Neh+bT+XgGMIQDiLrdyzHJx3yMGLkKG2cLgwQ8NS4HhvoANRZhDc5zHRRB0GYXryOnFgg0tnzmO9pSIADtGsvEB8VAyi9SrPlrva+N+HKH3BhO8MrvRi9Yc54I3cEAhI.a1wrEJh3cKYD8JhZXMLQF6ctOSJhGHI.Yfwbpve5fwhOvyF+aYIraBnJi1nAPhxbi5NlE32OuRSPHic6WT26jU2es4kLe1b+E0+WlFvo.QYMvnQcTp8FPIiRTZ2LJ8XyAdwrHYQDEe9LydbIMdHAj5xTIarnFWaZ1U.ifKONjbK8hXvXNhlOuUqibfeN7DaaPtSjNumD6b5DoTva67RmbninxthvHAGLZdfN9A.p6CBuBP3p.4tBPtGrH+5qVAtb5kEdwIJ0GtdH3Jf3VOjLlESGo4z6fg2F25jBWXkKbqxtbSc8BvksMiGv3TmgS3dRlf6H3ZwUMowhfld4y3Q.oBlPOz9OssXCcZpsr.SqrI+3DXkVNN0qTc.7wITfvSO3nbVVDy8dwvowty1x1hFjPWZ5au7ziqI8t5zaeGT7qXwkBpd55RBBtA19279xyg0og3MWCwKSCqVmrd5S2PUDuLUrZkpdUbUhHtdQDuNhnashXN8JWSOQG+jUxO254maI9UhWWIjzWyalN+12Y6b+PCGVYLcxBnwUFVc6Sbc.axmDdCMtb0qFHb77hm4u25cluWltTZfBdONS95Hp19BQfu5rb0+e3MDHsvB2Urilgv+jo2T7E5aJxjQDCRhkodiCJk9kuUFsAvweZvcq.9u16LhjntxSWQPUFQikLkXZbF88POCYW.ZYdFM4VoHBD44qk.8eMJ5+nXJeWmoyM96etCZixDVkISiOBX+DxhaVV9KiZxx9YY4Q4W5q1nklj8MyNNdY0D5267AlubrZF9GXFFSYiFKUV8gfLIMLuoJq8PnYyPK3EW18lvG7C4yd+q9U75ymYeUk7Q6dS3iaE74aL1P9LCcTU7I2M5gMoAsGJ7mDPjK1ynp4Xc.3PkEZTS0LFOgImVt44MnQxV01H45RwGa1mI8FWMGaTAGgMr+evQc62Ox77gCodxBBtq4E+111q8Jl9eQLQx3itjHiYpMlWMIb.7p1iByNGVJknVbzPs7KytkxVo.Cnb+TiYviNXaksgNX67fnPhWr3ZuriJUM3uepGfS7zumwx7Rksy7ymMMacbKTH7sFW64oJ+m.2BTMF7VfwcKv7rs.y2tEXd9Vf461BLunVLpOy66mHEgYaG.G8OO8lJCiy4DXkU5pPz+Afi31zL
-
This post is deleted! -
@DanH not so much scripting after all, and I'm sure one could come up with something nicer :
HiseSnippet 1077.3ocsWE0ahaDDdMfihc6U0qpObOZwSFcDDXRudRQmNJjjJTaRnkznVEEcZwdAVE6csrWeInpH0eJ8mRer+b5+.5r1FXIwI5f6N+PT1Yluweyrq+1gAQbWRbLOBoYb9rPBR6K0GNiIl1aJlxP8OTZHDyH9VBRr.0cVHNNl3gzzJ+ixHzLpfRe9u21E6iYtjUlPnK3TWxOSCnhUVGz4mn99Gi8HmSCThd+N8c4rdbedBvlx5MQgX2qwSHmhkgURGosyQdTAOZn.CjAoUoK2a1vo7aXYweAMlNxmHWzBMDRTl4i49dRFKsh5Mk56MXQUGifrLXUOnbVO3a0Og5QWZeUu3qScXsBgZ+Pqz5zq7ZzqkJ8ZpPuBnjlBkpjQomqOzMhFJV4QxmuPuOSPhFig1tJUxhEUZ+J583PDLQi.70jiifEKQX+plMqaA+o1AllPqOVX8dbj0jnvtBl0artbAzIDQOdPHmAKrq1MQH3rVUqU2zpfmmBjy1.pc0ZWcf4Xdj8HKJKmd0rF0HVFLSDw86g88GAGVr4LvWtwGTUCX9OdUMPdFeCKpTLNaAlrRJmcyFvik7pkCra3H2RbdcSoaJymxHViSXtBJmYoVb1tKRYcn77SH0L+SSCetK1GZRdjagLl0oZjt7rwqP.Ml7HiSBrf.syh7xlWII6ExzYWy5k4I3xVplkfANDy8IMBinPIAIQZzzfN1N+U+Fql0LM.BYj01uL09UMhgOFVT.s1Ki2GbundI75fcV6pypVOs2bYdjW8vPctenNJgdmoAwOlXoRqVeBokydPkq9l1fTem4cGnrudJWPNiYmtGZdmo08cMdbg9xSrOIpP2R40nmBnMKIXDIR8DjLPPyYcgL8GWHSUm0M6.uRfbVeFUbVHg8Xpun7uR.Qux4rB9OQpj2WkK4kICfnfxlgdt5CJkxpW0f1.3NebvaW.7eq+gXAVpcmWQPUFRhDTYCT6Px6gKByTxMzOjDesfGB2msTX.54e.E8sqdk+QmYKW7W+RGzFkIG0Lw9XxTakL8O273YZ2rL8rE2hIUASSzt5YJuOr11417V6MTOwzkd+6YclRnSlpLQw4cnBRvhIGL1AglOWZekUGUyaBubJfW+6Vyq4eSg7J27lvq1EvqWnsk7ZNpdQ7ZgYzCmFAlCh6k3iEqObjbhvbGfPyZSjHm5fESEyTmX7S1DSenT745CnB2oEywREvQ3C5OGbLeNymoez3wDWwJBVQ+3e+yyPknekmHnrImfEQT3vi9oIACgsZWB71YvQJoPuVI4wvr0MkqkcfgDlW5h4vStyVx0Z4NasvIJ.6FwemalTpbR1cSs.bhkNDug9Ix0VK0u00a1nIJ.Fp9cttxxeO3Vhhw3rEXZuEX1eKv7caAlWsEX99s.yqeRLxeOyOjH3AYeN.FFbT5MYZZGwvvIqzSgn+G.yi9L2
-
@Matt_SF this looks very nice indeed, thank you! However, when clicking out of a couple of button positions the panels are then left out of position. So if you click 1, 2, and then 1 again, Panel 3 is out of position. I'm going to have a crack but I've added labels to the panels to make it less confusing!
HiseSnippet 1182.3ocsW0saaaCElJIpHRac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wxinI.yXZfsOt+Dfk9+TfoqI8abwexAjt1+.KK.itlKnRPtVjlTxQlZhF.0B8n+YYoxGda6HbLrypbSAEflMttGg4beB6I+Wds37SX29cURX4hur38cXFm4g6bdDbmybwcNn4oXqUEb2Onsfb2sn0qh6JDOWDVqGAg0ZtHrVvb32aFSX5Vt+n.rX5Qdky4mq.t9Xp4LkyRxRnhwpsR+rMG7mJDeltKU3MrZLtTEXDNV9Rfw7ud3o5cGLf3IJA3J5696eY9TAza4iDT14GfEwTYwygiB6A0fdDX2YvAs75askjWOlstQQcUOByOcwsvStxlx0Z4JaVnDEh8h4u2K6BR42mrZpD.SrzOMyP+.4ZqI2Jqq2ndCTH7oRu2ySl9a.M2p1GmEvmVKfOat.97iKfOuXA74mV.ed4C5i7qTeyHAOL60APfa2z4Szz5xvPkUZUH5+AcW8y.
-
@DanH You're right, depending on the clicking order, it might mess up the whole thing :detective: :grinning_face_with_sweat:
-
@Matt_SF I can't figure it out
Let me know if you have any more brainwaves!
-
@DanH I'm on it
-
@DanH funny how it seems so simple at first.
If you, HISE master who sees this post and has the answer, please send it to Dan in PM, I want to figure it on my own!
-
@DanH try this
HiseSnippet 1210.3ocsWE2SaaDE+LfY3r0o0o8Avi+JoPgD6ttJwpVJAXBsAjsvPqZZp5h8kjS3bmk8kBQSHsOJ8ix9H0uAr2c9brM0wPRWif.26898teue97cuqaD2iDGyiPFVmOMjfL9BydSYhQcFgoLzwGHMDhYj.aAIVf1eZHNNl3iLLV8mjQXXsFR848+393.LyijYBgtfS8H+BcLUjYsa6elFDbD1mbNcbtneV6i83rN7.9DfMqZ1DEh8tDOjbJVF1JlHi0OzmJ3Q8DXfLHi01m6Os2H9Urj3ufFS6GPjCZg5AIJw7Q7.eIikVQcFQC76lV0wHHKcyzfUSzfuw7DpOcl8Ls3qTNryPjWOLVoH8Vs.8ZkmdMyQuRnjQNJsVBkdrYOuHZnHyijOet4wLAIZ.Fj87TIIVzJ89LyNbHBlXmw3KIGEAClgn9ya1baa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sLOQN1d192llM2oIZLbmy234IK+mBmRTNFmk.i6Rf4YKAluaIv77k.y2uDXdQkXjW2+USD7wIuN.F5dn5jLCiCYXXkkZUH5+.d1P0C.
-
@ulrik You're making good use of that
getAllComponents
function again. I need to do that more. -
@d-healey yes it's handy, but it's easy to unintentionally collect wrong components if you're not certain of how you named the components
-
@ulrik brilliant, thank you!
so .getAllComponents will give me an array of all named components? Eg. Panel1, Panel2 etc ?
-
@ulrik Elegant!
@DanHContent.getAllComponents
returns all components whichs name matche the string you pass in the function.I.e.
Content.getAllComponents("pnl_")
will retreive all components which have "pnl_" in their name. Obvisouly you have to be consistent in the naming of your GUI elements but it's quite handy :) -
@Matt_SF said in 3 buttons, 3 panels, and lots of potential scripting...:
@ulrik Elegant!
@DanHContent.getAllComponents
returns all components whichs name matche the string you pass in the function.I.e.
Content.getAllComponents("pnl_")
will retreive all components which have "pnl_" in their name. Obvisouly you have to be consistent in the naming of your GUI elements but it's quite handy :)to be honest I prefer this naming approach;
Button_01
Button_02
Button_03
etc.and then load in a sequenced and ordered way into my array
const var NUM_VOICES = 4; //some number of voices const var myButtonArray = []; myButtonArray.reserve(NUM_VOICES) for(i=0;i<NUM_VOICES; i++) { myButtonArray[i] = Content.getComponent("Button_0" + (i+1)); myButtonArray[i].setControlCallback(onMyButtonControl); }
This gives me everyone in the array in the correct sequenced order....and lets assume these buttons are turning some filter on or off, I can also add the filter itself(again in the right order):
const var NUM_VOICES = 4; //some number of voices const var myButtonArray = []; myButtonArray.reserve(NUM_VOICES) const var myFilterArray = []; myFilterArray.reserve(NUM_VOICES) for(i=0;i<NUM_VOICES; i++) { myButtonArray[i] = Content.getComponent("Button_0" + (i+1)); myButtonArray[i].setControlCallback(onMyButtonControl); myFilterArray[i] = Synth.getEffect("Filter" + (i+1)); }
which means the callback for the button only needs to be this:
inline function onMyButtonControl(component, value) { local pos = myButtonArray.indexOf(component); myFilterArray[pos].setBypassed(1-value); }
always interested in a faster - cleaner- better way if someone has one...
-
@Lindon if your elements are numbered the function will sort them automatically. I usualy don't number them and I also liketo have control on my elements (like the script you wrote) but sometimes it can be useful to get all of typed elements quickly.
-
This post is deleted! -
I rarely put the full type of component in the component id, it seems redundant to call a button button.
I use a prefix to describe the type of component followed by a name that describes the button's function, if the button is part of a group of buttons I follow this with a number, almost always indexed from 0.
So I could have 10 buttons that toggle 10 panels, I might call them
btnToggle0
,btnToggle1
, etc.Then I could use either the loop technique or the
getAllComponents
technique to populate an array of references. I usually use the loop technique because most of the time I will also assign a LAF object and callback to the controls at the same time. From now on I think I'll be using thegetAllComponents
function when I only need a reference.The
getAll...
functions are also useful when you want to loop over a set of components/modules that you haven't stored references to already. For example if I had 5 filter effects and I wanted to change a parameter on all of them but I have no other need to keep references to them:for (x in Synth.getAllEffects("filter")) { // Do the thing }
The
getAll...
functions don't require additional allocation (as far as I know) so they are safe to use at runtime. By contrast you don't want to useContent.getComponent()
at runtime. -
@d-healey said in 3 buttons, 3 panels, and lots of potential scripting...:
The
getAll...
functions don't require additional allocation (as far as I know) so they are safe to use at runtime. By contrast you don't want to useContent.getComponent()
at runtime.Good to know