Re: Binding to CoreImage?
Re: Binding to CoreImage?
- Subject: Re: Binding to CoreImage?
- From: Colin Cornaby <email@hidden>
- Date: Fri, 21 Oct 2005 15:01:22 -0700
Thanks for the help!
I'm trying to create the binding progmatically though and am running
into trouble. This is probably going to be more a pure bindings
question rather than CoreImage question. I'm create an interface on
the fly for a filter and trying to bind a control I've just created
on the fly to a given filter. I just have a loop that goes through
and creates the controls.
NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
[bindingOptions setObject:[NSNumber numberWithBool:YES]
forKey:NSValidatesImmediatelyBindingOption];
[bindingOptions setObject:[NSNumber numberWithBool:YES]
forKey:NSContinuouslyUpdatesValueBindingOption];
for(i;i<[[aFilter inputKeys] count];i++)
{
...
if([[[[aFilter attributes] objectForKey:[[aFilter inputKeys]
objectAtIndex:i]] objectForKey:kCIAttributeClass]
isEqualToString:@"NSNumber"])
{
NSSlider *newSlider = [[NSSlider alloc] init];
...
[newSlider bind:@"value" toObject: aFilter withKeyPath:
[[aFilter inputKeys] objectAtIndex:i] options:bindingOptions];
}
}
This is supposed to bind the control to the input value of the
filter, but it's not working. I was going over the code with someone
this morning and they mentioned something about how the control value
is bound to the input value, but the input value isn't bound to the
control value? Anyway, he wasn't up on his binding code and this is
the first time I've tried to do it progmatically.
Is there something simple I missed with this? The filters value never
changes when I move the slider. Thanks for the observer code
clarification though. I think there was some confusion on that before.
-Colin
On Oct 21, 2005, at 1:27 PM, Troy Stephens wrote:
On Oct 20, 2005, at 11:58 PM, Colin Cornaby wrote:
Has anyone tried binding to a CIFilter? Anyone have any success?
Doesn't look like binding to the attributes will work too well
because that won't actually render it. I just have some controls
on the screen that I want to progmatically bind.
Has anyone ever played with this? Google search found nothing.
See
http://developer.apple.com/samplecode/Reducer/Reducer.html
for one example. Some of Reducer's UI elements have their values
bound directly to CIFilter properties -- for example, the sharpen
"Intensity" slider is bound to a CIUnsharpMaskFilter's
"inputIntensity" attribute.
To receive notification that the output image needs to be re-
rendered when one of these attributes is changed, the ImageReducer
object uses KVO to add itself as an observer of the same attributes:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)
object change:(NSDictionary *)change context:(void *)context {
if (object == unsharpMaskFilter || object == shadow) {
[self updateOutputImage];
}
}
- init {
...
[unsharpMaskFilter addObserver:self
forKeyPath:@"inputIntensity" options:0 context:NULL];
[unsharpMaskFilter addObserver:self
forKeyPath:@"inputRadius" options:0 context:NULL];
...
Hope this helps!
--
Troy Stephens
Cocoa Frameworks
Apple Computer, Inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden