midiin, midiout, and picture support.

This commit is contained in:
Kelvin Sherlock 2021-07-10 23:33:20 -04:00
parent 0d4a08113b
commit 82a73ef79c
5 changed files with 94 additions and 16 deletions

View File

@ -73,8 +73,8 @@
</pathCell>
<connections>
<action selector="pathAction:" target="-2" id="4oX-bW-ANp"/>
<binding destination="yGq-lc-RCM" name="enabled" keyPath="objectValue.valid" id="f8P-gt-vmK"/>
<binding destination="yGq-lc-RCM" name="value" keyPath="objectValue.url" id="Ony-ph-VVo"/>
<binding destination="yGq-lc-RCM" name="enabled" keyPath="objectValue.valid" id="f8P-gt-vmK"/>
</connections>
</pathControl>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="6g1-NT-J1w">
@ -132,12 +132,12 @@
</textFieldCell>
<connections>
<action selector="textAction:" target="-2" id="lmX-t8-mEc"/>
<binding destination="2Nq-Xz-tkV" name="enabled" keyPath="objectValue.valid" id="ZTM-E3-Y9P"/>
<binding destination="2Nq-Xz-tkV" name="value" keyPath="objectValue.string" id="2dZ-JJ-asM">
<dictionary key="options">
<string key="NSNullPlaceholder">socket.address:port or /path/to/file</string>
</dictionary>
</binding>
<binding destination="2Nq-Xz-tkV" name="enabled" keyPath="objectValue.valid" id="ZTM-E3-Y9P"/>
</connections>
</textField>
</subviews>
@ -146,6 +146,51 @@
<outlet property="ejectButton" destination="zxn-1E-o34" id="eC6-Mf-tN6"/>
</connections>
</tableCellView>
<tableCellView identifier="OutputItemView" id="jQd-Ar-5uf" customClass="TablePathView">
<rect key="frame" x="1" y="71" width="296" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="Jg1-Wh-HDk">
<rect key="frame" x="0.0" y="1" width="20" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageAlignment="left" image="drag-handle-4x10" id="SjY-iM-xSZ"/>
</imageView>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vG4-PP-efF" customClass="EjectButton">
<rect key="frame" x="277" y="3" width="16" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="eject-16x16" imagePosition="only" alignment="center" alternateImage="eject-hover-16x16" imageScaling="proportionallyDown" inset="2" id="VX6-hb-mCU">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="ejectAction:" target="-2" id="LNr-rK-kpx"/>
<binding destination="jQd-Ar-5uf" name="enabled" keyPath="objectValue.occupied" id="p4S-6q-dCG"/>
</connections>
</button>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Tm9-Zq-fag">
<rect key="frame" x="20" y="0.0" width="244" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="/path/to/file" drawsBackground="YES" id="RUQ-s4-75A">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="textAction:" target="-2" id="N7h-6y-D8W"/>
<binding destination="jQd-Ar-5uf" name="enabled" keyPath="objectValue.valid" id="1wE-NY-Vb2"/>
<binding destination="jQd-Ar-5uf" name="value" keyPath="objectValue.string" id="kXU-qJ-HKa">
<dictionary key="options">
<string key="NSNullPlaceholder">/path/to/file</string>
</dictionary>
</binding>
</connections>
</textField>
</subviews>
<connections>
<outlet property="dragHandle" destination="Jg1-Wh-HDk" id="o14-ay-0Ou"/>
<outlet property="ejectButton" destination="vG4-PP-efF" id="X2I-2N-t5r"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>

View File

@ -18,6 +18,9 @@ typedef struct Media {
unsigned floppy_3_5;
unsigned pseudo_disk;
unsigned bitbanger;
unsigned midiin;
unsigned midiout;
unsigned picture;
} Media;

View File

