Gui confusion (sliders linking)

I cannot for the life of me figure this out. This project is coming from the Template project. No matter what I do, the last slider I make is the only one that moves. Even when I move the first two sliders, the last one moves. I don’t see how they are linked. I am sure it is something stupid. Thanks for any help.

Sam

    //-----------------Graphics
    
    GetParam(kParamGain)->InitDouble("Gain", 0., 0., 100.0, 0.01, "%");
    GetParam(kParamDurMult)->InitDouble("Dur Mult", 20., 2., 200.0, 1.0, "x");
    GetParam(kParamTemp)->InitDouble("Temp", 0., 0., 10.0, 1.0, "nils");
    
#if IPLUG_EDITOR // http://bit.ly/2S64BDd
    mMakeGraphicsFunc = [&]() {
        return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS);
    };
    
    mLayoutFunc = [&](IGraphics* pGraphics) {
        const IRECT bounds = pGraphics->GetBounds();
        const IRECT innerBounds = bounds.GetPadded(-10.f);
        
        const IRECT sliderBounds = innerBounds.GetFromLeft(150).GetMidVPadded(100);
        const IRECT sliderBounds2 = innerBounds.GetFromLeft(350).GetMidVPadded(100);
        const IRECT sliderBounds3 = innerBounds.GetFromLeft(550).GetMidVPadded(100);
        
        const IRECT versionBounds = innerBounds.GetFromTRHC(300, 20);
        const IRECT titleBounds = innerBounds.GetCentredInside(200, 50);
        
        if (pGraphics->NControls()) {
            pGraphics->GetBackgroundControl()->SetTargetAndDrawRECTs(bounds);
            
            pGraphics->GetControlWithTag(kCtrlTagSlider)->SetTargetAndDrawRECTs(sliderBounds);
            pGraphics->GetControlWithTag(kCtrlTagSlider2)->SetTargetAndDrawRECTs(sliderBounds2);
            pGraphics->GetControlWithTag(kCtrlTagSlider3)->SetTargetAndDrawRECTs(sliderBounds3);
            
            pGraphics->GetControlWithTag(kCtrlTagTitle)->SetTargetAndDrawRECTs(titleBounds);
            pGraphics->GetControlWithTag(kCtrlTagVersionNumber)->SetTargetAndDrawRECTs(versionBounds);
            return;
        }
        
        pGraphics->SetLayoutOnResize(true);
        pGraphics->AttachCornerResizer(EUIResizerMode::Size, true);
        pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
        pGraphics->AttachPanelBackground(COLOR_LIGHT_GRAY);
        
        pGraphics->AttachControl(new IVSliderControl(sliderBounds, kParamGain), kCtrlTagSlider);
        pGraphics->AttachControl(new IVSliderControl(sliderBounds2, kParamDurMult), kCtrlTagSlider2);
        pGraphics->AttachControl(new IVSliderControl(sliderBounds3, kParamTemp), kCtrlTagSlider3);
        
        pGraphics->AttachControl(new ITextControl(titleBounds, "Ness Stretch", IText(30)), kCtrlTagTitle);
        WDL_String buildInfoStr;
        GetBuildInfoStr(buildInfoStr, __DATE__, __TIME__);
        pGraphics->AttachControl(new ITextControl(versionBounds, buildInfoStr.Get(), DEFAULT_TEXT.WithAlign(EAlign::Far)), kCtrlTagVersionNumber);
    };
#endif

hi sam!

what are the values of kParamGain, kParamDurMult and kParamTemp ?

Hi Oli,

I am using these enums in the .h file:

enum EParams
{
kParamGain, kParamDurMult, kParamTemp,
kNumParams
};

enum ECtrlTags
{
kCtrlTagSlider,
kCtrlTagSlider2,
kCtrlTagSlider3,
kCtrlTagVersionNumber,
kCtrlTagTitle
};

I am not sure what is going on, but here is a git patch you can apply to IPlugOOS/master to show that it works:

