@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8187.4" systemVersion="15A262e" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="15C40a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment identifier="macosx"/>
<development version="6300" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8187.4"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="HBAddPresetController">
@@ -102,6 +102,7 @@
<string key="toolTip">Select the maximum width allowed by the preset (has no effect if the preset specifies Strict anamorphic). 0 means no limit is placed on the width.</string>
<animations/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" drawsBackground="YES" id="ExG-3m-WxY">
<numberFormatter key="formatter" formatterBehavior="default10_4" localizesFormat="NO" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="Rn4-AK-xTD"/>
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -124,6 +125,7 @@
<string key="toolTip">Select the maximum height allowed by the preset (has no effect if the preset specifies Strict anamorphic). 0 means no limit is placed on the height.</string>
<animations/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" drawsBackground="YES" id="tBe-1m-0r9">
<numberFormatter key="formatter" formatterBehavior="default10_4" localizesFormat="NO" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="Udu-cs-fdK"/>
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9052" systemVersion="15B30a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="15C48a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment identifier="macosx"/>
<development version="6300" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9052"/>
<development version="7000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="HBController">
@@ -698,6 +698,7 @@ IA
<toolbarItem reference="ZEH-cS-zXY"/>
<toolbarItem reference="DZZ-Fe-wjw"/>
<toolbarItem reference="HCx-ku-nF7"/>
<toolbarItem reference="ZEH-cS-zXY"/>
<toolbarItem reference="byg-kj-sEM"/>
<toolbarItem reference="wTQ-KF-5KW"/>
<toolbarItem reference="wjB-Tl-5qq"/>
@@ -1,10 +1,8 @@
//
// HBAddPresetController.h
// HandBrake
//
// Created by Damiano Galassi on 23/11/14.
//
//
/* HBAddPresetController.h
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr/>.
It may be used under the terms of the GNU General Public License. */

#import <Cocoa/Cocoa.h>

@@ -14,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface HBAddPresetController : NSWindowController

- (instancetype)initWithPreset:(HBPreset *)preset videoSize:(NSSize)size;
- (instancetype)initWithPreset:(HBPreset *)preset customWidth:(int)customWidth customHeight:(int)customHeight defaultToCustom:(BOOL)defaultToCustom;

@property (nonatomic, readonly) HBPreset *preset;

@@ -1,15 +1,19 @@
//
// HBAddPresetController.m
// HandBrake
//
// Created by Damiano Galassi on 23/11/14.
//
//
/* HBAddPresetController.m
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr/>.
It may be used under the terms of the GNU General Public License. */

#import "HBAddPresetController.h"
#import "HBPreset.h"
#import "HBMutablePreset.h"

typedef NS_ENUM(NSUInteger, HBAddPresetControllerMode) {
HBAddPresetControllerModeNone,
HBAddPresetControllerModeCustom,
HBAddPresetControllerModeSourceMaximum,
};

@interface HBAddPresetController ()

@property (unsafe_unretained) IBOutlet NSTextField *name;
@@ -21,20 +25,26 @@ @interface HBAddPresetController ()
@property (unsafe_unretained) IBOutlet NSBox *picWidthHeightBox;

@property (nonatomic, strong) HBPreset *preset;
@property NSSize size;
@property (nonatomic) int width;
@property (nonatomic) int height;

@property (nonatomic) BOOL defaultToCustom;


@end

@implementation HBAddPresetController

