Esempio n. 1
0
void	AUControlGroup::CreateLabelledSliderAndEditText(
										AUCarbonViewBase *			auView,
										const CAAUParameter &		auvp,
										const Rect &				area,
										Point 						labelSize,
										Point						editTextSize,
										const ControlFontStyleRec &	inFontStyle)
{
#if !__LP64__
	ControlFontStyleRec fontStyle = inFontStyle;
	Rect sliderArea, textArea;
	ControlRef newControl;
	int width = area.right - area.left, height = area.bottom - area.top;

	bool horizontal = (width > height);

	sliderArea = area;
	textArea = area;
	if (horizontal) {
		textArea.left = area.right - editTextSize.h;
			// provide a large text box if param is generic and its values have strings...
		if (auvp.ValuesHaveStrings() && (auvp.ParamInfo().unit == kAudioUnitParameterUnit_Generic))
		{
			textArea.right += 30;
		}
		sliderArea.right = textArea.left - kLabelAndSliderSpacing;
		textArea.top = area.top + (height - editTextSize.v) / 2;
		textArea.bottom = textArea.top + editTextSize.v;
	} else {
		textArea.top = area.bottom - editTextSize.v;
		sliderArea.bottom = textArea.top - kLabelAndSliderSpacing;
		textArea.left = area.left + (width - editTextSize.h) / 2;
		textArea.right = textArea.left + editTextSize.h;
	}
	CreateLabelledSlider(auView, auvp, sliderArea, labelSize, fontStyle);

	verify_noerr(CreateEditUnicodeTextControl(auView->GetCarbonWindow(), &textArea, CFSTR(""), false,
			&fontStyle, &newControl));
	auView->AddCarbonControl(AUCarbonViewControl::kTypeText, auvp, newControl);
#endif
}
Esempio n. 2
0
void	AUControlGroup::CreatePopupMenu (AUCarbonViewBase *			auView,
										const CAAUParameter &		auvp,
										const Rect &				area,
										const ControlFontStyleRec &	inFontStyle,
										const bool					inSizeToFit)
{
#if !__LP64__
	ControlRef thePopUp;

	verify_noerr(CreatePopupButtonControl (auView->GetCarbonWindow(), &area, NULL,
												-12345,	// DON'T GET MENU FROM RESOURCE mMenuID
												FALSE,	// variableWidth,
												0,		// titleWidth,
												0,		// titleJustification,
												0,		// titleStyle,
												&thePopUp));

	ControlSize small = kControlSizeSmall;
	SetControlData(thePopUp, kControlEntireControl, kControlSizeTag, sizeof(ControlSize), &small);

	MenuRef menuRef;
	verify_noerr(CreateNewMenu( 1, 0, &menuRef));

	for (int i = 0; i < auvp.GetNumIndexedParams(); ++i) {
		verify_noerr(AppendMenuItemTextWithCFString (menuRef, auvp.GetParamName(i), kMenuItemAttrIgnoreMeta, 0, 0));
	}

	verify_noerr(SetControlData(thePopUp, 0, kControlPopupButtonMenuRefTag, sizeof(menuRef), &menuRef));
	SetControl32BitMaximum(thePopUp, auvp.GetNumIndexedParams());

	verify_noerr (SetControlFontStyle (thePopUp, &inFontStyle));

	if (inSizeToFit) {
		AUCarbonViewControl::SizeControlToFit(thePopUp);
	}

	auView->AddCarbonControl(AUCarbonViewControl::kTypeDiscrete, auvp, thePopUp);
#endif
}
Esempio n. 3
0
void	AUControlGroup::CreateLabelledSlider(
										AUCarbonViewBase *			auView,
										const CAAUParameter &		auvp,
										const Rect &				area,
										Point 						labelSize,
										const ControlFontStyleRec &	inFontStyle)
{
#if !__LP64__
	ControlFontStyleRec fontStyle = inFontStyle;
	Rect minValRect, maxValRect, sliderRect;
	ControlRef newControl;
	int width = area.right - area.left, height = area.bottom - area.top;
	CFStringRef cfstr;
	int sliderValueMax, sliderValueMin, sliderValueDefault;
	AUCarbonViewControl::ControlType sliderType;

	bool horizontal = (width > height);

	if (horizontal) {
		maxValRect.top = minValRect.top = area.top + (height - labelSize.v) / 2;
		minValRect.left = area.left;
		maxValRect.left = area.right - labelSize.h;

		minValRect.bottom = minValRect.top + labelSize.v;
		minValRect.right = minValRect.left + labelSize.h;
		maxValRect.bottom = maxValRect.top + labelSize.v;
		maxValRect.right = maxValRect.left + labelSize.h;

		sliderRect.left = minValRect.right + kLabelAndSliderSpacing;
		sliderRect.right = maxValRect.left - kLabelAndSliderSpacing;
		sliderRect.top = area.top + (height - kSliderThinDimension) / 2;
		sliderRect.bottom = sliderRect.top + kSliderThinDimension + 4;

		if (auvp.IsIndexedParam ()) {
			sliderValueMin = sliderValueDefault = int(auvp.ParamInfo().minValue);
			sliderValueMax = int(auvp.ParamInfo().maxValue);
			sliderType = AUCarbonViewControl::kTypeDiscrete;
		} else {
			sliderValueMin = sliderValueDefault = 0;
			sliderValueMax = sliderRect.right - sliderRect.left;
			sliderType = AUCarbonViewControl::kTypeContinuous;
		}
	} else {
		maxValRect.left = minValRect.left = area.left + (width - labelSize.h) / 2;
		maxValRect.top = area.top;
		minValRect.top = area.bottom - labelSize.v;

		minValRect.bottom = minValRect.top + labelSize.v;
		minValRect.right = minValRect.left + labelSize.h;
		maxValRect.bottom = maxValRect.top + labelSize.v;
		maxValRect.right = maxValRect.left + labelSize.h;

		sliderRect.left = area.left + (width - kSliderThinDimension) / 2;
		sliderRect.right = sliderRect.left + kSliderThinDimension + 4;
		sliderRect.top = maxValRect.bottom + kLabelAndSliderSpacing;
		sliderRect.bottom = minValRect.top - kLabelAndSliderSpacing;

		if (auvp.IsIndexedParam ()) {
			sliderValueMin = sliderValueDefault = int(auvp.ParamInfo().minValue);
			sliderValueMax = int(auvp.ParamInfo().maxValue);
			sliderType = AUCarbonViewControl::kTypeDiscrete;
		} else {
			sliderValueMin = sliderValueDefault = 0;
			sliderValueMax = sliderRect.bottom - sliderRect.top;
			sliderType = AUCarbonViewControl::kTypeContinuous;
		}
	}

	// minimum value label
	if (labelSize.v > 0 && labelSize.h > 0) {
		// check to see if the minimum value has a label
		cfstr = auvp.GetStringFromValueCopy(&auvp.ParamInfo().minValue);
		fontStyle.just = horizontal ? teFlushRight : teCenter;
		verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &minValRect, cfstr, &fontStyle, &newControl));
		CFRelease(cfstr);
		verify_noerr(auView->EmbedControl(newControl));

		// maximum value label
		cfstr = auvp.GetStringFromValueCopy(&auvp.ParamInfo().maxValue);
		fontStyle.just = horizontal ? teFlushLeft : teCenter;
		verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &maxValRect, cfstr, &fontStyle, &newControl));
		CFRelease(cfstr);
		verify_noerr(auView->EmbedControl(newControl));
	}

	// slider
	verify_noerr(CreateSliderControl(auView->GetCarbonWindow(), &sliderRect, sliderValueDefault, sliderValueMin, sliderValueMax, kControlSliderDoesNotPoint, 0, true, AUCarbonViewControl::SliderTrackProc, &newControl));


	ControlSize small = kControlSizeSmall;
	SetControlData(newControl, kControlEntireControl, kControlSizeTag, sizeof(ControlSize), &small);
	auView->AddCarbonControl(sliderType, auvp, newControl);
