Switching question.



  • I am wondering what is the best approach to do this kind of switching .
    I need to have each button switch the whole image strip for all buttons (would not look right using individual images for each buttom) and leave the images as not enabled so they are "transparent" to the mouse cursor.
    And no Image at all on the actual knobs ...meaning no blue dots of course.
    I also need to use these buttons to switch impulses.

    Just wondering if I should make one filmstrip of all of them and then use some sort of index from the buttons or do each individually ? I guess I would need to index the buttons to switch impulses anyway ?

    Any pointers or methods ?

    Switches.jpg



  • @lalalandsynth You can place a panel on top of the buttons and draw the filmstrip inside:
    UPDATE: WRONG SNIPPET

    HiseSnippet 1128.3ocuWstaiSDEdba7xFujUrRH98n7KGTIqSuAhUqnzzjk.aaiZJqPBAUSrGmLp1yXYOd2FUEDON7JwaAuAvY7Xm31FUZcgZIK4yku47MmY7YNyvXgKMIQDiLpe5rHJx3iMGMiKm1cJgwQCN.Y7byCIIRZLVqZ+YQjjDpGxvX82nTXTuFJ64u9l8IADtKcoJD5cBlK8srPlbo1g68Crff9DO5orvRdu8dCbE7th.QJvm0McPQD2yISnGQTtslIx3I87XRQ7HIQRSPF01W3MazTwG3Z+eGKgMNfpD5fFACjVceQfmhwJsntSYAdCKl2IHXTFtLKrtNK7olGx7XKzuLa7IYFvKQTNeXr1sQuN+6zyYUzynD8poo2KLG4FyhjKsn31yLGvgEJeBrDTlVZeQqYTyrq.7fKaGRNm1OFDVfvdWGmMv633z5UMrZXAKDIR76Iw3wRdB903et.5DprqHLRvAA6l6mJkBdmls1ngE9FO2FlMq.lsp.lsq.lcp.lca15WxRc2DV4z4PBmFzARnqdrzlapWDzBsCDDuAgv+A1Mub3IG+885d5Y8O9sGz6j4Lk5j1Q7IM2.2LbVeVPXhDVtyGgEiQBUND1CKOQjJYbpseJ2UxDb6Isrtzp9KeIF7.6W.GK78UJRSX7IX4TVRaOhjzl4cQCq5Yxf4bRUNrafgcQWwe7mqkg442QYSlJsa05UVygWE8X7.fN3B5fE77cTpzSrHv1sH2rAj9BRosZXcoNGy7w1ZUfh5JM4y0EQ90Yaday3dzKN1e4PoxMkADSiT4Fakdk54MrlCe5Khw1iwLd1vzBOVMmy4UWRPvXn5j80IrZLJMaNRHoGysyRxVysvW2ju+JskOXAz3UZVU2L91.ZySCGSiKxYENBEPtZEpmc2pP4p2qVxQAe.mIONhlKWtDawrtvpCZwjsrpkywxZylZqvskptYIRT9+RPwxmj6N3pLqT4yyKUpWkPLfi0MyWxPYYmxmfgtGv275vyIxcD9VOL3a+vfuyCC9tq.9ON3.3GO0AV4KGvRTDMVxTazLNf9dnS.8wW0MOflbtTDgL9nE09fuuCqXWfLLMt.h1L0G+F7wGXdxoJglfvzrJLERwDOl3Mwhznhy9uOAaScv9iGkfskNX+4iRv1VGr5FOFAaGcv95GkfsqNXm+eWvZTzpk5nhrX8TS8wFpPUr8+W2a1Bge+r8VDxOy35gjxIPA1r9xP2rwNn8RgWZ.Qd0dNUMZma.Jyekl6TMvwSXxYkKicOZD04N2m7cktuvbHS5Nc07csUvWnjw+27Mus9Fl878otxkjslY+epp8veOnhtsqIGRfljT6POJMbDbKGWJvDNrYJQs8XMUMXsriRVkYFQ4dYB+M7jariR1H2XmBinPhar3LWcQb0EGdZlFfS7r6OUGtHGHiWbrmooSaGTHbelybcUohu.39pwrYEvrUEvrcEvrSEvraEv7kU.yWcqXTWk7aSkhP8uIfhg8xNC0vnWoxD+CvxgMxJ
    

    You don't care about the blue dots if the panel is above
    You need to set the panel to disablelike in the snippet the mouse click is not affected...

    UPDATE: buttons were in the wrong order...



  • @ustk Great , testing that !
    Would you suggest then using that index to switch the impulses as well or do that separately ?
    I am getting slightly better at this but get confused pretty quick when I need to combine functions.



  • @lalalandsynth Wait a minute, my snippet doesn't seem to work...
    Yes you can set the reverb using this idx, but in this case I'd prefer to use another variable like:

    reg revIdx;
    
    inline function onButton1Control(component, value)
    {
        if (value){
            revIdx = btns.indexOf(component);
    	Panel1.repaint();
        }
    };
    for (b in btns) b.setControlCallback(onButton1Control);
    
    Panel1.setPaintRoutine(function(g)
    {
        // set filmstrip offset
        this.setImage("myFilmstrip", 0, revIdx * this.getHeight());
    });
    


  • @ustk said in Switching question.:

    UPDATE: buttons were in the wrong order..

    What do you mean , in the interface or the script ?



  • @lalalandsynth in the script declaration...
    I don't know what happened but I wasn't able to paint the panel so I restarted Hise and it works 🤔



  • This whole scripting thing is such chinese to me sometimes 😉



  • ok, so this says it does not find the image in the project folder.

    // MultiButtonSwitch
    
    const var btns = [Content.getComponent("Button6"),
                      Content.getComponent("Button5"),
                      Content.getComponent("Button4"),
                      Content.getComponent("Button3"),
                      Content.getComponent("Button2"),
                      Content.getComponent("Button1")];
    
                      
    const var Panel1 = Content.getComponent("Panel1");
    
    Panel1.loadImage("{PROJECT_FOLDER}/switchStrip.png", "myFilmstrip");
    
    
    Panel1.setPaintRoutine(function(g)
    {
    	// set filmstrip offset using this.data.idx
    	this.setImage("myFilmstrip", 0, this.data.idx * this.getHeight());
    });
    
    
    inline function onButton1Control(component, value)
    {
        if (value){
    	    Panel1.data.idx = btns.indexOf(component);
    	    Panel1.repaint();
        }
    };
    for (b in btns) b.setControlCallback(onButton1Control);
    


  • @lalalandsynth Ok, I was TOTALLY WRONG! 😇
    No need for a paint routine...
    Here's something that works 🙂
    It's normal for the image error, you need to place yours inside the folder and change its name...

    HiseSnippet 1082.3ocuW0saiSDEdbZ8xFujJVo8FtyJbSBJDbZSxhTEPo4mk.aahZJqVIzR0D6IIip8LV1S51nRj3ddV3Qh2AdCfy3wN1caTowBpuxme9ly2Y94LmYT.2lDFxCPZEOeoOAo8w5iWxDy6LGSYnAcQZ6oeBNTPBLUpNdoONLj3fzz14UREZE2EE88We6wXWLyljpBgdCmZSdM0iJR0N5nej551G6PNm5kw6lGMvly5vc4K.9ritExGaeIdF4TrzsB5HsmzygJ3AiEXAIDos6wbmkimyeOS4+angzItDoPCzXXfTp6yccjLVpE0YN00YTRdGhfQYT5rvNpYgWneB0gtVe5rwmDYvLEQ14CsB2G8Z7uSOqMQOsLzaWE8dt9X6.puH0hjaOSe.CVnlhgkfrzR4KpvuuidGN3AST2CeIoe.HrFQk1VV0LaYYU8vRFkLfEhPg4U3.yIBVn4Wa9yIPmQDc3d9bFHTo7wKDBNqQ4p0JYXdmu6Cy94.yA4.SybfoUNvztb02c3l.kcxbDlQba.SmadjTlKqVBTB0c4XmAdvofJkuYzYC+gdcN+h9Cec2dmshJUGV2mMqbMyxdK6Sc8BEvhc7HDPlYFPtZfy0QhkLnLWJiXNcAyVP4LSNSt5J4R.2shcBQpAb0cAoZIiaJYTjN0rhRVJIyH0XBYgDccJygb8voovkAOxu3LHjHhSfrTrlIreKdj97DWgoiumPmMWToZ0CMJtpjwJXvlxCLqLwjxhBXUyIxgLl0cvttSfxDUtUtTMNgyjomxEjgrJUMtwnnwJCyOzzzoazV7.5RB1nYYErf6CXE1BuIjfjozDGgix2tVwydX0JrU6ax3HmMfQEC8IwxYK1kj0IVsPqS1rpRywrZiRsM3Vpp6VrBEuuFJa8jX2AWEQEs1Ktnk53BhBbrndb8CTzrCRSWK5lfs.59IPSuFZafeP9iby7CsU9g19Cf9SC5hEX40DwS8vxgOIPPkapz5RtBt+UcoQQ8tjvKEbej1GstlC7+CX04ZY3VAQao7meE948TGwbovmAByiNxlHEfcn7WEvW3mbi61Dr8UA6OdTB1Apf8mOJAqoJX6o8XDrVpf8MOJAqsJXr+6BVojFbjWKDEqmpqthPFp3i5+1ubzxTg2cz5P9oZYC4WBVILLTLMpaHzcamBZpi6rvEKtcmdx1aiM.kzuUKUx1lXgTwxr0c1h1+rdvcm9Po6y0GQE1y2LeKrA9BkL9+luwMSWRu2zoDaQJY2Uu+ayamyaAUNiuPPYyNACMbH2gd5BuwvaKrI.SXvloP41iBx5uJYqjppiILmHg+F9hM1PJqEarQhQjG1Nfegsp.trc8mFoA3DK5UKEgmOAxloWwoaU2B4Auh3Baa4TwW.beyX1OGXNHGXZlCLsxAl14.yKyAlu5dwHe.22sPv8TGS.Ei5EcGplVuLkI9Gr9Q7qL
    


  • @ustk said in Switching question.:

    It's normal for the image error, you need to place yours inside the folder and change its name...

    you mean like this ?

    // MultiButtonSwitch
    
    const var btns = [Content.getComponent("Button1"),
                      Content.getComponent("Button2"),
                      Content.getComponent("Button3"),
                      Content.getComponent("Button4"),
                      Content.getComponent("Button5"),
                      Content.getComponent("Button6")];
                      
    const var Panel1 = Content.getComponent("Panel1");
    
    Panel1.loadImage("{PROJECT_FOLDER}switchStrip.png", "switchStrip");
    
    reg revIdx;
    
    
    inline function onbtnsControl(component, value)
    {
    	if (value){
    	    revIdx = btns.indexOf(component);
    	    Panel1.setImage("switchStrip", 0, revIdx * Panel1.getHeight());
    	}
    };
    for (b in btns) b.setControlCallback(onbtnsControl);
    


  • @lalalandsynth Exactly 😉



  • Awesome , , thanks so much mate !!
    Sweet !.gif


Log in to reply
 

8
Online

673
Users

2.7k
Topics

22.7k
Posts