OSDN Git Service

MacGui: Picture window now uses a subclass of HBController to access the main controller.
authordynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 15 Dec 2008 15:11:49 +0000 (15:11 +0000)
committerdynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 15 Dec 2008 15:11:49 +0000 (15:11 +0000)
- fixed issue where preview movie keeps playing even if the picture window is closed
- Removed deprecated -ClosePanel method since we now use the windows native close button.

git-svn-id: svn://localhost/HandBrake/trunk@2033 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.h
macosx/Controller.mm
macosx/English.lproj/MainMenu.xib
macosx/English.lproj/PictureSettings.xib
macosx/PictureController.h
macosx/PictureController.mm

index 5ab03c6..e05b0af 100644 (file)
@@ -15,6 +15,7 @@
 #import "HBAdvancedController.h"
 #import "HBPreferencesController.h"
 #import "HBPresets.h"
+
 @class HBOutputPanelController;
 
 /* We subclass NSView so that our drags show both the icon as well as PresetName columns */
@@ -102,7 +103,7 @@ BOOL                        fIsDragging;
     IBOutlet NSButton            * fVidTurboPassCheck;
        
        /* Picture Settings box */
-       IBOutlet NSTextField         * fPicLabelSettings;
+    IBOutlet NSTextField         * fPicLabelSettings;
        IBOutlet NSTextField         * fPicLabelSrc;
     IBOutlet NSTextField         * fPicSettingsSrc;
        IBOutlet NSTextField         * fPicLabelOutp;
@@ -298,6 +299,7 @@ BOOL                        fIsDragging;
 - (IBAction) audioDRCSliderChanged: (id) sender;
 
 - (IBAction) showPicturePanel: (id) sender;
+- (void)pictureSettingsDidChange;
 - (IBAction) calculatePictureSizing: (id) sender;
 - (IBAction) openMainWindow: (id) sender;
 
index 0bf28c7..cf5ad30 100644 (file)
@@ -60,7 +60,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
                                                    attributes:nil];
     }                                                            
     outputPanel = [[HBOutputPanelController alloc] init];
-    fPictureController = [[PictureController alloc] initWithDelegate:self];
+    fPictureController = [[PictureController alloc] init];
     fQueueController = [[HBQueueController alloc] init];
     fAdvancedOptions = [[HBAdvancedController alloc] init];
     /* we init the HBPresets class which currently is only used
@@ -89,6 +89,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     [GrowlApplicationBridge setGrowlDelegate: self];
     /* Init others controllers */
     [fPictureController SetHandle: fHandle];
+    [fPictureController   setHBController: self];
     [fQueueController   setHandle: fQueueEncodeLibhb];
     [fQueueController   setHBController: self];
 
@@ -239,6 +240,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
        [browsedSourceDisplayName release];
     [outputPanel release];
        [fQueueController release];
+    [fPictureController release];
        hb_close(&fHandle);
     hb_close(&fQueueEncodeLibhb);
 }
@@ -4102,7 +4104,8 @@ the user is using "Custom" settings by determining the sender*/
  * Registers changes made in the Picture Settings Window.
  */
 
