Single button that switches between multiple panels ?



  • I made a better performance update I wanted to share with anyone who needs it. I used 1 image with 4 states. Then I'm scripting through the changes updating the offset.

     ++currentSelectRow
        
        if (currentSelectRow > 4){
            
            currentSelectRow = 1;
        }
        
        if (currentSelectRow == 1){
            
            Content.setPropertiesFromJSON("selectInstImage", {"offset": "0"});
                
        } else if (currentSelectRow == 2){
            
            Content.setPropertiesFromJSON("selectInstImage", {"offset": "150"});
            
        
        } else if (currentSelectRow == 3){
            
            Content.setPropertiesFromJSON("selectInstImage", {"offset": "300"});
        
        } else if (currentSelectRow == 4){
            
            Content.setPropertiesFromJSON("selectInstImage", {"offset": "451"});
        }
        	
    };
    
    Content.getComponent("instrSelect").setControlCallback(onplaySelectInstrControl);
    


  • @jssrecording Might be able to switch your if block for a switch statement. Another option is to put your offsets in an array and use the currentSelectRow value as the index.



  • Great Idea @d-healey!



  • Im using the code from d.healey here:

    // Panel Switcher //

    const var panels = [];

    for (i = 1; i < 5; i++) {
    panels[i-1] = Content.getComponent("Panel"+i);
    panels[i-1].showControl(false);
    }

    var currentPanel = -1;

    inline function onBankButtonControl(component, value)
    {
    if (value == 0) {
    if (currentPanel > -1) panels[currentPanel].showControl(false); //Hide previous panel
    currentPanel = (currentPanel + 1) % panels.length; //Move to next index
    panels[currentPanel].showControl(true); //Show panel
    }
    };

    Content.getComponent("BankButton").setControlCallback(onBankButtonControl);


    is there a way to call more than 1 element in: "Content.getComponent("Panel"+i);" ?

    For example if I had panels named "PanelA, PanelB, PanelC & PanelD" could I show all of these elements where it displays (Panel"+i) ?



  • @Dalart Sure, just add an extra line for each one..... but.... that sounds like a bad idea to me. You see that loop isn't grabbing 1 element. It's grabbing 4, panel1, panel2, panel3, and panel4. So why not just rename your panels instead of A, B, C, D. Call them 1, 2, 3, 4. Using letters is generally not as useful because you can't iterate letters in a loop like you can with numbers.



  • @d-healey thank you for your input, I will tinker with this and your suggestion and see what happens =). Thank you for your time.



  • @d-healey Ive been tinkering around a little bit without success in showing multiple elements in that one component, could you please give me an example of using an extra line for each element ?



  • @Dalart Post a snippet because I'm not 100% sure what you're trying to do.



  • @d-healey Ok here it is, might not be the best way to do what Im trying but my coding brain is in an infancy stage at the moment, Im trying my best to learn though.

    HiseSnippet 1546.3oc0Z0saaaCElJIpM1aYscXWtKD51.rQZSrjcRaQWac8OY0XMoF0ccEnnnPQhNlnxjFRzownnX8oXXON6AXuJCnWsa8H0O1TNJNRprHaNWDyCO+7wOc34HI5ttDKnmGwEnT3YSFAAJeoZuIX5flCLQXPmV.kKq1vzCYAZLYjomGzFnnr5OwmTovZ.+Oe7AMLcLwVv4h.fmSPVvGiFhnyk1s9Oibb1yzF9LzPAsqUuiEA2j3PFy.xppU.iLsdi4QvCL4pshJP4RssQThaOpIE5ATVqAwdRuAj2hCz+4HOzgNP9.cPOliBDuGwwliXtTPyAHG6tQKXO.yKcmu7WMX4+Mp6irQyjOmFtp+DZysPjOTVYYvSWDdURO7TDf2ZAv6Zp8rbQinymgisuPsClBc6axtDHBq.cAq7appMILMvzsFZ9F3dtrAyrnztUpbCscpTo7c2nH+us2Vq6COn8i058qcdVyG09oZauMWN6RjGU6XSWsQlXnim18zd4q7soOwUqDhMV+tZHseTaG1+1byxZuaihZrOAp+RzM0eESmHjbDj1jLbDAyFT55c45b8MQbPrfMa4wHRtUtDmR8Mc7fkuaw2GnFO5bDYM10k4GeuvhwM08wEB6fvPs9iwVTDAqQvMFSoDrQj2rh.vMXqKmwvxaTLDyn9Zk7Eocu6oUY1RIZpXw69r3UNBwhyjHzYr4iP1PsQtviQjwdAFN28KrThGpM0XQ5GBi0VNP7QzAbOtO4XnFknggmP0PXa3Iyc34BLp63.bwyXCT22XFG+dedL4KYgb40KukGWtuuZZ53bHauaoEoZgjqlO5IcZ19ryt5ypO3tjrqZwytBTe4YW7RNr8x7RROTHISvzLjj46ryOISWVIYAwKHIKDwhy7ojjEsThGpvjrfXkxjryEXeRIY5KOISWHIS35vADJ7I3RkK9thEJ99SMS+9IMUnqbftIMKuu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v1Blfts8eWwJJswlrrJ+LPv+Bd65Gy.
    

    So to summarize what Im trying to do here in this snippet is have button 2 choose the panels and button 1 would choose the 1 of the 3 panels within that panel.

    I have it partly working where I have "FaderChoiceA"+i, so I was trying to get the other options to show as well, "FaderChoiceB"+i, and so on. Probably just not building the idea right would be my guess.

    Thank You for your time !



  • @Dalart

    I see. Panels inside panels. Well there are a few ways to do this. For me the most straightforward is to use a 2D array for the inner panels that use the outer panel as the first index and the inner panel as the second index. And I replaced A,B,C with 0,1,2 for the reasons I said before.

    HiseSnippet 1563.3oc0Z0saaaCElJMps1adscXO.DYX.1HsIVRNosn+L233rZrlTi5rtMDTzoHQGyTYRCIpzZTDf9ns2j8DLfd0tMiT+XSYqjZ6Hgk4aR3g7b3G+NGcNTTrsK0B44QcAJE1e3.DP4qU6Ljv50nmIl.ZsMP4FpaY5gs.aMbfomGxFnnbseRzoRgkAA+97OtkoiIwBMVD.7ZJ1B8BbeLarz10+YriyNl1n8w8kFcs5srnjFTGpOGHWSsJXfo06LOBsmoXXKoBTtdSaLi51gYxPd.kk2hZOrSO56Igi+0XO7gNHQCMPGtgBEuC0wVfXgTPidXG61wKXO.2JsGu7uV3x+6T2EaiGIeLMb6fNfi0PlOTV5hfmlL7pN6vSQBdKGBu6n1wxEOfMtGA19J0VDFxsqI2EHCqvwBV5uTUaP4ifvVqu46P63xaLRixaVs5cgaTsZkGUpXohbGgGCdhoKbfIA43AeB7f27HY4c49O2H4v0WWeanoqq4vRE6Rcgkw7NzdDDCeLbC9eVc0JvOVpHj+KzdGfum1a3iIFPGgXMn8GPI7FkWosXLqrJVfkIzYMONeJzxk5TtqoiGJDvhgEBoXSGf2.wB.cbHfNlCnZ7+HAnIzbsA9d8JmNtDwr7fAQL8JqVlO5JqdbkXPNgcN33yAsAC9zhmFpk.6quNr8y1q4Kfc90V6234MeEmOKUTPxV9tt7YNfO3KfpAKULwASPvt9DKFlRfTxV9LFknGOQVwH9tbOkiOpRohQqUbWX4.QvmvsVBJP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pswLqdoi2kRAu.Pti2napQI0lc6hrXiA6xp67a4+0x.7JpOCSNZWSlKlGentme+N7ZfVHNRHhOMs3biVRbXzgsqFdNR.PGDwNnwY7eQcpIZqD0oVbmf9lVtz2ZEdZ1h6BxMCjvwDI3JwTPcWQa3ny.Wf69Xa7asrDDw83HOcMzmaMLlaMpM2ZrwbqwlysF2et03AWfFhaCzy7Yz9gOVvEztYvGOPQoIwjGUEDAB9WPp7ZmD
    

    This will be buggy though because all the inner panels are sharing the same variable currentFader you'll need to modify this so each panel gets it's own variable. BTW a panel can have a value panel.setValue() so you could use this to store the currently selected fader for the panel rather than creating a separate variable. There are many ways to do this kind of thing.



  • @d-healey Thank You again, I think I might have figured this out with your help !


 

4
Online

424
Users

1.5k
Topics

10.6k
Posts