Changeset 4731

Show
Ignore:
Timestamp:
04/27/07 19:12:01 (2 years ago)
Author:
morris
Message:

Add support for spreads

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Footagehead/trunk/English.lproj/MainMenu.nib/classes.nib

    r4716 r4731  
    3939                setAsDesktopBackground = id;  
    4040                slideshow = id;  
     41                spreadMode = id;  
    4142                submitSheet = id;  
    4243                toggleStatusBar = id;  
  • Footagehead/trunk/English.lproj/MainMenu.nib/info.nib

    r4723 r4731  
    44<dict> 
    55        <key>IBDocumentLocation</key> 
    6         <string>838 346 395 374 0 0 1920 1178 </string> 
     6        <string>594 300 395 374 0 0 1920 1178 </string> 
    77        <key>IBEditorPositions</key> 
    88        <dict> 
    99                <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> 
    1111        </dict> 
    1212        <key>IBFramework Version</key> 
     
    1919        </array> 
    2020        <key>IBSystem Version</key> 
    21         <string>8P2137</string> 
     21        <string>8P135</string> 
    2222</dict> 
    2323</plist> 
  • Footagehead/trunk/FHApplicationController.m

    r4726 r4731  
    3939- (void)_addGoMenuItemWithPath:(NSString *)path keyEquivalent:(NSString *)keyEquivalent; 
    4040- (void)_reloadPathsInGoMenuForHandler:(FHHandler *)handler; 
     41- (void)_updateViewMenu; 
    4142 
    4243@end 
     
    170171} 
    171172 
    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 { 
    279176        NSEnumerator    *enumerator; 
    280177        NSMenuItem              *item; 
    281178        FHImageScaling  scaling; 
     179        int                             spread; 
    282180         
    283181        scaling = [FHSettings intForKey:FHImageScalingMethod]; 
    284         enumerator = [[_viewMenu itemArray] objectEnumerator]; 
     182        enumerator = [[[_viewMenu itemArray] subarrayWithRange:NSMakeRange(0, 6)] objectEnumerator]; 
    285183         
    286184        while((item = [enumerator nextObject])) 
    287185                [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]; 
    288312} 
    289313 
  • Footagehead/trunk/FHBrowserController.m

    r4726 r4731  
    282282        [[self window] setTitle:@"Footagehead" withSubtitle:[[_handler stringComponents] lastObject]]; 
    283283         
     284        [self updateSpreads]; 
     285         
    284286        [self _updateLeftStatus]; 
    285287         
     
    358360        CGFloat                         zoom, size; 
    359361         
    360         if(![[_imageView images] count] > 0) { 
    361                 [_rightStatusTextField setStringValue:@""]; 
    362                  
    363                 return; 
    364         } 
    365          
    366         imageSize = [_imageView imageSize]; 
     362        imageSize = [_imageView combinedImageSize]; 
    367363         
    368364        if(imageSize.width < 1.0 || imageSize.height <= 1.0) { 
     
    419415 
    420416- (id)init { 
     417        FHImageLoader   *imageLoader; 
     418         
    421419        self = [super initWithWindowNibName:@"Browser"]; 
    422420         
    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]; 
    434423         
    435424        [[_imageLoader notificationCenter] 
     
    437426                   selector:@selector(imageLoaderDidLoadThumbnail:) 
    438427                           name:FHImageLoaderDidLoadThumbnail]; 
     428 
     429        [imageLoader release]; 
    439430 
    440431        [self window]; 
     
    585576 
    586577- (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]; 
    616578} 
    617579 
  • Footagehead/trunk/FHImageLoader.m

    r4726 r4731  
    8787                percent = (double) [_asynchronousData length] / (double) _asynchronousLength; 
    8888                 
    89                 if(percent > [_asynchronousFile percentReceived] + 0.1 || [_asynchronousFile percentReceived] == 0.0) { 
     89                if(percent > [_asynchronousFile percentReceived] + 0.05 || [_asynchronousFile percentReceived] == 0.0) { 
    9090                        [_asynchronousFile setPercentReceived:percent]; 
    9191         
     
    9393                                                                                                                 object:_asynchronousFile]; 
    9494                } 
    95         } else { 
    96                 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderReceivedImageData 
    97                                                                                                          object:_asynchronousFile]; 
    9895        } 
    9996} 
  • Footagehead/trunk/FHImageView.h

    r4723 r4731  
    4545        IBOutlet NSScrollView           *_scrollView; 
    4646         
    47         NSArray                                         *_images; 
    48         NSSize                                          _imageSize; 
     47        FHImage                                         *_image; 
     48        FHImage                                         *_leftImage, *_rightImage; 
     49        NSSize                                          _combinedImageSize; 
     50        NSSize                                          _leftSize, _rightSize; 
    4951         
    5052        FHImageScaling                          _imageScaling; 
     
    6163 
    6264 
    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; 
    6671- (void)setImageScaling:(FHImageScaling)newScaling; 
    6772- (FHImageScaling)imageScaling; 
  • Footagehead/trunk/FHImageView.m

    r4723 r4731  
    3636 
    3737- (void)_adjustScaling; 
    38 - (NSSize)_scaledImageSizeForBounds:(NSSize)bounds; 
     38- (NSSize)_scaledImageSizeForSize:(NSSize)size bounds:(NSSize)bounds; 
    3939 
    4040@end 
     
    9292                [self setFrameSize:contentSize]; 
    9393                 
    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]; 
    9899                         
    99100                        if(ABS(_imageRotation) == 90.0 || ABS(_imageRotation) == 270.0) { 
     
    135136 
    136137 
    137 - (NSSize)_scaledImageSizeForBounds:(NSSize)bounds { 
    138         NSSize          size; 
     138- (NSSize)_scaledImageSizeForSize:(NSSize)size bounds:(NSSize)bounds { 
    139139        float           dx, dy, d; 
    140          
    141         size = _imageSize; 
    142140         
    143141        if(_imageScaling == FHScaleNone) 
     
    148146         
    149147        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; 
    152150        } 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; 
    155153        } 
    156154         
     
    196194 
    197195- (void)dealloc { 
    198         [_images release]; 
     196        [_image release]; 
     197        [_rightImage release]; 
     198        [_leftImage release]; 
    199199 
    200200        [_backgroundColor release]; 
     
    210210#pragma mark - 
    211211 
    212 - (void)setImages:(NSArray *)images
     212- (void)setImage:(FHImage *)image
    213213        BOOL    display; 
    214214 
    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]; 
    224230        } else { 
    225                 _imageSize.width = 0.0; 
    226                 _imageSize.height = 0.0; 
     231                _combinedImageSize.width = 0.0; 
     232                _combinedImageSize.height = 0.0; 
    227233        } 
    228234 
     
    235241 
    236242 
    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; 
    245306} 
    246307 
     
    394455        FHImage         *image; 
    395456        NSRect          bounds, rect; 
     457        NSSize          size; 
    396458         
    397459        bounds = [self bounds]; 
     
    400462        NSRectFill(bounds); 
    401463         
    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                         
    411498                if(_label && [_label length] > 0) 
    412499                        [_label drawAtPoint:NSMakePoint(10.0, 10.0) withAttributes:_labelAttributes]; 
  • Footagehead/trunk/FHSettings.h

    r4719 r4731  
    4444#define FHHTMLImageOnlyLinks                                    2 
    4545#define FHShowStatusBar                                         @"FHShowStatusBar" 
     46#define FHSpreadMode                                            @"FHSpreadMode" 
     47#define FHSpreadNone                                                    0 
     48#define FHSpreadEvenPages                                               1 
     49#define FHSpreadOddPages                                                2 
    4650 
    4751@end 
  • Footagehead/trunk/FHSettings.m

    r4719 r4731  
    5353                [NSNumber numberWithBool:YES], 
    5454                        FHShowStatusBar, 
     55                [NSNumber numberWithInt:FHSpreadNone], 
     56                        FHSpreadMode, 
    5557                NULL]; 
    5658} 
  • Footagehead/trunk/FHSlideshowController.m

    r4728 r4731  
    3939        self = [super initWithWindowNibName:@"Slideshow"]; 
    4040         
    41         _imageLoader = [imageLoader retain]; 
    4241        _index = index; 
    4342        _images = images; 
     43         
     44        [self setImageLoader:imageLoader]; 
    4445 
    4546        [[_imageLoader notificationCenter] 
     
    6667 
    6768        [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]; 
    9969} 
    10070 
     
    12696                                         screen:screen]; 
    12797         
    128 //    [_slideshowWindow setLevel:NSScreenSaverWindowLevel]; 
     98      [_slideshowWindow setLevel:NSScreenSaverWindowLevel]; 
    12999        [_slideshowWindow setDelegate:self]; 
    130100        [_slideshowWindow setReleasedWhenClosed:NO]; 
  • Footagehead/trunk/FHWindowController.h

    r4726 r4731  
    2828 
    2929@class FHImageView; 
    30 @class FHImageLoader, FHFile
     30@class FHImageLoader, FHFile, FHSpread
    3131 
    3232@interface FHWindowController : WIWindowController { 
     
    3535 
    3636        FHImageLoader                                   *_imageLoader; 
     37         
     38        NSMutableDictionary                             *_spreads; 
    3739} 
    3840 
    3941 
    4042#define FHWindowControllerChangedZoomMode       @"FHWindowControllerChangedZoomMode" 
     43#define FHWindowControllerChangedSpreadMode     @"FHWindowControllerChangedSpreadMode" 
    4144 
     45 
     46- (void)setImageLoader:(FHImageLoader *)imageLoader; 
     47- (FHImageLoader *)imageLoader; 
    4248 
    4349- (NSArray *)files; 
     
    4854- (void)showFile:(FHFile *)file; 
    4955- (void)updateFileStatus; 
     56- (FHSpread *)spreadForFile:(FHFile *)file; 
     57- (FHSpread *)selectedSpread; 
     58- (void)updateSpreads; 
    5059 
    5160- (void)firstFile:(id)sender; 
     
    5766 
    5867- (void)zoomMode:(id)sender; 
     68- (void)spreadMode:(id)sender; 
    5969- (void)rotateRight:(id)sender; 
    6070- (void)rotateLeft:(id)sender; 
  • Footagehead/trunk/FHWindowController.m

    r4726 r4731  
    2929#import "FHFile.h" 
    3030#import "FHHandler.h" 
     31#import "FHImageLoader.h" 
    3132#import "FHImageView.h" 
    3233#import "FHSettings.h" 
     34#import "FHSpread.h" 
    3335#import "FHWindowController.h" 
    3436 
    3537@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 
    3648 
    3749- (void)dealloc { 
    3850        [[_imageLoader notificationCenter] removeObserver:self]; 
     51         
     52        [_spreads release]; 
    3953 
    4054        [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; 
    41114} 
    42115 
     
    82155 
    83156- (void)showFile:(FHFile *)file { 
    84         FHImage         *image; 
     157        FHSpread        *spread; 
     158        FHFile          *leftFile, *rightFile; 
     159        FHImage         *image, *leftImage, *rightImage; 
     160        double          percentReceived; 
    85161        BOOL            success; 
    86162 
    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]; 
    93190                 
    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