COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 02-11-2018, 01:19 AM   #1
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 506
Default IKnobMultiControl with text field

I want to make a class which is a small box showing a value and which when dragged the value changes. I thought for this an IKnobMultiControl with rendered bitmaps of all the values needed would do the job without making a derived class.
I would like to have a text label for it built in that gets set in the constructor and is always adjacent to the value box with chosen alignment.
Best approach?
I'm thinking I would derive from IKnobMultiControl and add an ITextControl as a member to the new class. Does this makes sense or is there a better way? I'd like to have it that if the text label itself is dragged the value changes in the box (not just dragging the target area of the bitmap).
Thanks
Guod3 is offline   Reply With Quote
Old 02-11-2018, 08:31 AM   #2
olilarkin
Human being with feelings
 
olilarkin's Avatar
 
Join Date: Apr 2009
Location: Huddersfield, UK
Posts: 1,111
Default

https://github.com/olilarkin/wdl-ol/...ontrols.h#L294
__________________
VirtualCZ | pMix | Endless Series | WDL-OL | Linkedin | Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
olilarkin is offline   Reply With Quote
Old 02-11-2018, 05:07 PM   #3
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 506
Default

Thanks Oli!
Guod3 is offline   Reply With Quote
Old 02-13-2018, 12:12 AM   #4
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 506
Default

The one Oli linked to was not exactly what I was after but it showed me how to do it.(I simply wanted an unchanging text label positioned near the bitmap.) The rectangle of the control covers the text, so that the control can be changed by click-dragging an area including the label.
Here it is:
Code:
class IMultiBitmapLabelled : public IKnobControl
{
private:
	IRECT mTextRECT, mImgRECT;
	IBitmap mBitmap;
	char Label[20];

public:
	IMultiBitmapLabelled(IPlugBase* pPlug, IRECT pR, int paramIdx, IBitmap* pBitmap, IText* pText,char*label)
		: IKnobControl(pPlug, pR, paramIdx), mBitmap(*pBitmap)
	{
		strcpy(Label,label);
		mText = *pText;
		mTextRECT = IRECT(mRECT.L, mRECT.B- mText.mSize, mRECT.R, mRECT.B);
		mImgRECT = IRECT(mRECT.L+(mRECT.R- mRECT.L-(pBitmap->W))/2,mRECT.T,&mBitmap);//place bitmap centred
	}

	~IMultiBitmapLabelled() {}

	bool Draw(IGraphics* pGraphics)
	{
		int i = 1 + int(0.5 + mValue * (double)(mBitmap.N - 1));
		i = BOUNDED(i, 1, mBitmap.N);
		pGraphics->DrawBitmap(&mBitmap, &mImgRECT, i, &mBlend);
		return pGraphics->DrawIText(&mText, Label, &mTextRECT);
	}
};
Guod3 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.