From b93c4fb4f10e63ad5ba202de75056452f22af7da Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Thu, 30 Nov 2017 16:52:38 +0100 Subject: MacGui: add a header to the presets popover. --- macosx/English.lproj/Presets.xib | 23 ++++++++++++++++++----- macosx/HBController.m | 2 ++ macosx/HBPresetsViewController.h | 7 ++++++- macosx/HBPresetsViewController.m | 33 +++++++++++++++++++++++++++++---- 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 @@ + + @@ -21,16 +23,16 @@ - + 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. - + - + @@ -178,22 +180,33 @@ Overrides all encode settings. Settings may be further adjusted after selecting + + + + + + + + - + + + + - + 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 - (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]) -- cgit v1.2.3