예제 #1
0
void AUEditWindow::SetUnitToDisplay (AudioUnit editUnit, ComponentDescription& inDesc)
{
	CloseView();
	
	mEditUnit = editUnit;

	Component editComp = FindNextComponent(NULL, &inDesc);
	
	verify_noerr(OpenAComponent(editComp, &mEditView));
	
	ControlRef rootControl;
	verify_noerr(GetRootControl(mWindow, &rootControl));

	Rect r;
	ControlRef viewPane;
	GetControlBounds(rootControl, &r);
	Float32Point location = { kOffsetForAUView_X, kOffsetForAUView_Y };
	Float32Point size = { Float32(r.right), Float32(r.bottom) };
	verify_noerr(AudioUnitCarbonViewCreate(mEditView, mEditUnit, mWindow, rootControl, &location, &size, &viewPane));
	
	AudioUnitCarbonViewSetEventListener(mEditView, EventListener, this);

	GetControlBounds(viewPane, &r);
	size.x = r.right-r.left + kOffsetForAUView_X; size.y = r.bottom-r.top + kOffsetForAUView_Y;
	
	Rect r2;
	GetControlBounds (mResizeableControl->MacControl(), &r2);
	
	if ((r.bottom - r.top) < (r2.bottom - r2.top + 20))
		size.y = r2.bottom + 20;
		
	SetSize(size);	
}
예제 #2
0
AUEditWindow::AUEditWindow(XController *owner, IBNibRef nibRef, CFStringRef name, AudioUnit editUnit, bool forceGeneric) :
	XWindow(owner, nibRef, name),
	mEditUnit(editUnit)
{
	OSStatus err;
	ComponentDescription editorComponentDesc;
	
	// set up to use generic UI component
	editorComponentDesc.componentType = kAudioUnitCarbonViewComponentType;
	editorComponentDesc.componentSubType = 'gnrc';
	editorComponentDesc.componentManufacturer = 'appl';
	editorComponentDesc.componentFlags = 0;
	editorComponentDesc.componentFlagsMask = 0;
	
	if (!forceGeneric) {
		// ask the AU for its first editor component
		UInt32 propertySize;
		err = AudioUnitGetPropertyInfo(editUnit, kAudioUnitProperty_GetUIComponentList,
			kAudioUnitScope_Global, 0, &propertySize, NULL);
		if (!err) {
			int nEditors = propertySize / sizeof(ComponentDescription);
			ComponentDescription *editors = new ComponentDescription[nEditors];
			err = AudioUnitGetProperty(editUnit, kAudioUnitProperty_GetUIComponentList,
				kAudioUnitScope_Global, 0, editors, &propertySize);
			if (!err)
				// just pick the first one for now
				editorComponentDesc = editors[0];
			delete[] editors;
		}
	}
	Component editComp = FindNextComponent(NULL, &editorComponentDesc);
	
	verify_noerr(OpenAComponent(editComp, &mEditView));
	
	ControlRef rootControl;
	verify_noerr(GetRootControl(mWindow, &rootControl));

	Rect r;
	ControlRef viewPane;
	GetControlBounds(rootControl, &r);
	Float32Point location = { 0., 0. };
	Float32Point size = { Float32(r.right), Float32(r.bottom) };
	verify_noerr(AudioUnitCarbonViewCreate(mEditView, mEditUnit, mWindow, rootControl, &location, &size, &viewPane));
	
	AudioUnitCarbonViewSetEventListener(mEditView, EventListener, this);

	GetControlBounds(viewPane, &r);
	size.x = r.right-r.left; size.y = r.bottom-r.top;
	SetSize(size);
	Show();

/*	EventLoopTimerRef timer;
	RequireNoErr(
		InstallEventLoopTimer(
			GetMainEventLoop(), 5., 0., TimerProc, this, &timer));*/
}