disk images window [WIP].

uses bound nsarray controller.
This commit is contained in:
Kelvin Sherlock 2020-09-13 22:48:55 -04:00
parent 97c27328d0
commit 376f808d29
12 changed files with 455 additions and 46 deletions

View File

@ -79,6 +79,14 @@
B63C1BA8250192E600511A71 /* zijini.plist in Resources */ = {isa = PBXBuildFile; fileRef = B63C1BA7250192E600511A71 /* zijini.plist */; };
B63C1BA9250192E600511A71 /* zijini.plist in Resources */ = {isa = PBXBuildFile; fileRef = B63C1BA7250192E600511A71 /* zijini.plist */; };
B64979C224EF6703008ABD20 /* MediaViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B64979C124EF6703008ABD20 /* MediaViewController.m */; };
B64AF1EE250EC35B00A09B9B /* DiskImages.xib in Resources */ = {isa = PBXBuildFile; fileRef = B64AF1EC250EC35B00A09B9B /* DiskImages.xib */; };
B64AF1EF250EC35B00A09B9B /* DiskImages.xib in Resources */ = {isa = PBXBuildFile; fileRef = B64AF1EC250EC35B00A09B9B /* DiskImages.xib */; };
B64AF1F2250ECB2E00A09B9B /* DiskImagesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F1250ECB2E00A09B9B /* DiskImagesWindowController.m */; };
B64AF1F3250ECB2E00A09B9B /* DiskImagesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F1250ECB2E00A09B9B /* DiskImagesWindowController.m */; };
B64AF1F6250ED5E400A09B9B /* TableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F5250ED5E400A09B9B /* TableCellView.m */; };
B64AF1F7250ED5E400A09B9B /* TableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F5250ED5E400A09B9B /* TableCellView.m */; };
B64AF1FA250EF6A500A09B9B /* Transformers.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F9250EF6A500A09B9B /* Transformers.m */; };
B64AF1FB250EF6A500A09B9B /* Transformers.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F9250EF6A500A09B9B /* Transformers.m */; };
B64E15A924EA1D5300E8AD3D /* MachineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B64E15A824EA1D5300E8AD3D /* MachineViewController.m */; };
B66236A924FD9A34006CABD7 /* PreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B66236A824FD9A34006CABD7 /* PreferencesWindowController.m */; };
B66236B524FDA527006CABD7 /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = B66236B224FDA522006CABD7 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@ -282,6 +290,13 @@
B63C1BA7250192E600511A71 /* zijini.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = zijini.plist; sourceTree = "<group>"; };
B64979C024EF6703008ABD20 /* MediaViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaViewController.h; sourceTree = "<group>"; };
B64979C124EF6703008ABD20 /* MediaViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MediaViewController.m; sourceTree = "<group>"; };
B64AF1ED250EC35B00A09B9B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/DiskImages.xib; sourceTree = "<group>"; };
B64AF1F0250ECB2E00A09B9B /* DiskImagesWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DiskImagesWindowController.h; sourceTree = "<group>"; };
B64AF1F1250ECB2E00A09B9B /* DiskImagesWindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DiskImagesWindowController.m; sourceTree = "<group>"; };
B64AF1F4250ED5E400A09B9B /* TableCellView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TableCellView.h; sourceTree = "<group>"; };
B64AF1F5250ED5E400A09B9B /* TableCellView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TableCellView.m; sourceTree = "<group>"; };
B64AF1F8250EF6A500A09B9B /* Transformers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Transformers.h; sourceTree = "<group>"; };
B64AF1F9250EF6A500A09B9B /* Transformers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Transformers.m; sourceTree = "<group>"; };
B64E15A724EA1D5300E8AD3D /* MachineViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MachineViewController.h; sourceTree = "<group>"; };
B64E15A824EA1D5300E8AD3D /* MachineViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MachineViewController.m; sourceTree = "<group>"; };
B65593AF24ECB61800722E0C /* SlotViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SlotViewController.h; sourceTree = "<group>"; };
@ -450,6 +465,8 @@
B6BA257D24E99BE9005FB8FF /* Ample */ = {
isa = PBXGroup;
children = (
B64AF1F4250ED5E400A09B9B /* TableCellView.h */,
B64AF1F5250ED5E400A09B9B /* TableCellView.m */,
B6E9A17E25088B1B005E7525 /* NewSlotViewController.h */,
B6E9A17F25088B1B005E7525 /* NewSlotViewController.m */,
B63C1B9125008A2700511A71 /* DownloadWindowController.h */,
@ -476,6 +493,10 @@
B66236A824FD9A34006CABD7 /* PreferencesWindowController.m */,
B6B9EA652506A5550080E70D /* EjectButton.h */,
B6B9EA642506A5550080E70D /* EjectButton.m */,
B64AF1F0250ECB2E00A09B9B /* DiskImagesWindowController.h */,
B64AF1F1250ECB2E00A09B9B /* DiskImagesWindowController.m */,
B64AF1F8250EF6A500A09B9B /* Transformers.h */,
B64AF1F9250EF6A500A09B9B /* Transformers.m */,
B6BA258124E99BEB005FB8FF /* Assets.xcassets */,
B64E15AF24EA365E00E8AD3D /* Resources */,
B6BA258624E99BEB005FB8FF /* Info.plist */,
@ -500,6 +521,7 @@
B61099E524F5F230005CB652 /* MediaView.xib */,
B6D6DE3724FAC8B500661A5F /* Preferences.xib */,
B61099E324F5F230005CB652 /* SlotView.xib */,
B64AF1EC250EC35B00A09B9B /* DiskImages.xib */,
);
name = Nibs;
sourceTree = "<group>";
@ -648,6 +670,7 @@
B6109A2B24F5F377005CB652 /* elppa.plist in Resources */,
B63C1B8E25004C6D00511A71 /* mame-data.tgz in Resources */,
B6DDECCE2505A86E0093587A /* eject-16x16@3x.png in Resources */,
B64AF1EE250EC35B00A09B9B /* DiskImages.xib in Resources */,
B6109A3B24F5F377005CB652 /* apple2gsr1.plist in Resources */,
B63C1B9625008A2700511A71 /* DownloadWindow.xib in Resources */,
B6D6DE3B24FACF4F00661A5F /* Defaults.plist in Resources */,
@ -691,6 +714,7 @@
B6E4B5C424FDE2670094A35C /* LogWindow.xib in Resources */,
B6E4B5C524FDE2670094A35C /* Assets.xcassets in Resources */,
B6E4B5C624FDE2670094A35C /* apple2e.plist in Resources */,
B64AF1EF250EC35B00A09B9B /* DiskImages.xib in Resources */,
B63C1BA2250192D800511A71 /* cecg.plist in Resources */,
B6E4B5C724FDE2670094A35C /* am100.plist in Resources */,
B6E4B5C824FDE2670094A35C /* laser2c.plist in Resources */,
@ -768,7 +792,10 @@
B6BA258024E99BE9005FB8FF /* AppDelegate.m in Sources */,
B6004DF024FB05D600D38596 /* LogWindowController.m in Sources */,
B66236A924FD9A34006CABD7 /* PreferencesWindowController.m in Sources */,
B64AF1F2250ECB2E00A09B9B /* DiskImagesWindowController.m in Sources */,
B64AF1F6250ED5E400A09B9B /* TableCellView.m in Sources */,
B63C1B9425008A2700511A71 /* DownloadWindowController.m in Sources */,
B64AF1FA250EF6A500A09B9B /* Transformers.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -777,12 +804,15 @@
buildActionMask = 2147483647;
files = (
B608E1802502FE0C00D53465 /* TransparentScroller.m in Sources */,
B64AF1FB250EF6A500A09B9B /* Transformers.m in Sources */,
B6E4B5B024FDE2670094A35C /* main.m in Sources */,
B63C1B8C24FF4BF700511A71 /* Ample.m in Sources */,
B64AF1F3250ECB2E00A09B9B /* DiskImagesWindowController.m in Sources */,
B6B9EA672506A5550080E70D /* EjectButton.m in Sources */,
B6E4B5B124FDE2670094A35C /* LaunchWindowController.m in Sources */,
B6E4B5B224FDE2670094A35C /* MachineViewController.m in Sources */,
B6E4B5B324FDE2670094A35C /* MediaViewController.m in Sources */,
B64AF1F7250ED5E400A09B9B /* TableCellView.m in Sources */,
B6E4B5B424FDE2670094A35C /* FlippedView.m in Sources */,
B6E4B5B524FDE2670094A35C /* AppDelegate.m in Sources */,
B6E4B5B624FDE2670094A35C /* LogWindowController.m in Sources */,
@ -810,6 +840,14 @@
name = MediaView.xib;
sourceTree = "<group>";
};
B64AF1EC250EC35B00A09B9B /* DiskImages.xib */ = {
isa = PBXVariantGroup;
children = (
B64AF1ED250EC35B00A09B9B /* Base */,
);
name = DiskImages.xib;
sourceTree = "<group>";
};
B66236BF24FDB7A6006CABD7 /* Credits.rtf */ = {
isa = PBXVariantGroup;
children = (

View File

@ -10,6 +10,8 @@
#import "LaunchWindowController.h"
#import "PreferencesWindowController.h"
#import "DownloadWindowController.h"
#import "DiskImagesWindowController.h"
#import "Transformers.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *installWindow;
@ -20,6 +22,7 @@
NSWindowController *_prefs;
NSWindowController *_launcher;
NSWindowController *_downloader;
NSWindowController *_diskImages;
}
@ -31,6 +34,8 @@
NSDictionary *dict;
RegisterTransformers();
path = [bundle pathForResource: @"Defaults" ofType: @"plist"];
dict = [NSDictionary dictionaryWithContentsOfFile: path];
@ -143,12 +148,17 @@
}
- (IBAction)downloadROMS:(id)sender {
- (IBAction)displayROMS:(id)sender {
if (!_downloader) {
_downloader = [DownloadWindowController new];
}
[_downloader showWindow: sender];
}
- (IBAction)displayRecentDiskImages:(id)sender {
if (!_diskImages) {
_diskImages = [DiskImagesWindowController new];
}
[_diskImages showWindow: sender];
}
@end

View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="DiskImagesWindowController">
<connections>
<outlet property="arrayController" destination="vmp-9h-Z5R" id="WYF-Xq-BnN"/>
<outlet property="tableView" destination="J5l-1d-030" id="3hU-ho-1ag"/>
<outlet property="window" destination="R7r-B9-Bw0" id="hDE-Qa-m4g"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Recent Disk Images" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" frameAutosaveName="" animationBehavior="default" titlebarAppearsTransparent="YES" id="R7r-B9-Bw0" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="272" y="172" width="300" height="400"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" focusRingType="none" id="Kkg-Tp-4m1">
<rect key="frame" x="0.0" y="0.0" width="300" height="400"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView focusRingType="none" fixedFrame="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" findBarPosition="belowContent" translatesAutoresizingMaskIntoConstraints="NO" id="ivr-XT-BPS">
<rect key="frame" x="-1" y="-1" width="302" height="402"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="1jn-uc-06s">
<rect key="frame" x="0.0" y="0.0" width="302" height="402"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView focusRingType="none" verticalHuggingPriority="750" ambiguous="YES" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" selectionHighlightStyle="sourceList" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="J5l-1d-030">
<rect key="frame" x="0.0" y="0.0" width="302" height="402"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="_sourceListBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="282" minWidth="40" maxWidth="1000" id="1rF-M3-pYV">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="erY-fh-OHK">
<font key="font" metaFont="system"/>
<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="AJH-gH-E8G">
<rect key="frame" x="1" y="1" width="282" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="esO-OR-AcY">
<rect key="frame" x="6" y="5" width="196" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" sendsActionOnEndEditing="YES" title="Image Name.2mg" id="xgc-u7-sFX">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="AJH-gH-E8G" name="toolTip" keyPath="objectValue.path" id="gXq-2p-MpM"/>
<binding destination="AJH-gH-E8G" name="value" keyPath="objectValue.path" id="S0h-hl-OPM">
<dictionary key="options">
<string key="NSValueTransformerName">FilePathTransformer</string>
</dictionary>
</binding>
</connections>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wzl-mV-Pmp">
<rect key="frame" x="206" y="3" width="75" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" sendsActionOnEndEditing="YES" alignment="right" title="32MB" id="QYB-us-igD">
<font key="font" metaFont="system" size="11"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="AJH-gH-E8G" name="value" keyPath="objectValue.size" id="omG-8X-flx">
<dictionary key="options">
<string key="NSValueTransformerName">FileSizeTransformer</string>
</dictionary>
</binding>
</connections>
</textField>
</subviews>
<connections>
<outlet property="textField" destination="esO-OR-AcY" id="9mX-Yt-vpg"/>
</connections>
</tableCellView>
</prototypeCellViews>
<connections>
<binding destination="vmp-9h-Z5R" name="value" keyPath="arrangedObjects.selection" id="32X-Ez-K7S"/>
</connections>
</tableColumn>
</tableColumns>
<connections>
<binding destination="vmp-9h-Z5R" name="content" keyPath="arrangedObjects" id="GHn-tz-ash"/>
<outlet property="dataSource" destination="-2" id="PRV-Rt-UuC"/>
<outlet property="delegate" destination="-2" id="WuV-c9-o5I"/>
</connections>
</tableView>
</subviews>
<nil key="backgroundColor"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="ynD-Kb-eb3">
<rect key="frame" x="-100" y="-100" width="223" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="Dbq-yF-MKx">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
</subviews>
</view>
<connections>
<outlet property="delegate" destination="-2" id="1Hn-2t-Vzj"/>
</connections>
<point key="canvasLocation" x="-188" y="143"/>
</window>
<arrayController id="vmp-9h-Z5R">
<connections>
<binding destination="-2" name="contentArray" keyPath="self.content" id="UTv-za-ry7"/>
</connections>
</arrayController>
</objects>
</document>

View File

@ -402,7 +402,13 @@
<menuItem title="Manage ROMs…" id="St3-qR-2Y8">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="downloadROMS:" target="Voe-Tx-rLC" id="jFm-nv-kRC"/>
<action selector="displayROMS:" target="Voe-Tx-rLC" id="jFm-nv-kRC"/>
</connections>
</menuItem>
<menuItem title="Recent Disk Images…" id="QY9-lF-kDy">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="displayRecentDiskImages:" target="Voe-Tx-rLC" id="9W1-nJ-8eJ"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>

View File

@ -0,0 +1,22 @@
//
// DiskImagesWindowController.h
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import <Cocoa/Cocoa.h>
NS_ASSUME_NONNULL_BEGIN
@interface DiskImagesWindowController : NSWindowController
@end
@interface DiskImagesWindowController (TableView) <NSTableViewDelegate, NSTableViewDataSource>
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,80 @@
//
// DiskImagesWindowController.m
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import "DiskImagesWindowController.h"
#import "TableCellView.h"
@interface DiskImagesWindowController ()
@property (weak) IBOutlet NSTableView *tableView;
@property (strong) IBOutlet NSArrayController *arrayController;
@property NSMutableArray *content;
@end
@implementation DiskImagesWindowController {
//NSArray *_data;
}
-(NSString *)windowNibName {
return @"DiskImages";
}
- (void)windowDidLoad {
//_data = [NSMutableArray new];
[self setContent:
[NSMutableArray arrayWithObject:
[NSMutableDictionary dictionaryWithObjectsAndKeys:
@"/path/to/a/file.2mg", @"path",
@(12345), @"size",
nil]
]];
[super windowDidLoad];
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}
@end
@implementation DiskImagesWindowController (TableView)
#if 0
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
return 5; //[_data count];
}
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
NSTableCellView *v = [tableView makeViewWithIdentifier: @"PathCell" owner: self];
return v;
}
#endif
- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard {
// if ([rowIndexes count] > 1) return NO; // ?
id objects = [_arrayController arrangedObjects];
[pboard declareTypes: @[NSPasteboardTypeURL] owner: nil];
// NSURLPboardType deprecated
[rowIndexes enumerateIndexesUsingBlock: ^(NSUInteger index, BOOL *stop) {
NSDictionary *d = [objects objectAtIndex: index];
NSString *path = [d objectForKey: @"path"];
NSURL *url = [NSURL fileURLWithPath: path];
[url writeToPasteboard: pboard];
}];
// NSFilenamesPboardType -- old way of handling it ...
return YES;
}
@end