diff --git a/TemplateProject/TemplateProject.cpp b/TemplateProject/TemplateProject.cpp
index 6541ca0..8ae410b 100644
--- a/TemplateProject/TemplateProject.cpp
+++ b/TemplateProject/TemplateProject.cpp
@@ -9,6 +9,8 @@ TemplateProject::TemplateProject(const InstanceInfo& info)
 : Plugin(info, MakeConfig(kNumParams, kNumPresets))
 {
   GetParam(kParamGain)->InitDouble("Gain", 0., 0., 100.0, 0.01, "%");
+  GetParam(kParamFreq)->InitDouble("Freq", 0., 0., 100.0, 0.01, "%");
+  GetParam(kParamVol)->InitDouble("Vol", 0., 0., 100.0, 0.01, "%");
 
 #if IPLUG_EDITOR // http://bit.ly/2S64BDd
   mMakeGraphicsFunc = [&]() {
@@ -16,15 +18,19 @@ TemplateProject::TemplateProject(const InstanceInfo& info)
   };
   
   mLayoutFunc = [&](IGraphics* pGraphics) {
-    const IRECT bounds = pGraphics->GetBounds();
-    const IRECT innerBounds = bounds.GetPadded(-10.f);
-    const IRECT sliderBounds = innerBounds.GetFromLeft(150).GetMidVPadded(100);
-    const IRECT versionBounds = innerBounds.GetFromTRHC(300, 20);
-    const IRECT titleBounds = innerBounds.GetCentredInside(200, 50);
 
+layout:
     if (pGraphics->NControls()) {
+      const IRECT bounds = pGraphics->GetBounds();
+      const IRECT innerBounds = bounds.GetPadded(-10.f);
+      const IRECT sliderBounds = innerBounds.GetFromLeft(150).GetMidVPadded(100);
+      const IRECT versionBounds = innerBounds.GetFromTRHC(300, 20);
+      const IRECT titleBounds = innerBounds.GetCentredInside(200, 50);
+      
       pGraphics->GetBackgroundControl()->SetTargetAndDrawRECTs(bounds);
-      pGraphics->GetControlWithTag(kCtrlTagSlider)->SetTargetAndDrawRECTs(sliderBounds);
+      pGraphics->GetControlWithTag(kCtrlTagSlider1)->SetTargetAndDrawRECTs(sliderBounds);
+      pGraphics->GetControlWithTag(kCtrlTagSlider2)->SetTargetAndDrawRECTs(sliderBounds.GetHShifted(sliderBounds.W()));
+      pGraphics->GetControlWithTag(kCtrlTagSlider3)->SetTargetAndDrawRECTs(sliderBounds.GetHShifted(sliderBounds.W() * 2));
       pGraphics->GetControlWithTag(kCtrlTagTitle)->SetTargetAndDrawRECTs(titleBounds);
       pGraphics->GetControlWithTag(kCtrlTagVersionNumber)->SetTargetAndDrawRECTs(versionBounds);
       return;
@@ -34,11 +40,15 @@ TemplateProject::TemplateProject(const InstanceInfo& info)
     pGraphics->AttachCornerResizer(EUIResizerMode::Size, true);
     pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
     pGraphics->AttachPanelBackground(COLOR_LIGHT_GRAY);
-    pGraphics->AttachControl(new IVSliderControl(sliderBounds, kParamGain), kCtrlTagSlider);
-    pGraphics->AttachControl(new ITextControl(titleBounds, "TemplateProject", IText(30)), kCtrlTagTitle);
+    pGraphics->AttachControl(new IVSliderControl(IRECT(), kParamGain), kCtrlTagSlider1);
+    pGraphics->AttachControl(new IVSliderControl(IRECT(), kParamFreq), kCtrlTagSlider2);
+    pGraphics->AttachControl(new IVSliderControl(IRECT(), kParamVol), kCtrlTagSlider3);
+    pGraphics->AttachControl(new ITextControl(IRECT(), "TemplateProject", IText(30)), kCtrlTagTitle);
     WDL_String buildInfoStr;
     GetBuildInfoStr(buildInfoStr, __DATE__, __TIME__);
-    pGraphics->AttachControl(new ITextControl(versionBounds, buildInfoStr.Get(), DEFAULT_TEXT.WithAlign(EAlign::Far)), kCtrlTagVersionNumber);
+    pGraphics->AttachControl(new ITextControl(IRECT(), buildInfoStr.Get(), DEFAULT_TEXT.WithAlign(EAlign::Far)), kCtrlTagVersionNumber);
+    
+    goto layout;
   };
 #endif
 }
diff --git a/TemplateProject/TemplateProject.h b/TemplateProject/TemplateProject.h
index 74cf709..2eceadc 100644
--- a/TemplateProject/TemplateProject.h
+++ b/TemplateProject/TemplateProject.h
@@ -7,13 +7,17 @@ const int kNumPresets = 1;
 enum EParams
 {
   kParamGain = 0,
+  kParamFreq,
+  kParamVol,
   kNumParams
 };
 
 enum ECtrlTags
 {
   kCtrlTagVersionNumber = 0,
-  kCtrlTagSlider,
+  kCtrlTagSlider1,
+  kCtrlTagSlider2,
+  kCtrlTagSlider3,
   kCtrlTagTitle
 };
 

That did it. Thanks!

Sam