Changeset 3879

Show
Ignore:
Timestamp:
03/05/06 19:27:34 (3 years ago)
Author:
morris
Message:

Add rotate right button

Files:

Legend:

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

    r3876 r3879  
    1919                reload = id;  
    2020                revealInFinder = id;  
     21                rotateRight = id;  
    2122                setAsDesktopPicture = id;  
    2223                slideshow = id;  
     
    4445                "_rightStatusTextField" = NSTextField;  
    4546                "_rightView" = NSView;  
     47                "_rotateRightButton" = NSButton;  
    4648                "_screenAutoSwitchButton" = NSButton;  
    4749                "_screenAutoSwitchTextField" = NSTextField;  
  • Footagehead/trunk/English.lproj/MainMenu.nib/info.nib

    r3876 r3879  
    1818        <key>IBOpenObjects</key> 
    1919        <array> 
     20                <integer>21</integer> 
    2021                <integer>438</integer> 
    21                 <integer>21</integer> 
    2222        </array> 
    2323        <key>IBSystem Version</key> 
  • Footagehead/trunk/FHController.h

    r3876 r3879  
    102102- (IBAction)reload:(id)sender; 
    103103- (IBAction)zoom:(id)sender; 
     104- (IBAction)rotateRight:(id)sender; 
    104105- (IBAction)slideshow:(id)sender; 
    105106- (IBAction)slideshowButtons:(id)sender; 
  • Footagehead/trunk/FHController.m

    r3876 r3879  
    815815         
    816816        [_imageView setImageScaling:[FHSettings intForKey:FHImageScaling]]; 
     817        [_imageView setImageRotation:[FHSettings floatForKey:FHImageRotation]]; 
    817818 
    818819        // --- create locks 
     
    13961397 
    13971398 
     1399- (IBAction)rotateRight:(id)sender { 
     1400        float           rotation; 
     1401         
     1402        rotation = [_imageView imageRotation]; 
     1403         
     1404        if(rotation == -270.0f) 
     1405                rotation = 0.0f; 
     1406        else 
     1407                rotation -= 90.0f; 
     1408         
     1409        [_imageView setImageRotation:rotation]; 
     1410         
     1411        [FHSettings setFloat:rotation forKey:FHImageRotation]; 
     1412} 
     1413 
     1414 
     1415 
    13981416- (IBAction)slideshow:(id)sender { 
    13991417        [NSApp beginSheet:_screenPanel 
  • Footagehead/trunk/FHFileCell.m

    r2948 r3879  
    113113         
    114114        [icon setFlipped:YES]; 
    115         [icon drawInRect:imageRect]; 
     115        [icon drawInRect:imageRect atAngle:0.0]; 
    116116} 
    117117 
  • Footagehead/trunk/FHImage.h

    r3400 r3879  
    5050- (NSSize)size; 
    5151 
    52 - (void)drawInRect:(NSRect)rect
     52- (void)drawInRect:(NSRect)rect atAngle:(float)angle
    5353 
    5454@end 
  • Footagehead/trunk/FHImage.m

    r3400 r3879  
    234234#pragma mark - 
    235235 
    236 - (void)drawInRect:(NSRect)rect { 
    237         if(_CGImage) { 
    238                 CGContextRef    cgContext; 
    239                 CGRect                  cgRect; 
    240                  
    241                 cgContext       = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; 
    242                 cgRect          = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); 
    243  
     236 
     237static inline double radians (double degrees) {return degrees * M_PI/180;} 
     238 
     239- (void)drawInRect:(NSRect)rect atAngle:(float)angle { 
     240        NSImageRep              *imageRep; 
     241        CGContextRef    cgContext; 
     242        CGRect                  cgRect; 
     243        BOOL                    restore = NO; 
     244         
     245        cgContext       = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; 
     246        cgRect          = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); 
     247 
     248        if(_flipped || angle != 0.0f) { 
     249                CGContextSaveGState(cgContext); 
     250                 
    244251                if(_flipped) { 
    245                         CGContextSaveGState(cgContext); 
    246252                        CGContextTranslateCTM(cgContext, 0.0f, rect.origin.y + rect.origin.y + rect.size.height); 
    247253                        CGContextScaleCTM(cgContext, 1.0f, -1.0f); 
    248                 } 
    249                  
     254                } else { 
     255                        float x = rect.origin.x + (rect.size.width / 2.0f); 
     256                        float y = rect.origin.y + (rect.size.height / 2.0f); 
     257                        CGContextTranslateCTM(cgContext, x, y); 
     258                        CGContextRotateCTM(cgContext, radians(angle)); 
     259                        CGContextTranslateCTM(cgContext, -x, -y); 
     260                } 
     261                 
     262                restore = YES; 
     263        } 
     264 
     265        if(_CGImage) { 
    250266                CGContextDrawImage(cgContext, cgRect, _CGImage); 
    251                  
    252                 if(_flipped) 
    253                         CGContextRestoreGState(cgContext); 
    254         } 
    255         else if(_NSImage) { 
    256                 NSImageRep              *imageRep; 
    257                  
     267        } else { 
    258268                imageRep = [_NSImage bestRepresentationForDevice:NULL]; 
    259269                 
    260270                if(imageRep) { 
    261                         [_NSImage setFlipped:_flipped]; 
    262  
    263271                        if([imageRep hasAlpha] || _flipped) 
    264272                                [_NSImage drawInRect:rect fromRect:NSMakeRect(0.0, 0.0, _size.width, _size.height) operation:NSCompositeSourceOver fraction:1.0]; 
     
    267275                } 
    268276        } 
     277         
     278        if(restore) 
     279                CGContextRestoreGState(cgContext); 
    269280} 
    270281 
  • Footagehead/trunk/FHImageView.h

    r3023 r3879  
    3434        FHImage                                         *_image; 
    3535        NSImageScaling                          _imageScaling; 
     36        float                                           _imageRotation; 
    3637         
    3738        NSColor                                         *_backgroundColor; 
     
    4849- (void)setImageScaling:(NSImageScaling)newScaling; 
    4950- (NSImageScaling)imageScaling; 
     51- (void)setImageRotation:(float)rotation; 
     52- (float)imageRotation; 
    5053- (void)setBackgroundColor:(NSColor *)color; 
    5154- (NSColor *)backgroundColor; 
  • Footagehead/trunk/FHImageView.m

    r3388 r3879  
    181181 
    182182 
     183- (void)setImageRotation:(float)imageRotation { 
     184        _imageRotation = imageRotation; 
     185 
     186        [self setNeedsDisplay:YES]; 
     187} 
     188 
     189 
     190 
     191- (float)imageRotation { 
     192        return _imageRotation; 
     193} 
     194 
     195 
     196 
    183197- (void)setBackgroundColor:(NSColor *)color { 
    184198        NSColor         *textColor; 
     
    311325                rect.origin.y = floorf((bounds.size.height - rect.size.height) / 2.0); 
    312326                 
    313                 [_image drawInRect:rect]; 
     327                [_image drawInRect:rect atAngle:_imageRotation]; 
    314328                 
    315329                if(_label && [_label length] > 0) 
  • Footagehead/trunk/FHSettings.h

    r3876 r3879  
    3232#define FHScreen                                        @"FHScreen" 
    3333#define FHImageScaling                          @"FHImageScaling" 
     34#define FHImageRotation                         @"FHImageRotation" 
    3435#define FHBackground                            @"FHBackground" 
    3536#define FHBackgroundBlack                               0 
  • Footagehead/trunk/FHSettings.m

    r3876 r3879  
    4040                [NSNumber numberWithInt:NSScaleProportionally], 
    4141                        FHImageScaling, 
     42                [NSNumber numberWithFloat:0.0f], 
     43                        FHImageRotation, 
    4244                [NSNumber numberWithInt:FHBackgroundBlack], 
    4345                        FHBackground, 
  • Footagehead/trunk/Footagehead.xcodeproj/project.pbxproj

    r3877 r3879  
    144144                A58BE56A09BA054F00C3C20D /* White.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A58BE56709BA054F00C3C20D /* White.tiff */; }; 
    145145                A58BE56B09BA054F00C3C20D /* Gray.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A58BE56809BA054F00C3C20D /* Gray.tiff */; }; 
     146                A58BE75009BB53C400C3C20D /* RotateRight.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A58BE74F09BB53C400C3C20D /* RotateRight.tiff */; }; 
    146147                A599A110075F94F400A03BA5 /* FHFileCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A599A10E075F94F400A03BA5 /* FHFileCell.m */; }; 
    147148                A5B1F611067B3AA100111D0A /* FHHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = A5B1F60F067B3AA100111D0A /* FHHandler.m */; }; 
     
    426427                A58BE56709BA054F00C3C20D /* White.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = White.tiff; sourceTree = "<group>"; }; 
    427428                A58BE56809BA054F00C3C20D /* Gray.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Gray.tiff; sourceTree = "<group>"; }; 
     429                A58BE74F09BB53C400C3C20D /* RotateRight.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = RotateRight.tiff; sourceTree = "<group>"; }; 
    428430                A591E22C056686CB00215980 /* prefix.pch */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = prefix.pch; sourceTree = "<group>"; }; 
    429431                A599A10D075F94F400A03BA5 /* FHFileCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FHFileCell.h; sourceTree = "<group>"; }; 
     
    673675                                A58BE56809BA054F00C3C20D /* Gray.tiff */, 
    674676                                A583338D069E30D100D6A96D /* Reload.tiff */, 
     677                                A58BE74F09BB53C400C3C20D /* RotateRight.tiff */, 
    675678                                A50933FA083F5141006646D1 /* Spotlight.tiff */, 
    676679                                A587DF70055AA3C4005D2097 /* Up.tiff */, 
     
    11881191                                A58BE56A09BA054F00C3C20D /* White.tiff in Resources */, 
    11891192                                A58BE56B09BA054F00C3C20D /* Gray.tiff in Resources */, 
     1193                                A58BE75009BB53C400C3C20D /* RotateRight.tiff in Resources */, 
    11901194                        ); 
    11911195                        runOnlyForDeploymentPostprocessing = 0; 
  • Footagehead/trunk/Japanese.lproj/MainMenu.nib/classes.nib

    r3876 r3879  
    1919                reload = id;  
    2020                revealInFinder = id;  
     21                rotateRight = id;  
    2122                setAsDesktopPicture = id;  
    2223                slideshow = id;  
  • Footagehead/trunk/Japanese.lproj/MainMenu.nib/info.nib

    r3876 r3879  
    44<dict> 
    55        <key>IBDocumentLocation</key> 
    6         <string>1464 275 395 374 1280 0 1280 1024 </string> 
     6        <string>1368 185 395 374 1280 0 1280 1024 </string> 
    77        <key>IBEditorPositions</key> 
    88        <dict> 
     
    1717        <array> 
    1818                <integer>534</integer> 
    19                 <integer>571</integer> 
    2019                <integer>29</integer> 
    2120                <integer>438</integer> 
    2221                <integer>21</integer> 
     22                <integer>571</integer> 
    2323        </array> 
    2424        <key>IBSystem Version</key>