diff options
author | johnallen <[email protected]> | 2007-01-14 01:26:22 +0000 |
---|---|---|
committer | johnallen <[email protected]> | 2007-01-14 01:26:22 +0000 |
commit | 17a07e8bd6ff83eff4def00e2393086a88f0bba5 (patch) | |
tree | 9849c10750113f208a3ff5ff555858b60d0084c0 /macosx | |
parent | 84bcaf125ca3119eca11bc44207eba3a0b2b3e37 (diff) |
barber pole progress bar is shown during the "muxing" phase and no longer show 0.0%. applies to both HB and IHB
When we can figure out how to get a percent complete, we can use that.
IHB now uses same app icon as HB. Probably want to change the actual icon, but I wanted IHB to make use of the dock progress bar like in HB.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@105 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.mm | 10 | ||||
-rw-r--r-- | macosx/Express.plist | 2 | ||||
-rw-r--r-- | macosx/ExpressController.m | 96 | ||||
-rw-r--r-- | macosx/HandBrake.xcodeproj/project.pbxproj | 8 |
4 files changed, 106 insertions, 10 deletions
diff --git a/macosx/Controller.mm b/macosx/Controller.mm index d4242ace8..281c3372b 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -334,6 +334,7 @@ static int FormatSettings[3][4] = /* Update slider */ progress_total = ( p.progress + p.job_cur - 1 ) / p.job_count; + [fRipIndicator setIndeterminate: NO]; [fRipIndicator setDoubleValue: 100.0 * progress_total]; /* Update dock icon */ @@ -350,19 +351,19 @@ static int FormatSettings[3][4] = #define p s.param.muxing case HB_STATE_MUXING: { - float progress_total; NSMutableString * string; /* Update text field */ string = [NSMutableString stringWithFormat: - _( @"Muxing: %.2f %%" ), 100.0 * p.progress]; + _( @"Muxing..." )]; [fStatusField setStringValue: string]; /* Update slider */ - [fRipIndicator setDoubleValue: 100.0 * p.progress]; + [fRipIndicator setIndeterminate: YES]; + [fRipIndicator startAnimation: nil]; /* Update dock icon */ - [self UpdateDockIcon: 100.0 * p.progress]; + [self UpdateDockIcon: 1.0]; [fPauseButton setEnabled: YES]; [fPauseButton setTitle: _( @"Pause" )]; @@ -384,6 +385,7 @@ static int FormatSettings[3][4] = { [self EnableUI: YES]; [fStatusField setStringValue: _( @"Done." )]; + [fRipIndicator setIndeterminate: NO]; [fRipIndicator setDoubleValue: 0.0]; [fRipButton setTitle: _( @"Rip" )]; diff --git a/macosx/Express.plist b/macosx/Express.plist index 262a7ec55..81703d1d6 100644 --- a/macosx/Express.plist +++ b/macosx/Express.plist @@ -16,6 +16,8 @@ <string>????</string> <key>CFBundleVersion</key> <string>1.0a2</string> + <key>CFBundleIconFile</key> + <string>HandBrake.icns</string> <key>NSMainNibFile</key> <string>Express</string> <key>NSPrincipalClass</key> diff --git a/macosx/ExpressController.m b/macosx/ExpressController.m index d5d17449c..c1a78a807 100644 --- a/macosx/ExpressController.m +++ b/macosx/ExpressController.m @@ -521,6 +521,90 @@ } } +/*********************************************************************** +* UpdateDockIcon +*********************************************************************** +* Shows a progression bar on the dock icon, filled according to +* 'progress' (0.0 <= progress <= 1.0). +* Called with progress < 0.0 or progress > 1.0, restores the original +* icon. +**********************************************************************/ +- (void) UpdateDockIcon: (float) progress +{ + NSImage * icon; + NSData * tiff; + NSBitmapImageRep * bmp; + uint32_t * pen; + uint32_t black = htonl( 0x000000FF ); + uint32_t red = htonl( 0xFF0000FF ); + uint32_t white = htonl( 0xFFFFFFFF ); + int row_start, row_end; + int i, j; + + /* Get application original icon */ + icon = [NSImage imageNamed: @"NSApplicationIcon"]; + + if( progress < 0.0 || progress > 1.0 ) + { + [NSApp setApplicationIconImage: icon]; + return; + } + + /* Get it in a raw bitmap form */ + tiff = [icon TIFFRepresentationUsingCompression: + NSTIFFCompressionNone factor: 1.0]; + bmp = [NSBitmapImageRep imageRepWithData: tiff]; + + /* Draw the progression bar */ + /* It's pretty simple (ugly?) now, but I'm no designer */ + + row_start = 3 * (int) [bmp size].height / 4; + row_end = 7 * (int) [bmp size].height / 8; + + for( i = row_start; i < row_start + 2; i++ ) + { + pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] ); + for( j = 0; j < (int) [bmp size].width; j++ ) + { + pen[j] = black; + } + } + for( i = row_start + 2; i < row_end - 2; i++ ) + { + pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] ); + pen[0] = black; + pen[1] = black; + for( j = 2; j < (int) [bmp size].width - 2; j++ ) + { + if( j < 2 + (int) ( ( [bmp size].width - 4.0 ) * progress ) ) + { + pen[j] = red; + } + else + { + pen[j] = white; + } + } + pen[j] = black; + pen[j+1] = black; + } + for( i = row_end - 2; i < row_end; i++ ) + { + pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] ); + for( j = 0; j < (int) [bmp size].width; j++ ) + { + pen[j] = black; + } + } + + /* Now update the dock icon */ + tiff = [bmp TIFFRepresentationUsingCompression: + NSTIFFCompressionNone factor: 1.0]; + icon = [[NSImage alloc] initWithData: tiff]; + [NSApp setApplicationIconImage: icon]; + [icon release]; +} + - (void) convertTimer: (NSTimer *) timer { hb_state_t s; @@ -559,7 +643,8 @@ [fConvertInfoString setStringValue: string]; [fConvertIndicator setIndeterminate: NO]; [fConvertIndicator setDoubleValue: 100.0 * progress_total]; - break; + [self UpdateDockIcon: progress_total]; + break; } #undef p @@ -567,11 +652,11 @@ case HB_STATE_MUXING: { NSMutableString * string = [NSMutableString - stringWithFormat: @"Muxing: %.1f %%", - 100.0 * p.progress]; + stringWithFormat: @"Muxing..."]; [fConvertInfoString setStringValue: string]; - [fConvertIndicator setIndeterminate: NO]; - [fConvertIndicator setDoubleValue: 100.0 * p.progress]; + [fConvertIndicator setIndeterminate: YES]; + [fConvertIndicator startAnimation: nil]; + [self UpdateDockIcon: 1.0]; break; } #undef p @@ -581,6 +666,7 @@ [timer invalidate]; [fConvertIndicator setIndeterminate: NO]; [fConvertIndicator setDoubleValue: 0.0]; + [self UpdateDockIcon: -1.0]; [self convertEnable: YES]; #define p s.param.workdone diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj index b77f580b7..6920e3a91 100644 --- a/macosx/HandBrake.xcodeproj/project.pbxproj +++ b/macosx/HandBrake.xcodeproj/project.pbxproj @@ -38,6 +38,9 @@ 4DD93FA3082036E8008E1322 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DEB2024052B055F00C39CA9 /* IOKit.framework */; }; 4DD93FA4082036E8008E1322 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DDE9724052B7B2B00C39CA9 /* OpenGL.framework */; }; 4DE09E63082038A400FB751F /* HandBrake.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4DE09E62082038A400FB751F /* HandBrake.plist */; }; + 52AFF8690B59BCFB000DA7C4 /* HandBrake.icns in Resources */ = {isa = PBXBuildFile; fileRef = 4D118405053054CD00C39CA9 /* HandBrake.icns */; }; + 52AFF86A0B59BD07000DA7C4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; + 52AFF86B0B59BD14000DA7C4 /* Express.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4D1EA2DC0993B01000FDC1A2 /* Express.plist */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -49,7 +52,7 @@ 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 4D1125D709D72FD200E0657B /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; }; 4D118405053054CD00C39CA9 /* HandBrake.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = HandBrake.icns; sourceTree = "<group>"; }; - 4D1EA2DA0993B01000FDC1A2 /* Instant HandBrake.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Instant HandBrake.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 4D1EA2DA0993B01000FDC1A2 /* Instant HandBrake.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = "Instant HandBrake.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 4D1EA2DC0993B01000FDC1A2 /* Express.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Express.plist; sourceTree = "<group>"; }; 4D1EA3000993B13700FDC1A2 /* Express.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Express.nib; path = English.lproj/Express.nib; sourceTree = "<group>"; }; 4D1EA31A0993B24700FDC1A2 /* ExpressController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ExpressController.h; sourceTree = "<group>"; }; @@ -347,6 +350,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 52AFF86B0B59BD14000DA7C4 /* Express.plist in Resources */, + 52AFF86A0B59BD07000DA7C4 /* InfoPlist.strings in Resources */, + 52AFF8690B59BCFB000DA7C4 /* HandBrake.icns in Resources */, 4D1EA3010993B13700FDC1A2 /* Express.nib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; |