Improve position time display.
This commit is contained in:
parent
8eeebd0b20
commit
97298d6a77
3 changed files with 12 additions and 12 deletions
|
@ -13,21 +13,21 @@
|
||||||
|
|
||||||
- (void)setDoubleValue:(double)value
|
- (void)setDoubleValue:(double)value
|
||||||
{
|
{
|
||||||
self.positionTextField.currentTime = (long)value;
|
self.positionTextField.currentTime = value;
|
||||||
|
|
||||||
[super setDoubleValue:value];
|
[super setDoubleValue:value];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMaxValue:(double)value
|
- (void)setMaxValue:(double)value
|
||||||
{
|
{
|
||||||
self.positionTextField.duration = (long)value;
|
self.positionTextField.duration = value;
|
||||||
|
|
||||||
[super setMaxValue:value];
|
[super setMaxValue:value];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDragged:(NSEvent *)theEvent
|
- (void)mouseDragged:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
self.positionTextField.currentTime = (long)[self doubleValue];
|
self.positionTextField.currentTime = [self doubleValue];
|
||||||
|
|
||||||
[super mouseDragged:theEvent];
|
[super mouseDragged:theEvent];
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
@interface TimeField : NSTextField
|
@interface TimeField : NSTextField
|
||||||
|
|
||||||
@property (nonatomic) NSInteger currentTime;
|
@property (nonatomic) NSTimeInterval currentTime;
|
||||||
@property (nonatomic) NSInteger duration;
|
@property (nonatomic) NSTimeInterval duration;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
|
|
||||||
static NSString *kTimerModeKey = @"timerShowTimeRemaining";
|
static NSString *kTimerModeKey = @"timerShowTimeRemaining";
|
||||||
|
|
||||||
NSString * formatTimer(long minutes, long seconds, unichar prefix) {
|
NSString * formatTimer(NSTimeInterval minutes, NSTimeInterval seconds, char *prefix) {
|
||||||
return [NSString localizedStringWithFormat:@"%C%lu:%02lu", prefix, minutes, seconds];
|
return [NSString localizedStringWithFormat:@"%s%02u:%02u", prefix, (unsigned)minutes, (unsigned)seconds];
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation TimeField {
|
@implementation TimeField {
|
||||||
|
@ -35,13 +35,13 @@ NSString * formatTimer(long minutes, long seconds, unichar prefix) {
|
||||||
NSString *text;
|
NSString *text;
|
||||||
if (showTimeRemaining == NO)
|
if (showTimeRemaining == NO)
|
||||||
{
|
{
|
||||||
long sec = self.currentTime;
|
NSTimeInterval sec = self.currentTime;
|
||||||
text = formatTimer(sec / 60, sec % 60, 0x2007); // Digit-width space
|
text = formatTimer(sec / 60, fmod(sec, 60), ""); // No prefix.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
long sec = MAX(0, self.duration - self.currentTime);
|
NSTimeInterval sec = MAX(0.0, self.duration - self.currentTime);
|
||||||
text = formatTimer(sec / 60, sec % 60, 0x2012); // Hyphen
|
text = formatTimer(sec / 60, fmod(sec, 60), "-"); // Hyphen-minus.
|
||||||
}
|
}
|
||||||
NSAttributedString *string = [[NSAttributedString alloc] initWithString:text
|
NSAttributedString *string = [[NSAttributedString alloc] initWithString:text
|
||||||
attributes:fontAttributes];
|
attributes:fontAttributes];
|
||||||
|
@ -55,7 +55,7 @@ NSString * formatTimer(long minutes, long seconds, unichar prefix) {
|
||||||
[self update];
|
[self update];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setCurrentTime:(NSInteger)currentTime
|
- (void)setCurrentTime:(NSTimeInterval)currentTime
|
||||||
{
|
{
|
||||||
_currentTime = currentTime;
|
_currentTime = currentTime;
|
||||||
[self update];
|
[self update];
|
||||||
|
|
Loading…
Reference in a new issue