@ -23,6 +23,9 @@ struct Media MediaFromDictionary(NSDictionary *dict) {
_(floppy_5_25);
_(pseudo_disk);
_(bitbanger);
_(midiin);
_(midiout);
_(picture);
return m;
#undef _
@ -40,6 +43,9 @@ void MediaAdd(Media *dest, const Media *src) {
_(floppy_5_25);
_(pseudo_disk);
_(bitbanger);
_(midiin);
_(midiout);
_(picture);
#undef _
}
@ -56,6 +62,10 @@ BOOL MediaEqual(const Media *lhs, const Media *rhs) {
_(floppy_5_25);
_(pseudo_disk);
_(bitbanger);
_(midiin);
_(midiout);
_(picture);
return YES;
#undef _
}

View File

@ -17,11 +17,18 @@ enum {
kIndexCassette,
kIndexDiskImage,
kIndexBitBanger,
kIndexMidiIn,
kIndexMidiOut,
kIndexPicture, // computer eyes -pic, .png only.
// kIndexPrintout // -prin, .prn extension only?
kIndexLast
};
#define CATEGORY_COUNT 7
#define CATEGORY_COUNT 10
#define SIZEOF(x) (sizeof(x) / sizeof(x[0]))
static_assert(kIndexLast == CATEGORY_COUNT, "Invalid Category Count");
@protocol MediaNode
-(BOOL)isGroupItem;
@ -278,6 +285,7 @@ enum {
-(NSString *)viewIdentifier {
if (_category == kIndexBitBanger) return @"BBItemView";
if (_category == kIndexBitBanger) return @"OutputItemView";
return @"ItemView";
}
@ -330,6 +338,10 @@ enum {
_data[kIndexDiskImage] = [MediaCategory categoryWithTitle: @"Hard Disk Images"]; // Mac Nubus psuedo image device
_data[kIndexBitBanger] = [MediaCategory categoryWithTitle: @"Serial Bit Banger"]; // null_modem
_data[kIndexMidiIn] = [MediaCategory categoryWithTitle: @"MIDI (In)"];
_data[kIndexMidiOut] = [MediaCategory categoryWithTitle: @"MIDI (Out)"];
_data[kIndexPicture] = [MediaCategory categoryWithTitle: @"Picture"];
for (unsigned i = 0; i < CATEGORY_COUNT; ++i)
[_data[i] setCategory: i];
@ -342,7 +354,7 @@ enum {
-(void)rebuildArgs {
static char* prefix[] = {
"flop", "flop", "hard", "cdrm", "cass", "disk", "bitb",
"flop", "flop", "hard", "cdrm", "cass", "disk", "bitb", "min", "mout", "pic"
};
static_assert(SIZEOF(prefix) == CATEGORY_COUNT, "Missing item");
NSMutableArray *args = [NSMutableArray new];
@ -394,6 +406,8 @@ enum {
-(void)setMedia: (Media)media {
// todo -- fancy diff algorithm to animate changes.
MediaCategory *cat;
BOOL delta = NO;
unsigned x;
@ -412,6 +426,9 @@ x = media.name; cat = _data[index]; delta |= [cat setItemCount: x]
_(floppy_5_25, kIndexFloppy525);
_(pseudo_disk, kIndexDiskImage);
_(bitbanger, kIndexBitBanger);
_(midiin, kIndexMidiIn);
_(midiout, kIndexMidiOut);
_(picture, kIndexPicture);
if (delta) {
@ -635,7 +652,7 @@ static NSString *kDragType = @"private.ample.media";
}
- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id<NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index {
if (index < 0) return NO;
@ -734,12 +751,12 @@ static NSString *kDragType = @"private.ample.media";
[nc postNotificationName: kNotificationDiskImageAdded object: url];
}
break;
/*
kIndexPicture,
kIndexMIn,
kIndexMout,
*/
case kIndexPicture:
case kIndexMidiIn:
// these don't currently use a path control.
case kIndexMidiOut:
case kIndexBitBanger:
default: break;
}
@ -790,8 +807,8 @@ static NSString *kDragType = @"private.ample.media";
case MediaType_HardDisk: ix = kIndexHardDrive; break;
case MediaType_CDROM: ix = kIndexCDROM; break;
case MediaType_Picture:
case MediaType_MIDI:
case MediaType_Picture: ix = kIndexPicture; break;
case MediaType_MIDI: ix = kIndexMidiIn; break;
case MediaTypeError:
case MediaTypeUnknown:
return NO;
@ -828,7 +845,7 @@ static NSString *kDragType = @"private.ample.media";
}
static NSString * BookmarkStrings[] = {
@"flop_525", @"flop_35", @"hard", @"cdrm", @"cass", @"disk", @"bitb",
@"flop_525", @"flop_35", @"hard", @"cdrm", @"cass", @"disk", @"bitb", @"midiin", @"midiout", @"pic"
};
static_assert(SIZEOF(BookmarkStrings) == CATEGORY_COUNT, "Missing item");
@ -864,7 +881,7 @@ static int BookmarkIndex(NSString *str) {
MediaItem *item = [cat objectAtIndex: i++];
if (![path length]) continue;
if (ix == kIndexBitBanger) {
if (ix == kIndexBitBanger || ix == kIndexMidiOut) {
[item setString: path];
} else {
NSURL *url = [NSURL fileURLWithPath: path];
@ -896,7 +913,7 @@ static int BookmarkIndex(NSString *str) {
MediaItem *item = [cat objectAtIndex: i++];
if (![path length]) continue;
if (ix == kIndexBitBanger) {
if (ix == kIndexBitBanger || ix == kIndexMidiOut) {
[item setString: path];
} else {
NSURL *url = [NSURL fileURLWithPath: path];

View File

@ -165,7 +165,7 @@ static NSDictionary *IndexMap = nil;
// _name is :rs232. should be set to -sl3:ssc:rs232 :/
#if 0
if (!_title) {
BOOL found = NO;
unsigned ix = 0;
for (SlotOption *option in _options) {
@ -512,6 +512,9 @@ https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/KeyVa
_(floppy_5_25);
_(pseudo_disk);
_(bitbanger);
_(midiin);
_(midiout);
_(picture);
#undef _
for (Slot *s in _children) {