View File

@ -26,10 +26,4 @@ NS_ASSUME_NONNULL_BEGIN
@interface TablePathView : NSTableCellView
@property (weak) IBOutlet NSPathControl *pathControl;
@property (weak) IBOutlet NSButton *ejectButton;
@property (weak) IBOutlet NSImageView *dragHandle;
@end
NS_ASSUME_NONNULL_END

View File

@ -7,42 +7,7 @@
//
#import "MediaViewController.h"
@implementation TablePathView {
NSTrackingRectTag _trackingRect;
}
#if 0
-(void)awakeFromNib {
// this is apparently necessary for setTintColor to work.
NSImage *img;
img = [_ejectButton image];
[img setTemplate: YES];
img = [_ejectButton alternateImage];
[img setTemplate: YES];
}
#endif
-(void)viewDidMoveToSuperview {
return;
if (_trackingRect) {
[self removeTrackingRect: _trackingRect];
}
NSRect rect = [_dragHandle frame];
_trackingRect = [self addTrackingRect: rect owner: self userData: NULL assumeInside:NO];
}
-(void)mouseEntered:(NSEvent *)event {
[_dragHandle setHidden: NO];
}
-(void)mouseExited:(NSEvent *)event {
[_dragHandle setHidden: YES];
}
@end
#import "TableCellView.h"
@protocol MediaNode
@ -526,7 +491,7 @@ static NSString *kDragType = @"private.ample.media";
NSInteger indexes[2] = { 0, 0 };
indexes[0] = [cat index];
indexes[1] = [item index];
NSData *data =[NSData dataWithBytes: indexes length: sizeof(indexes)];
NSData *data = [NSData dataWithBytes: indexes length: sizeof(indexes)];
[pasteboard setData: data forType: kDragType];
return YES;

