From 0a94b62b0695fc0635b198fb9ac8e05ef41df414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wei=C3=9F?= Date: Tue, 4 May 2021 15:38:00 +0200 Subject: [PATCH] Implement and use MonospacedDigitTextFieldCell. This way the digits of numbers in playlist columns consisting of mostly digits will be aligned vertically. --- Base.lproj/MainMenu.xib | 8 ++++---- Cog.xcodeproj/project.pbxproj | 6 ++++++ Utils/MonospacedDigitTextFieldCell.h | 18 ++++++++++++++++++ Utils/MonospacedDigitTextFieldCell.m | 23 +++++++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 Utils/MonospacedDigitTextFieldCell.h create mode 100644 Utils/MonospacedDigitTextFieldCell.m diff --git a/Base.lproj/MainMenu.xib b/Base.lproj/MainMenu.xib index ccd1cca5f..8754df5ce 100644 --- a/Base.lproj/MainMenu.xib +++ b/Base.lproj/MainMenu.xib @@ -46,7 +46,7 @@ - + @@ -147,7 +147,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -200,7 +200,7 @@ - + diff --git a/Cog.xcodeproj/project.pbxproj b/Cog.xcodeproj/project.pbxproj index 9e80da785..b5c8d8109 100644 --- a/Cog.xcodeproj/project.pbxproj +++ b/Cog.xcodeproj/project.pbxproj @@ -90,6 +90,7 @@ 17F561400C3BD4F30019975C /* CogAudio.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17F561330C3BD4DC0019975C /* CogAudio.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 17F6C8070F603701000D9DA9 /* PlaybackEventController.m in Sources */ = {isa = PBXBuildFile; fileRef = 17F6C8060F603701000D9DA9 /* PlaybackEventController.m */; }; 17FAEBAC0F662985007C8707 /* ToolTipTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 17FAEBAB0F662985007C8707 /* ToolTipTextField.m */; }; + 3D42D1302641739C002A170C /* MonospacedDigitTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D42D12F2641739C002A170C /* MonospacedDigitTextFieldCell.m */; }; 5604D45B0D60349B004F5C5D /* SpotlightWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5604D4590D60349B004F5C5D /* SpotlightWindowController.m */; }; 5604D4F60D60726E004F5C5D /* SpotlightPlaylistEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = 5604D4F50D60726E004F5C5D /* SpotlightPlaylistEntry.m */; }; 56462EAF0D6341F6000AB68C /* SpotlightTransformers.m in Sources */ = {isa = PBXBuildFile; fileRef = 56462EAE0D6341F6000AB68C /* SpotlightTransformers.m */; }; @@ -809,6 +810,8 @@ 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 32CA4F630368D1EE00C91783 /* Cog_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cog_Prefix.pch; sourceTree = ""; }; + 3D42D12E2641739C002A170C /* MonospacedDigitTextFieldCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MonospacedDigitTextFieldCell.h; sourceTree = ""; }; + 3D42D12F2641739C002A170C /* MonospacedDigitTextFieldCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MonospacedDigitTextFieldCell.m; sourceTree = ""; }; 3DDFC2462344EC6B000F1453 /* DEVELOPMENT_TEAM.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DEVELOPMENT_TEAM.xcconfig; sourceTree = ""; }; 3DDFC2472344EC6B000F1453 /* Shared.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Shared.xcconfig; sourceTree = ""; }; 5604D4590D60349B004F5C5D /* SpotlightWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SpotlightWindowController.m; path = Spotlight/SpotlightWindowController.m; sourceTree = ""; }; @@ -1078,6 +1081,8 @@ 17FAEBAB0F662985007C8707 /* ToolTipTextField.m */, 8355D6B4180612F300D05687 /* NSData+MD5.h */, 8355D6B5180612F300D05687 /* NSData+MD5.m */, + 3D42D12E2641739C002A170C /* MonospacedDigitTextFieldCell.h */, + 3D42D12F2641739C002A170C /* MonospacedDigitTextFieldCell.m */, ); path = Utils; sourceTree = ""; @@ -2256,6 +2261,7 @@ 17F6C8070F603701000D9DA9 /* PlaybackEventController.m in Sources */, 83BC5AB220E4C87100631CD4 /* DualWindow.m in Sources */, 1784560F0F631E24007E8021 /* FileTreeViewController.m in Sources */, + 3D42D1302641739C002A170C /* MonospacedDigitTextFieldCell.m in Sources */, 178456120F631E31007E8021 /* SideViewController.m in Sources */, 17D1B1010F63255200694C57 /* InfoWindowController.m in Sources */, 17D1B1680F632ABB00694C57 /* BlankZeroFormatter.m in Sources */, diff --git a/Utils/MonospacedDigitTextFieldCell.h b/Utils/MonospacedDigitTextFieldCell.h new file mode 100644 index 000000000..21b876b07 --- /dev/null +++ b/Utils/MonospacedDigitTextFieldCell.h @@ -0,0 +1,18 @@ +// +// MonospacedDigitTextFieldCell.h +// Cog +// +// Created by Jan on 04.05.21. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface MonospacedDigitTextFieldCell : NSTextFieldCell { + +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/Utils/MonospacedDigitTextFieldCell.m b/Utils/MonospacedDigitTextFieldCell.m new file mode 100644 index 000000000..1ddf84837 --- /dev/null +++ b/Utils/MonospacedDigitTextFieldCell.m @@ -0,0 +1,23 @@ +// +// MonospacedDigitTextFieldCell.m +// Cog +// +// Created by Jan on 04.05.21. +// + +#import "MonospacedDigitTextFieldCell.h" + +@implementation MonospacedDigitTextFieldCell + +- (void)setFont:(NSFont *)font +{ + CGFloat size = font.pointSize; + + NSNumber *weightNum = [font.fontDescriptor objectForKey:NSFontWeightTrait]; + NSFontWeight weight = weightNum ? weightNum.doubleValue : NSFontWeightRegular; + + super.font = [NSFont monospacedDigitSystemFontOfSize:size + weight:weight]; +} + +@end