-- (void)pictureSettingsDidChange {
+- (void)pictureSettingsDidChange 
+{
        [self calculatePictureSizing:nil];
 }
 
@@ -5146,11 +5149,13 @@ the user is using "Custom" settings by determining the sender*/
 
 - (IBAction) showPicturePanel: (id) sender
 {
-       hb_list_t  * list  = hb_get_titles( fHandle );
+       /*
+    hb_list_t  * list  = hb_get_titles( fHandle );
     hb_title_t * title = (hb_title_t *) hb_list_item( list,
             [fSrcTitlePopUp indexOfSelectedItem] );
-    //[fPictureController SetTitle:title];
-    [fPictureController showPreviewPanel:sender forTitle:title];
+            */
+    //[fPictureController showPreviewPanel:sender forTitle:title];
+    [fPictureController showPictureWindow:sender];
 }
 
 #pragma mark -
index d910dda..aa14d93 100644 (file)
                                                        <string>fPicSettingsAnamorphic</string>
                                                        <string>fPicSettingsOutp</string>
                                                        <string>fPicSettingsSrc</string>
-                                                       <string>fPictureButton</string>
                                                        <string>fPresetDrawer</string>
                                                        <string>fPresetNewDesc</string>
                                                        <string>fPresetNewFolderCheck</string>
                                                        <string>NSTextField</string>
                                                        <string>NSTextField</string>
                                                        <string>NSTextField</string>
-                                                       <string>NSButton</string>
                                                        <string>NSDrawer</string>
                                                        <string>NSTextField</string>
                                                        <string>NSButton</string>
index 68ea6c4..d57a665 100644 (file)
@@ -8,7 +8,7 @@
                <string key="IBDocument.HIToolboxVersion">352.00</string>
                <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
                        <bool key="EncodedWithXMLCoder">YES</bool>
-                       <integer value="23"/>
+                       <integer value="5"/>
                </object>
                <object class="NSArray" key="IBDocument.PluginDependencies">
                        <bool key="EncodedWithXMLCoder">YES</bool>
@@ -1670,6 +1670,14 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                        </object>
                                        <int key="connectionID">239</int>
                                </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPictureWindow</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="616825745"/>
+                                       </object>
+                                       <int key="connectionID">240</int>
+                               </object>
                        </object>
                        <object class="IBMutableOrderedSet" key="objectRecords">
                                <object class="NSArray" key="orderedObjects">
@@ -2705,10 +2713,10 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
-                                       <string>{{497, 299}, {484, 557}}</string>
+                                       <string>{{491, 299}, {484, 557}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
-                                       <string>{{497, 299}, {484, 557}}</string>
+                                       <string>{{491, 299}, {484, 557}}</string>
                                        <reference ref="9"/>
                                        <string>{{221, 276}, {533, 580}}</string>
                                        <reference ref="9"/>
@@ -2747,7 +2755,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                </object>
                        </object>
                        <nil key="sourceID"/>
-                       <int key="maxID">239</int>
+                       <int key="maxID">240</int>
                </object>
                <object class="IBClassDescriber" key="IBDocument.Classes">
                        <object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -2762,13 +2770,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">NSObject</string>
-                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="251078365">
-                                               <string key="majorKey">IBProjectSource</string>
-                                               <string key="minorKey">PictureController.h</string>
-                                       </object>
-                               </object>
-                               <object class="IBPartialClassDescription">
-                                       <string key="className">NSObject</string>
                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
                                                <string key="majorKey">IBUserSource</string>
                                                <string key="minorKey"/>
@@ -2788,6 +2789,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                        <string>pictureSliderChanged:</string>
                                                        <string>previewDurationPopUpChanged:</string>
                                                        <string>showMoviePreview:</string>
+                                                       <string>showPictureWindow:</string>
                                                </object>
                                                <object class="NSMutableArray" key="dict.values">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
@@ -2798,6 +2800,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                        <string>id</string>
                                                        <string>id</string>
                                                        <string>NSString</string>
+                                                       <string>id</string>
                                                </object>
                                        </object>
                                        <object class="NSMutableDictionary" key="outlets">
@@ -2831,6 +2834,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                        <string>fPictureSlider</string>
                                                        <string>fPictureView</string>
                                                        <string>fPictureViewArea</string>
+                                                       <string>fPictureWindow</string>
                                                        <string>fPreviewMovieLengthPopUp</string>
                                                        <string>fPreviewMovieStatusField</string>
                                                        <string>fRatioCheck</string>
@@ -2867,6 +2871,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                        <string>NSSlider</string>
                                                        <string>NSImageView</string>
                                                        <string>NSBox</string>
+                                                       <string>NSWindow</string>
                                                        <string>NSPopUpButton</string>
                                                        <string>NSTextField</string>
                                                        <string>NSButton</string>
@@ -2875,7 +2880,10 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                        <string>NSStepper</string>
                                                </object>
                                        </object>
-                                       <reference key="sourceIdentifier" ref="251078365"/>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBProjectSource</string>
+                                               <string key="minorKey">PictureController.h</string>
+                                       </object>
                                </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">PictureController</string>
index 631a1d1..6c6eef7 100644 (file)
@@ -10,6 +10,8 @@
 /* Needed for Quicktime movie previews */
 #import <QTKit/QTKit.h> 
 
+@class HBController;
+
 #define HB_NUM_HBLIB_PICTURES      20   // # of preview pictures libhb should generate
 
 @interface PictureController : NSWindowController
@@ -17,6 +19,8 @@
     hb_handle_t              * fHandle;
     hb_title_t               * fTitle;
 
+    HBController             *fHBController;        // reference to HBController
+    IBOutlet NSWindow        * fPictureWindow;
     NSMutableDictionary      * fPicturePreviews;        // NSImages, one for each preview libhb creates, created lazily
     int                        fPicture;
 
     IBOutlet QTMovieView            * fMovieView;
     IBOutlet NSPopUpButton          * fPreviewMovieLengthPopUp; // popup of choices for length of preview in seconds
 }
-- (id)initWithDelegate:(id)del;
+- (id)init;
 
 - (void) SetHandle: (hb_handle_t *) handle;
 - (void) SetTitle:  (hb_title_t *)  title;
+- (void)setHBController: (HBController *)controller;
+- (IBAction) showPictureWindow: (id)sender;
+
 - (void) setInitialPictureFilters;
 - (void) displayPreview;
 
 - (IBAction) showMoviePreview: (NSString *) path;
 - (IBAction) previewDurationPopUpChanged: (id) sender;
 
-
-- (IBAction) ClosePanel: (id) sender;
-
 - (BOOL) autoCrop;
 - (void) setAutoCrop: (BOOL) setting;
 
 - (void) purgeImageCache;
 @end
 
-@interface NSObject (PictureControllertDelegateMethod)
-- (void)pictureSettingsDidChange;
-- (void)prepareJobForPreview;
-@end
index 08d5c3e..8d61f56 100644 (file)
@@ -5,6 +5,7 @@
    It may be used under the terms of the GNU General Public License. */
 
 #import "PictureController.h"
+#import "Controller.h"
 
 @interface PictureController (Private)
 
@@ -17,7 +18,7 @@
 
 @implementation PictureController
 
-- (id)initWithDelegate:(id)del
+- (id)init
 {
        if (self = [super initWithWindowNibName:@"PictureSettings"])
        {
@@ -31,8 +32,7 @@
         // go away.
         [self window];
         
-               delegate = del;
-        fPicturePreviews = [[NSMutableDictionary dictionaryWithCapacity: HB_NUM_HBLIB_PICTURES] retain];
+               fPicturePreviews = [[NSMutableDictionary dictionaryWithCapacity: HB_NUM_HBLIB_PICTURES] retain];
         /* Init libhb with check for updates libhb style set to "0" so its ignored and lets sparkle take care of it */
         int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue];
         fPreviewLibhb = hb_init(loggingLevel, 0);
        return self;
 }
 
+//------------------------------------------------------------------------------------
+// Displays and brings the picture window to the front
+//------------------------------------------------------------------------------------
+- (IBAction) showPictureWindow: (id)sender
+{
+    [self showWindow:sender];
+}
+
+- (void)setHBController: (HBController *)controller
+{
+    fHBController = controller;
+}
+
+- (void)awakeFromNib
+{
+    [fPictureWindow setDelegate:self];
+}
+
+
+- (void)windowWillClose:(NSNotification *)aNotification
+{
+    /* Upon Closing the picture window, we make sure we clean up any
+     * preview movie that might be playing
+     */
+    play_movie = NO;
+    hb_stop( fPreviewLibhb );
+    [self pictureSliderChanged:nil];
+}
+
+- (BOOL)windowShouldClose:(id)fPictureWindow
+{
+    return YES;
+}
+
 - (void) dealloc
 {
     hb_stop(fPreviewLibhb);
@@ -478,8 +512,7 @@ are maintained across different sources */
 
     if (sender != nil)
     {
-        if ([delegate respondsToSelector:@selector(pictureSettingsDidChange)])
-            [delegate pictureSettingsDidChange];
+        [fHBController pictureSettingsDidChange];
     }   
     
 }
@@ -505,6 +538,8 @@ are maintained across different sources */
 #pragma mark Movie Preview
 - (IBAction) createMoviePreview: (id) sender
 {
+    
+    
     /* Lets make sure the still picture previews are showing in case
      * there is currently a movie showing */
     [self pictureSliderChanged:nil];
@@ -526,18 +561,18 @@ are maintained across different sources */
         return;
     }
     
+    
     /* we use controller.mm's prepareJobForPreview to go ahead and set all of our settings
      * however, we want to use a temporary destination field of course
      * so that we do not put our temp preview in the users chosen
      * directory */
     
     hb_job_t * job = fTitle->job;
+    
     /* We run our current setting through prepeareJob in Controller.mm
      * just as if it were a regular encode */
-    if ([delegate respondsToSelector:@selector(prepareJobForPreview)])
-    {
-        [delegate prepareJobForPreview];
-    }
+    
+    [fHBController prepareJobForPreview];
     
     /* Destination file. We set this to our preview directory
      * changing the extension appropriately.*/
@@ -813,15 +848,6 @@ are maintained across different sources */
 
 #pragma mark -
 
-- (IBAction) ClosePanel: (id) sender
-{
-    if ([delegate respondsToSelector:@selector(pictureSettingsDidChange)])
-        [delegate pictureSettingsDidChange];
-
-    [NSApp endSheet:[self window]];
-    [[self window] orderOut:self];
-}
-
 - (BOOL) autoCrop
 {
     return autoCrop;