summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2017-11-30 16:52:38 +0100
committerDamiano Galassi <[email protected]>2017-11-30 16:52:38 +0100
commitb93c4fb4f10e63ad5ba202de75056452f22af7da (patch)
tree0e43b20e4031af9a28493575bdd90a424a1ae4f9
parent72cc6397d64e89a41cc654d9173942bb49f148aa (diff)
MacGui: add a header to the presets popover.
-rw-r--r--macosx/English.lproj/Presets.xib23
-rw-r--r--macosx/HBController.m2
-rw-r--r--macosx/HBPresetsViewController.h7
-rw-r--r--macosx/HBPresetsViewController.m33
4 files changed, 55 insertions, 10 deletions
diff --git a/macosx/English.lproj/Presets.xib b/macosx/English.lproj/Presets.xib
index f88a50469..6dde03dae 100644
--- a/macosx/English.lproj/Presets.xib
+++ b/macosx/English.lproj/Presets.xib
@@ -9,6 +9,8 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="HBPresetsViewController">
<connections>
+ <outlet property="headerBottomConstraint" destination="jy6-AG-t3l" id="0Ar-a2-XjQ"/>
+ <outlet property="headerLabel" destination="jCz-Aw-giC" id="eh7-O4-fFD"/>
<outlet property="outlineView" destination="00W-tb-wgY" id="T3u-ix-uIb"/>
<outlet property="treeController" destination="ohT-Pp-wBT" id="YGP-sN-dS3"/>
<outlet property="view" destination="Hz6-mo-xeY" id="xR8-5v-xDQ"/>
@@ -21,16 +23,16 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="16" horizontalPageScroll="10" verticalLineScroll="16" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uad-bt-uKD">
- <rect key="frame" x="3" y="33" width="224" height="288"/>
+ <rect key="frame" x="3" y="33" width="224" height="266"/>
<string key="toolTip">Presets are groups of encode settings tailored for specific scenarios. Select the one closest matching your intent.
Overrides all encode settings. Settings may be further adjusted after selecting a preset.</string>
<clipView key="contentView" id="Rcx-jI-nnq">
- <rect key="frame" x="1" y="1" width="222" height="286"/>
+ <rect key="frame" x="1" y="1" width="222" height="264"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="14" rowSizeStyle="automatic" viewBased="YES" indentationPerLevel="16" outlineTableColumn="jhC-ge-H1w" id="00W-tb-wgY">
- <rect key="frame" x="0.0" y="0.0" width="222" height="286"/>
+ <rect key="frame" x="0.0" y="0.0" width="222" height="264"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -178,22 +180,33 @@ Overrides all encode settings. Settings may be further adjusted after selecting
<binding destination="ohT-Pp-wBT" name="enabled" keyPath="canRemove" id="WNd-yX-UEH"/>
</connections>
</button>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jCz-Aw-giC">
+ <rect key="frame" x="92" y="305" width="47" height="14"/>
+ <textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Presets" id="r4V-6L-SO8">
+ <font key="font" metaFont="smallSystemBold"/>
+ <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ </textField>
</subviews>
<constraints>
<constraint firstItem="kfi-wq-mgV" firstAttribute="bottom" secondItem="b3V-8w-euU" secondAttribute="bottom" id="1dB-xo-p39"/>
<constraint firstItem="b3V-8w-euU" firstAttribute="top" secondItem="Ybq-Zt-sta" secondAttribute="top" id="6P9-lr-Dic"/>
<constraint firstAttribute="trailing" secondItem="uad-bt-uKD" secondAttribute="trailing" constant="3" id="Awe-NX-Pxq"/>
- <constraint firstItem="uad-bt-uKD" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="4" id="F4f-bv-59S"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Ybq-Zt-sta" secondAttribute="trailing" constant="20" id="MTA-L0-QDh"/>
+ <constraint firstItem="jCz-Aw-giC" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="NYS-NA-dEh"/>
<constraint firstAttribute="bottom" secondItem="kfi-wq-mgV" secondAttribute="bottom" constant="4" id="Rsn-71-jKi"/>
<constraint firstItem="uad-bt-uKD" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="3" id="UV6-xv-JfW"/>
<constraint firstItem="kfi-wq-mgV" firstAttribute="top" secondItem="b3V-8w-euU" secondAttribute="top" id="Vji-my-7O6"/>
<constraint firstItem="kfi-wq-mgV" firstAttribute="top" secondItem="uad-bt-uKD" secondAttribute="bottom" constant="8" id="VuV-22-Ur9"/>
+ <constraint firstItem="jCz-Aw-giC" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="6" id="WCV-tV-CtJ"/>
<constraint firstItem="b3V-8w-euU" firstAttribute="leading" secondItem="kfi-wq-mgV" secondAttribute="trailing" constant="-1" id="bhQ-Pb-gsQ"/>
<constraint firstItem="kfi-wq-mgV" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="3" id="dhx-Bz-GhP"/>
+ <constraint firstItem="uad-bt-uKD" firstAttribute="top" secondItem="jCz-Aw-giC" secondAttribute="bottom" constant="6" id="jy6-AG-t3l"/>
<constraint firstItem="Ybq-Zt-sta" firstAttribute="leading" secondItem="b3V-8w-euU" secondAttribute="trailing" constant="8" id="k1Z-q1-OXB"/>
+ <constraint firstItem="uad-bt-uKD" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" priority="250" constant="6" id="qPU-x9-bnh"/>
</constraints>
- <point key="canvasLocation" x="32" y="293.5"/>
+ <point key="canvasLocation" x="21" y="276"/>
</customView>
<treeController objectClassName="HBPreset" childrenKeyPath="children" leafKeyPath="isLeaf" id="ohT-Pp-wBT">
<declaredKeys>
diff --git a/macosx/HBController.m b/macosx/HBController.m
index 4d7c44c17..8e535ae4b 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -253,6 +253,8 @@
}
else
{
+ fPresetsView.showHeader = YES;
+
// Set up the presets popover
self.presetsPopover = [[NSPopover alloc] init];
diff --git a/macosx/HBPresetsViewController.h b/macosx/HBPresetsViewController.h
index 36dc44dfb..11390e452 100644
--- a/macosx/HBPresetsViewController.h
+++ b/macosx/HBPresetsViewController.h
@@ -9,6 +9,8 @@
@class HBPresetsManager;
@class HBPreset;
+NS_ASSUME_NONNULL_BEGIN
+
@protocol HBPresetsViewControllerDelegate <NSObject>
- (void)selectionDidChange;
@@ -30,9 +32,12 @@
- (IBAction)insertCategory:(id)sender;
-@property (nonatomic, readonly, weak) HBPreset *selectedPreset;
+@property (nonatomic, readonly) HBPreset *selectedPreset;
@property (nonatomic, readonly) NSUInteger indexOfSelectedItem;
@property (nonatomic, readwrite, getter=isEnabled) BOOL enabled;
+@property (nonatomic, readwrite) BOOL showHeader;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/macosx/HBPresetsViewController.m b/macosx/HBPresetsViewController.m
index 9834d9b3d..7763a3a56 100644
--- a/macosx/HBPresetsViewController.m
+++ b/macosx/HBPresetsViewController.m
@@ -7,8 +7,7 @@
#import "HBPresetsViewController.h"
#import "HBAddCategoryController.h"
-@import HandBrakeKit.HBPresetsManager;
-@import HandBrakeKit.HBPreset;
+@import HandBrakeKit;
// drag and drop pasteboard type
#define kHandBrakePresetPBoardType @"handBrakePresetPBoardType"
@@ -47,6 +46,9 @@
@property (nonatomic, strong) HBPresetsManager *presets;
@property (nonatomic, unsafe_unretained) IBOutlet NSTreeController *treeController;
+@property (nonatomic, strong) IBOutlet NSTextField *headerLabel;
+@property (nonatomic, strong) IBOutlet NSLayoutConstraint *headerBottomConstraint;
+
/**
* Helper var for drag & drop
*/
@@ -63,8 +65,6 @@
@implementation HBPresetsViewController
-@synthesize enabled = _enabled;
-
- (instancetype)initWithPresetManager:(HBPresetsManager *)presetManager
{
self = [super initWithNibName:@"Presets" bundle:nil];
@@ -93,6 +93,9 @@
[self expandNodes:[self.treeController.arrangedObjects childNodes]];
[self.treeController setSelectionIndexPath:[self.presets indexPathOfPreset:self.presets.defaultPreset]];
+
+ // Update header state
+ self.showHeader = _showHeader;
}
- (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem
@@ -192,6 +195,28 @@
#pragma mark - UI Methods
+- (void)setShowHeader:(BOOL)showHeader
+{
+ _showHeader = showHeader;
+
+ self.headerLabel.hidden = !showHeader;
+ if (NSAppKitVersionNumber < NSAppKitVersionNumber10_10)
+ {
+ if (showHeader)
+ {
+ [self.view addConstraint:self.headerBottomConstraint];
+ }
+ else
+ {
+ [self.view removeConstraint:self.headerBottomConstraint];
+ }
+ }
+ else
+ {
+ self.headerBottomConstraint.active = showHeader;
+ }
+}
+
- (IBAction)clicked:(id)sender
{
if (self.delegate && [[self.treeController.selectedObjects firstObject] isLeaf])