diff options
author | Damiano Galassi <[email protected]> | 2015-12-05 10:21:23 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2015-12-05 10:21:23 +0100 |
commit | 5e4109859754c58b27534627dbfd014441f48e91 (patch) | |
tree | ad70beb85ecbf30d8db2f00e41de838a3529eb0e | |
parent | 0d0b4bccc71886f694e5f0a843488d7c5593b3e0 (diff) |
MacGui: use a view-based outline view in the presets drawer.
-rw-r--r-- | macosx/English.lproj/Presets.xib | 56 | ||||
-rw-r--r-- | macosx/HBPresetsViewController.m | 66 |
2 files changed, 66 insertions, 56 deletions
diff --git a/macosx/English.lproj/Presets.xib b/macosx/English.lproj/Presets.xib index 07d4b80d6..d3f43933e 100644 --- a/macosx/English.lproj/Presets.xib +++ b/macosx/English.lproj/Presets.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="9058" systemVersion="15B38b" 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="9058"/> + <development version="7000" identifier="xcode"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/> </dependencies> <objects> <customObject id="-2" userLabel="File's Owner" customClass="HBPresetsViewController"> @@ -26,8 +26,8 @@ <rect key="frame" x="1" y="1" width="222" height="288"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="14" indentationPerLevel="16" outlineTableColumn="jhC-ge-H1w" id="00W-tb-wgY"> - <rect key="frame" x="0.0" y="0.0" width="222" height="16"/> + <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="0.0"/> <autoresizingMask key="autoresizingMask"/> <animations/> <size key="intercellSpacing" width="3" height="2"/> @@ -46,20 +46,38 @@ <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> - <connections> - <binding destination="ohT-Pp-wBT" name="editable" keyPath="arrangedObjects.isBuiltIn" id="JA3-ww-RjO"> - <dictionary key="options"> - <string key="NSValueTransformerName">NSNegateBoolean</string> - </dictionary> - </binding> - <binding destination="ohT-Pp-wBT" name="fontBold" keyPath="arrangedObjects.isDefault" id="Bki-AQ-Pa7"/> - <binding destination="ohT-Pp-wBT" name="value" keyPath="arrangedObjects.name" id="hDR-Al-iwT"> - <dictionary key="options"> - <string key="NSNullPlaceholder">Unamed Preset</string> - <bool key="NSValidatesImmediately" value="YES"/> - </dictionary> - </binding> - </connections> + <prototypeCellViews> + <tableCellView id="czB-kB-CXf" customClass="HBPresetCellView"> + <rect key="frame" x="1" y="1" width="219" height="14"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="VdJ-Vk-fzJ"> + <rect key="frame" x="0.0" y="0.0" width="219" height="14"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> + <animations/> + <textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="oBC-Nh-TwB"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + <connections> + <binding destination="czB-kB-CXf" name="editable" keyPath="objectValue.isBuiltIn" id="ynB-cm-NHg"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="czB-kB-CXf" name="fontBold" keyPath="objectValue.isDefault" id="dvM-HC-sa7"/> + <binding destination="czB-kB-CXf" name="value" keyPath="objectValue.name" id="1Ss-se-o7m"/> + <binding destination="czB-kB-CXf" name="toolTip" keyPath="objectValue.presetDescription" id="DkC-o0-2Nf"/> + </connections> + </textField> + </subviews> + <animations/> + <connections> + <outlet property="textField" destination="VdJ-Vk-fzJ" id="mk8-r5-kBa"/> + </connections> + </tableCellView> + </prototypeCellViews> </tableColumn> </tableColumns> <connections> diff --git a/macosx/HBPresetsViewController.m b/macosx/HBPresetsViewController.m index 8933c7e27..532968692 100644 --- a/macosx/HBPresetsViewController.m +++ b/macosx/HBPresetsViewController.m @@ -11,6 +11,35 @@ // drag and drop pasteboard type #define kHandBrakePresetPBoardType @"handBrakePresetPBoardType" +@interface HBPresetCellView : NSTableCellView +@end + +@implementation HBPresetCellView + +- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle +{ + [super setBackgroundStyle:backgroundStyle]; + + // Customize the built-in preset text color + if ([self.objectValue isBuiltIn]) + { + if (backgroundStyle == NSBackgroundStyleDark) + { + self.textField.textColor = [NSColor selectedControlTextColor]; + } + else + { + self.textField.textColor = [NSColor blueColor]; + } + } + else + { + self.textField.textColor = [NSColor controlTextColor]; + } +} + +@end + @interface HBPresetsViewController () <NSOutlineViewDelegate> @property (nonatomic, strong) HBPresetsManager *presets; @@ -253,43 +282,6 @@ [self expandNodes:[self.treeController.arrangedObjects childNodes]]; } -#pragma mark - Added Functionality (optional) - -/* We use this to provide tooltips for the items in the presets outline view */ -- (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView - toolTipForCell:(NSCell *)cell - rect:(NSRectPointer)rect - tableColumn:(NSTableColumn *)tc - item:(id)item - mouseLocation:(NSPoint)mouseLocation -{ - return [[item representedObject] presetDescription]; -} - -/* Use to customize the font and display characteristics of the title cell */ -- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item -{ - NSColor *fontColor; - - if ([self.outlineView selectedRow] == [self.outlineView rowForItem:item]) - { - fontColor = [NSColor blackColor]; - } - else - { - if ([[item representedObject] isBuiltIn]) - { - fontColor = [NSColor blueColor]; - } - else // User created preset, use a black font - { - fontColor = [NSColor blackColor]; - } - } - - [cell setTextColor:fontColor]; -} - #pragma mark - Expanded node persistence methods - (void)expandNodes:(NSArray *)childNodes |