diff options
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/HBPreviewController.m | 94 | ||||
-rw-r--r-- | macosx/PictureController.m | 635 |
2 files changed, 241 insertions, 488 deletions
diff --git a/macosx/HBPreviewController.m b/macosx/HBPreviewController.m index 9d9d2c6fd..d71f996c3 100644 --- a/macosx/HBPreviewController.m +++ b/macosx/HBPreviewController.m @@ -54,8 +54,9 @@ #endif #define BORDER_SIZE 2.0 -#define MIN_WIDTH 480.0 -#define MIN_HEIGHT 360.0 +// make min width and height of preview window large enough for hud +#define MIN_WIDTH 460.0 +#define MIN_HEIGHT 128.0 #define ANIMATION_DUR 0.2 @@ -356,13 +357,14 @@ typedef enum ViewMode : NSUInteger { */ - (void) resizeWindowForViewSize: (NSSize) viewSize { - // Figure out the deltas for the new frame area NSSize currentSize = [[[self window] contentView] frame].size; - CGFloat deltaX = viewSize.width - currentSize.width; - CGFloat deltaY = viewSize.height - currentSize.height; - - // Now resize the whole panel by those same deltas, but don't exceed the min NSRect frame = [[self window] frame]; + + // Calculate border around content region of the frame + int borderX = frame.size.width - currentSize.width; + int borderY = frame.size.height - currentSize.height; + + // Make sure the frame is smaller than the screen NSSize maxSize = [[[self window] screen] visibleFrame].size; /* if we are not Scale To Screen, put an 10% of visible screen on the window */ @@ -372,40 +374,22 @@ typedef enum ViewMode : NSUInteger { maxSize.height = maxSize.height * 0.90; } - /* Set our min size to the storage size */ - NSSize minSize; - minSize.width = self.title->width / self.backingScaleFactor; - minSize.height = self.title->height / self.backingScaleFactor; + // Set the new frame size + // Add the border to the new frame size so that the content region + // of the frame is large enough to accomodate the preview image + frame.size.width = viewSize.width + borderX; + frame.size.height = viewSize.height + borderY; - frame.size.width += deltaX; - frame.size.height += deltaY; - if( frame.size.width < minSize.width ) - { - frame.size.width = minSize.width; - deltaX = frame.size.width - currentSize.width; - } - if( frame.size.height < minSize.height ) - { - frame.size.height = minSize.height; - //deltaY = frame.size.height - currentSize.height; - } /* compare frame to max size of screen */ - if( frame.size.width > maxSize.width ) { frame.size.width = maxSize.width; } - if( frame.size.height > maxSize.height ) { frame.size.height = maxSize.height; } - // But now the sheet is off-center, so also shift the origin to center it and - // keep the top aligned. - if (frame.size.width != [[self window] frame].size.width) - frame.origin.x -= (deltaX / 2.0); - /* Since upon launch we can open up the preview window if it was open * the last time we quit (and at the size it was) we want to make * sure that upon resize we do not have the window off the screen @@ -414,14 +398,6 @@ typedef enum ViewMode : NSUInteger { */ NSSize screenSize = [[[self window] screen] visibleFrame].size; NSPoint screenOrigin = [[[self window] screen] visibleFrame].origin; - if (screenSize.height < frame.size.height) - { - frame.size.height = screenSize.height; - } - if (screenSize.width < frame.size.width) - { - frame.size.width = screenSize.width; - } /* our origin is off the screen to the left*/ if (frame.origin.x < screenOrigin.x) @@ -643,58 +619,36 @@ typedef enum ViewMode : NSUInteger { NSString *sizeInfoString; /* Set the picture size display fields below the Preview Picture*/ - int output_width, output_height, output_par_width, output_par_height; int display_width; + display_width = title->job->width * title->job->anamorphic.par_width / title->job->anamorphic.par_height; if( title->job->anamorphic.mode == 1 ) // Original PAR Implementation { - output_width = title->width-title->job->crop[2]-title->job->crop[3]; - output_height = title->height-title->job->crop[0]-title->job->crop[1]; - display_width = output_width * title->job->anamorphic.par_width / title->job->anamorphic.par_height; sizeInfoString = [NSString stringWithFormat: @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Strict", - title->width, title->height, output_width, output_height, display_width, output_height]; - - displaySize.width = display_width; - displaySize.height = title->height; - imageScaledSize.width = display_width; - imageScaledSize.height = output_height; + title->width, title->height, title->job->width, title->job->height, display_width, title->job->height]; } else if (title->job->anamorphic.mode == 2) // Loose Anamorphic { - hb_set_anamorphic_size(title->job, &output_width, &output_height, &output_par_width, &output_par_height); - display_width = output_width * output_par_width / output_par_height; sizeInfoString = [NSString stringWithFormat: @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Loose", - title->width, title->height, output_width, output_height, display_width, output_height]; - - displaySize.width = display_width; - displaySize.height = title->height; - imageScaledSize.width = display_width; - imageScaledSize.height = output_height; + title->width, title->height, title->job->width, title->job->height, display_width, title->job->height]; } else if (title->job->anamorphic.mode == 3) // Custom Anamorphic { - hb_set_anamorphic_size(title->job, &output_width, &output_height, &output_par_width, &output_par_height); sizeInfoString = [NSString stringWithFormat: @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Custom", - title->width, title->height, output_width, output_height, title->job->anamorphic.dar_width, title->job->anamorphic.dar_height]; - - displaySize.width = title->job->anamorphic.dar_width + title->job->crop[2] + title->job->crop[3] ; - displaySize.height = title->job->anamorphic.dar_height + title->job->crop[0] + title->job->crop[1]; - imageScaledSize.width = (int)title->job->anamorphic.dar_width; - imageScaledSize.height = (int)title->job->height; + title->width, title->height, title->job->width, title->job->height, display_width, title->job->height]; } else // No Anamorphic { sizeInfoString = [NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d", title->width, title->height, - title->job->width, title->job->height]; - - displaySize.width = title->width; - displaySize.height = title->height; - imageScaledSize.width = title->job->width; - imageScaledSize.height = title->job->height; + @"Source: %dx%d, Output: %dx%d", + title->width, title->height, title->job->width, title->job->height]; } + displaySize.width = display_width; + displaySize.height = title->job->height; + imageScaledSize.width = display_width; + imageScaledSize.height = title->job->height; if (self.backingScaleFactor != 1.0) { diff --git a/macosx/PictureController.m b/macosx/PictureController.m index 7bf9bf404..2387f689d 100644 --- a/macosx/PictureController.m +++ b/macosx/PictureController.m @@ -46,25 +46,9 @@ IBOutlet NSTextField * fParWidthLabel; IBOutlet NSTextField * fParHeightLabel; - /* for now we setup some values to remember our pars and dars - * from scan - */ - int titleParWidth; - int titleParHeight; - float dar; - IBOutlet NSPopUpButton * fAnamorphicPopUp; IBOutlet NSTextField * fSizeInfoField; - int output_width, output_height, output_par_width, output_par_height; - int display_width; - - /* used to track the previous state of the keep aspect - ratio checkbox when turning anamorphic on, so it can be - returned to the previous state when anamorphic is turned - off */ - BOOL keepAspectRatioPreviousState; - /* Video Filters */ IBOutlet NSBox * fDetelecineBox; IBOutlet NSPopUpButton * fDetelecinePopUp; @@ -208,35 +192,49 @@ fTitle = title; - [fWidthStepper setMaxValue: title->width]; - [fWidthStepper setIntValue: job->width]; - [fWidthField setIntValue: job->width]; - [fHeightStepper setMaxValue: title->height]; - [fHeightStepper setIntValue: job->height]; - [fHeightField setIntValue: job->height]; - [fRatioCheck setState: job->keep_ratio ? NSOnState : NSOffState]; - [fCropTopStepper setMaxValue: title->height/2-2]; - [fCropBottomStepper setMaxValue: title->height/2-2]; - [fCropLeftStepper setMaxValue: title->width/2-2]; - [fCropRightStepper setMaxValue: title->width/2-2]; - [fAnamorphicPopUp selectItemAtIndex: job->anamorphic.mode]; + if (job->anamorphic.mode == HB_ANAMORPHIC_STRICT) + { + [fWidthStepper setEnabled: NO]; + [fHeightStepper setEnabled: NO]; + } + else + { + [fWidthStepper setEnabled: YES]; + [fHeightStepper setEnabled: YES]; + } + if (job->anamorphic.mode == HB_ANAMORPHIC_STRICT || + job->anamorphic.mode == HB_ANAMORPHIC_LOOSE) + { + job->anamorphic.keep_display_aspect = 1; + [fRatioCheck setState: NSOnState]; + [fRatioCheck setEnabled: NO]; + } + else + { + [fRatioCheck setEnabled: YES]; + [fRatioCheck setState: job->anamorphic.keep_display_aspect ? + NSOnState : NSOffState]; + } + [fParWidthField setEnabled: !job->anamorphic.keep_display_aspect]; + [fParHeightField setEnabled: !job->anamorphic.keep_display_aspect]; + [fDisplayWidthField setEnabled: !job->anamorphic.keep_display_aspect]; if (job->modulus) { [fModulusPopUp selectItemWithTitle: [NSString stringWithFormat:@"%d",job->modulus]]; + [fWidthStepper setIncrement: job->modulus]; + [fHeightStepper setIncrement: job->modulus]; } else { [fModulusPopUp selectItemAtIndex: 0]; + [fWidthStepper setIncrement: 16]; + [fHeightStepper setIncrement: 16]; } - - /* We initially set the previous state of keep ar to on */ - keepAspectRatioPreviousState = 1; - if (!self.autoCrop) - { + if (!self.autoCrop) + { [fCropMatrix selectCellAtRow: 1 column:0]; - /* If auto, lets set the crop steppers according to current job->crop values */ [fCropTopStepper setIntValue: job->crop[0]]; [fCropTopField setIntValue: job->crop[0]]; [fCropBottomStepper setIntValue: job->crop[1]]; @@ -245,11 +243,47 @@ [fCropLeftField setIntValue: job->crop[2]]; [fCropRightStepper setIntValue: job->crop[3]]; [fCropRightField setIntValue: job->crop[3]]; - } - else - { + } + else + { [fCropMatrix selectCellAtRow: 0 column:0]; - } + + [fCropTopStepper setEnabled: !self.autoCrop]; + [fCropBottomStepper setEnabled: !self.autoCrop]; + [fCropLeftStepper setEnabled: !self.autoCrop]; + [fCropRightStepper setEnabled: !self.autoCrop]; + + /* If auto, lets set the crop steppers according to + * current fTitle->crop values */ + memcpy( job->crop, fTitle->crop, 4 * sizeof( int ) ); + [fCropTopStepper setIntValue: fTitle->crop[0]]; + [fCropTopField setIntValue: fTitle->crop[0]]; + [fCropBottomStepper setIntValue: fTitle->crop[1]]; + [fCropBottomField setIntValue: fTitle->crop[1]]; + [fCropLeftStepper setIntValue: fTitle->crop[2]]; + [fCropLeftField setIntValue: fTitle->crop[2]]; + [fCropRightStepper setIntValue: fTitle->crop[3]]; + [fCropRightField setIntValue: fTitle->crop[3]]; + } + [fWidthStepper setMaxValue: title->width - job->crop[2] - job->crop[3]]; + [fWidthStepper setIntValue: job->width]; + [fWidthField setIntValue: job->width]; + [fHeightStepper setMaxValue: title->height - job->crop[0] - job->crop[1]]; + [fHeightStepper setIntValue: job->height]; + [fHeightField setIntValue: job->height]; + [fCropTopStepper setMaxValue: title->height/2-2]; + [fCropBottomStepper setMaxValue: title->height/2-2]; + [fCropLeftStepper setMaxValue: title->width/2-2]; + [fCropRightStepper setMaxValue: title->width/2-2]; + + [fParWidthField setIntValue: job->anamorphic.par_width]; + [fParHeightField setIntValue: job->anamorphic.par_height]; + + int display_width; + display_width = job->width * job->anamorphic.par_width / + job->anamorphic.par_height; + [fDisplayWidthField setIntValue: display_width]; + /* Set filters widgets according to the filters struct */ [fDetelecinePopUp selectItemAtIndex:self.detelecine]; @@ -261,9 +295,6 @@ [self deblockSliderChanged: nil]; - titleParWidth = job->anamorphic.par_width; - titleParHeight = job->anamorphic.par_height; - [fPreviewController setTitle:title]; [self FilterSettingsChanged:nil]; @@ -334,8 +365,8 @@ NSSize pictureCropBoxSize = [fPictureCropBox frame].size; NSPoint fPictureCropBoxOrigin = [fPictureCropBox frame].origin; - if ([fAnamorphicPopUp indexOfSelectedItem] == 3) // custom / power user jamboree - { + if ([fAnamorphicPopUp indexOfSelectedItem] == HB_ANAMORPHIC_CUSTOM) + { // custom / power user jamboree pictureSizingBoxSize.width = 350; /* Set visibility of capuj widgets */ @@ -360,13 +391,16 @@ } /* Check to see if we have changed the size from current */ - if (pictureSizingBoxSize.height != [fPictureSizeBox frame].size.height || pictureSizingBoxSize.width != [fPictureSizeBox frame].size.width) + if (pictureSizingBoxSize.height != [fPictureSizeBox frame].size.height || + pictureSizingBoxSize.width != [fPictureSizeBox frame].size.width) { /* Get our delta for the change in picture size box height */ - CGFloat deltaYSizeBoxShift = pictureSizingBoxSize.height - [fPictureSizeBox frame].size.height; + CGFloat deltaYSizeBoxShift = pictureSizingBoxSize.height - + [fPictureSizeBox frame].size.height; fPictureSizeBoxOrigin.y -= deltaYSizeBoxShift; /* Get our delta for the change in picture size box width */ - CGFloat deltaXSizeBoxShift = pictureSizingBoxSize.width - [fPictureSizeBox frame].size.width; + CGFloat deltaXSizeBoxShift = pictureSizingBoxSize.width - + [fPictureSizeBox frame].size.width; //fPictureSizeBoxOrigin.x += deltaXSizeBoxShift; /* set our new Picture size box size */ [fPictureSizeBox setFrameSize:pictureSizingBoxSize]; @@ -582,409 +616,174 @@ return; hb_job_t * job = fTitle->job; + int keep = 0, dar_updated = 0; - /* if we are anything but strict anamorphic */ - if ([fAnamorphicPopUp indexOfSelectedItem] != 1) + if (sender == fAnamorphicPopUp) { - [fModulusLabel setHidden:NO]; - [fModulusPopUp setHidden:NO]; - if (sender == fModulusPopUp) + job->anamorphic.mode = (int)[fAnamorphicPopUp indexOfSelectedItem]; + if (job->anamorphic.mode == HB_ANAMORPHIC_STRICT) { - /* 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]; - } + [fModulusLabel setHidden: YES]; + [fModulusPopUp setHidden: YES]; + [fWidthStepper setEnabled: NO]; + [fHeightStepper setEnabled: NO]; + } + else + { + [fModulusLabel setHidden: NO]; + [fModulusPopUp setHidden: NO]; + [fWidthStepper setEnabled: YES]; + [fHeightStepper setEnabled: YES]; + } + if (job->anamorphic.mode == HB_ANAMORPHIC_STRICT || + job->anamorphic.mode == HB_ANAMORPHIC_LOOSE) + { + job->anamorphic.keep_display_aspect = 1; + [fRatioCheck setState: NSOnState]; + [fRatioCheck setEnabled: NO]; + } + else + { + [fRatioCheck setEnabled: YES]; + [fRatioCheck setState: job->anamorphic.keep_display_aspect ? + NSOnState : NSOffState]; } } - else + else if (sender == fModulusPopUp) { - /* 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]; } - 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 - */ - [fHeightStepper setMaxValue: fTitle->height]; - - self.autoCrop = ( [fCropMatrix selectedRow] == 0 ); - [fCropTopStepper setEnabled: !self.autoCrop]; - [fCropBottomStepper setEnabled: !self.autoCrop]; - [fCropLeftStepper setEnabled: !self.autoCrop]; - [fCropRightStepper setEnabled: !self.autoCrop]; - - if( self.autoCrop ) + if (sender == fRatioCheck) { - memcpy( job->crop, fTitle->crop, 4 * sizeof( int ) ); + job->anamorphic.keep_display_aspect = [fRatioCheck state] == NSOnState; + [fParWidthField setEnabled: !job->anamorphic.keep_display_aspect]; + [fParHeightField setEnabled: !job->anamorphic.keep_display_aspect]; + [fDisplayWidthField setEnabled: !job->anamorphic.keep_display_aspect]; } - else + + if (sender == fHeightStepper) { - job->crop[0] = [fCropTopStepper intValue]; - job->crop[1] = [fCropBottomStepper intValue]; - job->crop[2] = [fCropLeftStepper intValue]; - job->crop[3] = [fCropRightStepper intValue]; + keep |= HB_KEEP_HEIGHT; + job->height = [fHeightStepper intValue]; } - [fRatioCheck setEnabled: YES]; - - [fParWidthField setEnabled: NO]; - [fParHeightField setEnabled: NO]; - [fDisplayWidthField setEnabled: NO]; - - /* If we are not custom anamorphic, make sure we retain the orginal par */ - if( [fAnamorphicPopUp indexOfSelectedItem] != 3 ) + if (sender == fWidthStepper) { - job->anamorphic.par_width = titleParWidth; - job->anamorphic.par_height = titleParHeight; - [fRatioLabel setHidden: NO]; + keep |= HB_KEEP_WIDTH; + job->width = [fWidthStepper intValue]; } - if( [fAnamorphicPopUp indexOfSelectedItem] > 0 ) - { - if ([fAnamorphicPopUp indexOfSelectedItem] == 1) // strict - { - [fWidthStepper setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]]; - [fWidthField setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]]; - - /* This will show correct anamorphic height values, but - show distorted preview picture ratio */ - [fHeightStepper setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]]; - [fHeightField setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]]; - job->width = [fWidthStepper intValue]; - job->height = [fHeightStepper intValue]; - - job->anamorphic.mode = 1; - [fWidthStepper setEnabled: NO]; - [fWidthField setEnabled: NO]; - [fHeightStepper setEnabled: NO]; - [fHeightField setEnabled: NO]; - [fRatioCheck setEnabled: NO]; - } - else if ([fAnamorphicPopUp indexOfSelectedItem] == 2) // Loose anamorphic - { - job->anamorphic.mode = 2; - [fWidthStepper setEnabled: YES]; - [fWidthField setEnabled: YES]; - [fRatioCheck setEnabled: NO]; - [fHeightStepper setEnabled: NO]; - [fHeightField setEnabled: NO]; - /* We set job->width and call hb_set_anamorphic_size in libhb to do a "dry run" to get - * the values to be used by libhb for loose anamorphic - */ - /* if the sender is the anamorphic popup, then we know that loose anamorphic has just - * been turned on, so snap the width to full width for the source. - */ - if (sender == fAnamorphicPopUp) - { - [fWidthStepper setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]]; - [fWidthField setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]]; - } - job->width = [fWidthStepper intValue]; - hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height); - [fHeightStepper setIntValue: output_height]; - [fHeightField setIntValue: output_height]; - job->height = [fHeightStepper intValue]; - - } - else if ([fAnamorphicPopUp indexOfSelectedItem] == 3) // custom / power user jamboree - { - job->anamorphic.mode = 3; - - /* Set the status of our custom ana only widgets accordingly */ - [fModulusPopUp setEnabled:YES]; - - [fWidthStepper setEnabled: YES]; - [fWidthField setEnabled: YES]; - - [fHeightStepper setEnabled: YES]; - /* for capuj the storage field is immaterial */ - [fHeightField setEnabled: YES]; - - [fRatioCheck setEnabled: YES]; - if (sender == fRatioCheck) - { - if ([fRatioCheck state] == NSOnState) - { - [fParWidthField setEnabled: NO]; - [fParHeightField setEnabled: NO]; - } - else - { - [fParWidthField setEnabled: YES]; - [fParHeightField setEnabled: YES]; - } - } - - [fParWidthField setEnabled: YES]; - [fParHeightField setEnabled: YES]; - - [fDisplayWidthField setEnabled: YES]; - - - /* If we are coming into custom anamorphic we reset the par to original - * which gives us a way back if things get hosed up. - */ - - if (sender == fAnamorphicPopUp) - { - /* When entering custom anamorphic, we start with keep ar on */ - [fRatioCheck setState: NSOnState]; - /* - KEEPING ASPECT RATIO - Disable editing: PIXEL WIDTH, PIXEL HEIGHT - */ - [fParWidthField setEnabled: NO]; - [fParHeightField setEnabled: NO]; - - job->width = [fWidthStepper intValue]; - job->height = [fHeightStepper intValue]; - - /* make sure our par is set back to original */ - job->anamorphic.par_width = titleParWidth; - job->anamorphic.par_height = titleParHeight; - - [fParWidthField setIntValue: titleParWidth]; - [fParHeightField setIntValue: titleParHeight]; - - /* modify our par dims from our storage dims */ - hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height); - float par_display_width = (float)output_width * (float)output_par_width / (float)output_par_height; - - /* go ahead and mod the display dims */ - [fDisplayWidthField setStringValue: [NSString stringWithFormat:@"%.2f", par_display_width]]; - - job->anamorphic.dar_width = [fDisplayWidthField floatValue]; - job->anamorphic.dar_height = (float)[fHeightStepper intValue]; - - /* Set our dar here assuming we are just coming into capuj mode */ - dar = [fDisplayWidthField floatValue] / (float)[fHeightField intValue]; - - } - - /* For capuj we disable these fields if we are keeping the dispay aspect */ - if ([fRatioCheck state] == NSOnState) - { - /* - KEEPING ASPECT RATIO - DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification) */ - /*Disable editing: PIXEL WIDTH, PIXEL HEIGHT */ - - [fParWidthField setEnabled: NO]; - [fParHeightField setEnabled: NO]; - - /* Changing DISPLAY WIDTH: */ - if (sender == fDisplayWidthField) - { - job->anamorphic.dar_width = [fDisplayWidthField floatValue]; - /* Changes HEIGHT to keep DAR */ - /* calculate the height to retain the dar */ - int raw_calulated_height = (int)((int)[fDisplayWidthField floatValue] / dar); - /* now use the modulus to go lower if there is a remainder */ - /* Note to me, raw_calulated_height % [[fModulusPopUp titleOfSelectedItem] intValue] - * gives me the remainder we are not mod (whatever our modulus is) subtract that from - * the actual calculated value derived from the dar to round down to the nearest mod value. - * This should be desireable over rounding up to the next mod value - */ - int modulus_height = raw_calulated_height - (raw_calulated_height % [[fModulusPopUp titleOfSelectedItem] intValue]); - if (modulus_height > fTitle->height) - { - [fHeightStepper setMaxValue: modulus_height]; - } - [fHeightStepper setIntValue: modulus_height]; - job->anamorphic.dar_height = (float)[fHeightStepper intValue]; - job->height = [fHeightStepper intValue]; - - /* Changes PIXEL WIDTH to new DISPLAY WIDTH */ - [fParWidthField setIntValue: [fDisplayWidthField intValue]]; - job->anamorphic.par_width = [fParWidthField intValue]; - /* Changes PIXEL HEIGHT to STORAGE WIDTH */ - [fParHeightField setIntValue: [fWidthField intValue]]; - job->anamorphic.par_height = [fParHeightField intValue]; - - } - /* Changing HEIGHT: */ - if (sender == fHeightStepper) - { - job->anamorphic.dar_height = (float)[fHeightStepper intValue]; - job->height = [fHeightStepper intValue]; - - /* Changes DISPLAY WIDTH to keep DAR*/ - [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",[fHeightStepper intValue] * dar]]; - job->anamorphic.dar_width = [fDisplayWidthField floatValue]; - /* Changes PIXEL WIDTH to new DISPLAY WIDTH */ - [fParWidthField setIntValue: [fDisplayWidthField intValue]]; - job->anamorphic.par_width = [fParWidthField intValue]; - /* Changes PIXEL HEIGHT to STORAGE WIDTH */ - [fParHeightField setIntValue: [fWidthField intValue]]; - job->anamorphic.par_height = [fParHeightField intValue]; - } - /* Changing STORAGE_WIDTH: */ - if (sender == fWidthStepper) - { - job->width = [fWidthStepper intValue]; - - job->anamorphic.dar_width = [fDisplayWidthField floatValue]; - job->anamorphic.dar_height = [fHeightStepper floatValue]; - - /* Changes PIXEL WIDTH to DISPLAY WIDTH */ - [fParWidthField setIntValue: [fDisplayWidthField intValue]]; - job->anamorphic.par_width = [fParWidthField intValue]; - /* Changes PIXEL HEIGHT to new STORAGE WIDTH */ - [fParHeightField setIntValue: [fWidthStepper intValue]]; - job->anamorphic.par_height = [fParHeightField intValue]; - } - } - else if ([fRatioCheck state] == NSOffState) - { - /* Changing STORAGE_WIDTH: */ - if (sender == fWidthStepper) - { - job->width = [fWidthStepper intValue]; - /* changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT */ - [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",(float)[fWidthStepper intValue] * [fParWidthField intValue] / [fParHeightField intValue]]]; - job->anamorphic.dar_width = [fDisplayWidthField floatValue]; - } - /* Changing PIXEL dimensions */ - if (sender == fParWidthField || sender == fParHeightField) - { - job->anamorphic.par_width = [fParWidthField intValue]; - job->anamorphic.par_height = [fParHeightField intValue]; - /* changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT */ - [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",(float)[fWidthStepper intValue] * [fParWidthField intValue] / [fParHeightField intValue]]]; - job->anamorphic.dar_width = [fDisplayWidthField floatValue]; - } - /* Changing DISPLAY WIDTH: */ - if (sender == fDisplayWidthField) - { - job->anamorphic.dar_width = [fDisplayWidthField floatValue]; - job->anamorphic.dar_height = (float)[fHeightStepper intValue]; - /* changes PIXEL WIDTH to DISPLAY WIDTH and PIXEL HEIGHT to STORAGE WIDTH */ - [fParWidthField setIntValue: [fDisplayWidthField intValue]]; - job->anamorphic.par_width = [fParWidthField intValue]; - - [fParHeightField setIntValue: [fWidthField intValue]]; - job->anamorphic.par_height = [fParHeightField intValue]; - hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height); - } - /* Changing HEIGHT: */ - if (sender == fHeightStepper) - { - /* just....changes the height.*/ - job->anamorphic.dar_height = [fHeightStepper intValue]; - job->height = [fHeightStepper intValue]; - } - - } - } - - /* if the sender is the Anamorphic checkbox, record the state - of KeepAspect Ratio so it can be reset if Anamorphic is unchecked again */ - if (sender == fAnamorphicPopUp) - { - keepAspectRatioPreviousState = [fRatioCheck state]; - } - if ([fAnamorphicPopUp indexOfSelectedItem] != 3) - { - [fRatioCheck setState:NSOffState]; - } + if (sender == fParWidthField || sender == fParHeightField) + { + job->anamorphic.par_width = [fParWidthField intValue]; + job->anamorphic.par_height = [fParHeightField intValue]; + } + if (sender == fDisplayWidthField) + { + dar_updated = 1; + job->anamorphic.dar_width = [fDisplayWidthField intValue]; + job->anamorphic.dar_height = [fHeightStepper intValue]; } - else - { - job->width = [fWidthStepper intValue]; - job->height = [fHeightStepper intValue]; - job->anamorphic.mode = 0; - [fWidthStepper setEnabled: YES]; - [fWidthField setEnabled: YES]; - [fHeightStepper setEnabled: YES]; - [fHeightField setEnabled: YES]; - [fRatioCheck setEnabled: YES]; - /* if the sender is the Anamorphic checkbox, we return the - keep AR checkbox to its previous state */ - if (sender == fAnamorphicPopUp) - { - [fRatioCheck setState:keepAspectRatioPreviousState]; - } - } - if ([fAnamorphicPopUp indexOfSelectedItem] != 3) + if (sender == fCropMatrix) { - job->keep_ratio = ( [fRatioCheck state] == NSOnState ); - if( job->keep_ratio ) + if (self.autoCrop != ( [fCropMatrix selectedRow] == 0 )) { - if( sender == fWidthStepper || sender == fRatioCheck || - sender == fCropTopStepper || sender == fCropBottomStepper|| - sender == fCropMatrix || sender == nil ) - { - hb_fix_aspect( job, HB_KEEP_WIDTH ); - if( job->height > fTitle->height ) - { - job->height = fTitle->height; - hb_fix_aspect( job, HB_KEEP_HEIGHT ); - } - } - else + self.autoCrop = !self.autoCrop; + if (self.autoCrop) { - hb_fix_aspect( job, HB_KEEP_HEIGHT ); - if( job->width > fTitle->width ) - { - job->width = fTitle->width; - hb_fix_aspect( job, HB_KEEP_WIDTH ); - } + /* If auto, lets set the crop steppers according to + * current fTitle->crop values */ + memcpy( job->crop, fTitle->crop, 4 * sizeof( int ) ); + [fCropTopStepper setIntValue: fTitle->crop[0]]; + [fCropTopField setIntValue: fTitle->crop[0]]; + [fCropBottomStepper setIntValue: fTitle->crop[1]]; + [fCropBottomField setIntValue: fTitle->crop[1]]; + [fCropLeftStepper setIntValue: fTitle->crop[2]]; + [fCropLeftField setIntValue: fTitle->crop[2]]; + [fCropRightStepper setIntValue: fTitle->crop[3]]; + [fCropRightField setIntValue: fTitle->crop[3]]; } - + [fCropTopStepper setEnabled: !self.autoCrop]; + [fCropBottomStepper setEnabled: !self.autoCrop]; + [fCropLeftStepper setEnabled: !self.autoCrop]; + [fCropRightStepper setEnabled: !self.autoCrop]; } } - - // hb_get_preview can't handle sizes that are larger than the original title - if ([fAnamorphicPopUp indexOfSelectedItem] != 3) + if (sender == fCropTopStepper) { - // dimensions - if( job->width > fTitle->width ) - { - job->width = fTitle->width; - } - - if( job->height > fTitle->height ) - { - job->height = fTitle->height; - } + job->crop[0] = [fCropTopStepper intValue]; + [fCropTopField setIntValue: job->crop[0]]; + [fHeightStepper setMaxValue: fTitle->height - job->crop[0] - job->crop[1]]; + } + if (sender == fCropBottomStepper) + { + job->crop[1] = [fCropBottomStepper intValue]; + [fCropBottomField setIntValue: job->crop[1]]; + [fHeightStepper setMaxValue: fTitle->height - job->crop[0] - job->crop[1]]; + } + if (sender == fCropLeftStepper) + { + job->crop[2] = [fCropLeftStepper intValue]; + [fCropLeftField setIntValue: job->crop[2]]; + [fWidthStepper setMaxValue: fTitle->width - job->crop[2] - job->crop[3]]; + } + if (sender == fCropRightStepper) + { + job->crop[3] = [fCropRightStepper intValue]; + [fCropRightField setIntValue: job->crop[3]]; + [fWidthStepper setMaxValue: fTitle->width - job->crop[2] - job->crop[3]]; } - [fWidthStepper setIntValue: job->width]; - [fWidthField setIntValue: job->width]; - if( [fAnamorphicPopUp indexOfSelectedItem] != 2) // if we are not loose or custom + keep |= !!job->anamorphic.keep_display_aspect * HB_KEEP_DISPLAY_ASPECT; + + hb_geometry_t srcGeo, resultGeo; + hb_ui_geometry_t uiGeo; + + srcGeo.width = fTitle->width; + srcGeo.height = fTitle->height; + srcGeo.par.num = fTitle->pixel_aspect_width; + srcGeo.par.den = fTitle->pixel_aspect_height; + + uiGeo.mode = job->anamorphic.mode; + uiGeo.keep = keep; + uiGeo.itu_par = 0; + uiGeo.modulus = job->modulus; + memcpy(uiGeo.crop, job->crop, sizeof(int[4])); + uiGeo.width = job->width; + uiGeo.height = job->height; + uiGeo.maxWidth = fTitle->width - job->crop[2] - job->crop[3]; + uiGeo.maxHeight = fTitle->height - job->crop[0] - job->crop[1]; + uiGeo.par.num = job->anamorphic.par_width; + uiGeo.par.den = job->anamorphic.par_height; + uiGeo.dar.num = 0; + uiGeo.dar.den = 0; + if (job->anamorphic.mode == HB_ANAMORPHIC_CUSTOM && dar_updated) { - [fHeightStepper setIntValue: job->height]; - [fHeightField setIntValue: job->height]; + uiGeo.dar.num = job->anamorphic.dar_width; + uiGeo.dar.den = job->anamorphic.dar_height; } + hb_set_anamorphic_size2(&srcGeo, &uiGeo, &resultGeo); - [fCropTopStepper setIntValue: job->crop[0]]; - [fCropTopField setIntValue: job->crop[0]]; - [fCropBottomStepper setIntValue: job->crop[1]]; - [fCropBottomField setIntValue: job->crop[1]]; - [fCropLeftStepper setIntValue: job->crop[2]]; - [fCropLeftField setIntValue: job->crop[2]]; - [fCropRightStepper setIntValue: job->crop[3]]; - [fCropRightField setIntValue: job->crop[3]]; + job->width = resultGeo.width; + job->height = resultGeo.height; + job->anamorphic.par_width = resultGeo.par.num; + job->anamorphic.par_height = resultGeo.par.den; + + int display_width; + display_width = resultGeo.width * resultGeo.par.num / resultGeo.par.den; + + [fWidthStepper setIntValue: resultGeo.width]; + [fWidthField setIntValue: resultGeo.width]; + [fHeightStepper setIntValue: resultGeo.height]; + [fHeightField setIntValue: resultGeo.height]; + [fParWidthField setIntValue: resultGeo.par.num]; + [fParHeightField setIntValue: resultGeo.par.den]; + [fDisplayWidthField setIntValue: display_width]; /* * Sanity-check here for previews < 16 pixels to avoid crashing |