Forum

    • Register
    • Login
    • Search
    • Categories

    Painted Button?

    General Questions
    4
    19
    198
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MikeB
      MikeB last edited by MikeB

      A simple beginner question
      How do I get the Paint Routine button to to take the color and shape of the PaintRoutine on click and execute another function?

      const var plnTriAngle_Delay1 = Content.getComponent("plnTriAngle_Delay1");
      plnTriAngle_Delay1.setPaintRoutine(function(g)
      { 
          // Off Triangle
          g.setColour(0XFF800d9d);
          g.fillTriangle([0, 0, 200, 100],Math.toRadians(180)); 
         
          // On Triangle
          g.setColour(0XFFff7800);
          g.fillTriangle([0, 0, 200, 100],Math.toRadians(180)); 
      });
      
      plnTriAngle_Delay1.setMouseCallback(function(event)
      {
          if (event.clicked)
          {          
          
             //on click show "On Triangle and make anything?          
          }   
              
      });
      

      "One hour of trial and error can save 10 minutes of reading the manual."
      "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
      HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

      1 Reply Last reply Reply Quote 0
      • d.healey
        d.healey last edited by d.healey

        To repaint the panel after a change you call the panel's repaint() function.

        You can put this in the mouse callback directly or you can trigger the panel's control callback from the mouse callback and trigger the repaint in the control callback 😛

        For the different colour just check the panel's value in the paint routine and set the value in either the mouse callback or control callback as appropriate.

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        1 Reply Last reply Reply Quote 1
        • MikeB
          MikeB last edited by

          Solved - Thank you David

          "One hour of trial and error can save 10 minutes of reading the manual."
          "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
          HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

          1 Reply Last reply Reply Quote 1
          • Natan
            Natan last edited by

            @MikeB
            Use Look&Feel, The Moethd Of LAF Is Easy To Paint Your Buttons, And Also You Can Make Your Icon Buttons, Clickable, And Super Easier Than Painting The Panels.

            Take A Look:

            HiseSnippet 1546.3ocsX01aaaCDVJIpawadXEXeYeSHexAPKPjR1RZAEMMu3hf0zZrz0shggBEYZasHKZHSmzfhBreZ6mz9GrcGojrjpZPSJlbSpO9v6tm6NRpiYTFOhsbIOSSe6WdyBll9Wab9MohYGMKLNU6zi0z+FiyBWJXYlpgN7lEgKWxFqoqu4SwAz2dKM4y+73CCSBSiXqGRS6U73H1yhmGKVO5nC9o3jjggiYuLddkY6dvoQ7zi3I7U.e1zvVaQXzkgSYOODm1FFZ5O3jwwBd14hPAaILmC4iu47Y7qSUy+UwKiuHggBDsyACoFV6nYwIiGUDqK0zz2Zz5HeSUj+cFmEONtb70YfuUBXtVip4.8MpSospQIxGiRC4IiQC7QnmdE5skhdOz37nr3Eh0HH29JiSSghyjPHsWkVp4psw2uswQbXFoh8lGdIaXFHTpQuA11Vl8ss2c+tcvOP5eovLIbh4iLOIcZbJaunLFDXOMgeQXhxnOiyu7IoiGxXI8JTD+bUXl4H90rrCWID7ziCEgfYJ7txNiBEyjJo7ToJvD+cytcHDaKhcfE0tukquEwOvZfmEw0A9Y.LpMJF..1tfjKLAebjACrBJgc6a46TfP5CFbfS6XA.Ve.hja05nC7s7rKPItAVDhWInMED8KQcbjyOGEkbcqXXOWKGao+jlxxyC.oRBEfxj.hU2NRmBgAAieGqBQvJ4Z5YKiGL4nrKE8D9ScK6IE.yLnHCRc.i3Q.r7rB0pee.TNSW.mVhIMKDJAXlvMObbn.rpVDfVBHhuj+AtXvU3x5X1VU4ZCPBxHpeQjBkdZdg1WNPeB9u7rDkNPRwbBI4mqckDLTFInpRmQnpZUQwIHvx0s.DBaOm1gHNvhAZIlseSbLkTyqMfwBlcwRsApPMmxATqf9EPDx.0BM2hLAD9xELEquoDL6PJSVv5.Bsj1x4AwnOoDz1qHSN.HjiWIHlY5SqtlwkJqW4SfhKnnzhRHFTtE0.bynuSQkmBLT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ply Quote 1
            • MikeB
              MikeB last edited by MikeB

              Ok thanks - I tried that
              I already use the LAF method for my buttons
              But I didn't know that you can create different shapes by if-statement.

              What I noticed in your example is that after compiling endless values are created.
              Is that correct?

              Furthermore the question is how would I create it?
              with this method now with a button for example
              to integrate the text On and Off?

              "One hour of trial and error can save 10 minutes of reading the manual."
              "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
              HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

              Natan 1 Reply Last reply Reply Quote 0
              • Natan
                Natan @MikeB last edited by

                @MikeB said in Painted Button?:

                What I noticed in your example is that after compiling endless values are created.
                Is that correct?

                What do you mean By Endless Values?

                @MikeB said in Painted Button?:

                Furthermore the question is how would I create it?
                with this method now with a button for example
                to integrate the text On and Off?

                There is more examples On The forum For on/Off Text LAF,

                MikeB 1 Reply Last reply Reply Quote 1
                • MikeB
                  MikeB last edited by MikeB

                  @Natan Probably also an early riser 🙂

                  If I attach Console.print(value) to a button and press the button it will print once
                  Interface: 1 is generated.

                  If I attach Console.print(value) to a button in your example it will be generated endlessly.
                  Interface: 1
                  Interface: 1
                  Interface: 1
                  Interface: 1
                  etc.

                  I will look for more examples - thanks

                  "One hour of trial and error can save 10 minutes of reading the manual."
                  "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                  HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

                  Natan 1 Reply Last reply Reply Quote 0
                  • Natan
                    Natan @MikeB last edited by

                    @MikeB said in Painted Button?:

                    Console.print(value)

                    Here it Shows The Correct Value Of Buttons:
                    Interface: 1
                    Interface: 0
                    Interface: 1
                    Interface: 0
                    Interface: 1
                    Interface: 0
                    Interface: 1

                    Give it a try:

                    HiseSnippet 1609.3ocsX01aaaCDVJIZa1aYXEX+.D7mb.zLDkjsjVPQSyKtHX8EikttULLTnHSayEYICY5jFTDf8Sa+j5W2m1tijRVR0MqMEUtI0jO7t64dg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BaAYdUv98mGfsXDHaB55Of2Zz30K8RxhFCuRaNNnq.r5Kj1sM7lrd4zoLrWlgqRi4rrztcFmGc0yylNMgJUUGKyIEfSsLyN+O2a21uAk2Ddv2QguHCltWD7Rr8kSK+MahYWDfSeM27922rifDc1Sh9F4+gOS6MA5+4gIIcsess5Yu8MqtfkTtrOHXICGF3iefkTZq5eCs5XnKCyGzPT+9CCwO68ilc5recAtLJYEsgD37LNctbHooXMcAwavajGrJCN6oj7FL5cS81Jv.oTFRk9BlhDY9hrTXP2NJ7NRIYoIPKHkIGyrTENJbdVR23BIsLEtlLu0BfWlkP6sHmAJUh.J7FgR+eLrLxHT+QQIImCci1socqVjUgbOMiSeVZ28Z+l1sZeSaylPSlrQLkRSn4aDF6WN+1Dra5p4mSyKBAEKDZbrdmoFu+NSq13brL9TYgYomlx3OaAM880uplJnBcttshUv23h9V+VUeqxPnFCZOskgJdpInb06Nn8QHtyml3tME+sOP6WNEqmwFvUdD3kKn4bFF.0OldIbyFY63sLNlt7Bd1BgKqpizz+xO.m90qM4udv0kCN3UGbEaLe1ZzSOXFkMcFu5L3IMfYLDaAQ+8ivzNUL8eM6VM8KeGS+xOIS6VwzGb4sY5+97llFlogoe2aGA2QKa7pjHd8Ktg2VUA.6YpcCI7VPoKY7qqV.7Y41benz8dFiX73YaluasA9B0oet4q5tw6ZbxjIzX9Zxtiwve6y+Eg094rUbV5zmDwyYPEjwSWM+L30TwTfIoozD7bM8svM9xw13XLxbFMcrXv+BOJPBNVWARJ.0lGEmm8pX4IG3su+JwL.mRE+QHZY7DbrY4wUFF18r0lyFydUbLFJ9Af6aVFm6fLt2AY7tCxz+NHyf6fL92AYBtUYv+dLObEOatbaBLwnSDGbqqeRZDTkIpH09O.zJ7kzA
                    
                    1 Reply Last reply Reply Quote 1
                    • MikeB
                      MikeB last edited by

                      my mistake - wrong value used - Is still too early here 🙂
                      Thanks for your support

                      "One hour of trial and error can save 10 minutes of reading the manual."
                      "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                      HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

                      Natan 1 Reply Last reply Reply Quote 0
                      • Natan
                        Natan @MikeB last edited by

                        @MikeB said in Painted Button?:

                        my mistake - wrong value used - Is still too early here 🙂
                        Thanks for your support

                        No Problem👏 Glad to Help

                        1 Reply Last reply Reply Quote 1
                        • MikeB
                          MikeB @Natan last edited by

                          @Natan said in Painted Button?:

                          There is more examples On The forum For on/Off Text LAF,

                          So - now I've read all 532 posts on the subject of LAF.
                          In none of them is there an example of a LAF-generated button where I can change the text to "On" and "Off" in addition to the color change.

                          You are sure that this is possible.
                          Before I continue to search here for hours without success.

                          laf.registerFunction("drawToggleButton", function(g, obj)
                          {
                          
                              var a = obj.area;
                              
                              if (obj.text == "Power")
                              {
                                  g.fillAll(0x00000000); 
                                  g.setColour(0xFF878787);   
                          //Text "off" visible 
                                  
                                  obj.down ? g.setColour(0x75F9F9F9): "";
                          //Text "on" visible
                                  obj.value ? g.setColour(obj.itemColour1): "";
                                  
                                  g.fillPath(PowerButtonData, obj.area);
                              }
                                  g.setFont("Arial", 15.0);
                                 g.drawAlignedText("on", [0, 2, a[2], h/2], "centred");
                          
                          });
                          

                          "One hour of trial and error can save 10 minutes of reading the manual."
                          "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                          HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

                          DanH 2 Replies Last reply Reply Quote 0
                          • DanH
                            DanH @MikeB last edited by

                            @MikeB You need to use lots of 'if' and 'else if' statements - ran into this the other day, I'll grab a snippet one sec

                            1 Reply Last reply Reply Quote 0
                            • DanH
                              DanH @MikeB last edited by

                              @MikeB

                              HiseSnippet 1296.3oc6Y0yaabCFlmsufHkp.azBzUBMDHA3ndR1NMvFFMV1RAN0eHXIGTjk.p63IypSjB2QYaACu0otkr0gNTfLzwL2eAcon+A5Tm5XmaQQJ4wS5NYcVQVAwEw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rpNgIz2B60jyZ6yXsZynR5S61iAmcJPSWyRLZckegJ9Ru85Bqt027qI9KITBSvHkJNtvdPoEjhmed9eKEGdlpTZylm7l.13J.rBJf8wZA.icAfA.e++LLv9tWA9wX.1m9hWDCvdxSNXB.1RJf8y8XreeHPr5pm3yNQg6qR95eJFf0oyuECvZ29am.fsrBX18XrU0FDBIRvObXF6ku70wsT9rm8Cw.rUV4WT.a3JUOu9tLKwAz7AKht7lCBTHNPafpUKqHM0iv6F8lEtBUV2XrK7+3B2EzqP3lGEOdmIF7J1Z99FuA2SQJ8R11hjqgfcN8xe0jdoDWAnHRryIzF6h3tDY70dcZUUDMXhEHgRE+pJYn1LxXUUaCYaIyTESs7a7FwSfx7x1ZAJy2SInExzk8bS0gkxaB419RDXh5egPIz2U1F1+.dccibFfVDKxyMMkTw8EXOdeJLA9rzD3yxSfOqLA97fIvmOeB74gizG4cisQGNqkZahPPkR94pzzJQQhnL+HRv+RIU9zg
                              
                              d.healey 1 Reply Last reply Reply Quote 0
                              • d.healey
                                d.healey @DanH last edited by

                                @DanH Nice demo. You could simplify that code a little (Google DRY programming)

                                const var laf = Engine.createGlobalScriptLookAndFeel();
                                
                                laf.registerFunction("drawToggleButton", function(g, obj)
                                {    
                                    obj.value == 0 ? g.setColour(obj.bgColour) : g.setColour(obj.itemColour1);
                                            
                                    if (obj.over && !obj.value)
                                        g.setColour(obj.itemColour2);
                                    else if (obj.over && obj.value)
                                        g.setColour(obj.textColour); 
                                    
                                    g.fillRoundedRectangle(obj.area, 2);
                                    g.setColour(0xFFE3E3E3);
                                    g.setFont("Abel-Regular", 18.0);
                                    g.drawAlignedText(obj.text, obj.area, "centred"); 
                                });
                                

                                Libre Wave - Freedom respecting instruments and effects
                                My Patreon - HISE tutorials
                                YouTube Channel - Public HISE tutorials

                                MikeB 1 Reply Last reply Reply Quote 2
                                • MikeB
                                  MikeB last edited by

                                  @DanH
                                  Thank you. That helps me very much.
                                  This is exactly what I was looking for.

                                  But much less lines are enough for me - see snippet

                                  HiseSnippet 1032.3ocuVs0aaaCElJIpaVctXEn+.H7S1.tdxoWVAJBpsisJLVRrQsSwF1CEzRTxblhTPhNNdAAX+N1y6G3dd6grCkriraUxJ7tP+hOW4GO5b9HGFKcoIIxXjQowKinHiuxbzRgZ5wSILApeWjwiLOkjnnw3LUcVFQRRndHCi8eqVgQoCPoqe+McHbhvklqBgduj4ROgExT4ZG156XbtCwiNlEtg2OuUeWo3XIWNGvy9l1nHh6LR.8Lh1s8LQFOnmGSIiGoHJZBx3fNRukilJWHx7+8rD1DNUKzDMBRTlZGI2SiXsVzwSYbugqO2IHHKCyqB6mUEdh4oLO1s5yqFecpAbdDaVOL169fWyMgmcgvytH3YrA7NHCdO1bjaLKRkaQisGZ1W.en7IvmfMgUlun8908MOVBdHTMBIynNwfvsQT8k110wuv1t1qKaU15azKb2dNsO+jw3NmOd7fyJaAedRT3KHwXNwGeDtmHfInMbiovA9sb4DBOayNQJm0V34Po7p5DBt2HgpxbwA12pUZOgxe56nAy4j3J0wG9pFq1Zsuwz.ltoyYtvUwjhpU7hIKFKCB3zNyUJo.Bweswf5X4jepVYqqv4qxVXLyGWErzPQuTgO5HbkH4BZbkZWk6hdEnwVgnpYJpvErVGqdSR2iKH74zZWkq+1Lm0Qm5zjfLAcN+XO8gghdbNKJgl5KApp5JxckO6Kcb58L8uO0Kc0pMmEHndigyd0JC78qjVkRSacbEWnMHl5UAPRdvWm+WJOg92bXXJZXlXy++OOh653r0oIS35zuWWW60q6XvRwYREcfnZMqqrJYcsE9iM46WnM8.TrjyowEZVSnEeeAVULObBMtNNqcYsivj81TGl2M0wlLatYyya3nTzWvTChnh6huCshDPSsrBUfqpThkGshXIaFCw.9CKyIJwP8bCJEyaxtiNueWhhrNSPRgMJhFqX5yfQW5E.6eFkUIytzjYJYTpugQRgFBFO7yYeuLeO+gVKuU3W9wVqmm.cO.g9s+PqNusTqs7Oaby1ZOTqdvMn+TqVyLj67rYKRcdAySMMeS62ZJkELUsoFcfHiuvLkQAtS6S3ngaJjd.MhZ6qOz2Ytx.zXrEOslKVjvTK27N0+w2oTXKvmIber4PlxcZw3cuBvKzI7eMdWcCcYyd99TWUNXOvz46+2853Bgx6jyULQvoDULCZLMOad3Hn8wkBHQH.ZSPmwd5wrLYasrtxLhJ7REtAVqL1TKarxXy0FQgD2X4GbyFN0uA3KS0.XRj9TnRvax.Yby0ijll1MrQgvSS9fqqtT7T.6EGyg6PLOaGh446PLuXGh4k6PLe6NDyqt2XzuJr8bkLLaLATLrWJ0ngQOAA5xR6HQ+EPWnavG
                                  

                                  "One hour of trial and error can save 10 minutes of reading the manual."
                                  "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                                  HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

                                  1 Reply Last reply Reply Quote 0
                                  • MikeB
                                    MikeB @d.healey last edited by

                                    @d-healey said in Painted Button?:

                                    @DanH Nice demo. You could simplify that code a little (Google DRY programming)

                                    const var laf = Engine.createGlobalScriptLookAndFeel();
                                    
                                    laf.registerFunction("drawToggleButton", function(g, obj)
                                    {    
                                        obj.value == 0 ? g.setColour(obj.bgColour) : g.setColour(obj.itemColour1);
                                                
                                        if (obj.over && !obj.value)
                                            g.setColour(obj.itemColour2);
                                        else if (obj.over && obj.value)
                                            g.setColour(obj.textColour); 
                                        
                                        g.fillRoundedRectangle(obj.area, 2);
                                        g.setColour(0xFFE3E3E3);
                                        g.setFont("Abel-Regular", 18.0);
                                        g.drawAlignedText(obj.text, obj.area, "centred"); 
                                    });
                                    

                                    @David
                                    Now I have already shortened my example and learned from you. (see snippet)
                                    But your version is of course even more elegant

                                    "One hour of trial and error can save 10 minutes of reading the manual."
                                    "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                                    HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

                                    1 Reply Last reply Reply Quote 0
                                    • MikeB
                                      MikeB last edited by MikeB

                                      @d-healey
                                      Whereas your example concerns the general LAF button
                                      not a second or third one which is defined by "(obj.text == "XXXXX"){
                                      is created.

                                      "One hour of trial and error can save 10 minutes of reading the manual."
                                      "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                                      HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

                                      d.healey 1 Reply Last reply Reply Quote 0
                                      • d.healey
                                        d.healey @MikeB last edited by

                                        @MikeB Because all those buttons need the same code. If a particular button needs different code then it's time to use an if statement.

                                        Libre Wave - Freedom respecting instruments and effects
                                        My Patreon - HISE tutorials
                                        YouTube Channel - Public HISE tutorials

                                        1 Reply Last reply Reply Quote 0
                                        • MikeB
                                          MikeB last edited by

                                          I understood that now - thanks

                                          "One hour of trial and error can save 10 minutes of reading the manual."
                                          "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                                          HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

                                          1 Reply Last reply Reply Quote 1
                                          • First post
                                            Last post

                                          20
                                          Online

                                          982
                                          Users

                                          6.6k
                                          Topics

                                          60.8k
                                          Posts