Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Controller Classes/EndpointTableDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import <PYMIDI/PYMIDI.h>


@interface EndpointTableDataSource : NSObject {
@interface EndpointTableDataSource : NSObject <NSTableViewDataSource, NSTabViewDelegate, NSTableViewDelegate> {
Class endpointClass;
NSMutableArray* endpointArray;
NSUndoManager* undoManager;
Expand Down
37 changes: 22 additions & 15 deletions Controller Classes/EndpointTableDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ - (id)tableView:(NSTableView*)tableView objectValueForTableColumn:(NSTableColumn
- (BOOL)control:(NSControl*)control isValidObject:(id)value
{
if (PYMIDIIsEndpointNameTaken (value)) {
NSRunAlertPanel (
[NSString stringWithFormat:@"The name \"%@\" is already taken.", value],
@"Please choose a different name.",
nil, nil, nil
);
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert setMessageText: [NSString stringWithFormat:@"The name \"%@\" is already taken.", value]];
[alert setInformativeText:@"Please choose a different name."];
[alert setAlertStyle:NSWarningAlertStyle];
[alert runModal];

return NO;
}
else
Expand All @@ -72,11 +74,13 @@ - (void)tableView:(NSTableView*)tableView setObjectValue:(id)value forTableColum

if (![value isEqualToString:@""] && ![value isEqualToString:[endpoint name]]) {
if (PYMIDIIsEndpointNameTaken (value)) {
NSRunAlertPanel (
[NSString stringWithFormat:@"The name \"%@\" is already taken.", value],
@"Please choose a different name.",
nil, nil, nil
);
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert setMessageText: [NSString stringWithFormat:@"The name \"%@\" is already taken.", value]];
[alert setInformativeText:@"Please choose a different name."];
[alert setAlertStyle:NSWarningAlertStyle];
[alert runModal];

}
else {
[self tableView:tableView setName:(NSString*)value forEndpointAtIndex:rowIndex];
Expand All @@ -90,11 +94,14 @@ - (void)deleteSelection:(NSTableView*)tableView
PYMIDIVirtualEndpoint* endpoint = [endpointArray objectAtIndex:[tableView selectedRow]];

if ([endpoint isInUse]) {
NSRunAlertPanel (
@"The selection is in use by one or more patches and cannot be deleted.",
@"",
nil, nil, nil
);
NSAlert *alert = [[NSAlert alloc] init];

[alert addButtonWithTitle:@"OK"];
[alert setMessageText:@"The selection is in use by one or more patches and cannot be deleted."];
[alert setInformativeText:@""];
[alert setAlertStyle:NSWarningAlertStyle];
[alert runModal];

}
else {
[self tableView:tableView removeEndpointAtIndex:[tableView selectedRow]];
Expand Down
2 changes: 1 addition & 1 deletion Controller Classes/PatchTableDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@class PatchbayDocument;


@interface PatchTableDataSource : NSObject {
@interface PatchTableDataSource : NSObject <NSTableViewDataSource, NSTableViewDelegate> {
PatchbayDocument* document;
NSMutableArray* patchArray;
}
Expand Down
6 changes: 4 additions & 2 deletions Controller Classes/PatchbayDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@class EndpointTableDataSource;


@interface PatchbayDocument : NSDocument {
@interface PatchbayDocument : NSDocument <NSWindowDelegate> {
IBOutlet NSWindow* documentWindow;

// Stuff related to the table of patches
Expand All @@ -20,10 +20,11 @@
PatchTableDataSource* patchTableDataSource;

IBOutlet NSButton* addPatchButton;
IBOutlet NSButton* removePatchButton;

NSMutableArray* patchArray;
Patch* selectedPatch;

int selectedIndex;

// Stuff related to editing a patch

Expand Down Expand Up @@ -89,6 +90,7 @@

- (void)selectedPatchChanged:(NSNotification*)notification;
- (IBAction)addPatchButtonPressed:(id)sender;
- (IBAction)removePatchButtonPressed:(id)sender;

- (void)addPatch:(Patch*)patch atIndex:(int)index;
- (void)addPatchFromArchive:(NSData*)data atIndex:(int)index;
Expand Down
56 changes: 34 additions & 22 deletions Controller Classes/PatchbayDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ - (id)init
// Uncomment the following line for debugging if you want to
// disable undo, which makes tracking retain/release issues easier.
//[self setUndoManager:nil];

selectedIndex = -1;
return self;
}

Expand All @@ -50,7 +50,7 @@ - (void)windowControllerDidLoadNib:(NSWindowController*)windowController
{
NSButtonCell* buttonCell;
PatchTableCell* patchTableCell;

[super windowControllerDidLoadNib:windowController];

// These are so that our window and panel use the correct undo manager
Expand Down Expand Up @@ -113,7 +113,6 @@ - (void)windowControllerDidLoadNib:(NSWindowController*)windowController
// See the comment on tabView:shouldSelectTabViewItem; in EndpointTableDataSource
[virtualEndpointTabView setDelegate:inputTableDataSource];


[self syncWithLoadedData];
}

Expand Down Expand Up @@ -192,7 +191,7 @@ - (void)syncWithLoadedData
[patchTable reloadData];

if ([patchArray count] > 0)
[patchTable selectRow:0 byExtendingSelection:NO];
[patchTable selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO];
else
[patchTable deselectAll:self];

Expand Down Expand Up @@ -252,15 +251,17 @@ - (void)selectedPatchChanged:(NSNotification*)notification
[self setTransposeControls];
[self setTransmitClockControls];
[self setOutputPopUp];

selectedIndex = patchIndex;
}


- (IBAction)addPatchButtonPressed:(id)sender
- (IBAction) addPatchButtonPressed:(id)sender
{
Patch* patch;

if (selectedPatch != nil) {
patch = [[Patch alloc] initFromPatch:selectedPatch];
Patch *patch = [[Patch alloc] initFromPatch:selectedPatch];
[self addPatch:patch atIndex:[patchArray count]];
[patch release];
}
else {
// Pick a default input and output for a blank patch
Expand All @@ -276,14 +277,20 @@ - (IBAction)addPatchButtonPressed:(id)sender
PYMIDIEndpoint* output;
do { output = [enumerator nextObject]; } while ([output isIACBus]);

patch = [[Patch alloc] initWithInput:input output:output];
Patch *patch = [[Patch alloc] initWithInput:input output:output];
[self addPatch:patch atIndex:[patchArray count]];
[patch release];
}

[self addPatch:patch atIndex:[patchArray count]];

[patch release];

}

- (IBAction)removePatchButtonPressed:(id)sender
{
if (selectedIndex >= 0) {
[self removePatchAtIndex: selectedIndex];
}

}

- (void)addPatch:(Patch*)patch atIndex:(int)index
{
Expand All @@ -293,7 +300,7 @@ - (void)addPatch:(Patch*)patch atIndex:(int)index
[patchArray insertObject:patch atIndex:index];

[patchTable reloadData];
[patchTable selectRow:index byExtendingSelection:NO];
[patchTable selectRowIndexes:[NSIndexSet indexSetWithIndex:index] byExtendingSelection:NO];

[[undoManager prepareWithInvocationTarget:self]
removePatchAtIndex:index
Expand Down Expand Up @@ -1021,13 +1028,15 @@ - (IBAction)editVirtualInputs:(id)sender

panelWasOpenedToInputs = YES;

[documentWindow beginSheet: virtualEndpointPanel completionHandler: nil];
/*
[[NSApplication sharedApplication]
beginSheet:virtualEndpointPanel
modalForWindow:documentWindow
modalDelegate:self
didEndSelector:@selector(endpointPanelDidEnd:returnCode:contextInfo:)
contextInfo:nil
];
];*/
}


Expand All @@ -1041,14 +1050,15 @@ - (IBAction)editVirtualOutputs:(id)sender
[[self undoManager] beginUndoGrouping];

panelWasOpenedToInputs = NO;

[documentWindow beginSheet:virtualEndpointPanel completionHandler: nil];
/*
[[NSApplication sharedApplication]
beginSheet:virtualEndpointPanel
modalForWindow:documentWindow
modalDelegate:self
didEndSelector:@selector(endpointPanelDidEnd:returnCode:contextInfo:)
contextInfo:nil
];
];*/
}


Expand All @@ -1058,10 +1068,11 @@ - (IBAction)newInputButtonPressed:(id)sender
[[[self displayName] lastPathComponent] stringByDeletingPathExtension]
];

[[inputTable dataSource] tableView:inputTable newEndpointWithName:baseName];
[(EndpointTableDataSource *)[inputTable dataSource] tableView:inputTable newEndpointWithName:baseName];

// Set up the newly created endpoint for editing
[inputTable selectRow:[inputTable numberOfRows]-1 byExtendingSelection:NO];

[inputTable selectRowIndexes:[NSIndexSet indexSetWithIndex:[inputTable numberOfRows]-1] byExtendingSelection:NO];
[inputTable editColumn:0 row:[inputTable selectedRow] withEvent:nil select:YES];
}

Expand All @@ -1073,10 +1084,11 @@ - (IBAction)newOutputButtonPressed:(id)sender
[[[self displayName] lastPathComponent] stringByDeletingPathExtension]
];

[[outputTable dataSource] tableView:outputTable newEndpointWithName:baseName];
[(EndpointTableDataSource *)[outputTable dataSource] tableView:outputTable newEndpointWithName:baseName];

// Set up the newly created endpoint for editing
[outputTable selectRow:[outputTable numberOfRows]-1 byExtendingSelection:NO];
[outputTable selectRowIndexes:[NSIndexSet indexSetWithIndex:[outputTable numberOfRows]-1] byExtendingSelection:NO];

[outputTable editColumn:0 row:[outputTable selectedRow] withEvent:nil select:YES];
}

Expand All @@ -1086,7 +1098,7 @@ - (IBAction)endpointPanelButtonPressed:(id)sender
{
if ([virtualEndpointPanel makeFirstResponder:nil]) {
[virtualEndpointPanel orderOut:self];
[[NSApplication sharedApplication] endSheet:virtualEndpointPanel returnCode:0];
[documentWindow endSheet:virtualEndpointPanel returnCode:0];
}
}

Expand Down
36 changes: 0 additions & 36 deletions English.lproj/MainMenu.nib/classes.nib

This file was deleted.

Loading