summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2019-03-06 10:14:02 +0100
committerDamiano Galassi <[email protected]>2019-03-06 10:14:02 +0100
commit1ca62a0b52244e988f5505dd3cb9cf509cc3552a (patch)
treebf039cba47e6863373fd7ceab16b38ced9bea745 /macosx
parent8d78f7d001b06872b1c31620c6387da239ae51eb (diff)
MacGui: show the start/end seconds range as formatted time strings.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/Base.lproj/MainWindow.xib16
-rw-r--r--macosx/HBRange+UIAdditions.h3
-rw-r--r--macosx/HBRange+UIAdditions.m49
3 files changed, 58 insertions, 10 deletions
diff --git a/macosx/Base.lproj/MainWindow.xib b/macosx/Base.lproj/MainWindow.xib
index d2d7383e8..59b5a211d 100644
--- a/macosx/Base.lproj/MainWindow.xib
+++ b/macosx/Base.lproj/MainWindow.xib
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.59" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.68" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.59"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.68"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -228,9 +228,6 @@
<constraint firstAttribute="width" constant="54" id="siy-Fa-XFI"/>
</constraints>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" drawsBackground="YES" id="5492">
- <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" minimumIntegerDigits="0" maximumIntegerDigits="42" id="Fdv-uE-tUA">
- <real key="minimum" value="0.0"/>
- </numberFormatter>
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -242,10 +239,11 @@
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
- <binding destination="-2" name="value" keyPath="self.job.range.secondsStart" id="0Cj-wW-5Se">
+ <binding destination="-2" name="value" keyPath="self.job.range.secondsStart" id="ETl-ke-STQ">
<dictionary key="options">
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
<bool key="NSValidatesImmediately" value="YES"/>
+ <string key="NSValueTransformerName">HBTimeInSecondsTransformer</string>
</dictionary>
</binding>
</connections>
@@ -281,9 +279,6 @@
<textField hidden="YES" toolTip="Last second to encode." verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5493" userLabel="Time End Encoding Field">
<rect key="frame" x="687" y="537" width="54" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" drawsBackground="YES" id="5494">
- <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" minimumIntegerDigits="0" maximumIntegerDigits="42" id="tD5-HN-B7h">
- <real key="minimum" value="0.0"/>
- </numberFormatter>
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -295,10 +290,11 @@
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
- <binding destination="-2" name="value" keyPath="self.job.range.secondsStop" id="5SR-rs-7eh">
+ <binding destination="-2" name="value" keyPath="self.job.range.secondsStop" id="AL1-NB-med">
<dictionary key="options">
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
<bool key="NSValidatesImmediately" value="YES"/>
+ <string key="NSValueTransformerName">HBTimeInSecondsTransformer</string>
</dictionary>
</binding>
</connections>
diff --git a/macosx/HBRange+UIAdditions.h b/macosx/HBRange+UIAdditions.h
index 47b7cde4f..21d323ebb 100644
--- a/macosx/HBRange+UIAdditions.h
+++ b/macosx/HBRange+UIAdditions.h
@@ -22,3 +22,6 @@
@interface HBTimeTransformer : NSValueTransformer
@end
+
+@interface HBTimeInSecondsTransformer: NSValueTransformer
+@end
diff --git a/macosx/HBRange+UIAdditions.m b/macosx/HBRange+UIAdditions.m
index f574225a3..559d5e26e 100644
--- a/macosx/HBRange+UIAdditions.m
+++ b/macosx/HBRange+UIAdditions.m
@@ -86,3 +86,52 @@
}
@end
+
+@implementation HBTimeInSecondsTransformer
+
++ (Class)transformedValueClass
+{
+ return [NSString class];
+}
+
+- (id)transformedValue:(id)value
+{
+ uint64_t duration = [value integerValue];
+ uint64_t hours = duration / 3600;
+ uint64_t minutes = (duration % 3600) / 60;
+ uint64_t seconds = duration % 60;
+
+ NSString *result = [NSString stringWithFormat:@"%02llu:%02llu:%02llu", hours, minutes, seconds];
+ return result;
+}
+
++ (BOOL)allowsReverseTransformation
+{
+ return YES;
+}
+
+- (id)reverseTransformedValue:(id)value
+{
+ const char *time = [value UTF8String];
+ if (time)
+ {
+ unsigned hour, minute, second, timeval;
+
+ if (sscanf(time, "%2u:%u:%u", &hour, &minute, &second) < 3) {
+ if (sscanf(time, "%u:%u:%u", &hour, &minute, &second) < 3) {
+ return 0;
+ }
+ }
+
+ if (second > 60) {
+ second = 0;
+ }
+
+ timeval = hour * 60 * 60 + minute * 60 + second;
+
+ return @(timeval);
+ }
+ return @"00:00:00";
+}
+
+@end