iPlug2 Forum

HideControl() and DisableControl() producing same result in Windows - SOLVED

HideControl() and DisableControl() are producing the same result in Windows - they both completely hide the control.

I checked back through the code and DisableControl() SHOULD be graying out with 0.25f alpha (GRAYED_ALPHA = 0.25f) - but it’s not, it’s completely gone. Don’t know why. This is with bitmaps, BTW, not VG.

just tested this, and it is working as expected on windows

  mLayoutFunc = [&](IGraphics* pGraphics) {
    pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
    pGraphics->AttachPanelBackground(COLOR_GRAY);
    pGraphics->AttachControl(new IBitmapControl(100, 100, pGraphics->LoadBitmap(VU2X_FN, 201), kGain));
    auto b = pGraphics->GetBounds();
    pGraphics->AttachControl(new IVToggleControl(b.GetFromBottom(100).FracRectHorizontal(0.5, false), [](IControl* pCaller) {
      pCaller->GetUI()->HideControl(0, pCaller->GetValue() > 0.5f);
      SplashClickActionFunc(pCaller);
      }, "HIDE"));

    pGraphics->AttachControl(new IVToggleControl(b.GetFromBottom(100).FracRectHorizontal(0.5, true), [](IControl* pCaller) {
      pCaller->GetUI()->DisableControl(0, pCaller->GetValue() > 0.5f);
      SplashClickActionFunc(pCaller);
      }, "DISABLE"));
  };

Just checked again and it is not working here. “Disable” and “Hide” both completely hide the control.

GetUI()->HideControl(kMonomixControl, true);
GetUI()->DisableControl(kTrimControl, true);

Any idea what’s wrong?

These methods are not very well named, the first argument is a parameter ID, not the control tag or index in the control stack.

Is kMonomixControl a parameter index in your EParams etc?

Yes, kMonomixControl and kTrimControl are EParams.

are you calling disable immediately after hide?

No, it’s two different controls used just to test the functions. I set them “true” statically as shown just to see what it does. When turned on/off at runtime Disable and Hide both completely hide/show the control.

don’t know what you’ve done, but it works here

  mLayoutFunc = [&](IGraphics* pGraphics) {
    pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
    pGraphics->AttachPanelBackground(COLOR_GRAY);
    pGraphics->AttachControl(new IBitmapControl(100, 100, pGraphics->LoadBitmap(VU2X_FN, 201), kGain));
    pGraphics->AttachControl(new IBitmapControl(100, 300, pGraphics->LoadBitmap(VU2X_FN, 201), kFreq));

    pGraphics->DisableControl(kGain, true);
    pGraphics->HideControl(kFreq, true);

Hang on - your example above is “Hidding/Disabling” from inside the mLayoutFunc where “pGraphics” is local. In order to access outside - in OnIdle or anywhere else - that doesn’t work. You have to use GetUI()-> AFAIK, which has the issue I’m reporting.

Am I misunderstanding something?

Where are you calling it? If GetUI() is returning a valid pointer (the graphics context exists) it should still work

The most important difference to grasp about the graphics in iPlug2 vs iPlug1 is that the IGraphics context is transient. Every time you open/close the plug-in UI it is destroyed and recreated.

I have shipped plugins on windows that use both without issue - we’d probably need full example code to look at why this is happening for you, as well as info on what drawing backend you are using etc.

Argh! My bad. It turns out “disable” does work but the nature of my graphics made it hard to see. I think I may increase Alpha to 0.35, or some other amount TBD, as my default. “GrayOutControl()” was a little more obvious in iPlug1.

Thank you for the input.