Lots of cleanups. Mainly cleaned up PlaylistHeader automatic sizing to use values from bindings.
This commit is contained in:
parent
cdd461412c
commit
71577bac3d
5 changed files with 45 additions and 78 deletions
10
English.lproj/MainMenu.nib/info.nib
generated
10
English.lproj/MainMenu.nib/info.nib
generated
|
@ -7,9 +7,11 @@
|
||||||
<key>IBEditorPositions</key>
|
<key>IBEditorPositions</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>1063</key>
|
<key>1063</key>
|
||||||
<string>0 228 136 49 0 0 1024 746 </string>
|
<string>0 320 136 49 0 0 1680 1028 </string>
|
||||||
<key>1156</key>
|
<key>1156</key>
|
||||||
<string>719 527 241 366 0 0 1680 1028 </string>
|
<string>719 527 241 366 0 0 1680 1028 </string>
|
||||||
|
<key>1324</key>
|
||||||
|
<string>788 657 137 182 0 0 1680 1028 </string>
|
||||||
<key>29</key>
|
<key>29</key>
|
||||||
<string>-3 975 383 44 0 0 1680 1028 </string>
|
<string>-3 975 383 44 0 0 1680 1028 </string>
|
||||||
<key>463</key>
|
<key>463</key>
|
||||||
|
@ -33,11 +35,13 @@
|
||||||
<key>IBOpenObjects</key>
|
<key>IBOpenObjects</key>
|
||||||
<array>
|
<array>
|
||||||
<integer>513</integer>
|
<integer>513</integer>
|
||||||
<integer>29</integer>
|
|
||||||
<integer>463</integer>
|
<integer>463</integer>
|
||||||
<integer>1156</integer>
|
<integer>29</integer>
|
||||||
<integer>21</integer>
|
<integer>21</integer>
|
||||||
<integer>1307</integer>
|
<integer>1307</integer>
|
||||||
|
<integer>1063</integer>
|
||||||
|
<integer>1156</integer>
|
||||||
|
<integer>1324</integer>
|
||||||
</array>
|
</array>
|
||||||
<key>IBSystem Version</key>
|
<key>IBSystem Version</key>
|
||||||
<string>8L2127</string>
|
<string>8L2127</string>
|
||||||
|
|
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -29,15 +29,6 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)awakeFromNib
|
|
||||||
{
|
|
||||||
[super awakeFromNib];
|
|
||||||
|
|
||||||
NSNotificationCenter* ns = [NSNotificationCenter defaultCenter];
|
|
||||||
[ns addObserver:self selector:@selector(handlePlaylistViewHeaderNotification:) name:@"PlaylistViewColumnSeparatorDoubleClick" object:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (void)tableView:(NSTableView *)tableView
|
- (void)tableView:(NSTableView *)tableView
|
||||||
didClickTableColumn:(NSTableColumn *)tableColumn
|
didClickTableColumn:(NSTableColumn *)tableColumn
|
||||||
{
|
{
|
||||||
|
@ -457,63 +448,4 @@
|
||||||
[ws selectFile:[url path] inFileViewerRootedAtPath:[url path]];
|
[ws selectFile:[url path] inFileViewerRootedAtPath:[url path]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)handlePlaylistViewHeaderNotification:(NSNotification*)notif
|
|
||||||
{
|
|
||||||
NSTableView *tv = [notif object];
|
|
||||||
NSNumber *colIdx = [[notif userInfo] objectForKey:@"column"];
|
|
||||||
NSTableColumn *col = [[tv tableColumns] objectAtIndex:[colIdx intValue]];
|
|
||||||
|
|
||||||
//Change to use NSSelectorFromString and NSMethodSignature returnType, see http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_5_section_7.html for info
|
|
||||||
//Maybe we can pull the column bindings out somehow, instead of selectorfromstring
|
|
||||||
|
|
||||||
// find which function to call on PlaylistEntry*
|
|
||||||
SEL sel;
|
|
||||||
NSString* identifier = [col identifier];
|
|
||||||
BOOL isNumeric = NO;
|
|
||||||
if ([identifier compare:@"title"] == NSOrderedSame)
|
|
||||||
sel = @selector(title);
|
|
||||||
else if ([identifier compare:@"length"] == NSOrderedSame)
|
|
||||||
sel = @selector(lengthString);
|
|
||||||
else if ([identifier compare:@"index"] == NSOrderedSame) {
|
|
||||||
sel = @selector(index);
|
|
||||||
isNumeric = YES;
|
|
||||||
}
|
|
||||||
else if ([identifier compare:@"artist"] == NSOrderedSame)
|
|
||||||
sel = @selector(artist);
|
|
||||||
else if ([identifier compare:@"album"] == NSOrderedSame)
|
|
||||||
sel = @selector(album);
|
|
||||||
else if ([identifier compare:@"year"] == NSOrderedSame)
|
|
||||||
sel = @selector(year);
|
|
||||||
else if ([identifier compare:@"genre"] == NSOrderedSame)
|
|
||||||
sel = @selector(genre);
|
|
||||||
else if ([identifier compare:@"track"] == NSOrderedSame) {
|
|
||||||
sel = @selector(track);
|
|
||||||
isNumeric = YES;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
|
|
||||||
NSCell *cell = [col dataCell];
|
|
||||||
NSAttributedString * as = [cell attributedStringValue];
|
|
||||||
|
|
||||||
// find the longest string display length in that column
|
|
||||||
NSArray *entries = [self arrangedObjects];
|
|
||||||
NSEnumerator *enumerator = [entries objectEnumerator];
|
|
||||||
PlaylistEntry *entry;
|
|
||||||
float maxlength = -1;
|
|
||||||
NSString *ret;
|
|
||||||
while (entry = [enumerator nextObject]) {
|
|
||||||
if (isNumeric)
|
|
||||||
ret = [NSString stringWithFormat:@"%d", objc_msgSend(entry, sel)];
|
|
||||||
else
|
|
||||||
ret = objc_msgSend(entry, sel);
|
|
||||||
if ([ret sizeWithAttributes:[as attributesAtIndex:0 effectiveRange:nil]].width > maxlength)
|
|
||||||
maxlength = [ret sizeWithAttributes:[as attributesAtIndex:0 effectiveRange:nil]].width;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// set the new width (plus a 5 pixel extra to avoid "..." string substitution)
|
|
||||||
[col setWidth:maxlength+5];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -33,12 +33,32 @@
|
||||||
clickedSeperator = YES;
|
clickedSeperator = YES;
|
||||||
|
|
||||||
if (clickedSeperator) {
|
if (clickedSeperator) {
|
||||||
|
NSTableColumn *col = [[[self tableView] tableColumns] objectAtIndex:column];
|
||||||
|
|
||||||
|
//Info about the font and such
|
||||||
|
NSCell *cell = [col dataCell];
|
||||||
|
NSAttributedString * as = [cell attributedStringValue];
|
||||||
|
|
||||||
|
//Binding info...reaching deep!
|
||||||
|
NSDictionary *bindingInfo = [col infoForBinding:@"value"];
|
||||||
|
NSArray *boundArray = [[bindingInfo objectForKey:NSObservedObjectKey] valueForKeyPath:[bindingInfo objectForKey:NSObservedKeyPathKey]];
|
||||||
|
|
||||||
|
//find the longest string display length in that column
|
||||||
|
float max_width = -1;
|
||||||
|
id row;
|
||||||
|
NSEnumerator *enumerator = [boundArray objectEnumerator];
|
||||||
|
while (row = [enumerator nextObject]) {
|
||||||
|
NSString *s = [row description];
|
||||||
|
|
||||||
|
float width = [s sizeWithAttributes:[as attributesAtIndex:0 effectiveRange:nil]].width;
|
||||||
|
if (width > max_width)
|
||||||
|
max_width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set the new width (plus a 5 pixel extra to avoid "..." string substitution)
|
||||||
|
[col setWidth:max_width+5];
|
||||||
|
|
||||||
NSNotificationCenter *center;
|
|
||||||
center = [NSNotificationCenter defaultCenter];
|
|
||||||
[center postNotificationName: @"PlaylistViewColumnSeparatorDoubleClick" object:
|
|
||||||
[self tableView] userInfo:
|
|
||||||
[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:column],@"column", nil]];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[super mouseDown: theEvent];
|
[super mouseDown: theEvent];
|
||||||
|
@ -47,4 +67,12 @@
|
||||||
[super mouseDown: theEvent];
|
[super mouseDown: theEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(NSMenu*)menuForEvent:(NSEvent*)event
|
||||||
|
{
|
||||||
|
NSString *hi = @"This is a test";
|
||||||
|
//Show a menu!
|
||||||
|
NSLog(@"MENU FOR HEADER!");
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
7
TODO
7
TODO
|
@ -1,2 +1,5 @@
|
||||||
Changed SourceNode to BufferedSource. It's not really a node.
|
Make playlist table header menu, (See Play _streamTableHeaderContextMenu).
|
||||||
Fix all plugins besides ogg vorbis (already fixed), so they use callbacks and the source.
|
Make PlaylistEntry numbers use NSNumber.
|
||||||
|
Instead of LengthString, use a formatter.
|
||||||
|
|
||||||
|
Add automatic header seperator without testing explicit types. Pull out binding? Perhaps the table column can do a objectAtIndex and then get a stringValue to get the width.
|
Loading…
Reference in a new issue