Skip to content

Instantly share code, notes, and snippets.

@olilarkin
Created July 14, 2021 17:54
Show Gist options
  • Save olilarkin/93bb02e85d174ebf0b0e1ca061b69a2a to your computer and use it in GitHub Desktop.
Save olilarkin/93bb02e85d174ebf0b0e1ca061b69a2a to your computer and use it in GitHub Desktop.

Revisions

  1. olilarkin created this gist Jul 14, 2021.
    47 changes: 47 additions & 0 deletions IPlugEffect.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    #include "IPlugEffect.h"
    #include "IPlug_include_in_plug_src.h"
    #include "IControls.h"

    class MyControl : public IControl {
    public:
    MyControl(const IRECT& r)
    : IControl(r)
    {
    mTimer = std::unique_ptr<Timer>(Timer::Create([&](Timer& t) {
    mColor = IColor::GetRandomColor();
    this->SetDirty(false);
    }, 100));
    }

    void Draw(IGraphics &g) override
    {
    g.FillEllipse(mColor, mRECT);
    }

    private:
    IColor mColor = COLOR_BLUE;
    std::unique_ptr<Timer> mTimer;
    };


    IPlugEffect::IPlugEffect(const InstanceInfo& info)
    : Plugin(info, MakeConfig(kNumParams, kNumPresets))
    {
    GetParam(kGain)->InitDouble("Gain", 0., 0., 100.0, 0.01, "%");

    #if IPLUG_EDITOR // http://bit.ly/2S64BDd
    mMakeGraphicsFunc = [&]() {
    return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS, GetScaleForScreen(PLUG_WIDTH, PLUG_HEIGHT));
    };

    mLayoutFunc = [&](IGraphics* pGraphics) {
    pGraphics->AttachCornerResizer(EUIResizerMode::Scale, false);
    pGraphics->AttachPanelBackground(COLOR_GRAY);
    pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
    const IRECT b = pGraphics->GetBounds();
    pGraphics->AttachControl(new MyControl(b.GetCentredInside(100)));
    };
    #endif
    }

    ...