]> granicus.if.org Git - handbrake/commitdiff
MacGui: add a "Start" column in the chapters tableview.
authorDamiano Galassi <damiog@gmail.com>
Mon, 11 Dec 2017 13:58:15 +0000 (14:58 +0100)
committerDamiano Galassi <damiog@gmail.com>
Mon, 11 Dec 2017 13:58:15 +0000 (14:58 +0100)
macosx/English.lproj/ChaptersTitles.xib
macosx/HBChapter.h
macosx/HBChapter.m
macosx/HBChapterTitlesController.m
macosx/HBRange+UIAdditions.h
macosx/HBRange+UIAdditions.m
macosx/HBTitle.m

index c39c41889e8f93fb3a55ba7c1a744f6fef33fc95..3144e14ec79f3aaa3e212653497761c1968b9703 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13770" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
     <dependencies>
         <deployment identifier="macosx"/>
         <development version="8000" identifier="xcode"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13770"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -77,8 +77,8 @@
                                 <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
                                 <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
                                 <tableColumns>
-                                    <tableColumn identifier="index" editable="NO" width="76" minWidth="40" maxWidth="1000" id="0iF-eL-NOC">
-                                        <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Chapter">
+                                    <tableColumn identifier="index" editable="NO" width="45" minWidth="40" maxWidth="1000" id="0iF-eL-NOC">
+                                        <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Index">
                                             <font key="font" metaFont="smallSystem"/>
                                             <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                             <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/>
                                         <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
                                         <prototypeCellViews>
                                             <tableCellView id="xTN-ym-UFK">
-                                                <rect key="frame" x="1" y="1" width="76" height="17"/>
+                                                <rect key="frame" x="1" y="1" width="45" height="17"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <subviews>
                                                     <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9mL-8S-7Nl">
-                                                        <rect key="frame" x="1" y="2" width="74" height="14"/>
+                                                        <rect key="frame" x="1" y="2" width="43" height="14"/>
                                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
-                                                        <textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="left" title="Chapter" id="G9p-Cg-wyC">
+                                                        <textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="left" title="1" id="G9p-Cg-wyC">
                                                             <font key="font" metaFont="smallSystem"/>
                                                             <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                                                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                                             </binding>
                                         </connections>
                                     </tableColumn>
-                                    <tableColumn identifier="duration" editable="NO" width="84" minWidth="10" maxWidth="3.4028234663852886e+38" id="QVB-Cw-DJD" userLabel="Timestamp">
+                                    <tableColumn identifier="timestamp" editable="NO" width="72" minWidth="10" maxWidth="3.4028234663852886e+38" id="NlF-th-Cg9" userLabel="Timestamp">
+                                        <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Start">
+                                            <font key="font" metaFont="smallSystem"/>
+                                            <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+                                            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+                                        </tableHeaderCell>
+                                        <textFieldCell key="dataCell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="All-Bz-NLv">
+                                            <font key="font" metaFont="smallSystem"/>
+                                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                            <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                        </textFieldCell>
+                                        <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+                                        <prototypeCellViews>
+                                            <tableCellView id="udT-y4-rGM">
+                                                <rect key="frame" x="49" y="1" width="72" height="17"/>
+                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                                <subviews>
+                                                    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="euR-W4-lv2">
+                                                        <rect key="frame" x="1" y="2" width="70" height="14"/>
+                                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+                                                        <textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Timestamp" id="zaN-qY-tke">
+                                                            <font key="font" metaFont="smallSystem"/>
+                                                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                                                        </textFieldCell>
+                                                        <connections>
+                                                            <binding destination="udT-y4-rGM" name="value" keyPath="objectValue.timestamp" id="wta-eX-RPt">
+                                                                <dictionary key="options">
+                                                                    <string key="NSValueTransformerName">HBTimeTransformer</string>
+                                                                </dictionary>
+                                                            </binding>
+                                                        </connections>
+                                                    </textField>
+                                                </subviews>
+                                                <connections>
+                                                    <outlet property="textField" destination="euR-W4-lv2" id="aim-6V-EeA"/>
+                                                </connections>
+                                            </tableCellView>
+                                        </prototypeCellViews>
+                                        <connections>
+                                            <binding destination="Gv0-qM-nu4" name="value" keyPath="arrangedObjects.duration" id="few-rg-26q">
+                                                <dictionary key="options">
+                                                    <bool key="NSConditionallySetsEditable" value="YES"/>
+                                                </dictionary>
+                                            </binding>
+                                        </connections>
+                                    </tableColumn>
+                                    <tableColumn identifier="duration" editable="NO" width="69" minWidth="10" maxWidth="3.4028234663852886e+38" id="QVB-Cw-DJD">
                                         <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Duration">
                                             <font key="font" metaFont="smallSystem"/>
                                             <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                         <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
                                         <prototypeCellViews>
                                             <tableCellView id="AVw-G2-Zyi">
