HISE Logo Forum
    • Categories
    • Register
    • Login

    I seem to have forgotten how to implement LAF on a label

    Scheduled Pinned Locked Moved Scripting
    5 Posts 3 Posters 85 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.
    • VirtualVirginV
      VirtualVirgin
      last edited by

      This isn't drawing the look and feel:

      // create the search bar
      const var searchBar = Content.addLabel("searchBar", 10, 10);
      searchBar.set("width", 250);
      searchBar.set("height", 30);
      searchBar.set("text", "Search...");
      searchBar.set("editable", true);
      
      // laf
      const laf = Content.createLocalLookAndFeel();
      searchBar.setLocalLookAndFeel(laf);
      
      laf.registerFunction("drawLabel", function(g, obj)
      {
          var w = obj.area[2];
          var h = obj.area[3];
      
          g.setColour(Colours.white);
          g.fillRect([0, 0, w, h]);
      
          g.setColour(Colours.grey);
          g.drawRoundedRectangle([0, 0, w, h], 5, 1);
      
          var iconSize = 12;
          var cx = 10;
          var cy = h / 2;
      
          g.setColour(Colours.grey);
          g.drawEllipse([cx, cy - iconSize / 2, iconSize, iconSize], 1.5);
      
          var angle = 45 * Math.PI / 180;
          var lineLength = 7;
          var startX = cx + iconSize / 2 * Math.cos(angle);
          var startY = cy + iconSize / 2 * Math.sin(angle);
          var endX = startX + lineLength * Math.cos(angle);
          var endY = startY + lineLength * Math.sin(angle);
      
          g.drawLine(startX, endX, startY, endY, 1.5);
      
          g.setColour(Colours.black);
          g.setFont("Arial", 14);
          
          var textOffset = 25;
          g.drawAlignedText(obj.text || "", [textOffset, 0, w - textOffset - 5, h], "left");
      });
      

      I'm suspecting the name of the laf function, but I do not see a reference to find what names to use.

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

        @VirtualVirgin Labels don't have laf. You need to draw it on the panel behind the label - or just use a panel.

        @VirtualVirgin said in I seem to have forgotten how to implement LAF on a label:

        but I do not see a reference to find what names to use.

        The autocomplete popup contains a full list.

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

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

          @d-healey said in I seem to have forgotten how to implement LAF on a label:

          @VirtualVirgin Labels don't have laf. You need to draw it on the panel behind the label - or just use a panel.

          @VirtualVirgin said in I seem to have forgotten how to implement LAF on a label:

          but I do not see a reference to find what names to use.

          The autocomplete popup contains a full list.

          These should probably be removed from the Docs then:
          Screenshot 2025-04-17 at 5.56.25 PM.png
          Screenshot 2025-04-17 at 5.56.09 PM.png

          Also, maybe I don't know how to use the autocomplete in the way you are referring to it, but it don't get anything when typing in the name argument in the script:
          Screenshot 2025-04-17 at 5.55.31 PM.png

          d.healeyD HISEnbergH 2 Replies Last reply Reply Quote 0
          • d.healeyD
            d.healey @VirtualVirgin
            last edited by

            @VirtualVirgin said in I seem to have forgotten how to implement LAF on a label:

            These should probably be removed from the Docs then:

            Yeah I think that's auto-generated.

            @VirtualVirgin said in I seem to have forgotten how to implement LAF on a label:

            Also, maybe I don't know how to use the autocomplete in the way you are referring to it, but it don't get anything when typing in the name argument in the script:

            Start typing register function and when the list pops up it will show all the available functions. If you don't have it set to auto popup then you need to press ESC to open it.

            5bd97b26-2fe5-4815-95c8-330f0d939883-image.png

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

            1 Reply Last reply Reply Quote 0
            • HISEnbergH
              HISEnberg @VirtualVirgin
              last edited by

              @VirtualVirgin You might try CSS on the Label instead:

              Link Preview Image
              HISE | Docs

              favicon

              (docs.hise.audio)

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

              14

              Online

              1.7k

              Users

              11.8k

              Topics

              102.3k

              Posts