From 2b694663e3a9ebb52e7723e53f6deaea1d94705d Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Tue, 11 Sep 2018 09:48:08 +0200 Subject: [PATCH] Fixed rendering bug on 10.10 and 10.11 for custom fields --- MacPass.xcodeproj/project.pbxproj | 6 ++++++ MacPass/Base.lproj/EntryInspectorView.xib | 2 +- MacPass/MPCustomFieldTableView.h | 13 ++++++++++++ MacPass/MPCustomFieldTableView.m | 24 +++++++++++++++++++++++ MacPass/MPCustomFieldTableViewDelegate.m | 18 +++++++++++++++++ MacPass/MPEntryInspectorViewController.m | 9 ++------- 6 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 MacPass/MPCustomFieldTableView.h create mode 100644 MacPass/MPCustomFieldTableView.m diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index d3654b1d..30a1fe08 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ 4C0B533F205C1561003D277E /* PickfieldView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C0B5341205C1561003D277E /* PickfieldView.xib */; }; 4C0C59F118B17F10009C7B76 /* DDHotKeyUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C59EF18B17F10009C7B76 /* DDHotKeyUtilities.m */; }; 4C0DBEF51BF508DE00F9B287 /* PluginSettings.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C0DBEF71BF508DE00F9B287 /* PluginSettings.xib */; }; + 4C0F04402147A6FA000B8568 /* MPCustomFieldTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0F043F2147A6FA000B8568 /* MPCustomFieldTableView.m */; }; 4C0F647B17B6BC9C00D9522A /* MPSavePanelAccessoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0F647A17B6BC9C00D9522A /* MPSavePanelAccessoryViewController.m */; }; 4C10207F1B750E2F00BFCD59 /* MPTestAutotype.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C10207E1B750E2F00BFCD59 /* MPTestAutotype.m */; }; 4C10412C178CDD44001B5239 /* NSDate+Humanized.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C10412B178CDD44001B5239 /* NSDate+Humanized.m */; }; @@ -350,6 +351,8 @@ 4C0C59EF18B17F10009C7B76 /* DDHotKeyUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDHotKeyUtilities.m; path = DDHotKey/DDHotKeyUtilities.m; sourceTree = ""; }; 4C0C59F018B17F10009C7B76 /* DDHotKeyUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = DDHotKeyUtilities.h; path = DDHotKey/DDHotKeyUtilities.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 4C0DBEF61BF508DE00F9B287 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/PluginSettings.xib; sourceTree = ""; }; + 4C0F043E2147A6FA000B8568 /* MPCustomFieldTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPCustomFieldTableView.h; sourceTree = ""; }; + 4C0F043F2147A6FA000B8568 /* MPCustomFieldTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPCustomFieldTableView.m; sourceTree = ""; }; 4C0F647917B6BC9C00D9522A /* MPSavePanelAccessoryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSavePanelAccessoryViewController.h; sourceTree = ""; }; 4C0F647A17B6BC9C00D9522A /* MPSavePanelAccessoryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSavePanelAccessoryViewController.m; sourceTree = ""; }; 4C10207E1B750E2F00BFCD59 /* MPTestAutotype.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTestAutotype.m; sourceTree = ""; }; @@ -1034,6 +1037,8 @@ 4CE082C21F6FCD2A0034FF56 /* MPCollectionView.m */, 4CF6C3001FBF39BF0055AD03 /* MPPluginTabelCellView.h */, 4CF6C3011FBF39BF0055AD03 /* MPPluginTabelCellView.m */, + 4C0F043E2147A6FA000B8568 /* MPCustomFieldTableView.h */, + 4C0F043F2147A6FA000B8568 /* MPCustomFieldTableView.m */, ); name = Views; sourceTree = ""; @@ -1934,6 +1939,7 @@ files = ( 4CD034AC1BFE113B003C002C /* MPPluginHost.m in Sources */, 4C77E37315B84A240093A587 /* main.m in Sources */, + 4C0F04402147A6FA000B8568 /* MPCustomFieldTableView.m in Sources */, 4CBA2ABA17074C07006D8139 /* MPSettingsHelper.m in Sources */, 4C77E37A15B84A240093A587 /* MPAppDelegate.m in Sources */, 4C37A84015B8B474005EF8EE /* MPOutlineDataSource.m in Sources */, diff --git a/MacPass/Base.lproj/EntryInspectorView.xib b/MacPass/Base.lproj/EntryInspectorView.xib index b9dc22ab..9510b916 100644 --- a/MacPass/Base.lproj/EntryInspectorView.xib +++ b/MacPass/Base.lproj/EntryInspectorView.xib @@ -798,7 +798,7 @@ - + diff --git a/MacPass/MPCustomFieldTableView.h b/MacPass/MPCustomFieldTableView.h new file mode 100644 index 00000000..05bb6f62 --- /dev/null +++ b/MacPass/MPCustomFieldTableView.h @@ -0,0 +1,13 @@ +// +// MPCustomFieldTableView.h +// MacPass +// +// Created by Michael Starke on 11.09.18. +// Copyright © 2018 HicknHack Software GmbH. All rights reserved. +// + +#import + +@interface MPCustomFieldTableView : NSTableView + +@end diff --git a/MacPass/MPCustomFieldTableView.m b/MacPass/MPCustomFieldTableView.m new file mode 100644 index 00000000..307392f3 --- /dev/null +++ b/MacPass/MPCustomFieldTableView.m @@ -0,0 +1,24 @@ +// +// MPCustomFieldTableView.m +// MacPass +// +// Created by Michael Starke on 11.09.18. +// Copyright © 2018 HicknHack Software GmbH. All rights reserved. +// + +#import "MPCustomFieldTableView.h" + +@implementation MPCustomFieldTableView + +- (NSSize)intrinsicContentSize { + if(@available(macOS 10.12, *)) { + return [super intrinsicContentSize]; + } + if(self.numberOfRows > 0) { + return NSMakeSize(-1, self.numberOfRows * self.rowHeight); + } + return NSMakeSize(-1, -1); + +} + +@end diff --git a/MacPass/MPCustomFieldTableViewDelegate.m b/MacPass/MPCustomFieldTableViewDelegate.m index 458c2927..9d998feb 100644 --- a/MacPass/MPCustomFieldTableViewDelegate.m +++ b/MacPass/MPCustomFieldTableViewDelegate.m @@ -35,6 +35,24 @@ NSInteger MPCustomFieldIndexFromTag(NSInteger tag) { @implementation MPCustomFieldTableViewDelegate +- (void)tableView:(NSTableView *)tableView didRemoveRowView:(NSTableRowView *)rowView forRow:(NSInteger)row { + if(@available(macOS 10.12, *)) { + // 10.12 and higher are working correctly + } + else { + [tableView invalidateIntrinsicContentSize]; + } +} + +- (void)tableView:(NSTableView *)tableView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row { + if(@available(macOS 10.12, *)) { + // 10.12 and higher are working correctly + } + else { + [tableView invalidateIntrinsicContentSize]; + } +} + /* - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row { static NSTextFieldCell *cell; diff --git a/MacPass/MPEntryInspectorViewController.m b/MacPass/MPEntryInspectorViewController.m index fbecc49d..6f49f69f 100644 --- a/MacPass/MPEntryInspectorViewController.m +++ b/MacPass/MPEntryInspectorViewController.m @@ -134,15 +134,10 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) { [self.attachmentTableView registerForDraggedTypes:@[NSFilenamesPboardType]]; /* extract custom field table view */ - self.customFieldsTableView.translatesAutoresizingMaskIntoConstraints = NO; NSView *customFieldTableView = self.customFieldsTableView; + self.customFieldsTableView.translatesAutoresizingMaskIntoConstraints = NO; [self.customFieldsTableView.enclosingScrollView removeFromSuperviewWithoutNeedingDisplay]; - if (@available(macOS 10.13, *)) { - //self.customFieldsTableView.usesAutomaticRowHeights = YES; - } else { - // Fallback on earlier versions - } - + [self.customFieldsTableView removeFromSuperviewWithoutNeedingDisplay]; [self.generalView addSubview:customFieldTableView];