iPlug2 Forum

Backgrounds , SVG and Panel

Hi.

I am having some difficulty getting SVG background attached.

I don’t understand why

    pGraphics->AttachPanelBackground(NEL_TUNGSTEN);
   pGraphics->AttachSVGBackground (GEN_DIAL);

hides the SVG, even tho bg is transparent in the SVG.

If I comment out the pGraphics->AttachPanelBackground(NEL_TUNGSTEN);

then the SVG is drawn with a bright blue background which I haven’t specified, and also my animations don’t seem to refresh properly, like the background isn’t been drawn again?

I’m not sure I understand the Layers thing. I noticed in the AttachSVGBackground method

IControl* pBG = new ISVGControl(GetBounds(), LoadSVG(fileName), true);

that the true at the end, refers to a Use Layers flag.

If I put that code in directly in my setup, and set that flag to false, then I get the redrawing behaviour I expect… like this

pGraphics->AttachPanelBackground(NEL_TUNGSTEN); pGraphics->AttachControl(new ISVGControl(pGraphics->GetBounds(), pGraphics->LoadSVG(GEN_DIAL), false));

So what’s the right way to use AttachSVGBackground ?

Is there any transparency in the SVG?

If I fill a background color with ISVGControl, it draws correctly

class ISVGControl : public IControl
{
public:
  ISVGControl(const IRECT& bounds, const ISVG& svg, bool useLayer = false)
  : IControl(bounds)
  , mSVG(svg)
  , mUseLayer(useLayer)
  {}

  virtual ~ISVGControl() {}

  void Draw(IGraphics& g) override
  {
    if(mUseLayer)
    {
      g.FillRect(COLOR_WHITE, mRECT); // added this

yes, the SVG background is transparent.

You can’t really have a transparent SVG as background because what is it going to show through to? We don’t support transparent windows, It will just show through to garbage in the framebuffer

I thought it might show the AttachPanelBackground(NEL_TUNGSTEN); colour background

hmm it should in that case …

… you can’t attach a panel background AND an SVG background. There can only be one background control (index #0). Attach an ISVGControl using pGraphics->AttachControl() for the SVG, after AttachPanelBackground()

Thanks for the info. I tried the way you suggested but by SVG is quite complex and the frame rate slowed.

I tried the same SVG with a solid rectangle included in it as a background and attached that as background and the frame rate is maintained ( nice and responsive ) so I’ll choose that route for now

Thanks!

:top:

You can also set the use layer argument true which will cache the SVG to a bitmap