2 #include "IPlug_include_in_plug_src.h"
5 #include "IBitmapMonoText.h"
7 const int kNumPrograms
= 1;
25 IPlugText::IPlugText(IPlugInstanceInfo instanceInfo
)
26 : IPLUG_CTOR(kNumParams
, kNumPrograms
, instanceInfo
), mGain(1.)
30 //arguments are: name, defaultVal, minVal, maxVal, step, label
31 GetParam(kGain
)->InitDouble("Gain", 50., 0., 100.0, 0.01, "%");
32 GetParam(kGain
)->SetShape(2.);
34 IGraphics
* pGraphics
= MakeGraphics(this, kWidth
, kHeight
);
35 pGraphics
->AttachPanelBackground(&COLOR_GRAY
);
37 IRECT
tmpRect(10, 10, 200, 30);
38 IText
textProps(12, &COLOR_BLACK
, "Arial", IText::kStyleNormal
, IText::kAlignCenter
, 0, IText::kQualityDefault
);
39 pGraphics
->AttachControl(new ITextControl(this, tmpRect
, &textProps
, "hello iplug!"));
41 IRECT
tmpRect2(30, 30, 200, 60);
42 IText
textProps2(18, &COLOR_WHITE
, "Tahoma", IText::kStyleNormal
, IText::kAlignCenter
, 0, IText::kQualityDefault
);
43 pGraphics
->AttachControl(new ITextControl(this, tmpRect2
, &textProps2
, "hello iplug!"));
45 IRECT
tmpRect3(80, 50, 200, 80.);
46 IText
textProps3(24, &COLOR_RED
, "Arial", IText::kStyleItalic
, IText::kAlignFar
, 0, IText::kQualityDefault
);
47 pGraphics
->AttachControl(new ITextControl(this, tmpRect3
, &textProps3
, "hello iplug!"));
49 IRECT
tmpRect4(120, 60, 300, 120);
50 IText
textProps4(40, &COLOR_ORANGE
, "Arial", IText::kStyleNormal
, IText::kAlignCenter
, 0, IText::kQualityDefault
);
51 pGraphics
->AttachControl(new ITextControl(this, tmpRect4
, &textProps4
, "hello iplug!"));
53 IRECT
tmpRect5(10, 100, 370, 170);
54 IText
textProps5(50, &COLOR_BLUE
, "Courier", IText::kStyleNormal
, IText::kAlignCenter
, 0, IText::kQualityDefault
);
56 pGraphics
->MeasureIText(&textProps5
, "hello iplug!", &tmpRect5
); // get the bounds of the text and stick them in tmpRect5
57 pGraphics
->AttachControl( new IPanelControl(this, tmpRect5
, &COLOR_WHITE
));
59 tmpRect5
= IRECT(10, 100, 370, 170);
60 pGraphics
->AttachControl(new ITextControl(this, tmpRect5
, &textProps5
, "hello iplug!"));
62 IBitmap blackText
= pGraphics
->LoadIBitmap(TEXT_BLACK_ID
, TEXT_BLACK_FN
, 95, true);
63 IBitmap whiteText
= pGraphics
->LoadIBitmap(TEXT_WHITE_ID
, TEXT_WHITE_FN
, 95, true);
65 IRECT
tmpRect6(10, 200, 300, 220);
66 IText
textProps6(12, &COLOR_BLACK
, "Arial", IText::kStyleNormal
, IText::kAlignCenter
, 0, IText::kQualityDefault
);
67 pGraphics
->AttachControl(new IBitmapTextControl(this, tmpRect6
, &blackText
, "i'm bitmap monospace text", &textProps6
, 6, 12, 0));
69 IRECT
tmpRect7(10, 220, 300, 260);
70 IText
textProps7(12, &COLOR_BLACK
, "Arial", IText::kStyleNormal
, IText::kAlignNear
, 0, IText::kQualityDefault
);
71 pGraphics
->AttachControl(new IBitmapTextControl(this, tmpRect7
, &whiteText
, "i'm also bitmap monospace text, but i'm a long string and i might overflow the control bounds or wrap onto new lines", &textProps7
, 6, 12, 0, true, false));
73 pGraphics
->ShowControlBounds(true);
75 AttachGraphics(pGraphics
);
76 //MakePreset("preset 1", ... );
77 MakeDefaultPreset((char *) "-", kNumPrograms
);
80 IPlugText::~IPlugText() {}
82 void IPlugText::ProcessDoubleReplacing(double** inputs
, double** outputs
, int nFrames
)
84 // Mutex is already locked for us.
86 double* in1
= inputs
[0];
87 double* in2
= inputs
[1];
88 double* out1
= outputs
[0];
89 double* out2
= outputs
[1];
91 //double samplesPerBeat = GetSamplesPerBeat();
92 //double samplePos = (double) GetSamplePos();
93 //double tempo = GetTempo();
95 for (int s
= 0; s
< nFrames
; ++s
, ++in1
, ++in2
, ++out1
, ++out2
)
102 void IPlugText::Reset()
105 IMutexLock
lock(this);
107 //double sr = GetSampleRate();
110 void IPlugText::OnParamChange(int paramIdx
)
112 IMutexLock
lock(this);
117 mGain
= GetParam(kGain
)->Value() / 100.;;