OSDN Git Service

barber pole progress bar is shown during the "muxing" phase and no longer show 0...
authorjohnallen <johnallen@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 14 Jan 2007 01:26:22 +0000 (01:26 +0000)
committerjohnallen <johnallen@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 14 Jan 2007 01:26:22 +0000 (01:26 +0000)
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://localhost/HandBrake/trunk@105 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.mm
macosx/Express.plist
macosx/ExpressController.m
macosx/HandBrake.xcodeproj/project.pbxproj

index d4242ac..281c337 100644 (file)
@@ -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" )];
 
index 262a7ec..81703d1 100644 (file)
@@ -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>
index d5d1744..c1a78a8 100644 (file)
     }
 }
 
+/***********************************************************************
+* 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;
             [fConvertInfoString setStringValue: string];
             [fConvertIndicator setIndeterminate: NO];
             [fConvertIndicator setDoubleValue: 100.0 * progress_total];
-            break;
+            [self UpdateDockIcon: progress_total];
+                       break;
         }
 #undef p
 
         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
                        [timer invalidate];
             [fConvertIndicator setIndeterminate: NO];
             [fConvertIndicator setDoubleValue: 0.0];
+            [self UpdateDockIcon: -1.0];
             [self convertEnable: YES];
                        
 #define p s.param.workdone
index b77f580..6920e3a 100644 (file)
@@ -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>"; };
                        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;