22
Ample/TableCellView.h Normal file
View File

@ -0,0 +1,22 @@
//
// TableCellView.h
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import <Cocoa/Cocoa.h>
//NS_ASSUME_NONNULL_BEGIN
@interface TablePathView : NSTableCellView
@property (weak) IBOutlet NSPathControl *pathControl;
@property (weak) IBOutlet NSButton *ejectButton;
@property (weak) IBOutlet NSImageView *dragHandle;
@property BOOL movable;
@end
//NS_ASSUME_NONNULL_END

47
Ample/TableCellView.m Normal file
View File

@ -0,0 +1,47 @@
//
// TableCellView.m
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import "TableCellView.h"
@implementation TablePathView {
NSTrackingRectTag _trackingRect;
}
#if 0
-(void)awakeFromNib {
// this is apparently necessary for setTintColor to work.
NSImage *img;
img = [_ejectButton image];
[img setTemplate: YES];
img = [_ejectButton alternateImage];
[img setTemplate: YES];
}
#endif
-(void)viewDidMoveToSuperview {
return;
if (_trackingRect) {
[self removeTrackingRect: _trackingRect];
}
NSRect rect = [_dragHandle frame];
_trackingRect = [self addTrackingRect: rect owner: self userData: NULL assumeInside:NO];
}
-(void)mouseEntered:(NSEvent *)event {
[_dragHandle setHidden: NO];
}
-(void)mouseExited:(NSEvent *)event {
[_dragHandle setHidden: YES];
}
@end

