HISE Logo Forum
    • Categories
    • Register
    • Login

    Painted Button?

    Scheduled Pinned Locked Moved General Questions
    19 Posts 4 Posters 648 Views
    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.
    • NatanN
      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
      • MikeBM
        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

        DanHD 2 Replies Last reply Reply Quote 0
        • DanHD
          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

          DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
          https://dhplugins.com/ | https://dcbreaks.com/
          London, UK

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

            @MikeB

            HiseSnippet 1296.3oc6Y0yaabCFlmsufHkp.azBzUBMDHA3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P0qjkrKvbgob+Jhc2fJho9Qf.h.iIzCJ0CvmchVURvUv8Buatuz6l6KGi6Gt8VHNRVYv.BQPRswtbhboVaK7wDSrpNgIz2B60jyZ6yXsZynR5S61iAmcJPSWyRLZckegJ9Ru85Bqt027qI9KITBSvHkJNtvdPoEjhmed9eKEGdlpTZylm7l.13J.rBJf8wZA.icAfA.e++LLv9tWA9wX.1m9hWDCvdxSNXB.1RJf8y8XreeHPr5pm3yNQg6qR95eJFf0oyuECvZ29am.fsrBX18XrU0FDBIRvObXF6ku70wsT9rm8Cw.rUV4WT.a3JUOu9tLKwAz7AKht7lCBTHNPafpUKqHM0iv6F8lEtBUV2XrK7+3B2EzqP3lGEOdmIF7J1Z99FuA2SQJ8R11hjqgfcN8xe0jdoDWAnHRryIzF6h3tDY70dcZUUDMXhEHgRE+pJYn1LxXUUaCYaIyTESs7a7FwSfx7x1ZAJy2SInExzk8bS0gkxaB419RDXh5egPIz2U1F1+.dccibFfVDKxyMMkTw8EXOdeJLA9rzD3yxSfOqLA97fIvmOeB74gizG4cisQGNqkZahPPkR94pzzJQQhnL+HRv+RIU9zg
            

            DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
            https://dhplugins.com/ | https://dcbreaks.com/
            London, UK

            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              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

              MikeBM 1 Reply Last reply Reply Quote 2
              • MikeBM
                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
                • MikeBM
                  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
                  • MikeBM
                    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.healeyD 1 Reply Last reply Reply Quote 0
                    • d.healeyD
                      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
                      • MikeBM
                        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

                        1.8k

                        Users

                        12.0k

                        Topics

                        104.3k

                        Posts