Rewrite some class in swift.
This commit is contained in:
21 files changed
+500
-508
No files matched your search
@@ -1,15 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13528" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13770" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13528"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13770"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="SBChapterViewController">
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="ChapterSearchController" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="chapterTableView" destination="22" id="49"/>
|
||||
<outlet property="removeChapter" destination="31" id="47"/>
|
||||
<outlet property="removeChapter" destination="31" id="faJ-CI-g36"/>
|
||||
<outlet property="tableView" destination="22" id="7Za-v5-yKx"/>
|
||||
<outlet property="view" destination="1" id="2"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
@@ -35,7 +35,7 @@
|
||||
<rect key="frame" x="1" y="0.0" width="446" height="194"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="14" headerView="23" id="22" customClass="ExpandedTableView" customModule="Subler" customModuleProvider="target">
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="14" headerView="23" viewBased="YES" id="22" customClass="ExpandedTableView" customModule="Subler" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="446" height="177"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
@@ -302,6 +302,29 @@
|
||||
</allowedInputSourceLocales>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView id="lUr-1t-Gov">
|
||||
<rect key="frame" x="1" y="1" width="96" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" misplaced="YES" id="sbg-eG-N9u">
|
||||
<rect key="frame" x="0.0" y="3" width="96" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" alignment="right" title="Table View Cell" id="fIl-II-Tfv">
|
||||
<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>
|
||||
<action selector="setChapterTimeStamp:" target="-2" id="SNb-Yy-l6Q"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="sbg-eG-N9u" id="rpX-jo-DcW"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
<tableColumn identifier="title" width="344" minWidth="40" maxWidth="2000" id="25">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Title">
|
||||
@@ -315,6 +338,29 @@
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView id="SuA-T8-hMx">
|
||||
<rect key="frame" x="100" y="1" width="344" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" misplaced="YES" id="KkS-kR-z72">
|
||||
<rect key="frame" x="0.0" y="3" width="344" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" title="Table View Cell" id="Ktq-AC-XnR">
|
||||
<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>
|
||||
<action selector="setChapterTitle:" target="-2" id="6Jm-gc-jcn"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="KkS-kR-z72" id="Psh-7t-gco"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
</tableColumns>
|
||||
<accessibility description="Chapters"/>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13528" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13770" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13528"/>
|
||||
<plugIn identifier="com.apple.imagekit.ibplugin" version="13528"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13770"/>
|
||||
<plugIn identifier="com.apple.imagekit.ibplugin" version="13770"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -255,7 +255,7 @@
|
||||
<comboBox verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="1000" translatesAutoresizingMaskIntoConstraints="NO" id="LbC-r6-Pau">
|
||||
<rect key="frame" x="3" y="0.0" width="319" height="19"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<comboBoxCell key="cell" controlSize="small" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" alignment="left" title="Do not localize" usesSingleLineMode="YES" buttonBordered="NO" numberOfVisibleItems="5" id="jkg-xz-Hbn" customClass="ComboBoxCell" customModule="Subler" customModuleProvider="target">
|
||||
<comboBoxCell key="cell" controlSize="small" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" alignment="left" title="Do not localize" usesSingleLineMode="YES" buttonBordered="NO" numberOfVisibleItems="5" id="jkg-xz-Hbn">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// ChapterViewController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 11/11/2017.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
@objc(SBChapterViewController) class ChapterViewController : NSViewController, NSTableViewDataSource, NSTableViewDelegate {
|
||||
|
||||
var track: MP42ChapterTrack {
|
||||
didSet {
|
||||
tableView.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet var tableView: ExpandedTableView!
|
||||
@IBOutlet var removeChapter: NSButton!
|
||||
|
||||
override var nibName: NSNib.Name? {
|
||||
return NSNib.Name(rawValue: "ChapterView")
|
||||
}
|
||||
|
||||
@objc init(track: MP42ChapterTrack) {
|
||||
self.track = track
|
||||
super.init(nibName: self.nibName, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
tableView.defaultEditingColumn = 1
|
||||
tableView.doubleAction = #selector(doubleClickAction(_:))
|
||||
}
|
||||
|
||||
// MARK: Table View
|
||||
|
||||
func numberOfRows(in tableView: NSTableView) -> Int {
|
||||
return Int(track.chapterCount())
|
||||
}
|
||||
|
||||
let trackTimeColumn = NSUserInterfaceItemIdentifier(rawValue: "time")
|
||||
let trackTitleColumn = NSUserInterfaceItemIdentifier(rawValue: "title")
|
||||
|
||||
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
||||
let chapter = track.chapter(at: UInt(row))
|
||||
switch tableColumn?.identifier {
|
||||
|
||||
case trackTimeColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: trackTimeColumn, owner:self) as? NSTableCellView
|
||||
cell?.textField?.attributedStringValue = StringFromTime(Int64(chapter.timestamp), 1000).boldMonospacedAttributedString()
|
||||
return cell
|
||||
|
||||
case trackTitleColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: trackTitleColumn, owner:self) as? NSTableCellView
|
||||
cell?.textField?.stringValue = chapter.title
|
||||
return cell
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func tableViewSelectionDidChange(_ notification: Notification) {
|
||||
removeChapter.isEnabled = tableView.selectedRow != -1 ? true : false
|
||||
}
|
||||
|
||||
@IBAction func setChapterTitle(_ sender: NSTextField) {
|
||||
let row = tableView.row(for: sender)
|
||||
if row > -1 {
|
||||
let chapter = track.chapter(at: UInt(row))
|
||||
track.setTitle(sender.stringValue, forChapter: chapter)
|
||||
|
||||
tableView.reloadData(forRowIndexes: IndexSet(integer: row), columnIndexes: IndexSet(integer: 1))
|
||||
updateChangeCount()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func setChapterTimeStamp(_ sender: NSTextField) {
|
||||
let row = tableView.row(for: sender)
|
||||
if row > -1 {
|
||||
let chapter = track.chapter(at: UInt(row))
|
||||
let timestamp = TimeFromString(sender.stringValue, 1000)
|
||||
track.setTimestamp(timestamp, forChapter: chapter)
|
||||
|
||||
tableView.reloadData()
|
||||
updateChangeCount()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func doubleClickAction(_ sender: NSTableView) {
|
||||
if sender.clickedRow > -1 && sender.clickedColumn > -1 {
|
||||
sender.editColumn(sender.clickedColumn, row: sender.clickedRow, with: nil, select: true)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
private func updateChangeCount() {
|
||||
view.window?.windowController?.document?.updateChangeCount(NSDocument.ChangeType.changeDone)
|
||||
}
|
||||
|
||||
@IBAction func removeChapter(_ sender: Any) {
|
||||
let currentIndex = tableView.selectedRow
|
||||
if currentIndex < track.chapterCount() {
|
||||
track.removeChapter(at: UInt(currentIndex))
|
||||
|
||||
let indexes = IndexSet(integer: currentIndex)
|
||||
tableView.removeRows(at: indexes, withAnimation: NSTableView.AnimationOptions.slideUp)
|
||||
tableView.selectRowIndexes(indexes, byExtendingSelection: false)
|
||||
|
||||
updateChangeCount()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func addChapter(_ sender: Any) {
|
||||
track.addChapter("Chapter", duration: 0)
|
||||
|
||||
tableView.reloadData()
|
||||
updateChangeCount()
|
||||
}
|
||||
|
||||
@IBAction func renameChapters(_ sender: Any) {
|
||||
for (index, chapter) in track.chapters.enumerated() {
|
||||
let title = "Chapter \(index + 1)"
|
||||
track.setTitle(title, forChapter: chapter)
|
||||
}
|
||||
tableView.reloadData()
|
||||
updateChangeCount()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// ChapterViewController.h
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 06/02/09.
|
||||
// Copyright 2009 Damiano Galassi. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <MP42Foundation/MP42File.h>
|
||||
#import <MP42Foundation/MP42ChapterTrack.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SBChapterViewController : NSViewController
|
||||
|
||||
@property (nonatomic, readwrite, nullable) MP42ChapterTrack *track;
|
||||
|
||||
- (IBAction)addChapter:(id)sender;
|
||||
- (IBAction)removeChapter:(id)sender;
|
||||
- (IBAction)renameChapters:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,152 +0,0 @@
|
||||
//
|
||||
// ChapterViewController.m
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 06/02/09.
|
||||
// Copyright 2009 Damiano Galassi. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SBChapterViewController.h"
|
||||
#import "Subler-Swift.h"
|
||||
|
||||
#import <MP42Foundation/MP42Utilities.h>
|
||||
|
||||
@implementation SBChapterViewController
|
||||
{
|
||||
NSDictionary *detailBoldAttr;
|
||||
|
||||
IBOutlet ExpandedTableView *chapterTableView;
|
||||
IBOutlet NSButton *removeChapter;
|
||||
}
|
||||
|
||||
- (void)loadView
|
||||
{
|
||||
[super loadView];
|
||||
|
||||
NSMutableParagraphStyle *ps = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||
ps.headIndent = -10.0;
|
||||
ps.alignment = NSTextAlignmentRight;
|
||||
|
||||
if ([[NSFont class] respondsToSelector:@selector(monospacedDigitSystemFontOfSize:weight:)]) {
|
||||
detailBoldAttr = @{ NSFontAttributeName: [NSFont monospacedDigitSystemFontOfSize:[NSFont smallSystemFontSize] weight:NSFontWeightBold],
|
||||
NSParagraphStyleAttributeName: ps,
|
||||
NSForegroundColorAttributeName: [NSColor grayColor] };
|
||||
}
|
||||
else {
|
||||
detailBoldAttr = @{ NSFontAttributeName: [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]],
|
||||
NSParagraphStyleAttributeName: ps,
|
||||
NSForegroundColorAttributeName: [NSColor grayColor] };
|
||||
}
|
||||
|
||||
chapterTableView.defaultEditingColumn = 1;
|
||||
}
|
||||
|
||||
- (NSAttributedString *)boldString:(NSString *)string
|
||||
{
|
||||
return [[NSAttributedString alloc] initWithString:string attributes:detailBoldAttr];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)t
|
||||
{
|
||||
return [self.track chapterCount];
|
||||
}
|
||||
|
||||
- (id) tableView:(NSTableView *)tableView
|
||||
objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
row:(NSInteger)rowIndex
|
||||
{
|
||||
MP42TextSample *chapter = [self.track chapterAtIndex:rowIndex];
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"time"]) {
|
||||
return [self boldString:StringFromTime(chapter.timestamp, 1000)];
|
||||
}
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"title"]) {
|
||||
return chapter.title;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)tableView:(NSTableView *)tableView
|
||||
setObjectValue:(id)anObject
|
||||
forTableColumn:(NSTableColumn *)tableColumn
|
||||
row:(NSInteger)rowIndex
|
||||
{
|
||||
MP42TextSample *chapter = [self.track chapterAtIndex:rowIndex];
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"title"]) {
|
||||
if (![chapter.title isEqualToString:anObject]) {
|
||||
[self.track setTitle:anObject forChapter:chapter];
|
||||
|
||||
[self.view.window.windowController.document updateChangeCount:NSChangeDone];
|
||||
}
|
||||
}
|
||||
else if ([tableColumn.identifier isEqualToString:@"time"]) {
|
||||
MP42Duration timestamp = TimeFromString(anObject, 1000);
|
||||
if (!(chapter.timestamp == timestamp)) {
|
||||
[self.track setTimestamp:timestamp forChapter:chapter];
|
||||
[chapterTableView reloadData];
|
||||
|
||||
[self.view.window.windowController.document updateChangeCount:NSChangeDone];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
|
||||
{
|
||||
if (chapterTableView.selectedRow != -1) {
|
||||
[removeChapter setEnabled:YES];
|
||||
}
|
||||
else {
|
||||
[removeChapter setEnabled:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
|
||||
{
|
||||
if ([tableColumn.identifier isEqualToString:@"time"]) {
|
||||
if ([tableView.selectedRowIndexes containsIndex:rowIndex]) {
|
||||
// Without this, the color won't change because
|
||||
// we are using a attributed string.
|
||||
NSMutableAttributedString *highlightedString = [[NSMutableAttributedString alloc] initWithAttributedString:[cell attributedStringValue]];
|
||||
[highlightedString addAttribute:NSForegroundColorAttributeName value:[NSColor blackColor] range:NSMakeRange(0, highlightedString.length)];
|
||||
[cell setAttributedStringValue:highlightedString];
|
||||
|
||||
[cell setTextColor:[NSColor blackColor]];
|
||||
}
|
||||
else {
|
||||
[cell setTextColor:[NSColor grayColor]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)removeChapter:(id)sender {
|
||||
NSInteger current_index = chapterTableView.selectedRow;
|
||||
if (current_index < [self.track chapterCount]) {
|
||||
[self.track removeChapterAtIndex:current_index];
|
||||
|
||||
[chapterTableView reloadData];
|
||||
[self.view.window.windowController.document updateChangeCount:NSChangeDone];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)addChapter:(id)sender {
|
||||
[self.track addChapter:@"Chapter" duration:0];
|
||||
|
||||
[chapterTableView reloadData];
|
||||
[self.view.window.windowController.document updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
- (IBAction)renameChapters:(id)sender {
|
||||
[self.track.chapters enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
NSString *title = [NSString stringWithFormat:@"Chapter %lu", (unsigned long) idx + 1];
|
||||
[self.track setTitle:title forChapter:(MP42TextSample *)obj];
|
||||
}];
|
||||
|
||||
[chapterTableView reloadData];
|
||||
[self.view.window.windowController.document updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -10,7 +10,6 @@ NSString *SublerMetadataPBoardType = @"SublerMetadataPBoardTypeV2";
|
||||
NSString *SublerCoverArtPBoardType = @"SublerCoverArtPBoardType";
|
||||
|
||||
#import "SBMovieViewController.h"
|
||||
#import "SBImageBrowserView.h"
|
||||
|
||||
#import <MP42Foundation/MP42Ratings.h>
|
||||
#import <MP42Foundation/MP42Image.h>
|
||||
@@ -982,7 +981,7 @@ static NSArray<NSArray *> *_mediaKinds;
|
||||
return itemIndexes.count;
|
||||
}
|
||||
|
||||
- (void)_pasteToImageBrowserView:(IKImageBrowserView *)ImageBrowserView
|
||||
- (void)pasteToImageBrowserView:(SBImageBrowserView *)imagebrowserview
|
||||
{
|
||||
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
|
||||
NSArray *items = nil;
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// SoundViewController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 11/11/2017.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class SoundViewController : NSViewController {
|
||||
|
||||
var track: MP42AudioTrack {
|
||||
didSet {
|
||||
}
|
||||
}
|
||||
|
||||
let fallbacks: [MP42AudioTrack]
|
||||
let follows: [MP42SubtitleTrack]
|
||||
let mediaTagsController: SBMediaTagsController
|
||||
|
||||
@IBOutlet var mediaTagsView: NSView!
|
||||
@IBOutlet var volume: NSSlider!
|
||||
@IBOutlet var alternateGroup: NSPopUpButton!
|
||||
@IBOutlet var fallback: NSPopUpButton!
|
||||
@IBOutlet var follow: NSPopUpButton!
|
||||
|
||||
override var nibName: NSNib.Name? {
|
||||
return NSNib.Name(rawValue: "SoundView")
|
||||
}
|
||||
|
||||
init(mp4: MP42File, track: MP42AudioTrack) {
|
||||
self.track = track
|
||||
self.fallbacks = Array()
|
||||
self.follows = Array()
|
||||
self.mediaTagsController = SBMediaTagsController(track: track)
|
||||
|
||||
super.init(nibName: self.nibName, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
|
||||
// Media Tags controls
|
||||
mediaTagsController.view.frame = mediaTagsView.bounds
|
||||
mediaTagsController.view.autoresizingMask = [.width, .height]
|
||||
|
||||
mediaTagsView.addSubview(mediaTagsController.view)
|
||||
|
||||
// Standard audio controls
|
||||
alternateGroup.selectItem(at: Int(track.alternateGroup))
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
private func updateChangeCount() {
|
||||
view.window?.windowController?.document?.updateChangeCount(NSDocument.ChangeType.changeDone)
|
||||
}
|
||||
|
||||
@IBAction func setTrackVolume(_ sender: NSSlider) {
|
||||
let value = sender.floatValue / 100
|
||||
if value != track.volume {
|
||||
track.volume = value
|
||||
updateChangeCount()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func seTracktFallback(_ sender: NSPopUpButton) {
|
||||
let index = sender.tag
|
||||
|
||||
if index > -1 {
|
||||
let newFallbackTrack = fallbacks[index]
|
||||
if newFallbackTrack != track.fallbackTrack {
|
||||
track.fallbackTrack = newFallbackTrack
|
||||
updateChangeCount()
|
||||
}
|
||||
}
|
||||
else {
|
||||
track.fallbackTrack = nil
|
||||
updateChangeCount()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func setTrackFollows(_ sender: NSPopUpButton) {
|
||||
let index = sender.tag
|
||||
|
||||
if index > -1 {
|
||||
let newFollowskTrack = follows[index]
|
||||
if newFollowskTrack != track.followsTrack {
|
||||
track.followsTrack = newFollowskTrack
|
||||
updateChangeCount()
|
||||
}
|
||||
}
|
||||
else {
|
||||
track.followsTrack = nil
|
||||
updateChangeCount()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func setTrackAlternateGroup(_ sender: NSPopUpButton) {
|
||||
if let group = sender.selectedItem?.tag {
|
||||
if track.alternateGroup != group {
|
||||
track.alternateGroup = UInt64(group)
|
||||
updateChangeCount()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user