#endif
}
Esempio n. 4
0
AUParamInfo::AUParamInfo (AudioUnit				inAU, 
							bool				inIncludeExpert, 
							bool				inIncludeReadOnly,
							AudioUnitScope		inScope,
							AudioUnitElement	inElement)
	: mAU (inAU),
	  mNumParams (0),
	  mParamListID(NULL),
	  mScope (inScope),
	  mElement (inElement)
{
	UInt32 size;
	OSStatus result = AudioUnitGetPropertyInfo(mAU, kAudioUnitProperty_ParameterList, inScope, mElement, &size, NULL);
		if (size == 0 || result) return;
	
	int nparams = size / sizeof(AudioUnitPropertyID);
	mParamListID = new AudioUnitParameterID[nparams];

	memset (mParamListID, 0xFF, size);

	AudioUnitParameterID *paramList = new AudioUnitParameterID[nparams];
	
	result = AudioUnitGetProperty(mAU, kAudioUnitProperty_ParameterList, mScope, mElement, paramList, &size);
	if (result) {
		delete [] mParamListID;
		delete [] paramList;
		mParamListID = NULL;
		return;
	}
	
	ParameterMap params;
	for (int i = 0; i < nparams; ++i) 
	{
		CAAUParameter auvp (mAU, paramList[i], mScope, mElement); // took out only using global scope in CAAUParameter creation
		const AudioUnitParameterInfo &paramInfo = auvp.ParamInfo();
			
		//	don't include if parameter can't be read or written
		if (!(paramInfo.flags & kAudioUnitParameterFlag_IsWritable) 
			&& !(paramInfo.flags & kAudioUnitParameterFlag_IsReadable))
			continue;

		// only include if expert params wanted
		if (!inIncludeExpert && auvp.IsExpert())
			continue;
		
		// only include if read only params are wanted
		if (!(paramInfo.flags & kAudioUnitParameterFlag_IsWritable) 
			&& (paramInfo.flags & kAudioUnitParameterFlag_IsReadable))
		{	
			if (!inIncludeReadOnly)
				continue;
		}
		
		mParamListID[mNumParams] = paramList[i];
		mNumParams++;
		
		// ok - if we're here, then we have a parameter we are going to display.
		UInt32 clump = 0;
		auvp.GetClumpID (clump);
		mParams[clump].push_back (auvp);
	}

	delete [] paramList;
}