HISE Logo Forum
    • Categories
    • Register
    • Login

    Look and feel drawing help

    Scheduled Pinned Locked Moved Scripting
    lookandfeelsliderhelp
    2 Posts 2 Posters 49 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.
    • E
      eokeefee
      last edited by

      I am trying to make a vertical slider show a circle where the value is. I have the following code:

      const laf = Engine.createGlobalScriptLookAndFeel();
      
      laf.registerFunction("drawLinearSlider", function(g, obj)
      {
          obj.drawOutside = true;
      
          var a = obj.area;
          var norm = obj.valueNormalized;
      
          var cx = a[0] + (a[2] / 2);
          var cy = a[1] + a[3] * (1.0 - norm);
      
          var radius = 15;
      
          g.setColour(obj.itemColour1);
          g.fillEllipse([cx - radius, cy - radius, radius * 2, radius * 2]);
      });
      

      This is working great, however the circle clips when it reaches the top
      Screenshot_1.jpg (The red is the circle).

      Is there a way to stop the clipping? I think it's something to do with the bounds of the slider, but I'm not sure...

      ustkU 1 Reply Last reply Reply Quote 0
      • ustkU
        ustk @eokeefee
        last edited by

        @eokeefee The full displacement is then the slider height minus the circle height:

        laf.registerFunction("drawLinearSlider", function(g, obj)
        {
            obj.drawOutside = true;
        
            var a = obj.area;
            var norm = obj.valueNormalized;
        
            var radius = 15;
            
            var cx = a[0] + (a[2] / 2);
            
            var start = a[1] + radius;
            var usefulDisplacement = a[3] - 2*radius;
            var cy = start + usefulDisplacement * (1.0 - norm);
            
            g.setColour(obj.itemColour1);
            g.fillEllipse([cx - radius, cy - radius, radius * 2, radius * 2]);
        });
        

        Hise made me an F5 dude, browser just suffers...

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

        37

        Online

        2.1k

        Users

        12.9k

        Topics

        112.1k

        Posts