- (instancetype)initWithPreset:(HBPreset *)preset videoSize:(NSSize)size;
- (instancetype)initWithPreset:(HBPreset *)preset customWidth:(int)customWidth customHeight:(int)customHeight defaultToCustom:(BOOL)defaultToCustom
{
self = [super initWithWindowNibName:@"AddPreset"];
if (self)
{
NSParameterAssert(preset);
_preset = preset;
_size = size;
_width = customWidth;
_height = customHeight;
_defaultToCustom = defaultToCustom;
}
return self;
}
@@ -49,30 +59,39 @@ - (void)windowDidLoad {
*
* Use [NSMenuItem tag] to store preset values for each option.
*/
[self.picSettingsPopUp addItemWithTitle:NSLocalizedString(@"None", @"")];
[[self.picSettingsPopUp lastItem] setTag: 0];

// Default to Source Maximum
HBAddPresetControllerMode mode = HBAddPresetControllerModeSourceMaximum;

[self.picSettingsPopUp addItemWithTitle:NSLocalizedString(@"None", nil)];
[[self.picSettingsPopUp lastItem] setTag:HBAddPresetControllerModeNone];

if (![self.preset[@"PicturePAR"] isEqualToString:@"strict"])
{
// not Strict, Custom is applicable
[self.picSettingsPopUp addItemWithTitle:NSLocalizedString(@"Custom", @"")];
[[self.picSettingsPopUp lastItem] setTag: 1];
[self.picSettingsPopUp addItemWithTitle:NSLocalizedString(@"Custom", nil)];
[[self.picSettingsPopUp lastItem] setTag:HBAddPresetControllerModeCustom];

if (self.defaultToCustom)
{
mode = HBAddPresetControllerModeCustom;
}
}
[self.picSettingsPopUp addItemWithTitle:NSLocalizedString(@"Source Maximum (post source scan)", @"")];
[[self.picSettingsPopUp lastItem] setTag: 2];
[self.picSettingsPopUp addItemWithTitle:NSLocalizedString(@"Source Maximum (post source scan)", nil)];
[[self.picSettingsPopUp lastItem] setTag:HBAddPresetControllerModeSourceMaximum];


//Default to Source Maximum
[self.picSettingsPopUp selectItemWithTag:2];
[self.picSettingsPopUp selectItemWithTag:mode];

/* Initialize custom height and width settings to current values */
[self.picWidth setStringValue: [NSString stringWithFormat:@"%d", (int)self.size.width]];
[self.picHeight setStringValue: [NSString stringWithFormat:@"%d",(int)self.size.height]];
// Initialize custom height and width settings to current values
[self.picWidth setIntValue:self.width];
[self.picHeight setIntValue:self.height];
[self addPresetPicDropdownChanged:nil];
}

- (IBAction)addPresetPicDropdownChanged:(id)sender
{
if (self.picSettingsPopUp.selectedItem.tag == 1)
if (self.picSettingsPopUp.selectedItem.tag == HBAddPresetControllerModeCustom)
{
self.picWidthHeightBox.hidden = NO;
}
@@ -112,15 +131,15 @@ - (IBAction)add:(id)sender

self.preset = [newPreset copy];

[[self window] orderOut:nil];
[NSApp endSheet:[self window] returnCode:NSModalResponseContinue];
[self.window orderOut:nil];
[NSApp endSheet:self.window returnCode:NSModalResponseContinue];
}
}

- (IBAction)cancel:(id)sender
{
[[self window] orderOut:nil];
[NSApp endSheet:[self window] returnCode:NSModalResponseAbort];
[self.window orderOut:nil];
[NSApp endSheet:self.window returnCode:NSModalResponseAbort];
}

@end
@@ -1371,9 +1371,14 @@ - (void)applyPreset:(HBPreset *)preset

- (IBAction)showAddPresetPanel:(id)sender
{
// Show the add panel
BOOL defaultToCustom = ((self.job.picture.width + self.job.picture.cropRight + self.job.picture.cropLeft) < self.job.picture.sourceWidth) ||
((self.job.picture.height + self.job.picture.cropTop + self.job.picture.cropBottom) < self.job.picture.sourceHeight);

// Show the add panel
HBAddPresetController *addPresetController = [[HBAddPresetController alloc] initWithPreset:[self createPresetFromCurrentSettings]
videoSize:NSMakeSize(self.job.picture.width, self.job.picture.height)];
customWidth:self.job.picture.width
customHeight:self.job.picture.height
defaultToCustom:defaultToCustom];

[NSApp beginSheet:addPresetController.window modalForWindow:self.window modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:(void *)CFBridgingRetain(addPresetController)];
}
@@ -706,7 +706,6 @@
273F200014ADAE950021BE6D /* Products */,
27D6C72314B1013400B785E4 /* Products (external) */,
273F20CD14ADC8E60021BE6D /* Resources */,
273F219214ADDE440021BE6D /* Resources (unused) */,
273F203414ADBAC30021BE6D /* Frameworks */,
273F20CE14ADC9210021BE6D /* Frameworks (bundled) */,
277A3FCF14AE848400A835E4 /* xcconfig */,
@@ -897,21 +896,6 @@
path = English.lproj;
sourceTree = "<group>";
};
273F219214ADDE440021BE6D /* Resources (unused) */ = {
isa = PBXGroup;
children = (
273F219314ADDE9A0021BE6D /* icons */,
);
name = "Resources (unused)";
sourceTree = "<group>";
};
273F219314ADDE9A0021BE6D /* icons */ = {
isa = PBXGroup;
children = (
);
path = icons;
sourceTree = "<group>";
};
277A3FCF14AE848400A835E4 /* xcconfig */ = {
isa = PBXGroup;
children = (