-                                                <rect key="frame" x="80" y="1" width="84" height="17"/>
+                                                <rect key="frame" x="124" y="1" width="69" height="17"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <subviews>
                                                     <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4HO-kO-Qtr">
-                                                        <rect key="frame" x="1" y="2" width="82" height="14"/>
+                                                        <rect key="frame" x="1" y="2" width="67" height="14"/>
                                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
                                                         <textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Duration" id="Vmq-zJ-NEA">
                                                             <font key="font" metaFont="smallSystem"/>
                                                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                                                         </textFieldCell>
                                                         <connections>
-                                                            <binding destination="AVw-G2-Zyi" name="value" keyPath="objectValue.duration" id="n18-Pn-gsL"/>
+                                                            <binding destination="AVw-G2-Zyi" name="value" keyPath="objectValue.duration" id="DF2-Dz-3dy">
+                                                                <dictionary key="options">
+                                                                    <string key="NSValueTransformerName">HBTimeTransformer</string>
+                                                                </dictionary>
+                                                            </binding>
                                                         </connections>
                                                     </textField>
                                                 </subviews>
                                             </binding>
                                         </connections>
                                     </tableColumn>
-                                    <tableColumn identifier="title" width="715" minWidth="77.217290000000006" maxWidth="1000" id="Z6H-lJ-ipr">
+                                    <tableColumn identifier="title" width="686" minWidth="77.217290000000006" maxWidth="1000" id="Z6H-lJ-ipr">
                                         <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Title">
                                             <font key="font" metaFont="smallSystem"/>
                                             <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                         <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
                                         <prototypeCellViews>
                                             <tableCellView id="yZu-QP-dyq">
-                                                <rect key="frame" x="167" y="1" width="715" height="17"/>
+                                                <rect key="frame" x="196" y="1" width="686" height="17"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <subviews>
                                                     <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rpj-MP-nnZ">
-                                                        <rect key="frame" x="0.0" y="1" width="715" height="15"/>
+                                                        <rect key="frame" x="0.0" y="1" width="686" height="15"/>
                                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
                                                         <textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" title="Title" id="UjY-nz-uSt">
                                                             <font key="font" metaFont="smallSystem"/>
                         </subviews>
                     </clipView>
                     <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="O2b-uL-5ea">
-                        <rect key="frame" x="-100" y="-100" width="488" height="15"/>
+                        <rect key="frame" x="1" y="241" width="884" height="16"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </scroller>
                     <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="yp0-pp-Yw7">
                 <constraint firstItem="7Xf-c0-jsr" firstAttribute="leading" secondItem="lqY-aE-MZi" secondAttribute="leading" id="xvS-rd-BVF"/>
                 <constraint firstItem="7Xf-c0-jsr" firstAttribute="leading" secondItem="qs9-Xl-pXA" secondAttribute="leading" constant="20" symbolic="YES" id="zIR-UV-LXe"/>
             </constraints>
-            <point key="canvasLocation" x="389" y="32"/>
+            <point key="canvasLocation" x="113" y="149"/>
         </view>
         <userDefaultsController representsSharedInstance="YES" id="coy-s6-QLx"/>
         <arrayController objectClassName="HBChapter" editable="NO" id="Gv0-qM-nu4">
index 070a0f53d4e9eeee6741c7f2959c0829f2bfaad7..b766d5979ee19c1cc7d1213661cb753903807ab4 100644 (file)
@@ -10,10 +10,11 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface HBChapter : NSObject <NSSecureCoding, NSCopying>
 
-- (instancetype)initWithTitle:(NSString *)title index:(NSUInteger)idx duration:(uint64_t)duration NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithTitle:(NSString *)title index:(NSUInteger)idx timestamp:(uint64_t)timestamp duration:(uint64_t)duration NS_DESIGNATED_INITIALIZER;
 
 @property (nonatomic, readwrite, copy) NSString *title;
-@property (nonatomic, readonly) NSString *duration;
+@property (nonatomic, readonly) uint64_t duration;
+@property (nonatomic, readonly) uint64_t timestamp;
 @property (nonatomic, readonly) NSUInteger index;
 
 @property (nonatomic, readwrite, weak, nullable) NSUndoManager *undo;
