From 57a7dd0de95235605ebabafd34a8d2a5e5725e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wei=C3=9F?= Date: Sun, 2 May 2021 17:01:51 +0200 Subject: [PATCH 01/30] Fix look of position time field to match the rest of the UI. --- Window/TimeField.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Window/TimeField.m b/Window/TimeField.m index e15dc3ff3..311a68816 100644 --- a/Window/TimeField.m +++ b/Window/TimeField.m @@ -22,10 +22,10 @@ NSString * formatTimer(long minutes, long seconds, unichar prefix) { - (void)awakeFromNib { showTimeRemaining = [[NSUserDefaults standardUserDefaults] boolForKey:kTimerModeKey]; - if (@available(macOS 10.15, *)) { + if (@available(macOS 10.11, *)) { fontAttributes = - @{NSFontAttributeName : [NSFont monospacedSystemFontOfSize:13 - weight:NSFontWeightMedium]}; + @{NSFontAttributeName : [NSFont monospacedDigitSystemFontOfSize:13 + weight:NSFontWeightRegular]}; [self update]; } } -- 2.45.2 From 8eeebd0b2031dfdb76b1f51ca136b49e63e1d69d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wei=C3=9F?= Date: Sun, 2 May 2021 17:02:26 +0200 Subject: [PATCH 02/30] Fix typo. --- Window/TimeField.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Window/TimeField.m b/Window/TimeField.m index 311a68816..ebdb38c94 100644 --- a/Window/TimeField.m +++ b/Window/TimeField.m @@ -11,7 +11,7 @@ static NSString *kTimerModeKey = @"timerShowTimeRemaining"; NSString * formatTimer(long minutes, long seconds, unichar prefix) { - return [NSString localizedStringWithFormat:@"%C%lu:%02lu", prefix, minutes, seconds];; + return [NSString localizedStringWithFormat:@"%C%lu:%02lu", prefix, minutes, seconds]; } @implementation TimeField { -- 2.45.2 From 97298d6a7794de305bb3d53f32a3bbe6a2ae76b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wei=C3=9F?= Date: Sun, 2 May 2021 17:35:38 +0200 Subject: [PATCH 03/30] Improve position time display. --- Window/PositionSlider.m | 6 +++--- Window/TimeField.h | 4 ++-- Window/TimeField.m | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Window/PositionSlider.m b/Window/PositionSlider.m index d857af3e7..790cd72d1 100644 --- a/Window/PositionSlider.m +++ b/Window/PositionSlider.m @@ -13,21 +13,21 @@ - (void)setDoubleValue:(double)value { - self.positionTextField.currentTime = (long)value; + self.positionTextField.currentTime = value; [super setDoubleValue:value]; } - (void)setMaxValue:(double)value { - self.positionTextField.duration = (long)value; + self.positionTextField.duration = value; [super setMaxValue:value]; } - (void)mouseDragged:(NSEvent *)theEvent { - self.positionTextField.currentTime = (long)[self doubleValue]; + self.positionTextField.currentTime = [self doubleValue]; [super mouseDragged:theEvent]; } diff --git a/Window/TimeField.h b/Window/TimeField.h index fd709e4b7..4e6f07b3a 100644 --- a/Window/TimeField.h +++ b/Window/TimeField.h @@ -11,7 +11,7 @@ @interface TimeField : NSTextField -@property (nonatomic) NSInteger currentTime; -@property (nonatomic) NSInteger duration; +@property (nonatomic) NSTimeInterval currentTime; +@property (nonatomic) NSTimeInterval duration; @end diff --git a/Window/TimeField.m b/Window/TimeField.m index ebdb38c94..e6d68bf8d 100644 --- a/Window/TimeField.m +++ b/Window/TimeField.m @@ -10,8 +10,8 @@ static NSString *kTimerModeKey = @"timerShowTimeRemaining"; -NSString * formatTimer(long minutes, long seconds, unichar prefix) { - return [NSString localizedStringWithFormat:@"%C%lu:%02lu", prefix, minutes, seconds]; +NSString * formatTimer(NSTimeInterval minutes, NSTimeInterval seconds, char *prefix) { + return [NSString localizedStringWithFormat:@"%s%02u:%02u", prefix, (unsigned)minutes, (unsigned)seconds]; } @implementation TimeField { @@ -35,13 +35,13 @@ NSString * formatTimer(long minutes, long seconds, unichar prefix) { NSString *text; if (showTimeRemaining == NO) { - long sec = self.currentTime; - text = formatTimer(sec / 60, sec % 60, 0x2007); // Digit-width space + NSTimeInterval sec = self.currentTime; + text = formatTimer(sec / 60, fmod(sec, 60), ""); // No prefix. } else { - long sec = MAX(0, self.duration - self.currentTime); - text = formatTimer(sec / 60, sec % 60, 0x2012); // Hyphen + NSTimeInterval sec = MAX(0.0, self.duration - self.currentTime); + text = formatTimer(sec / 60, fmod(sec, 60), "-"); // Hyphen-minus. } NSAttributedString *string = [[NSAttributedString alloc] initWithString:text attributes:fontAttributes]; @@ -55,7 +55,7 @@ NSString * formatTimer(long minutes, long seconds, unichar prefix) { [self update]; } -- (void)setCurrentTime:(NSInteger)currentTime +- (void)setCurrentTime:(NSTimeInterval)currentTime { _currentTime = currentTime; [self update]; -- 2.45.2 From df53cede9750c40e309ac65242f6b6320d409b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wei=C3=9F?= Date: Sun, 2 May 2021 18:18:44 +0200 Subject: [PATCH 04/30] Add days, hours support to position time display. --- Window/TimeField.m | 54 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/Window/TimeField.m b/Window/TimeField.m index e6d68bf8d..594401dd7 100644 --- a/Window/TimeField.m +++ b/Window/TimeField.m @@ -10,10 +10,54 @@ static NSString *kTimerModeKey = @"timerShowTimeRemaining"; -NSString * formatTimer(NSTimeInterval minutes, NSTimeInterval seconds, char *prefix) { - return [NSString localizedStringWithFormat:@"%s%02u:%02u", prefix, (unsigned)minutes, (unsigned)seconds]; +NSString * timeStringForTimeInterval(NSTimeInterval timeInterval, BOOL enforceMinusSign) { + const int64_t signed_total_seconds = (int64_t)timeInterval; + const bool need_minus_sign = enforceMinusSign || signed_total_seconds < 0; + const int64_t total_seconds = (need_minus_sign ? -1 : 1) * signed_total_seconds; + const int64_t seconds = total_seconds % 60; + const int64_t total_minutes = (total_seconds - seconds) / 60; + const int64_t minutes = total_minutes % 60; + const int64_t total_hours = (total_minutes - minutes) / 60; + const int64_t hours = total_hours % 24; + const int64_t days = (total_hours - hours) / 24; + + NSString *timeString = nil; + + if (days > 0) { + timeString = + [NSString localizedStringWithFormat:@"%s" "%02" PRIi64 ":" "%02" PRIi64 ":" "%02" PRIi64 ":" "%02" PRIi64, + need_minus_sign ? "-" : "", + days, + hours, + minutes, + seconds]; + } + else if (hours > 0) { + timeString = + [NSString localizedStringWithFormat:@"%s" "%02" PRIi64 ":" "%02" PRIi64 ":" "%02" PRIi64, + need_minus_sign ? "-" : "", + hours, + minutes, + seconds]; + } + else if (minutes > 0) { + timeString = + [NSString localizedStringWithFormat:@"%s" "%02" PRIi64 ":" "%02" PRIi64, + need_minus_sign ? "-" : "", + minutes, + seconds]; + } + else { + timeString = + [NSString localizedStringWithFormat:@"%s" "00" ":" "%02" PRIi64, + need_minus_sign ? "-" : "", + seconds]; + } + + return timeString; } + @implementation TimeField { BOOL showTimeRemaining; NSDictionary *fontAttributes; @@ -36,12 +80,12 @@ NSString * formatTimer(NSTimeInterval minutes, NSTimeInterval seconds, char *pre if (showTimeRemaining == NO) { NSTimeInterval sec = self.currentTime; - text = formatTimer(sec / 60, fmod(sec, 60), ""); // No prefix. + text = timeStringForTimeInterval(sec, NO); } else { - NSTimeInterval sec = MAX(0.0, self.duration - self.currentTime); - text = formatTimer(sec / 60, fmod(sec, 60), "-"); // Hyphen-minus. + NSTimeInterval sec = self.currentTime - self.duration; + text = timeStringForTimeInterval(sec, YES); } NSAttributedString *string = [[NSAttributedString alloc] initWithString:text attributes:fontAttributes]; -- 2.45.2 From d6cfd24ba07994daaa93e78901ae4e8937463a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wei=C3=9F?= Date: Tue, 4 May 2021 14:01:45 +0200 Subject: [PATCH 05/30] Fix "Current Time" toolbar item geometry/layout. --- Base.lproj/MainMenu.xib | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Base.lproj/MainMenu.xib b/Base.lproj/MainMenu.xib index 854465c55..9c2144a53 100644 --- a/Base.lproj/MainMenu.xib +++ b/Base.lproj/MainMenu.xib @@ -412,10 +412,10 @@ - + - - + + -- 2.45.2 From 99680cca7fe0249091fc20c5583cfd02cdbf0ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wei=C3=9F?= Date: Tue, 4 May 2021 14:03:31 +0200 Subject: [PATCH 06/30] =?UTF-8?q?Don=E2=80=99t=20enforce=20leading=20doubl?= =?UTF-8?q?e-digits=20in=20position=20time=20display.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Window/TimeField.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Window/TimeField.m b/Window/TimeField.m index 594401dd7..2c3e28184 100644 --- a/Window/TimeField.m +++ b/Window/TimeField.m @@ -25,7 +25,7 @@ NSString * timeStringForTimeInterval(NSTimeInterval timeInterval, BOOL enforceMi if (days > 0) { timeString = - [NSString localizedStringWithFormat:@"%s" "%02" PRIi64 ":" "%02" PRIi64 ":" "%02" PRIi64 ":" "%02" PRIi64, + [NSString localizedStringWithFormat:@"%s" "%" PRIi64 ":" "%02" PRIi64 ":" "%02" PRIi64 ":" "%02" PRIi64, need_minus_sign ? "-" : "", days, hours, @@ -34,7 +34,7 @@ NSString * timeStringForTimeInterval(NSTimeInterval timeInterval, BOOL enforceMi } else if (hours > 0) { timeString = - [NSString localizedStringWithFormat:@"%s" "%02" PRIi64 ":" "%02" PRIi64 ":" "%02" PRIi64, + [NSString localizedStringWithFormat:@"%s" "%" PRIi64 ":" "%02" PRIi64 ":" "%02" PRIi64, need_minus_sign ? "-" : "", hours, minutes, @@ -42,14 +42,14 @@ NSString * timeStringForTimeInterval(NSTimeInterval timeInterval, BOOL enforceMi } else if (minutes > 0) { timeString = - [NSString localizedStringWithFormat:@"%s" "%02" PRIi64 ":" "%02" PRIi64, + [NSString localizedStringWithFormat:@"%s" "%" PRIi64 ":" "%02" PRIi64, need_minus_sign ? "-" : "", minutes, seconds]; } else { timeString = - [NSString localizedStringWithFormat:@"%s" "00" ":" "%02" PRIi64, + [NSString localizedStringWithFormat:@"%s" "0" ":" "%02" PRIi64, need_minus_sign ? "-" : "", seconds]; } -- 2.45.2 From 978619a893f89a18c12aebcf7540652a7b7c27eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wei=C3=9F?= Date: Tue, 4 May 2021 14:19:27 +0200 Subject: [PATCH 07/30] MainMenu.xib touched by Xcode. --- Base.lproj/MainMenu.xib | 303 ++++++++++++++++++++-------------------- 1 file changed, 150 insertions(+), 153 deletions(-) diff --git a/Base.lproj/MainMenu.xib b/Base.lproj/MainMenu.xib index 9c2144a53..ccd1cca5f 100644 --- a/Base.lproj/MainMenu.xib +++ b/Base.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - + @@ -18,7 +18,7 @@ - + @@ -291,7 +291,7 @@ - + @@ -567,7 +567,7 @@ - +