Fixed rendering bug on 10.10 and 10.11 for custom fields

This commit is contained in:
Michael Starke
2018-09-11 09:48:08 +02:00
parent 366db91df5
commit 2b694663e3
6 changed files with 64 additions and 8 deletions

View File

@@ -798,7 +798,7 @@
<rect key="frame" x="1" y="1" width="259" height="268"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="none" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="54" viewBased="YES" id="193">
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="none" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="54" viewBased="YES" id="193" customClass="MPCustomFieldTableView">
<rect key="frame" x="0.0" y="0.0" width="259" height="268"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>

View File

@@ -0,0 +1,13 @@
//
// MPCustomFieldTableView.h
// MacPass
//
// Created by Michael Starke on 11.09.18.
// Copyright © 2018 HicknHack Software GmbH. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface MPCustomFieldTableView : NSTableView
@end

View File

@@ -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

View File

@@ -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;

View File

@@ -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];