Changeset 4731
- Timestamp:
- 04/27/07 19:12:01 (2 years ago)
- Files:
-
- Footagehead/trunk/English.lproj/MainMenu.nib/classes.nib (modified) (1 diff)
- Footagehead/trunk/English.lproj/MainMenu.nib/info.nib (modified) (2 diffs)
- Footagehead/trunk/English.lproj/MainMenu.nib/keyedobjects.nib (modified) (previous)
- Footagehead/trunk/English.lproj/MainMenu.nib/objects.nib (modified) (previous)
- Footagehead/trunk/FHApplicationController.m (modified) (2 diffs)
- Footagehead/trunk/FHBrowserController.m (modified) (5 diffs)
- Footagehead/trunk/FHImageLoader.m (modified) (2 diffs)
- Footagehead/trunk/FHImageView.h (modified) (2 diffs)
- Footagehead/trunk/FHImageView.m (modified) (9 diffs)
- Footagehead/trunk/FHSettings.h (modified) (1 diff)
- Footagehead/trunk/FHSettings.m (modified) (1 diff)
- Footagehead/trunk/FHSlideshowController.m (modified) (3 diffs)
- Footagehead/trunk/FHSpread.h (added)
- Footagehead/trunk/FHSpread.m (added)
- Footagehead/trunk/FHWindowController.h (modified) (4 diffs)
- Footagehead/trunk/FHWindowController.m (modified) (4 diffs)
- Footagehead/trunk/Footagehead.xcodeproj/project.pbxproj (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Footagehead/trunk/English.lproj/MainMenu.nib/classes.nib
r4716 r4731 39 39 setAsDesktopBackground = id; 40 40 slideshow = id; 41 spreadMode = id; 41 42 submitSheet = id; 42 43 toggleStatusBar = id; Footagehead/trunk/English.lproj/MainMenu.nib/info.nib
r4723 r4731 4 4 <dict> 5 5 <key>IBDocumentLocation</key> 6 <string> 838 346395 374 0 0 1920 1178 </string>6 <string>594 300 395 374 0 0 1920 1178 </string> 7 7 <key>IBEditorPositions</key> 8 8 <dict> 9 9 <key>29</key> 10 <string> 433 614 400 44 0 0 1280 778 </string>10 <string>748 949 400 44 0 0 1920 1178 </string> 11 11 </dict> 12 12 <key>IBFramework Version</key> … … 19 19 </array> 20 20 <key>IBSystem Version</key> 21 <string>8P 2137</string>21 <string>8P135</string> 22 22 </dict> 23 23 </plist> Footagehead/trunk/FHApplicationController.m
r4726 r4731 39 39 - (void)_addGoMenuItemWithPath:(NSString *)path keyEquivalent:(NSString *)keyEquivalent; 40 40 - (void)_reloadPathsInGoMenuForHandler:(FHHandler *)handler; 41 - (void)_updateViewMenu; 41 42 42 43 @end … … 170 171 } 171 172 172 @end 173 174 175 @implementation FHApplicationController 176 177 - (void)dealloc { 178 [_browserController release]; 179 180 [super dealloc]; 181 } 182 183 184 185 - (void)awakeFromNib { 186 _openLastURL = YES; 187 188 [self _buildGoMenu]; 189 190 [[_viewMenu itemWithTag:[FHSettings intForKey:FHImageScalingMethod]] setState:NSOnState]; 191 192 [[NSNotificationCenter defaultCenter] 193 addObserver:self 194 selector:@selector(windowControllerDidLoadHandler:) 195 name:FHBrowserControllerDidLoadHandler]; 196 197 [[NSNotificationCenter defaultCenter] 198 addObserver:self 199 selector:@selector(windowControllerChangedZoomMode:) 200 name:FHWindowControllerChangedZoomMode]; 201 202 [[[NSWorkspace sharedWorkspace] notificationCenter] 203 addObserver:self 204 selector:@selector(workspaceDidChangeMounts:) 205 name:NSWorkspaceDidMountNotification]; 206 207 [[[NSWorkspace sharedWorkspace] notificationCenter] 208 addObserver:self 209 selector:@selector(workspaceDidChangeMounts:) 210 name:NSWorkspaceDidUnmountNotification]; 211 212 _browserController = [[FHBrowserController alloc] init]; 213 } 214 215 216 217 #pragma mark - 218 219 - (void)applicationDidFinishLaunching:(NSNotification *)notification { 220 WIURL *url; 221 222 if((GetCurrentKeyModifiers() & optionKey) != 0) 223 [FHSettings setObject:[[WIURL fileURLWithPath:NSHomeDirectory()] string] forKey:FHOpenURL]; 224 225 if(_openLastURL) { 226 url = [WIURL URLWithString:[FHSettings objectForKey:FHOpenURL]]; 227 228 if([url isFileURL] && ![[NSFileManager defaultManager] fileExistsAtPath:[url path]]) 229 url = [WIURL fileURLWithPath:NSHomeDirectory()]; 230 231 [_browserController loadURL:url]; 232 } 233 234 [_browserController showWindow:self]; 235 } 236 237 238 239 - (void)applicationWillTerminate:(NSNotification *)notification { 240 WIURL *url; 241 242 url = [_browserController URL]; 243 244 if(url) 245 [FHSettings setObject:[url string] forKey:FHOpenURL]; 246 } 247 248 249 250 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)application { 251 return YES; 252 } 253 254 255 256 - (BOOL)application:(NSApplication *)application openFile:(NSString *)path { 257 [_browserController loadURL:[WIURL fileURLWithPath:path]]; 258 259 _openLastURL = NO; 260 261 return YES; 262 } 263 264 265 266 - (void)workspaceDidChangeMounts:(NSNotification *)notification { 267 [self _reloadVolumesInGoMenu]; 268 } 269 270 271 272 - (void)windowControllerDidLoadHandler:(NSNotification *)notification { 273 [self _reloadPathsInGoMenuForHandler:[notification object]]; 274 } 275 276 277 278 - (void)windowControllerChangedZoomMode:(NSNotification *)notification { 173 174 175 - (void)_updateViewMenu { 279 176 NSEnumerator *enumerator; 280 177 NSMenuItem *item; 281 178 FHImageScaling scaling; 179 int spread; 282 180 283 181 scaling = [FHSettings intForKey:FHImageScalingMethod]; 284 enumerator = [[ _viewMenu itemArray] objectEnumerator];182 enumerator = [[[_viewMenu itemArray] subarrayWithRange:NSMakeRange(0, 6)] objectEnumerator]; 285 183 286 184 while((item = [enumerator nextObject])) 287 185 [item setState:((FHImageScaling) [item tag] == scaling) ? NSOnState : NSOffState]; 186 187 spread = [FHSettings intForKey:FHSpreadMode]; 188 enumerator = [[[_viewMenu itemArray] subarrayWithRange:NSMakeRange(7, 3)] objectEnumerator]; 189 190 while((item = [enumerator nextObject])) 191 [item setState:([item tag] == spread) ? NSOnState : NSOffState]; 192 } 193 194 @end 195 196 197 @implementation FHApplicationController 198 199 - (void)dealloc { 200 [_browserController release]; 201 202 [super dealloc]; 203 } 204 205 206 207 - (void)awakeFromNib { 208 _openLastURL = YES; 209 210 [self _buildGoMenu]; 211 [self _updateViewMenu]; 212 213 [[NSNotificationCenter defaultCenter] 214 addObserver:self 215 selector:@selector(windowControllerDidLoadHandler:) 216 name:FHBrowserControllerDidLoadHandler]; 217 218 [[NSNotificationCenter defaultCenter] 219 addObserver:self 220 selector:@selector(windowControllerChangedZoomMode:) 221 name:FHWindowControllerChangedZoomMode]; 222 223 [[NSNotificationCenter defaultCenter] 224 addObserver:self 225 selector:@selector(windowControllerChangedSpreadMode:) 226 name:FHWindowControllerChangedSpreadMode]; 227 228 [[[NSWorkspace sharedWorkspace] notificationCenter] 229 addObserver:self 230 selector:@selector(workspaceDidChangeMounts:) 231 name:NSWorkspaceDidMountNotification]; 232 233 [[[NSWorkspace sharedWorkspace] notificationCenter] 234 addObserver:self 235 selector:@selector(workspaceDidChangeMounts:) 236 name:NSWorkspaceDidUnmountNotification]; 237 238 _browserController = [[FHBrowserController alloc] init]; 239 } 240 241 242 243 #pragma mark - 244 245 - (void)applicationDidFinishLaunching:(NSNotification *)notification { 246 WIURL *url; 247 248 if((GetCurrentKeyModifiers() & optionKey) != 0) 249 [FHSettings setObject:[[WIURL fileURLWithPath:NSHomeDirectory()] string] forKey:FHOpenURL]; 250 251 if(_openLastURL) { 252 url = [WIURL URLWithString:[FHSettings objectForKey:FHOpenURL]]; 253 254 if([url isFileURL] && ![[NSFileManager defaultManager] fileExistsAtPath:[url path]]) 255 url = [WIURL fileURLWithPath:NSHomeDirectory()]; 256 257 [_browserController loadURL:url]; 258 } 259 260 [_browserController showWindow:self]; 261 } 262 263 264 265 - (void)applicationWillTerminate:(NSNotification *)notification { 266 WIURL *url; 267 268 url = [_browserController URL]; 269 270 if(url) 271 [FHSettings setObject:[url string] forKey:FHOpenURL]; 272 } 273 274 275 276 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)application { 277 return YES; 278 } 279 280 281 282 - (BOOL)application:(NSApplication *)application openFile:(NSString *)path { 283 [_browserController loadURL:[WIURL fileURLWithPath:path]]; 284 285 _openLastURL = NO; 286 287 return YES; 288 } 289 290 291 292 - (void)workspaceDidChangeMounts:(NSNotification *)notification { 293 [self _reloadVolumesInGoMenu]; 294 } 295 296 297 298 - (void)windowControllerDidLoadHandler:(NSNotification *)notification { 299 [self _reloadPathsInGoMenuForHandler:[notification object]]; 300 } 301 302 303 304 - (void)windowControllerChangedZoomMode:(NSNotification *)notification { 305 [self _updateViewMenu]; 306 } 307 308 309 310 - (void)windowControllerChangedSpreadMode:(NSNotification *)notification { 311 [self _updateViewMenu]; 288 312 } 289 313 Footagehead/trunk/FHBrowserController.m
r4726 r4731 282 282 [[self window] setTitle:@"Footagehead" withSubtitle:[[_handler stringComponents] lastObject]]; 283 283 284 [self updateSpreads]; 285 284 286 [self _updateLeftStatus]; 285 287 … … 358 360 CGFloat zoom, size; 359 361 360 if(![[_imageView images] count] > 0) { 361 [_rightStatusTextField setStringValue:@""]; 362 363 return; 364 } 365 366 imageSize = [_imageView imageSize]; 362 imageSize = [_imageView combinedImageSize]; 367 363 368 364 if(imageSize.width < 1.0 || imageSize.height <= 1.0) { … … 419 415 420 416 - (id)init { 417 FHImageLoader *imageLoader; 418 421 419 self = [super initWithWindowNibName:@"Browser"]; 422 420 423 _imageLoader = [[FHImageLoader alloc] init]; 424 425 [[_imageLoader notificationCenter] 426 addObserver:self 427 selector:@selector(imageLoaderReceivedImageData:) 428 name:FHImageLoaderReceivedImageData]; 429 430 [[_imageLoader notificationCenter] 431 addObserver:self 432 selector:@selector(imageLoaderDidLoadImage:) 433 name:FHImageLoaderDidLoadImage]; 421 imageLoader = [[FHImageLoader alloc] init]; 422 [self setImageLoader:imageLoader]; 434 423 435 424 [[_imageLoader notificationCenter] … … 437 426 selector:@selector(imageLoaderDidLoadThumbnail:) 438 427 name:FHImageLoaderDidLoadThumbnail]; 428 429 [imageLoader release]; 439 430 440 431 [self window]; … … 585 576 586 577 - (void)handlerDidFinishLoading:(FHHandler *)handler { 587 }588 589 590 591 - (void)imageLoaderReceivedImageData:(NSNotification *)notification {592 FHFile *file;593 594 file = [notification object];595 596 if(file == [self selectedFile]) {597 if([_progressIndicator isHidden]) {598 [_progressIndicator setIndeterminate:!([file percentReceived] > 0.0)];599 [_progressIndicator setHidden:NO];600 }601 602 [_progressIndicator setDoubleValue:[file percentReceived]];603 [_progressIndicator animate:self];604 }605 }606 607 608 609 - (void)imageLoaderDidLoadImage:(NSNotification *)notification {610 FHFile *file;611 612 file = [notification object];613 614 if(file == [self selectedFile])615 [self showFile:file];616 578 } 617 579 Footagehead/trunk/FHImageLoader.m
r4726 r4731 87 87 percent = (double) [_asynchronousData length] / (double) _asynchronousLength; 88 88 89 if(percent > [_asynchronousFile percentReceived] + 0. 1|| [_asynchronousFile percentReceived] == 0.0) {89 if(percent > [_asynchronousFile percentReceived] + 0.05 || [_asynchronousFile percentReceived] == 0.0) { 90 90 [_asynchronousFile setPercentReceived:percent]; 91 91 … … 93 93 object:_asynchronousFile]; 94 94 } 95 } else {96 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderReceivedImageData97 object:_asynchronousFile];98 95 } 99 96 } Footagehead/trunk/FHImageView.h
r4723 r4731 45 45 IBOutlet NSScrollView *_scrollView; 46 46 47 NSArray *_images; 48 NSSize _imageSize; 47 FHImage *_image; 48 FHImage *_leftImage, *_rightImage; 49 NSSize _combinedImageSize; 50 NSSize _leftSize, _rightSize; 49 51 50 52 FHImageScaling _imageScaling; … … 61 63 62 64 63 - (void)setImages:(NSArray *)images; 64 - (NSArray *)images; 65 - (NSSize)imageSize; 65 - (void)setImage:(FHImage *)image; 66 - (FHImage *)image; 67 - (void)setLeftImage:(FHImage *)leftImage rightImage:(FHImage *)rightImage; 68 - (FHImage *)leftImage; 69 - (FHImage *)rightImage; 70 - (NSSize)combinedImageSize; 66 71 - (void)setImageScaling:(FHImageScaling)newScaling; 67 72 - (FHImageScaling)imageScaling; Footagehead/trunk/FHImageView.m
r4723 r4731 36 36 37 37 - (void)_adjustScaling; 38 - (NSSize)_scaledImageSizeFor Bounds:(NSSize)bounds;38 - (NSSize)_scaledImageSizeForSize:(NSSize)size bounds:(NSSize)bounds; 39 39 40 40 @end … … 92 92 [self setFrameSize:contentSize]; 93 93 94 if([_images count] > 0 && (_imageScaling == FHScaleNone || 95 _imageScaling == FHScaleWidthProportionally || 96 _imageScaling == FHScaleHeightProportionally)) { 97 imageSize = [self _scaledImageSizeForBounds:contentSize]; 94 if(_combinedImageSize.width > 0.0 && 95 (_imageScaling == FHScaleNone || 96 _imageScaling == FHScaleWidthProportionally || 97 _imageScaling == FHScaleHeightProportionally)) { 98 imageSize = [self _scaledImageSizeForSize:_combinedImageSize bounds:contentSize]; 98 99 99 100 if(ABS(_imageRotation) == 90.0 || ABS(_imageRotation) == 270.0) { … … 135 136 136 137 137 - (NSSize)_scaledImageSizeForBounds:(NSSize)bounds { 138 NSSize size; 138 - (NSSize)_scaledImageSizeForSize:(NSSize)size bounds:(NSSize)bounds { 139 139 float dx, dy, d; 140 141 size = _imageSize;142 140 143 141 if(_imageScaling == FHScaleNone) … … 148 146 149 147 if(ABS(_imageRotation) == 90.0 || ABS(_imageRotation) == 270.0) { 150 dx = bounds.width / size.height;151 dy = bounds.height / size.width;148 dx = bounds.width / _combinedImageSize.height; 149 dy = bounds.height / _combinedImageSize.width; 152 150 } else { 153 dx = bounds.width / size.width;154 dy = bounds.height / size.height;151 dx = bounds.width / _combinedImageSize.width; 152 dy = bounds.height / _combinedImageSize.height; 155 153 } 156 154 … … 196 194 197 195 - (void)dealloc { 198 [_images release]; 196 [_image release]; 197 [_rightImage release]; 198 [_leftImage release]; 199 199 200 200 [_backgroundColor release]; … … 210 210 #pragma mark - 211 211 212 - (void)setImage s:(NSArray *)images{212 - (void)setImage:(FHImage *)image { 213 213 BOOL display; 214 214 215 display = ([images count] != 0 || [_images count] != 0); 216 217 [images retain]; 218 [_images release]; 219 220 _images = images; 221 222 if([_images count] > 0) { 223 _imageSize = [[_images objectAtIndex:0] size]; 215 display = (image != NULL || _image != NULL || _leftImage != NULL || _rightImage != NULL); 216 217 [_leftImage release]; 218 _leftImage = NULL; 219 220 [_rightImage release]; 221 _rightImage = NULL; 222 223 [image retain]; 224 [_image release]; 225 226 _image = image; 227 228 if(_image) { 229 _combinedImageSize = [_image size]; 224 230 } else { 225 _ imageSize.width = 0.0;226 _ imageSize.height = 0.0;231 _combinedImageSize.width = 0.0; 232 _combinedImageSize.height = 0.0; 227 233 } 228 234 … … 235 241 236 242 237 - (NSArray *)images { 238 return _images; 239 } 240 241 242 243 - (NSSize)imageSize { 244 return _imageSize; 243 - (FHImage *)image { 244 return _image; 245 } 246 247 248 249 - (void)setLeftImage:(FHImage *)leftImage rightImage:(FHImage *)rightImage { 250 BOOL display; 251 252 display = (_image != NULL || leftImage != NULL || _leftImage != NULL || rightImage != NULL || _rightImage != NULL); 253 254 [_image release]; 255 _image = NULL; 256 257 [leftImage retain]; 258 [_leftImage release]; 259 260 _leftImage = leftImage; 261 262 if(_leftImage) { 263 _leftSize = [_leftImage size]; 264 } else { 265 _leftSize.width = 0.0; 266 _leftSize.height = 0.0; 267 } 268 269 [rightImage retain]; 270 [_rightImage release]; 271 272 _rightImage = rightImage; 273 274 if(_rightImage) { 275 _rightSize = [_rightImage size]; 276 } else { 277 _rightSize.width = 0.0; 278 _rightSize.height = 0.0; 279 } 280 281 _combinedImageSize.width = _leftSize.width + _rightSize.width; 282 _combinedImageSize.height = MAX(_leftSize.height, _rightSize.height); 283 284 [self _adjustScaling]; 285 286 if(display) 287 [self setNeedsDisplay:YES]; 288 } 289 290 291 292 - (FHImage *)leftImage { 293 return _leftImage; 294 } 295 296 297 298 - (FHImage *)rightImage { 299 return _rightImage; 300 } 301 302 303 304 - (NSSize)combinedImageSize { 305 return _combinedImageSize; 245 306 } 246 307 … … 394 455 FHImage *image; 395 456 NSRect bounds, rect; 457 NSSize size; 396 458 397 459 bounds = [self bounds]; … … 400 462 NSRectFill(bounds); 401 463 402 if([_images count] > 0) { 403 image = [_images objectAtIndex:0]; 404 405 rect.size = [self _scaledImageSizeForBounds:bounds.size]; 406 rect.origin.x = floorf((bounds.size.width - rect.size.width) / 2.0); 407 rect.origin.y = floorf((bounds.size.height - rect.size.height) / 2.0); 408 409 [image drawInRect:rect atAngle:_imageRotation]; 410 464 if(_image || _leftImage || _rightImage) { 465 if(_image) { 466 rect.size = [self _scaledImageSizeForSize:_combinedImageSize bounds:bounds.size]; 467 rect.origin.x = floorf((bounds.size.width - rect.size.width) / 2.0); 468 rect.origin.y = floorf((bounds.size.height - rect.size.height) / 2.0); 469 470 [_image drawInRect:rect atAngle:_imageRotation]; 471 } else { 472 if(_leftImage && _rightImage) { 473 size = [self _scaledImageSizeForSize:_combinedImageSize bounds:bounds.size]; 474 475 rect.size = [self _scaledImageSizeForSize:_leftSize bounds:bounds.size]; 476 rect.origin.x = floorf((bounds.size.width - size.width) / 2.0); 477 rect.origin.y = floorf((bounds.size.height - size.height) / 2.0); 478 479 [_leftImage drawInRect:rect atAngle:_imageRotation]; 480 481 rect.origin.x += rect.size.width; 482 rect.size = [self _scaledImageSizeForSize:_rightSize bounds:bounds.size]; 483 484 [_rightImage drawInRect:rect atAngle:_imageRotation]; 485 } 486 else if(_leftImage || _rightImage) { 487 image = _leftImage ? _leftImage : _rightImage; 488 size = _leftImage ? _leftSize : _rightSize; 489 490 rect.size = [self _scaledImageSizeForSize:size bounds:bounds.size]; 491 rect.origin.x = floorf((bounds.size.width - rect.size.width) / 2.0); 492 rect.origin.y = floorf((bounds.size.height - rect.size.height) / 2.0); 493 494 [image drawInRect:rect atAngle:_imageRotation]; 495 } 496 } 497 411 498 if(_label && [_label length] > 0) 412 499 [_label drawAtPoint:NSMakePoint(10.0, 10.0) withAttributes:_labelAttributes]; Footagehead/trunk/FHSettings.h
r4719 r4731 44 44 #define FHHTMLImageOnlyLinks 2 45 45 #define FHShowStatusBar @"FHShowStatusBar" 46 #define FHSpreadMode @"FHSpreadMode" 47 #define FHSpreadNone 0 48 #define FHSpreadEvenPages 1 49 #define FHSpreadOddPages 2 46 50 47 51 @end Footagehead/trunk/FHSettings.m
r4719 r4731 53 53 [NSNumber numberWithBool:YES], 54 54 FHShowStatusBar, 55 [NSNumber numberWithInt:FHSpreadNone], 56 FHSpreadMode, 55 57 NULL]; 56 58 } Footagehead/trunk/FHSlideshowController.m
r4728 r4731 39 39 self = [super initWithWindowNibName:@"Slideshow"]; 40 40 41 _imageLoader = [imageLoader retain];42 41 _index = index; 43 42 _images = images; 43 44 [self setImageLoader:imageLoader]; 44 45 45 46 [[_imageLoader notificationCenter] … … 66 67 67 68 [super dealloc]; 68 }69 70 71 72 #pragma mark -73 74 - (void)imageLoaderReceivedImageData:(NSNotification *)notification {75 FHFile *file;76 77 file = [notification object];78 79 if(file == [self selectedFile]) {80 if([_progressIndicator isHidden]) {81 [_progressIndicator setIndeterminate:!([file percentReceived] > 0.0)];82 [_progressIndicator setHidden:NO];83 }84 85 [_progressIndicator setDoubleValue:[file percentReceived]];86 [_progressIndicator animate:self];87 }88 }89 90 91 92 - (void)imageLoaderDidLoadImage:(NSNotification *)notification {93 FHFile *file;94 95 file = [notification object];96 97 if(file == [self selectedFile])98 [self showFile:file];99 69 } 100 70 … … 126 96 screen:screen]; 127 97 128 //[_slideshowWindow setLevel:NSScreenSaverWindowLevel];98 [_slideshowWindow setLevel:NSScreenSaverWindowLevel]; 129 99 [_slideshowWindow setDelegate:self]; 130 100 [_slideshowWindow setReleasedWhenClosed:NO]; Footagehead/trunk/FHWindowController.h
r4726 r4731 28 28 29 29 @class FHImageView; 30 @class FHImageLoader, FHFile ;30 @class FHImageLoader, FHFile, FHSpread; 31 31 32 32 @interface FHWindowController : WIWindowController { … … 35 35 36 36 FHImageLoader *_imageLoader; 37 38 NSMutableDictionary *_spreads; 37 39 } 38 40 39 41 40 42 #define FHWindowControllerChangedZoomMode @"FHWindowControllerChangedZoomMode" 43 #define FHWindowControllerChangedSpreadMode @"FHWindowControllerChangedSpreadMode" 41 44 45 46 - (void)setImageLoader:(FHImageLoader *)imageLoader; 47 - (FHImageLoader *)imageLoader; 42 48 43 49 - (NSArray *)files; … … 48 54 - (void)showFile:(FHFile *)file; 49 55 - (void)updateFileStatus; 56 - (FHSpread *)spreadForFile:(FHFile *)file; 57 - (FHSpread *)selectedSpread; 58 - (void)updateSpreads; 50 59 51 60 - (void)firstFile:(id)sender; … … 57 66 58 67 - (void)zoomMode:(id)sender; 68 - (void)spreadMode:(id)sender; 59 69 - (void)rotateRight:(id)sender; 60 70 - (void)rotateLeft:(id)sender; Footagehead/trunk/FHWindowController.m
r4726 r4731 29 29 #import "FHFile.h" 30 30 #import "FHHandler.h" 31 #import "FHImageLoader.h" 31 32 #import "FHImageView.h" 32 33 #import "FHSettings.h" 34 #import "FHSpread.h" 33 35 #import "FHWindowController.h" 34 36 35 37 @implementation FHWindowController 38 39 - (id)initWithWindowNibName:(NSString *)nibName { 40 self = [super initWithWindowNibName:nibName]; 41 42 _spreads = [[NSMutableDictionary alloc] init]; 43 44 return self; 45 } 46 47 36 48 37 49 - (void)dealloc { 38 50 [[_imageLoader notificationCenter] removeObserver:self]; 51 52 [_spreads release]; 39 53 40 54 [super dealloc]; 55 } 56 57 58 59 #pragma mark - 60 61 - (void)imageLoaderReceivedImageData:(NSNotification *)notification { 62 FHFile *file; 63 64 file = [notification object]; 65 66 if(file == [self selectedFile]) { 67 [_progressIndicator setIndeterminate:NO]; 68 [_progressIndicator setDoubleValue:[file percentReceived]]; 69 [_progressIndicator animate:self]; 70 } 71 } 72 73 74 75 - (void)imageLoaderDidLoadImage:(NSNotification *)notification { 76 FHFile *file; 77 78 file = [notification object]; 79 80 if([FHSettings intForKey:FHSpreadMode] == FHSpreadNone) { 81 if(file == [self selectedFile]) 82 [self showFile:file]; 83 } else { 84 if([self spreadForFile:file] == [self selectedSpread]) 85 [self showFile:file]; 86 } 87 } 88 89 90 91 #pragma mark - 92 93 - (void)setImageLoader:(FHImageLoader *)imageLoader { 94 [imageLoader retain]; 95 [_imageLoader release]; 96 97 _imageLoader = imageLoader; 98 99 [[_imageLoader notificationCenter] 100 addObserver:self 101 selector:@selector(imageLoaderReceivedImageData:) 102 name:FHImageLoaderReceivedImageData]; 103 104 [[_imageLoader notificationCenter] 105 addObserver:self 106 selector:@selector(imageLoaderDidLoadImage:) 107 name:FHImageLoaderDidLoadImage]; 108 } 109 110 111 112 - (FHImageLoader *)imageLoader { 113 return _imageLoader; 41 114 } 42 115 … … 82 155 83 156 - (void)showFile:(FHFile *)file { 84 FHImage *image; 157 FHSpread *spread; 158 FHFile *leftFile, *rightFile; 159 FHImage *image, *leftImage, *rightImage; 160 double percentReceived; 85 161 BOOL success; 86 162 87 [_progressIndicator setHidden:YES]; 88 [_progressIndicator setDoubleValue:0.0]; 89 90 if([file isLoaded]) { 91 image = [file image]; 92 success = (image && [image size].width > 0.0); 163 if([FHSettings intForKey:FHSpreadMode] == FHSpreadNone) { 164 if([file isLoaded]) { 165 [_progressIndicator setHidden:YES]; 166 [_progressIndicator setDoubleValue:0.0]; 167 168 image = [file image]; 169 success = (image && [image size].width > 0.0); 170 171 if(success) 172 [_imageView setImage:image]; 173 else 174 [_imageView setImage:[FHImage imageNamed:@"Error"]]; 175 } else { 176 if(![[file URL] isFileURL]) { 177 percentReceived = [file percentReceived]; 178 179 [_progressIndicator setHidden:NO]; 180 [_progressIndicator setIndeterminate:!(percentReceived > 0.0)]; 181 [_progressIndicator setDoubleValue:percentReceived]; 182 } 183 184 [_imageView setImage:NULL]; 185 } 186 } else { 187 spread = [self spreadForFile:file]; 188 leftFile = [spread leftFile]; 189 rightFile = [spread rightFile]; 93 190 94 if(success) 95 [_imageView setImages:[NSArray arrayWithObject:image]]; 96 else 97 [_imageView setImages:[NSArray arrayWithObject:[FHImage imageNamed:@"Error"]]]; 98 } else { 99 [_imageView setImages:NULL]; 191 if((!leftFile || [leftFile isLoaded]) && (!rightFile || [rightFile isLoaded])) { 192 [_progressIndicator setHidden:YES]; 193 [_progressIndicator setDoubleValue:0.0]; 194 195 leftImage = [leftFile image]; 196 rightImage = [rightFile image]; 197 success = ((leftImage || rightImage) && ([leftImage size].width > 0.0 || [rightImage size].width > 0.0)); 198 199 if(success) 200 [_imageView setLeftImage:leftImage rightImage:rightImage]; 201 &nbs
