childPanel painting issue

  • @Christoph-Hart This drove me crazy for hours until I found this might be a bug...

    In this example, a childPanel has a child at its right with the same alpha value as the reference rectangle at the left.
    We can see that the children seem to be painted twice, as the resulting alpha don't look the same...
    This also causes the font to be emphasized

    HiseSnippet 1420.3ocsX0uaaaCDmJMpswaoXcXO.D4uj67bkS+Z.EEyN1IqFKI0HNqc.EEELRzVDQlTPhNtFEA6UYOZ6QXuAaGo9h1V1KHEU8Op4c7t62c7tiGyfXgGMIQDir1474QTj02ZObNWFzMfv3n98PVOv9DRhjFiSIcv7HRRB0GYYcmeUQvZmsQ5u+4WNfDR3dzRRHzaELO5

  • When you choose a color tone that you want with 1.0 alpha value, I think it shouldn't look like this, even the children painted twice.

  • @Steve-Mohican I agree but this means something's going wrong in the back anyway

  • I updated the snippet above for a clearer demonstration...

  • @Steve-Mohican And this doesn't fix the font glitch (aliasing) when a text is painted twice

  • @Christoph-Hart Any insight on this?

  • I found a solution/workaround for you

    inline function addAlphaPanelToChild(p)
        local panel = p.addChildPanel(); = panel;
        panel.setPosition(110, 5, 70, 40);
            g.fillAll(Colours.white); // <<< I added this line
            g.setColour(Colours.withAlpha(, 0.3));
            g.fillRect([0, 0, 70, 20]);
            g.drawAlignedText("CHILD", [0, 20, 70, 20], "centred");

  • @d-healey Thank you Dave for this workaround. Effectively when it is painted for the second time it acts as a mask.
    This works but we still have to keep in mind an operation is done for nothing if painted twice.
    I'll use your workaround for now 😉

  • Have you played around with the opaque property? There are some glitches if you set it to true and then fill it with a (semi-)transparent background

  • @Christoph-Hart Yep, I tried, opaque doesn't help...

  • Wow, that was super annoying to fix, but it somehow added the child panel twice when you click the button.

    BTW, I noticed you're using an external array to keep a reference to the panel. This is not recommended as there is already a list that you can query with this function.

  • @Christoph-Hart Annoying? 7 lines of code? 😛

    The list I use is from the example in the documentation. This should be updated then...

    Thanks a lot!

    Noticed the last math APIs... What the difference between Math.wrap and Math.range? Is that more adapted for signals?

  • Fmod behaves weird for negative values so for any kind of looping wrap is better.

Log in to reply