Two gigaseconds #147

Merged
JanX2 merged 30 commits from two-gigaseconds into master 2021-05-06 22:50:26 -04:00
3 changed files with 12 additions and 12 deletions
Showing only changes of commit 97298d6a77 - Show all commits

View file

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

View file

@ -11,7 +11,7 @@
@interface TimeField : NSTextField
@property (nonatomic) NSInteger currentTime;
@property (nonatomic) NSInteger duration;
@property (nonatomic) NSTimeInterval currentTime;
@property (nonatomic) NSTimeInterval duration;
@end

View file

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