Changeset 2909

Show
Ignore:
Timestamp:
05/26/05 16:35:20 (4 years ago)
Author:
morris
Message:

Add support for dynamically zooming images and displaying scrollbars

Files:

Legend:

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

    r2897 r2909  
    1919                slideshow = id;  
    2020                slideshowButtons = id;  
     21                zoom = id;  
    2122            };  
    2223            CLASS = FHController;  
     
    6263            CLASS = ZAApplication;  
    6364            LANGUAGE = ObjC;  
     65            OUTLETS = {"_releaseNotesTextView" = NSTextView; "_releaseNotesWindow" = NSWindow; };  
    6466            SUPERCLASS = NSApplication;  
    6567        },  
  • Footagehead/trunk/English.lproj/MainMenu.nib/info.nib

    r2906 r2909  
    44<dict> 
    55        <key>IBDocumentLocation</key> 
    6         <string>299 513 395 374 0 0 1680 1028 </string> 
     6        <string>909 492 395 374 0 0 1680 1028 </string> 
    77        <key>IBEditorPositions</key> 
    88        <dict> 
     
    1414        <key>IBOldestOS</key> 
    1515        <integer>3</integer> 
     16        <key>IBOpenObjects</key> 
     17        <array> 
     18                <integer>288</integer> 
     19                <integer>21</integer> 
     20        </array> 
    1621        <key>IBSystem Version</key> 
    1722        <string>8B15</string> 
  • Footagehead/trunk/FHController.h

    r2887 r2909  
    9191- (IBAction)nextPage:(id)sender; 
    9292- (IBAction)reload:(id)sender; 
     93- (IBAction)zoom:(id)sender; 
    9394- (IBAction)slideshow:(id)sender; 
    9495- (IBAction)slideshowButtons:(id)sender; 
  • Footagehead/trunk/FHController.m

    r2907 r2909  
    122122         
    123123        [_fullscreenImageView setBackgroundColor:[NSColor blackColor]]; 
    124         [_fullscreenImageView setDrawsBorder:NO]; 
    125124 
    126125        // --- create locks 
     
    588587- (IBAction)reload:(id)sender { 
    589588        [self loadURL:[_handler URL] withHint:[_handler hint] selectRow:[_tableView selectedRow]]; 
     589} 
     590 
     591 
     592 
     593- (IBAction)zoom:(id)sender { 
     594        [_imageView toggleScaling]; 
     595         
     596        [self updateRightStatus]; 
    590597} 
    591598 
     
    11611168- (void)updateRightStatus { 
    11621169        NSSize          imageSize, frameSize; 
    1163         double          zoom = 100
     1170        double          zoom = 100.0
    11641171         
    11651172        if(![_imageView image]) { 
  • Footagehead/trunk/FHImageView.h

    r2883 r2909  
     1/* $Id$ */ 
     2 
     3/* 
     4 *  Copyright (c) 2003-2005 Axel Andersson 
     5 *  All rights reserved. 
     6 *  
     7 *  Redistribution and use in source and binary forms, with or without 
     8 *  modification, are permitted provided that the following conditions 
     9 *  are met: 
     10 *  1. Redistributions of source code must retain the above copyright 
     11 *     notice, this list of conditions and the following disclaimer. 
     12 *  2. Redistributions in binary form must reproduce the above copyright 
     13 *     notice, this list of conditions and the following disclaimer in the 
     14 *     documentation and/or other materials provided with the distribution. 
     15 *  
     16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
     17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
     18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
     19 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 
     20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
     21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
     22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
     23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
     24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
     25 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     26 * POSSIBILITY OF SUCH DAMAGE. 
     27 */ 
     28 
    129@interface FHImageView : NSView { 
    230        NSImage                                         *_image; 
    331        NSImageScaling                          _imageScaling; 
    432         
    5         BOOL                                            _drawsBorder; 
    6  
    733        NSColor                                         *_backgroundColor; 
    834         
     
    2046- (void)setLabel:(NSString *)label; 
    2147- (NSString *)label; 
    22 - (void)setDrawsBorder:(BOOL)value; 
    23 - (BOOL)drawsBorder
     48 
     49- (void)toggleScaling
    2450 
    2551@end 
  • Footagehead/trunk/FHImageView.m

    r2883 r2909  
     1/* $Id$ */ 
     2 
     3/* 
     4 *  Copyright (c) 2003-2005 Axel Andersson 
     5 *  All rights reserved. 
     6 *  
     7 *  Redistribution and use in source and binary forms, with or without 
     8 *  modification, are permitted provided that the following conditions 
     9 *  are met: 
     10 *  1. Redistributions of source code must retain the above copyright 
     11 *     notice, this list of conditions and the following disclaimer. 
     12 *  2. Redistributions in binary form must reproduce the above copyright 
     13 *     notice, this list of conditions and the following disclaimer in the 
     14 *     documentation and/or other materials provided with the distribution. 
     15 *  
     16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
     17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
     18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
     19 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 
     20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
     21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
     22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
     23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
     24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
     25 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     26 * POSSIBILITY OF SUCH DAMAGE. 
     27 */ 
     28 
     29#import "FHController.h" 
    130#import "FHImageView.h" 
    231 
     
    433 
    534- (void)_initImageView; 
     35 
     36- (void)_adjustScaling; 
    637 
    738@end 
     
    3364- (void)_initImageView { 
    3465        _imageScaling = NSScaleProportionally; 
    35         _drawsBorder = YES; 
    3666        _backgroundColor = [[NSColor whiteColor] retain]; 
    3767 
     
    6797         
    6898        _image = image; 
     99 
     100        [self _adjustScaling]; 
    69101         
    70102        if(display) 
     
    83115        _imageScaling = imageScaling; 
    84116 
     117        [self _adjustScaling]; 
    85118        [self setNeedsDisplay:YES]; 
    86119} 
     
    137170 
    138171 
    139 - (void)setDrawsBorder:(BOOL)value { 
    140         _drawsBorder = value; 
    141  
    142         [self setNeedsDisplay:YES]; 
    143 
    144  
    145  
    146  
    147 - (BOOL)drawsBorder { 
    148         return _drawsBorder; 
     172#pragma mark - 
     173 
     174- (void)toggleScaling { 
     175        if(_imageScaling == NSScaleNone) 
     176                _imageScaling = NSScaleProportionally; 
     177        else 
     178                _imageScaling = NSScaleNone; 
     179         
     180        [self _adjustScaling]; 
     181        [self display]; 
     182
     183 
     184 
     185 
     186- (void)_adjustScaling { 
     187        NSScrollView    *scrollView; 
     188        NSSize                  size, imageSize; 
     189         
     190        scrollView = [self enclosingScrollView]; 
     191         
     192        if(scrollView) { 
     193                size = [scrollView contentSize]; 
     194                 
     195                if(_imageScaling == NSScaleNone) { 
     196                        imageSize = _image ? [_image size] : NSZeroSize; 
     197                         
     198                        [self setFrameSize:NSMakeSize(MAX(size.width, imageSize.width), MAX(size.height, imageSize.height))]; 
     199                        [self scrollPoint:NSMakePoint(0.0, imageSize.height)]; 
     200                } else { 
     201                        [self setFrameSize:size]; 
     202                } 
     203        } 
     204
     205 
     206 
     207 
     208- (void)mouseDown:(NSEvent *)event { 
     209        [[FHController controller] zoom:self]; 
    149210} 
    150211 
     
    162223        NSImage         *image; 
    163224        NSImageRep      *imageRep; 
    164         NSRect          rect; 
     225        NSRect          bounds, rect; 
    165226        float           dx, dy, d; 
    166227         
    167         if(_drawsBorder) { 
    168                 [[NSColor lightGrayColor] set]; 
    169                 NSFrameRect(frame); 
    170                 frame = NSInsetRect(frame, 1.0, 1.0); 
    171         } 
    172  
     228        bounds = [self bounds]; 
     229         
    173230        [_backgroundColor set]; 
    174         NSRectFill(frame); 
     231        NSRectFill(bounds); 
    175232 
    176233        imageRep = [_image bestRepresentationForDevice:NULL]; 
     
    181238                switch (_imageScaling) { 
    182239                        case NSScaleProportionally: 
    183                                 dx      = frame.size.width  / rect.size.width; 
    184                                 dy      = frame.size.height / rect.size.height; 
     240                                dx      = bounds.size.width  / rect.size.width; 
     241                                dy      = bounds.size.height / rect.size.height; 
    185242                                d       = dx < dy ? dx : dy; 
    186243                                 
     
    192249                         
    193250                        case NSScaleToFit: 
    194                                 rect.size = frame.size; 
     251                                rect.size = bounds.size; 
    195252                                break; 
    196253                                 
     
    199256                } 
    200257                 
    201                 rect.origin.x = floorf(((frame.size.width  - rect.size.width)  / 2.0) + 1.0); 
    202                 rect.origin.y = floorf(((frame.size.height - rect.size.height) / 2.0) + 1.0); 
     258                rect.origin.x = floorf((bounds.size.width  - rect.size.width)  / 2.0); 
     259                rect.origin.y = floorf((bounds.size.height - rect.size.height) / 2.0); 
    203260                 
    204261                if([imageRep hasAlpha]) { 
  • Footagehead/trunk/Footagehead.xcode/project.pbxproj

    r2893 r2909  
    185185                                A587DF70055AA3C4005D2097, 
    186186                                A5DE34850567F307003E7FE9, 
     187                                77EA9C1508460B9C006C9F69, 
    187188                        ); 
    188189                        isa = PBXGroup; 
     
    14121413                        remoteInfo = "Zanka Additions"; 
    14131414                }; 
     1415                77EA9C1508460B9C006C9F69 = { 
     1416                        isa = PBXFileReference; 
     1417                        lastKnownFileType = image.tiff; 
     1418                        path = Zoom.tiff; 
     1419                        refType = 4; 
     1420                        sourceTree = "<group>"; 
     1421                }; 
     1422                77EA9C1608460B9C006C9F69 = { 
     1423                        fileRef = 77EA9C1508460B9C006C9F69; 
     1424                        isa = PBXBuildFile; 
     1425                        settings = { 
     1426                        }; 
     1427                }; 
    14141428//770 
    14151429//771 
     
    14821496                                A5DE34860567F307003E7FE9, 
    14831497                                A50933FB083F5141006646D1, 
     1498                                77EA9C1608460B9C006C9F69, 
    14841499                        ); 
    14851500                        isa = PBXResourcesBuildPhase; 
  • Footagehead/trunk/Japanese.lproj/MainMenu.nib/classes.nib

    r2906 r2909  
    1919                slideshow = id;  
    2020                slideshowButtons = id;  
     21                zoom = id;  
    2122            };  
    2223            CLASS = FHController;  
  • Footagehead/trunk/Japanese.lproj/MainMenu.nib/info.nib

    r2906 r2909  
    44<dict> 
    55        <key>IBDocumentLocation</key> 
    6         <string>709 112 395 374 0 0 1680 1028 </string> 
     6        <string>90 508 395 374 0 0 1680 1028 </string> 
    77        <key>IBEditorPositions</key> 
    88        <dict> 
     
    1414        <key>IBOpenObjects</key> 
    1515        <array> 
    16                 <integer>29</integer> 
     16                <integer>21</integer> 
    1717        </array> 
    1818        <key>IBSystem Version</key>