summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/English.lproj/AddPreset.xib6
-rw-r--r--macosx/HBAddPresetController.h14
-rw-r--r--macosx/HBAddPresetController.m71
-rw-r--r--macosx/HBController.m9
4 files changed, 62 insertions, 38 deletions
diff --git a/macosx/English.lproj/AddPreset.xib b/macosx/English.lproj/AddPreset.xib
index 07ffb9f62..b08b559f0 100644
--- a/macosx/English.lproj/AddPreset.xib
+++ b/macosx/English.lproj/AddPreset.xib
@@ -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"/>
diff --git a/macosx/HBAddPresetController.h b/macosx/HBAddPresetController.h
index 7162767fd..fe73e20fe 100644
--- a/macosx/HBAddPresetController.h
+++ b/macosx/HBAddPresetController.h
@@ -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;
diff --git a/macosx/HBAddPresetController.m b/macosx/HBAddPresetController.m
index 10165ecb5..e086d55fc 100644
--- a/macosx/HBAddPresetController.m
+++ b/macosx/HBAddPresetController.m
@@ -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 @@
@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 @@
*
* 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 @@
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
diff --git a/macosx/HBController.m b/macosx/HBController.m
index a0591bb67..9fcc8d20f 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -1371,9 +1371,14 @@
- (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)];
}