OSDN Git Service

import original 0.9.5 release
[handbrake-jp/handbrake-jp.git] / macosx / PictureController.m
index 67fe65f..7817410 100644 (file)
 //------------------------------------------------------------------------------------
 - (IBAction) showPictureWindow: (id)sender
 {
-    if ([fPreviewController fullScreen] == YES)
-    {
-        [self showWindow:sender];
-        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PictureSizeWindowIsOpen"];
-        [self setToFullScreenMode];
-    }
-    else
-    {
+
+
         if ([[self window] isVisible])
         {
             [[self window] close];
             [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PictureSizeWindowIsOpen"];
             [self setToWindowedMode];
         }
-    }
+
     [self adjustFilterDisplay:nil];
     [self adjustSizingDisplay:nil];
 }
 
-- (BOOL) previewFullScreenMode
-{
-    return [fPreviewController fullScreen];
-}
+
 
 /* this method is used to detect clicking on a tab in fSizeFilterView */
 - (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
         [fParHeightLabel setHidden: NO];
         [fDisplayWidthField setHidden: NO];
         [fDisplayWidthLabel setHidden: NO];
-        [fModulusLabel setHidden: NO];
-        [fModulusPopUp setHidden: NO];
         /* adjust/move keep ar checkbox */
         [fRatioLabel setHidden: YES];
         [fRatioLabel2 setHidden: NO];
         [fParHeightLabel setHidden: YES];
         [fDisplayWidthField setHidden: YES];
         [fDisplayWidthLabel setHidden: YES];
-        [fModulusLabel setHidden: YES];
-        [fModulusPopUp setHidden: YES];
         /* adjust/move keep ar checkbox */
         [fRatioLabel setHidden: NO];
         [fRatioLabel2 setHidden: YES];
 
 #pragma mark -
 
-- (IBAction) previewGoWindowed: (id)sender
-{
-    [fPreviewController goWindowedScreen:self];
-}
+
 
 - (IBAction) showPreviewWindow: (id)sender
 {
     [fPreviewController showWindow:sender];
 }
 
+- (void) enablePreviewHudControls
+{
+    [fPreviewController enableHudControls];
+}
 
-
-
-- (void) setToFullScreenMode
+- (void) disablePreviewHudControls
 {
-    int32_t shieldLevel = CGShieldingWindowLevel(); 
-    
-    [fPictureWindow setLevel:shieldLevel + 1]; 
-    // Show the window. 
-    [fPictureWindow makeKeyAndOrderFront:self];
+    [fPreviewController disableHudControls];
 }
 
 - (void) setToWindowedMode
     [fModulusPopUp addItemWithTitle: @"8"];
     [fModulusPopUp addItemWithTitle: @"4"];
     [fModulusPopUp addItemWithTitle: @"2"];
-    if (job->anamorphic.mode == 3)
+    if (job->modulus)
     {
-        [fModulusPopUp selectItemWithTitle: [NSString stringWithFormat:@"%d",job->anamorphic.modulus]];
+        [fModulusPopUp selectItemWithTitle: [NSString stringWithFormat:@"%d",job->modulus]];
     }
     else
     {
-        [fModulusPopUp selectItemWithTitle: @"16"];
+        [fModulusPopUp selectItemAtIndex: 0];
     }
     
+    
     /* We initially set the previous state of keep ar to on */
     keepAspectRatioPreviousState = 1;
        if (!autoCrop)
     titleParWidth = job->anamorphic.par_width;
     titleParHeight = job->anamorphic.par_height;
     
-    [self SettingsChanged: nil];
+    [self SettingsChanged:nil];
 }
 
 - (IBAction) storageLinkChanged: (id) sender
 - (IBAction) SettingsChanged: (id) sender
 {
     hb_job_t * job = fTitle->job;
-    [fModulusPopUp setEnabled:NO];
-    job->anamorphic.modulus = 16;
+
+    /* if we are anything but strict anamorphic */
+    if ([fAnamorphicPopUp indexOfSelectedItem] != 1)
+    {
+        [fModulusLabel setHidden:NO];
+        [fModulusPopUp setHidden:NO];
+        if (sender == fModulusPopUp)
+        {
+            /* do a dry run with hb_fix aspect to get new modulus */
+            job->modulus = [[fModulusPopUp titleOfSelectedItem] intValue];
+            job->keep_ratio  = 1;
+            hb_fix_aspect( job, HB_KEEP_WIDTH );
+            if( job->height > fTitle->height )
+            {
+                job->height = fTitle->height;
+                hb_fix_aspect( job, HB_KEEP_HEIGHT );
+            }
+            [fWidthStepper      setIntValue: job->width];
+            [fWidthField        setIntValue: job->width];
+            if( [fAnamorphicPopUp indexOfSelectedItem] != 2) // if we are not loose or custom
+            {
+                [fHeightStepper     setIntValue: job->height];
+                [fHeightField       setIntValue: job->height];
+            }    
+        }
+    }
+    else
+    {
+        /* we are strict so hide the mod popup since libhb uses mod 2 for strict anamorphic*/
+        [fModulusLabel setHidden:YES];
+        [fModulusPopUp setHidden:YES];
+    }
+
+    job->modulus = [[fModulusPopUp titleOfSelectedItem] intValue];
+    
+    [fWidthStepper  setIncrement: job->modulus];
+    [fHeightStepper setIncrement: job->modulus];
 
     /* Since custom anamorphic allows for a height setting > fTitle->height
      * check to make sure it is returned to fTitle->height for all other modes
         job->anamorphic.par_width = titleParWidth;
         job->anamorphic.par_height = titleParHeight;
         [fRatioLabel setHidden: NO];
-        
-        [fWidthStepper  setIncrement: 16];
-        [fHeightStepper setIncrement: 16];
-    }
-    else
-    {
-        [fWidthStepper  setIncrement: [[fModulusPopUp titleOfSelectedItem] intValue]];
-        [fHeightStepper setIncrement: [[fModulusPopUp titleOfSelectedItem] intValue]];
     }
     
        if( [fAnamorphicPopUp indexOfSelectedItem] > 0 )
             job->anamorphic.mode = 3;
             
             /* Set the status of our custom ana only widgets accordingly */
-            /* for mod 3 we can use modulus other than 16 */
             [fModulusPopUp setEnabled:YES];
-            job->anamorphic.modulus = [[fModulusPopUp titleOfSelectedItem] intValue];
             
             [fWidthStepper setEnabled: YES];
             [fWidthField setEnabled: YES];
         
        }
        
-    //job->keep_ratio  = ( [fRatioCheck state] == NSOnState );
-    
     if ([fAnamorphicPopUp indexOfSelectedItem] != 3)
     {
-    job->keep_ratio  = ( [fRatioCheck state] == NSOnState );
-            if( job->keep_ratio )
+        job->keep_ratio  = ( [fRatioCheck state] == NSOnState );
+        if( job->keep_ratio )
         {
             if( sender == fWidthStepper || sender == fRatioCheck ||
-               sender == fCropTopStepper || sender == fCropBottomStepper )
+               sender == fCropTopStepper || sender == fCropBottomStepper|| 
+               sender == fCropMatrix || sender == nil  )
             {
                 hb_fix_aspect( job, HB_KEEP_WIDTH );
                 if( job->height > fTitle->height )