24
Ample/Transformers.h Normal file
View File

@ -0,0 +1,24 @@
//
// Transformers.h
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import <Foundation/Foundation.h>
void RegisterTransformers(void);
NS_ASSUME_NONNULL_BEGIN
@interface FilePathTransformer : NSValueTransformer
@end
@interface FileSizeTransformer : NSValueTransformer
@end
NS_ASSUME_NONNULL_END

68
Ample/Transformers.m Normal file
View File

@ -0,0 +1,68 @@
//
// Transformers.m
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import "Transformers.h"
@implementation FilePathTransformer
+ (Class)transformedValueClass {
return [NSString class];
}
+ (BOOL)allowsReverseTransformation {
return NO;
}
- (id)transformedValue:(id)value {
if (!value) return value;
return [(NSString *)value lastPathComponent];
}
@end
@implementation FileSizeTransformer
+ (Class)transformedValueClass {
return [NSString class];
}
+ (BOOL)allowsReverseTransformation {
return NO;
}
- (id)transformedValue:(id)value {
if (!value) return value;
if (![value respondsToSelector: @selector(integerValue)]) {
[NSException raise: NSInternalInconsistencyException
format: @"Value (%@) does not respond to -integerValue.",
[value class]];
}
NSInteger size = [(NSNumber *)value integerValue];
if (size < 0) return nil;
if (size < 1024*1024) return [NSString stringWithFormat: @"%.1fKB", (float)size / 1024];
if (size < 1024*1024*1024) return [NSString stringWithFormat: @"%.1fMB", (float)size / (1024*1024)];
return [NSString stringWithFormat: @"%.1fGB", (float)size / (1024*1024*1024)];
}
@end
void RegisterTransformers(void) {
NSValueTransformer *t;
t = [FileSizeTransformer new];
[NSValueTransformer setValueTransformer: t forName: @"FileSizeTransformer"];
t = [FilePathTransformer new];
[NSValueTransformer setValueTransformer: t forName: @"FilePathTransformer"];
}