Changeset 2874
- Timestamp:
- 05/19/05 18:42:20 (4 years ago)
- Files:
-
- Footagehead/trunk/English.lproj/Credits.rtf (modified) (1 diff)
- Footagehead/trunk/FHController.h (modified) (1 diff)
- Footagehead/trunk/FHController.m (modified) (19 diffs)
- Footagehead/trunk/FHFile.h (modified) (4 diffs)
- Footagehead/trunk/FHFile.m (modified) (3 diffs)
- Footagehead/trunk/FHFileCell.m (modified) (1 diff)
- Footagehead/trunk/FHImageView.m (modified) (2 diffs)
- Footagehead/trunk/Footagehead.xcode/project.pbxproj (modified) (8 diffs)
- Footagehead/trunk/NSBitmapImageRep-FHAdditions.h (added)
- Footagehead/trunk/NSBitmapImageRep-FHAdditions.m (added)
- Footagehead/trunk/NSImage-FHAdditions.h (modified) (2 diffs)
- Footagehead/trunk/NSImage-FHAdditions.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Footagehead/trunk/English.lproj/Credits.rtf
r2871 r2874 23 23 \f1\b0 \cf0 \ 24 24 Contains software written by the\ 25 Independent JPEG Group .\25 Independent JPEG Group\ 26 26 \ 27 27 axel@zankasoftware.com\ Footagehead/trunk/FHController.h
r2858 r2874 60 60 FHHandler *_handler; 61 61 62 NSTimer *_timer; 63 NSConditionLock *_lock; 62 NSTimer *_loadImageTimer; 63 NSConditionLock *_loadImageLock; 64 NSConditionLock *_loadThumbnailsLock; 64 65 unsigned int _row; 65 66 Footagehead/trunk/FHController.m
r2858 r2874 27 27 */ 28 28 29 #import "NSImage-FHAdditions.h" 30 29 31 #import "FHCache.h" 30 32 #import "FHController.h" … … 41 43 42 44 43 - (FHFile *) selectedFile;44 - (FHFile *) fileAtIndex:(unsigned int)index;45 46 - (void) loadURL:(ZAURL *)url withHint:(FHHandlerHint)hint selectRow:(int)row;47 - (void) loadFile:(FHFile *)file;48 49 - (void) addMenuItemWithPath:(NSString *)path keyEquivalent:(NSString *)keyEquivalent;50 - (void) reloadVolumesMenu;51 - (void) reloadPathMenu;52 53 - (void) startSpinning;54 - (void) stopSpinning;55 - (void) updateImage;56 - (void) updateButtons;57 - (void) updateStatus;58 - (void) updateLeftStatus;59 - (void) updateRightStatus;60 - (void) updateFullscreenStatus;61 - (void) updateTableView;45 - (FHFile *)selectedFile; 46 - (FHFile *)fileAtIndex:(unsigned int)index; 47 48 - (void)loadURL:(ZAURL *)url withHint:(FHHandlerHint)hint selectRow:(int)row; 49 - (void)loadFile:(FHFile *)file; 50 51 - (void)addMenuItemWithPath:(NSString *)path keyEquivalent:(NSString *)keyEquivalent; 52 - (void)reloadVolumesMenu; 53 - (void)reloadPathMenu; 54 55 - (void)startSpinning; 56 - (void)stopSpinning; 57 - (void)updateImage; 58 - (void)updateButtons; 59 - (void)updateStatus; 60 - (void)updateLeftStatus; 61 - (void)updateRightStatus; 62 - (void)updateFullscreenStatus; 63 - (void)updateTableView; 62 64 63 65 @end … … 120 122 [_screenAutoSwitchTextField setIntValue:[FHSettings intForKey:FHAutoSwitchTime]]; 121 123 122 // --- create lock 123 _lock = [[NSConditionLock alloc] initWithCondition:0]; 124 // --- create locks 125 _loadImageLock = [[NSConditionLock alloc] initWithCondition:0]; 126 _loadThumbnailsLock = [[NSConditionLock alloc] initWithCondition:0]; 124 127 125 128 // --- open last directory by default (unset if started by opening a file) … … 158 161 159 162 // --- detach loader thread 160 [NSThread detachNewThreadSelector:@selector(loadFileThread:) toTarget:self withObject:[_handler files]]; 163 [NSThread detachNewThreadSelector:@selector(loadImageThread:) toTarget:self withObject:NULL]; 164 [NSThread detachNewThreadSelector:@selector(loadThumbnailsThread:) toTarget:self withObject:NULL]; 161 165 } 162 166 … … 241 245 - (void)windowWillClose:(NSNotification *)notification { 242 246 if([notification object] == _fullscreenWindow) { 243 [_ timer invalidate];244 [_ timer release];245 _ timer = NULL;247 [_loadImageTimer invalidate]; 248 [_loadImageTimer release]; 249 _loadImageTimer = NULL; 246 250 247 251 [self showWindow:self]; … … 394 398 395 399 if([FHSettings boolForKey:FHAutoSwitch]) { 396 _ timer = [[NSTimer scheduledTimerWithTimeInterval:[FHSettings intForKey:FHAutoSwitchTime]397 target:self398 selector:@selector(loadFileTimer:)399 userInfo:NULL400 repeats:YES] retain];400 _loadImageTimer = [[NSTimer scheduledTimerWithTimeInterval:[FHSettings intForKey:FHAutoSwitchTime] 401 target:self 402 selector:@selector(loadFileTimer:) 403 userInfo:NULL 404 repeats:YES] retain]; 401 405 } 402 406 } … … 508 512 } 509 513 510 [_ timer setFireDate:[NSDate distantFuture]];514 [_loadImageTimer setFireDate:[NSDate distantFuture]]; 511 515 [_tableView selectRow:i byExtendingSelection:NO]; 512 516 [_tableView scrollRowToVisible:i]; … … 540 544 i = 0; 541 545 542 [_ timer setFireDate:[NSDate distantFuture]];546 [_loadImageTimer setFireDate:[NSDate distantFuture]]; 543 547 [_tableView selectRow:i byExtendingSelection:NO]; 544 548 [_tableView scrollRowToVisible:i]; … … 562 566 } 563 567 564 [_ timer setFireDate:[NSDate distantFuture]];568 [_loadImageTimer setFireDate:[NSDate distantFuture]]; 565 569 [_tableView selectRow:i byExtendingSelection:NO]; 566 570 [_tableView scrollRowToVisible:i]; … … 594 598 i = count - 1; 595 599 596 [_ timer setFireDate:[NSDate distantFuture]];600 [_loadImageTimer setFireDate:[NSDate distantFuture]]; 597 601 [_tableView selectRow:i byExtendingSelection:NO]; 598 602 [_tableView scrollRowToVisible:i]; … … 688 692 [_tableView selectRow:row byExtendingSelection:NO]; 689 693 } else { 690 [_lo ck lock];694 [_loadImageLock lock]; 691 695 _row = row; 692 [_lo ck unlockWithCondition:1];693 } 694 696 [_loadImageLock unlockWithCondition:1]; 697 } 698 695 699 [_tableView scrollRowToVisible:row]; 700 701 if([_handler isLocal]) { 702 [_loadThumbnailsLock lock]; 703 [_loadThumbnailsLock unlockWithCondition:1]; 704 } 696 705 697 706 [self stopSpinning]; … … 711 720 712 721 713 - (void)loadFileThread:(id)arg { 722 - (void)loadFileTimer:(NSTimer *)timer { 723 NSArray *files; 724 int i, count; 725 BOOL next = NO; 726 727 [self nextImage:self]; 728 729 i = [_tableView selectedRow]; 730 files = [_handler files]; 731 count = [files count]; 732 733 while(i < count - 1) { 734 if(![[files objectAtIndex:i] isDirectory]) { 735 next = YES; 736 737 break; 738 } 739 } 740 741 if(!next) 742 [timer invalidate]; 743 } 744 745 746 747 - (void)loadImageThread:(id)arg { 714 748 NSAutoreleasePool *pool; 715 749 NSArray *files; 716 750 NSImage *image; 717 751 FHFile *file; 718 int i, row, images, count, lastRow = 0; 752 unsigned int i, count, images, row, lastRow; 753 754 lastRow = 0; 719 755 720 756 while(YES) { 721 757 pool = [[NSAutoreleasePool alloc] init]; 722 758 723 // --- wait for row switch 724 [_lock lockWhenCondition:1]; 759 [_loadImageLock lockWhenCondition:1]; 725 760 row = _row; 726 761 files = [[_handler files] retain]; 727 [_lo ck unlockWithCondition:0];762 [_loadImageLock unlockWithCondition:0]; 728 763 729 764 if(row >= 0 && (row == 0 || row >= lastRow + 5 || row < lastRow)) { … … 731 766 732 767 // --- purge all but the last 5 images 733 for(i = 0; i < row - 5; i++) {768 for(i = 0; i < count && i < row - 5; i++) { 734 769 file = [files objectAtIndex:i]; 735 770 … … 760 795 [image release]; 761 796 762 [self performSelectorOnMainThread:@selector(fileDidLoadImage:) withObject:file ];797 [self performSelectorOnMainThread:@selector(fileDidLoadImage:) withObject:file waitUntilDone:YES]; 763 798 } 764 799 … … 773 808 774 809 775 - (void)loadFileTimer:(NSTimer *)timer { 776 NSArray *files; 777 int i, count; 778 BOOL next = NO; 779 780 [self nextImage:self]; 781 782 i = [_tableView selectedRow]; 783 files = [_handler files]; 784 count = [files count]; 785 786 while(i < count - 1) { 787 if(![[files objectAtIndex:i] isDirectory]) { 788 next = YES; 789 790 break; 791 } 792 } 793 794 if(!next) 795 [timer invalidate]; 810 - (void)loadThumbnailsThread:(id)arg { 811 NSAutoreleasePool *pool; 812 NSArray *files; 813 NSImage *image; 814 FHFile *file; 815 unsigned int i, count; 816 817 while(YES) { 818 pool = [[NSAutoreleasePool alloc] init]; 819 820 [_loadThumbnailsLock lockWhenCondition:1]; 821 files = [[_handler files] retain]; 822 [_loadThumbnailsLock unlockWithCondition:0]; 823 824 count = [files count]; 825 826 for(i = 0; i < count; i++) { 827 file = [files objectAtIndex:i]; 828 829 if([file isDirectory]) 830 continue; 831 832 if([file hasThumbnail]) 833 continue; 834 835 image = [[NSImage alloc] initWithJPEGFile:[file path] preferredSize:NSMakeSize(128.0, 128.0)]; 836 837 if(image) { 838 [file setThumbnail:image]; 839 [image release]; 840 841 [self performSelectorOnMainThread:@selector(fileDidLoadThumbnail:) withObject:file waitUntilDone:YES]; 842 } 843 } 844 845 [files release]; 846 [pool release]; 847 } 796 848 } 797 849 … … 824 876 [_fullscreenImageView setImage:image]; 825 877 [self updateFullscreenStatus]; 826 [_ timer setFireDate:[NSDate dateWithTimeIntervalSinceNow:878 [_loadImageTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow: 827 879 [FHSettings intForKey:FHAutoSwitchTime]]]; 828 880 } else { … … 833 885 } 834 886 } 887 } 888 889 890 891 - (void)fileDidLoadThumbnail:(FHFile *)file { 892 [_tableView reloadData]; 835 893 } 836 894 … … 1104 1162 1105 1163 file = [self fileAtIndex:row]; 1106 icon = [file icon]; 1107 [icon setSize:NSMakeSize(128.0, 128.0)]; 1164 icon = [file thumbnail]; 1165 1166 if(![file hasThumbnail]) 1167 [icon setSize:NSMakeSize(128.0, 128.0)]; 1108 1168 1109 1169 return [NSDictionary dictionaryWithObjectsAndKeys: … … 1124 1184 [self updateImage]; 1125 1185 1126 [_lo ck lock];1186 [_loadImageLock lock]; 1127 1187 _row = [_tableView selectedRow]; 1128 [_lo ck unlockWithCondition:1];1188 [_loadImageLock unlockWithCondition:1]; 1129 1189 } 1130 1190 Footagehead/trunk/FHFile.h
r920 r2874 1 /* $Id : FHFile.h,v 1.7 2005/01/08 22:55:46 morris Exp$ */1 /* $Id$ */ 2 2 3 3 /* … … 29 29 #import "FHHandler.h" 30 30 31 @interface FHFile : ZAObject <NSCoding>{31 @interface FHFile : ZAObject { 32 32 NSString *_name; 33 33 ZAURL *_url; … … 36 36 NSImage *_image; 37 37 NSImage *_icon; 38 BOOL _loading;38 NSImage *_thumbnail; 39 39 BOOL _directory; 40 40 int _index; … … 43 43 44 44 45 - (id) initWithURL:(ZAURL *)url isDirectory:(BOOL)isDirectory index:(int)index;46 - (id) initWithURL:(ZAURL *)url isDirectory:(BOOL)isDirectory index:(int)index hint:(FHHandlerHint)hint;45 - (id)initWithURL:(ZAURL *)url isDirectory:(BOOL)isDirectory index:(int)index; 46 - (id)initWithURL:(ZAURL *)url isDirectory:(BOOL)isDirectory index:(int)index hint:(FHHandlerHint)hint; 47 47 48 - (void) setImage:(NSImage *)image; 49 - (NSImage *) image; 48 - (void)setImage:(NSImage *)image; 49 - (NSImage *)image; 50 - (void)setThumbnail:(NSImage *)thumbnaill; 51 - (NSImage *)thumbnail; 52 - (BOOL)hasThumbnail; 50 53 51 - (void) setLoading:(BOOL)value; 52 - (BOOL) isLoading; 53 54 - (NSString *) name; 55 - (ZAURL *) URL; 56 - (NSString *) path; 57 - (NSString *) extension; 58 - (NSImage *) icon; 59 - (BOOL) isDirectory; 60 - (int) index; 61 - (FHHandlerHint) hint; 54 - (NSString *)name; 55 - (ZAURL *)URL; 56 - (NSString *)path; 57 - (NSString *)extension; 58 - (BOOL)isDirectory; 59 - (int)index; 60 - (FHHandlerHint)hint; 62 61 63 62 @end Footagehead/trunk/FHFile.m
r2857 r2874 96 96 #pragma mark - 97 97 98 - (id)initWithCoder:(NSCoder *)coder {99 self = [super init];100 101 ZADecode(coder, _url);102 ZADecode(coder, _path);103 ZADecode(coder, _extension);104 ZADecode(coder, _name);105 ZADecode(coder, _image);106 ZADecode(coder, _icon);107 ZADecode(coder, _loading);108 ZADecode(coder, _directory);109 ZADecode(coder, _hint);110 111 return self;112 }113 114 115 116 - (void)encodeWithCoder:(NSCoder *)coder {117 ZAEncode(coder, _url);118 ZAEncode(coder, _path);119 ZAEncode(coder, _extension);120 ZAEncode(coder, _name);121 ZAEncode(coder, _icon);122 ZAEncode(coder, _image);123 ZAEncode(coder, _loading);124 ZAEncode(coder, _directory);125 ZAEncode(coder, _hint);126 }127 128 129 130 #pragma mark -131 132 98 - (void)setImage:(NSImage *)image { 133 99 [image retain]; … … 145 111 146 112 147 148 - (void)setLoading:(BOOL)value { 149 _loading = value; 113 - (void)setThumbnail:(NSImage *)thumbnail { 114 [thumbnail retain]; 115 [_thumbnail release]; 116 117 _thumbnail = thumbnail; 150 118 } 151 119 152 120 153 121 154 - (BOOL)isLoading { 155 return _loading; 122 - (NSImage *)thumbnail { 123 if(_thumbnail) 124 return _thumbnail; 125 126 return _icon; 127 } 128 129 130 131 - (BOOL)hasThumbnail { 132 return (_thumbnail != NULL); 156 133 } 157 134 … … 184 161 185 162 186 - (NSImage *)icon {187 return _icon;188 }189 190 191 192 163 - (BOOL)isDirectory { 193 164 return _directory; Footagehead/trunk/FHFileCell.m
r920 r2874 1 /* $Id : FHFileCell.m,v 1.3 2005/01/08 22:55:46 morris Exp$ */1 /* $Id$ */ 2 2 3 3 /* Footagehead/trunk/FHImageView.m
r2855 r2874 82 82 float dx, dy, d; 83 83 84 [[NSColor lightGrayColor] set]; 85 NSFrameRect(frame); 86 frame = NSInsetRect(frame, 2.0, 2.0); 87 84 88 [_backgroundColor set]; 85 89 NSRectFill(frame); … … 113 117 } 114 118 115 point.x = ( frame.size.width - size.width) / 2.0;116 point.y = ( frame.size.height - size.height) / 2.0;119 point.x = ((frame.size.width - size.width) / 2.0) + 1.0; 120 point.y = ((frame.size.height - size.height) / 2.0) + 1.0; 117 121 118 122 [image compositeToPoint:point operation:NSCompositeSourceOver]; Footagehead/trunk/Footagehead.xcode/project.pbxproj
r2872 r2874 22 22 ); 23 23 isa = PBXGroup; 24 name = "Footagehead Interface";24 name = Interface; 25 25 refType = 4; 26 26 sourceTree = "<group>"; … … 167 167 ); 168 168 isa = PBXGroup; 169 name = " FootageheadSources";169 name = "Other Sources"; 170 170 path = ""; 171 171 refType = 4; … … 310 310 target = 77CDC142083BA689003BE654; 311 311 targetProxy = 770EB7A8083BA9880094BD6C; 312 }; 313 770EBFC2083C94CE0094BD6C = { 314 fileEncoding = 4; 315 isa = PBXFileReference; 316 lastKnownFileType = sourcecode.c.h; 317 path = "NSBitmapImageRep-FHAdditions.h"; 318 refType = 4; 319 sourceTree = "<group>"; 320 }; 321 770EBFC3083C94CE0094BD6C = { 322 fileEncoding = 4; 323 isa = PBXFileReference; 324 lastKnownFileType = sourcecode.c.objc; 325 path = "NSBitmapImageRep-FHAdditions.m"; 326 refType = 4; 327 sourceTree = "<group>"; 328 }; 329 770EBFC4083C94CE0094BD6C = { 330 fileRef = 770EBFC2083C94CE0094BD6C; 331 isa = PBXBuildFile; 332 settings = { 333 }; 334 }; 335 770EBFC5083C94CE0094BD6C = { 336 fileRef = 770EBFC3083C94CE0094BD6C; 337 isa = PBXBuildFile; 338 settings = { 339 }; 312 340 }; 313 341 775BA322075F59E000F0941E = { … … 1512 1540 77BD99520760B7380007D034, 1513 1541 77CDB023083B6B85003BE654, 1542 770EBFC5083C94CE0094BD6C, 1514 1543 ); 1515 1544 isa = PBXSourcesBuildPhase; … … 1836 1865 files = ( 1837 1866 A54D42DD07663AA300227EBE, 1867 770EBFC4083C94CE0094BD6C, 1838 1868 ); 1839 1869 isa = PBXCopyFilesBuildPhase; … … 1878 1908 ); 1879 1909 isa = PBXGroup; 1880 name = "Footagehead Handlers";1910 name = Handlers; 1881 1911 refType = 4; 1882 1912 sourceTree = "<group>"; … … 1936 1966 ); 1937 1967 isa = PBXGroup; 1938 name = "Footagehead Data";1968 name = Data; 1939 1969 refType = 4; 1940 1970 sourceTree = "<group>"; … … 2163 2193 A5EE94DA055AA5EE00CC2AD8 = { 2164 2194 children = ( 2195 770EBFC3083C94CE0094BD6C, 2196 770EBFC2083C94CE0094BD6C, 2165 2197 775BA4F0075F70ED00F0941E, 2166 2198 775BA4EF075F70ED00F0941E, 2167 2199 ); 2168 2200 isa = PBXGroup; 2169 name = "Footagehead Additions";2201 name = Additions; 2170 2202 refType = 4; 2171 2203 sourceTree = "<group>"; Footagehead/trunk/NSImage-FHAdditions.h
r920 r2874 1 /* $Id : NSImage-FHAdditions.h,v 1.2 2005/01/08 22:55:46 morris Exp$ */1 /* $Id$ */ 2 2 3 3 /* … … 29 29 @interface NSImage(FHAdditions) 30 30 31 + (NSArray *) FHImageFileTypes; 31 + (NSArray *)FHImageFileTypes; 32 33 + (id)imageWithJPEGFile:(NSString *)path preferredSize:(NSSize)size; 34 - (id)initWithJPEGFile:(NSString *)path preferredSize:(NSSize)size; 32 35 33 36 @end Footagehead/trunk/NSImage-FHAdditions.m
r920 r2874 1 /* $Id : NSImage-FHAdditions.m,v 1.2 2005/01/08 22:55:46 morris Exp$ */1 /* $Id$ */ 2 2 3 3 /* … … 27 27 */ 28 28 29 #import "NSBitmapImageRep-FHAdditions.h" 29 30 #import "NSImage-FHAdditions.h" 30 31 … … 45 46 } 46 47 48 49 50 #pragma mark - 51 52 + (id)imageWithJPEGFile:(NSString *)path preferredSize:(NSSize)size { 53 return [[[self alloc] initWithJPEGFile:path preferredSize:size] autorelease]; 54 } 55 56 57 58 - (id)initWithJPEGFile:(NSString *)path preferredSize:(NSSize)size { 59 NSBitmapImageRep *imageRep; 60 61 imageRep = [[NSBitmapImageRep alloc] initWithJPEGFile:path preferredSize:size]; 62 63 if(!imageRep) { 64 [self release]; 65 66 return NULL; 67 } 68 69 self = [self initWithSize:NSMakeSize([imageRep pixelsWide], [imageRep pixelsHigh])]; 70 [self addRepresentation:imageRep]; 71 72 return self; 73 } 74 47 75 @end