index d33ec942784edd1cddfa5ebef89bc153a79d54e4..807309e138abee198c1242d84ff3ec6cb83d4e4f 100644 (file)
 
 - (instancetype)init
 {
-    self = [self initWithTitle:@"No Value" index:0 duration:0];
+    self = [self initWithTitle:@"No Value" index:0 timestamp:0 duration:0];
     return self;
 }
 
-- (instancetype)initWithTitle:(NSString *)title index:(NSUInteger)idx duration:(uint64_t)duration
+- (instancetype)initWithTitle:(NSString *)title index:(NSUInteger)idx timestamp:(uint64_t)timestamp duration:(uint64_t)duration
 {
     NSParameterAssert(title);
 
     self = [super init];
     if (self)
     {
-        uint64_t hours    = duration / 90000 / 3600;
-        uint64_t minutes  = ((duration / 90000 ) % 3600) / 60;
-        uint64_t seconds  = (duration / 90000 ) % 60;
-
-        _duration = [NSString stringWithFormat:@"%02llu:%02llu:%02llu", hours, minutes, seconds];
+        _timestamp = timestamp;
+        _duration = duration;
         _title = [title copy];
         _index = idx;
 
@@ -54,7 +51,8 @@
     if (copy)
     {
         copy->_title = [_title copy];
-        copy->_duration = [_duration copy];
+        copy->_timestamp = _timestamp;
+        copy->_duration = _duration;
         copy->_index = _index;
     }
 
@@ -74,7 +72,8 @@
     [coder encodeInt:1 forKey:@"HBChapterVersion"];
 
     encodeObject(_title);
-    encodeObject(_duration);
+    encodeInteger(_timestamp);
+    encodeInteger(_duration);
     encodeInteger(_index);
 }
 
@@ -85,7 +84,8 @@
     if (version == 1 && (self = [self init]))
     {
         decodeObjectOrFail(_title, NSString);
-        decodeObjectOrFail(_duration, NSString);
+        decodeInteger(_timestamp);
+        decodeInteger(_duration);
         decodeInteger(_index);
 
         return self;
index 83e3786a6b6ffe22b929014cc26bdc5850a5566d..d98594248259a42e838a1d7194932836d796dc95 100644 (file)
 - (void)controlTextDidEndEditing:(NSNotification *)notification
 {
     NSTableView *chapterTable = self.table;
-    NSInteger column = 2;
+    NSInteger column = [self.table columnForView:[notification object]];
     NSInteger row = [self.table rowForView:[notification object]];
     NSInteger textMovement;
 
index 0750b34b76af0434475ffd004c4190cb09fbbaae..47b7cde4f8ec74deff19f74452f05c163936a44f 100644 (file)
@@ -17,3 +17,8 @@
 @property (nonatomic, readonly) BOOL framesSelected;
 
 @end
+
+#pragma mark - Value Trasformers
+
+@interface HBTimeTransformer : NSValueTransformer
+@end
index 18710a159f7e6f5f01fee741165cacf31b6c4cba..e004fd72425aa8a44b33fd028af46d48373995f0 100644 (file)
 }
 
 @end
+
+@implementation HBTimeTransformer
+
++ (Class)transformedValueClass
+{
+    return [NSString class];
+}
+
+- (id)transformedValue:(id)value
+{
+    uint64_t duration = [value integerValue];
+    uint64_t hours    = duration / 90000 / 3600;
+    uint64_t minutes  = ((duration / 90000 ) % 3600) / 60;
+    uint64_t seconds  = (duration / 90000 ) % 60;
+
+    return [NSString stringWithFormat:@"%02llu:%02llu:%02llu", hours, minutes, seconds];
+}
+
++ (BOOL)allowsReverseTransformation
+{
+    return NO;
+}
+
+- (id)reverseTransformedValue:(id)value
+{
+    return nil;
+}
+
+@end
index 3a6bc134b3e22a7ded8691d059389916614545f5..1e5e8654eb6fa50d2e9627d153c2b97e10911ca8 100644 (file)
@@ -231,7 +231,7 @@ extern NSString *keySubTrackType;
     if (!_chapters)
     {
         NSMutableArray<HBChapter *> *chapters = [NSMutableArray array];
-
+        uint64_t currentTime = 0;
         for (int i = 0; i < hb_list_count(self.hb_title->list_chapter); i++)
         {
             hb_chapter_t *chapter = hb_list_item(self.hb_title->list_chapter, i);
@@ -250,7 +250,9 @@ extern NSString *keySubTrackType;
 
                 [chapters addObject:[[HBChapter alloc] initWithTitle:title
                                                                index:i + 1
+                                                           timestamp:currentTime
                                                             duration:chapter->duration]];
+                currentTime += chapter->duration;
             }
         }