mirror of
https://github.com/ksherlock/ample.git
synced 2024-10-31 15:04:56 +00:00
bind the media eject button.
contentTintColor is not exposed in interface builder, otherwise it could all be handled there.
This commit is contained in:
parent
68136487ff
commit
4425fe33f8
@ -163,7 +163,7 @@
|
||||
[item setIndex: ix];
|
||||
[item setValid: ix < _validCount];
|
||||
|
||||
[view reloadItem: item];
|
||||
// [view reloadItem: item];
|
||||
|
||||
++ix;
|
||||
}
|
||||
@ -201,21 +201,33 @@
|
||||
}
|
||||
|
||||
-(void)prepareView: (TablePathView *)view {
|
||||
|
||||
NSValueTransformer *t;
|
||||
NSDictionary *options;
|
||||
|
||||
NSPathControl *pc = [view pathControl];
|
||||
NSButton *button = [view ejectButton];
|
||||
|
||||
[pc unbind: @"value"];
|
||||
[pc unbind: @"enabled"];
|
||||
[pc bind: @"value" toObject: self withKeyPath: @"url" options: nil];
|
||||
[pc bind: @"enabled" toObject: self withKeyPath: @"valid" options: options];
|
||||
|
||||
[button unbind: @"enabled"];
|
||||
NSValueTransformer *t = [NSValueTransformer valueTransformerForName: NSIsNotNilTransformerName];
|
||||
NSDictionary *options = @{ NSValueTransformerBindingOption: t};
|
||||
[button unbind: @"contentTintColor"];
|
||||
t = [NSValueTransformer valueTransformerForName: NSIsNotNilTransformerName];
|
||||
options = @{ NSValueTransformerBindingOption: t};
|
||||
[button bind: @"enabled" toObject: self withKeyPath: @"url" options: options];
|
||||
|
||||
t = [NSValueTransformer valueTransformerForName: @"ValidColorTransformer"];
|
||||
options = @{ NSValueTransformerBindingOption: t};
|
||||
[button bind: @"contentTintColor" toObject: self withKeyPath: @"valid" options: options];
|
||||
|
||||
#if 0
|
||||
NSColor *tintColor = nil;
|
||||
if (!_valid) tintColor = [NSColor redColor];
|
||||
[button setContentTintColor: tintColor];
|
||||
#endif
|
||||
}
|
||||
|
||||
-(CGFloat)height {
|
||||
@ -223,7 +235,8 @@
|
||||
}
|
||||
|
||||
-(void)invalidate {
|
||||
_valid = NO;
|
||||
if (!_valid) return;
|
||||
[self setValid: NO];
|
||||
}
|
||||
@end
|
||||
|
||||
@ -391,6 +404,7 @@ static NSString *kDragType = @"private.ample.media";
|
||||
if (!ident) return nil;
|
||||
NSTableCellView *v = [outlineView makeViewWithIdentifier: ident owner: self];
|
||||
[(id<MediaNode>)item prepareView: v];
|
||||
[v setObjectValue: item];
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,12 @@ void RegisterTransformers(void);
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FilePathTransformer : NSValueTransformer
|
||||
|
||||
@end
|
||||
|
||||
@interface FileSizeTransformer : NSValueTransformer
|
||||
@end
|
||||
|
||||
@interface ValidColorTransformer : NSValueTransformer
|
||||
@end
|
||||
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#import "Transformers.h"
|
||||
|
||||
#import <AppKit/NSColor.h>
|
||||
|
||||
@implementation FilePathTransformer
|
||||
|
||||
+ (Class)transformedValueClass {
|
||||
@ -55,6 +57,22 @@
|
||||
@end
|
||||
|
||||
|
||||
@implementation ValidColorTransformer
|
||||
+ (BOOL)allowsReverseTransformation {
|
||||
return NO;
|
||||
}
|
||||
+ (Class)transformedValueClass {
|
||||
return [NSColor class];
|
||||
}
|
||||
|
||||
- (id)transformedValue:(id)value {
|
||||
BOOL valid = [(NSNumber *)value boolValue];
|
||||
return valid ? nil : [NSColor redColor];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
void RegisterTransformers(void) {
|
||||
|
||||
@ -65,4 +83,6 @@ void RegisterTransformers(void) {
|
||||
t = [FilePathTransformer new];
|
||||
[NSValueTransformer setValueTransformer: t forName: @"FilePathTransformer"];
|
||||
|
||||
t = [ValidColorTransformer new];
|
||||
[NSValueTransformer setValueTransformer: t forName: @"ValidColorTransformer"];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user