• R/O
  • SSH
  • HTTPS

alchemusica: Commit


Commit MetaInfo

Revisión143 (tree)
Tiempo2017-11-09 23:40:43
Autortoshinagata1964

Log Message

The focus ring in the graphic view is shown in piano roll or strip chart separately.

Cambiar Resumen

Diferencia incremental

--- trunk/Classes/GraphicBackgroundView.m (revision 142)
+++ trunk/Classes/GraphicBackgroundView.m (revision 143)
@@ -59,11 +59,13 @@
5959 }
6060 }
6161
62-- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
63- /* Call the window controller's "resizeClientViewsWithOldMainViewSize" */
62+- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize
63+{
64+ /* Call the window controller's "backgroundView:resizedWithOldSize:" */
6465 id cont = [[self window] windowController];
65- if ([cont respondsToSelector: @selector(resizeClientViewsWithOldMainViewSize:)]) {
66- [cont resizeClientViewsWithOldMainViewSize: oldBoundsSize];
66+ if ([cont respondsToSelector: @selector(backgroundView:resizedWithOldSize:)]) {
67+ if (![cont backgroundView:self resizedWithOldSize:oldBoundsSize])
68+ [super resizeSubviewsWithOldSize:oldBoundsSize];
6769 }
6870 }
6971
--- trunk/Classes/GraphicRulerView.m (revision 142)
+++ trunk/Classes/GraphicRulerView.m (revision 143)
@@ -139,6 +139,7 @@
139139 NSRect newRect = [self frame];
140140 newRect.size.height = rect.size.height;
141141 [self setFrame: newRect];
142+ [self setNeedsDisplay:YES];
142143 }
143144 }
144145
--- trunk/Classes/GraphicSplitterView.m (revision 142)
+++ trunk/Classes/GraphicSplitterView.m (revision 143)
@@ -137,8 +137,10 @@
137137 [kindPopup setTarget: target];
138138 [kindPopup setAction: @selector(kindPopUpPressed:)];
139139 if (sControlSubmenu == nil) {
140- sControlSubmenu = [MDMenuWithControlNames(target, @selector(codeMenuItemSelected:), 0) retain];
140+ sControlSubmenu = [MDMenuWithControlNames(nil, nil, 0) retain];
141141 }
142+ [codePopup setTarget: target];
143+ [codePopup setAction: @selector(codeMenuItemSelected:)];
142144 [trackPopup setTarget:target];
143145 [trackPopup setAction:@selector(trackPopUpPressedInSplitterView:)];
144146 [trackPopup setMenu:trackPopUp([target trackCount])];
@@ -162,8 +164,11 @@
162164 NSPoint mousePt, startPt, origin;
163165 NSEventType type;
164166 GraphicWindowController *controller = (GraphicWindowController *)[[self window] windowController];
167+ GraphicBackgroundView *container = [controller enclosingContainerForClientView:self];
165168 startPt = [theEvent locationInWindow];
166- origin = [self frame].origin;
169+ if (container != nil)
170+ origin = [container frame].origin;
171+ else origin = [self frame].origin;
167172 [controller splitterViewStartedDragging:self];
168173 do {
169174 theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask | NSLeftMouseDraggedMask];
--- trunk/Classes/GraphicWindowController.h (revision 142)
+++ trunk/Classes/GraphicWindowController.h (revision 143)
@@ -21,8 +21,10 @@
2121 @class GraphicRulerView;
2222 @class GraphicSplitterView;
2323 @class PlayingViewController;
24+@class GraphicBackgroundView;
2425
2526 typedef struct ClientRecord {
27+ GraphicBackgroundView *container;
2628 GraphicClientView *client;
2729 GraphicRulerView *ruler;
2830 GraphicSplitterView *splitter;
@@ -85,7 +87,7 @@
8587
8688 @interface GraphicWindowController : NSWindowController
8789 {
88- IBOutlet NSView *myMainView; // Main graphic view (containing piano roll, etc.)
90+ IBOutlet GraphicBackgroundView *myMainView; // Main graphic view (containing piano roll, etc.)
8991 IBOutlet NSTableView *myTableView; // Track table
9092 IBOutlet NSView *myFloatingView; // View to draw playing cursor etc.
9193 IBOutlet NSView *myToolbarView; // The view containing tools for graphic editing
@@ -221,7 +223,8 @@
221223 - (void)splitterView: (GraphicSplitterView *)theView isDraggedTo: (float)y confirm: (BOOL)confirm;
222224
223225 // Customized autoresizing for client views
224-- (void)resizeClientViewsWithOldMainViewSize: (NSSize)oldSize;
226+//- (void)resizeClientViewsWithOldMainViewSize: (NSSize)oldSize;
227+- (BOOL)backgroundView:(NSView *)aView resizedWithOldSize:(NSSize)oldSize;
225228
226229 // Modify data according to mouse events in the GraphicClientViews
227230 - (void)dragNotesByTick: (MDTickType)deltaTick andNote: (int)deltaNote sender: (GraphicClientView *)sender optionFlag: (BOOL)optionFlag;
@@ -238,6 +241,7 @@
238241 - (GraphicClientView *)clientViewAtIndex: (int)index;
239242 - (GraphicSplitterView *)splitterViewAtIndex: (int)index;
240243 - (GraphicRulerView *)rulerViewAtIndex: (int)index;
244+- (GraphicBackgroundView *)enclosingContainerForClientView:(id)view;
241245
242246 // Action methods for track table
243247 - (IBAction)openEventListWindow: (id)sender;
--- trunk/Classes/GraphicWindowController.m (revision 142)
+++ trunk/Classes/GraphicWindowController.m (revision 143)
@@ -22,6 +22,7 @@
2222 #import "StripChartView.h"
2323 #import "StripChartRulerView.h"
2424 #import "TimeChartView.h"
25+#import "GraphicBackgroundView.h"
2526 #import "MyDocument.h"
2627 #import "MyMIDISequence.h"
2728 #import "ColorCell.h"
@@ -112,9 +113,6 @@
112113 - (id)init {
113114 self = [super initWithWindowNibName:@"GraphicWindow"];
114115 [self setShouldCloseDocument: YES];
115-// myTrack = NULL;
116-// trackInfo = [[NSMutableArray allocWithZone: [self zone]] init];
117-// editFlags = nil;
118116 lastMouseClientViewIndex = -1;
119117 lastTimeIndicator = -1;
120118 return self;
@@ -132,11 +130,7 @@
132130 [records[i].client release];
133131 [records[i].ruler release];
134132 [records[i].splitter release];
135- // if (records[i].calib != NULL)
136- // MDCalibratorRelease(records[i].calib);
137133 }
138-// [editFlags release];
139-// [trackInfo release];
140134 if (sortedTrackNumbers != NULL)
141135 free(sortedTrackNumbers);
142136 if (zoomUndoBuffer != nil)
@@ -359,14 +353,11 @@
359353 bounds.size.width = ceil(bounds.origin.x + bounds.size.width - origin.x);
360354 bounds.size.height = ceil(bounds.origin.y + bounds.size.height - origin.y);
361355 bounds.origin = origin;
362- // cachedImage = [[myMainView bitmapImageRepForCachingDisplayInRect:bounds] retain];
363- // [myMainView cacheDisplayInRect:bounds toBitmapImageRep:cachedImage];
364356 [myFloatingView lockFocus];
365357 [path stroke];
366358 if (bpath)
367359 [bpath fill];
368360 [myFloatingView unlockFocus];
369-// bounds = [myFloatingView convertRect: bounds toView: nil]; // window base coordinate
370361 timeIndicatorRect = bounds;
371362 }
372363 timeIndicatorPos = beat;
@@ -375,11 +366,6 @@
375366
376367 - (void)hideTimeIndicator
377368 {
378-// NSWindow *theWindow = [self window];
379-// [theWindow restoreCachedImage];
380-// [theWindow discardCachedImage];
381-// [theWindow flushWindowIfNeeded];
382-// MDTickType epos = [[[self document] myMIDISequence] sequenceDuration];
383369 if (!NSIsEmptyRect(timeIndicatorRect)) {
384370 if ([myFloatingView canDraw]) {
385371 [myFloatingView lockFocus];
@@ -386,23 +372,7 @@
386372 NSEraseRect([myFloatingView convertRect:timeIndicatorRect fromView:myMainView]);
387373 [myFloatingView unlockFocus];
388374 }
389- /*
390- if (cachedImage != nil && epos == endOfSequencePos) {
391- if ([myMainView canDraw]) {
392- NSImage *image = [[[NSImage alloc] init] autorelease];
393- [image addRepresentation:cachedImage];
394- [myMainView lockFocus];
395- [image drawInRect:timeIndicatorRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
396- [myMainView unlockFocus];
397- }
398- } else {
399- // If the sequence duration changed during recording, then
400- // we need to redraw the cached part
401- [myMainView displayRect:timeIndicatorRect];
402- } */
403375 [myMainView displayRect:timeIndicatorRect];
404- /* [cachedImage release];
405- cachedImage = nil; */
406376 }
407377 timeIndicatorRect = NSZeroRect;
408378 }
@@ -442,12 +412,10 @@
442412 return;
443413 }
444414
445-// fprintf(stderr, "showPlayPosition: beat = %f, pos = %f\n", beat, pos);
446415 if (pos < 0) {
447416 [self hideTimeIndicator];
448417 return;
449418 }
450-// [myFloatingView setNeedsDisplay: YES];
451419 documentRect = [records[0].client frame];
452420 visibleRect = [[records[0].client superview] bounds];
453421 width = documentRect.size.width - visibleRect.size.width;
@@ -458,19 +426,10 @@
458426 pos = width;
459427 [myScroller setFloatValue: pos / width];
460428 [self scrollClientViewsToPosition: pos];
461- // visibleRect.origin.x = pos + documentRect.origin.x;
462- // [records[0].client scrollPoint: visibleRect.origin];
463429 }
464430 [self showTimeIndicatorAtBeat: beat];
465431 }
466432
467-/*
468-- (void)didStopPlaying: (NSNotification *)notification
469-{
470- [self hideTimeIndicator];
471-}
472-*/
473-
474433 #pragma mark ==== Time marks ====
475434
476435 // Calculate the intervals of vertical lines.
@@ -596,98 +555,57 @@
596555
597556 #pragma mark ==== Client views ====
598557
558+/* Adjust the sizes of the client views so that they are aligned from top of the
559+ main view and the total height is aHeight (i.e. there is an empty space below aHeight).
560+ The width is resized to fill the current main view */
599561 - (void)adjustClientViewsInHeight: (float)aHeight
600562 {
601- // Resize the client views (except for the top-most view = TimeChartView) so that
602- // the total height becomes aHeight and the height proportion is preserved
603- int i;
604- float totalHeight, amountToResize, newHeight, splitterHeight;
605- NSScrollView *scrollView;
606-// NSView *rulerView;
607- NSRect aFrame, frame, rFrame;
608- float scrollerWidth, rulerWidth;
563+ int i;
564+ float proportion;
565+ float totalHeight;
566+ GraphicBackgroundView *containerView;
567+ NSRect aFrame, frame;
609568
610- if (myClientViewsCount == 0)
611- return;
569+ if (myClientViewsCount == 0)
570+ return;
571+
572+ aFrame = [myMainView bounds];
573+ aFrame.origin.y = aFrame.size.height - aHeight;
574+ aFrame.size.height = aHeight;
612575
613- scrollerWidth = [NSScroller scrollerWidth];
614- rulerWidth = [self rulerWidth];
576+ // Relocate the TimeChartView
577+ containerView = records[0].container;
578+ frame = [containerView frame];
579+ frame.origin.y = (aFrame.origin.y + aFrame.size.height) - frame.size.height;
580+ frame.origin.x = aFrame.origin.x;
581+ frame.size.width = aFrame.size.width;
582+ [containerView setFrame:frame];
583+
584+ if (myClientViewsCount == 1) {
585+ [self setNeedsReloadClientViews];
586+ return;
587+ }
615588
616- // Target rectangle
617- aFrame = [myMainView bounds];
618- aFrame.origin.x += rulerWidth;
619- aFrame.size.width -= rulerWidth;
620- aFrame.origin.y = aFrame.origin.y + aFrame.size.height - aHeight;
621- aFrame.size.height = aHeight;
622- rFrame = aFrame;
623- rFrame.origin.x -= rulerWidth;
624- rFrame.size.width = rulerWidth;
625-
626- // Resize the TimeChartView (horizontal only)
627- scrollView = [records[0].client enclosingScrollView];
628- frame = [scrollView frame];
629- frame.origin.y = (aFrame.origin.y + aFrame.size.height) - frame.size.height;
630- frame.origin.x = aFrame.origin.x;
631- frame.size.width = aFrame.size.width;
632- if (![records[0].client hasVerticalScroller])
633- frame.size.width -= scrollerWidth;
634- [scrollView setFrame: frame];
635-// [records[0].client reloadData];
636-
637- if (myClientViewsCount == 1) {
638- [self setNeedsReloadClientViews];
639- return;
640- }
641-
642- // Calculate the total height
643- totalHeight = 0.0;
644- splitterHeight = 0.0;
645- for (i = 0; i < myClientViewsCount; i++) {
646- totalHeight += [[records[i].client enclosingScrollView] frame].size.height;
647- if (i > 0)
648- splitterHeight += [records[i].splitter frame].size.height;
649- }
650- amountToResize = aHeight - (totalHeight + splitterHeight);
651-// NSLog(@"totalHeight=%g, splitterHeight=%g, amountToResize=%g", totalHeight, splitterHeight, amountToResize);
652- frame.size.width = aFrame.size.width;
653- // Resize
654- for (i = myClientViewsCount - 1; i >= 1; i--) {
655-
656- // Move the splitter view
657- aFrame.origin.x -= rulerWidth;
658- aFrame.size.width += rulerWidth;
659- aFrame.size.height = [records[i].splitter frame].size.height;
660- [records[i].splitter setFrame: aFrame];
661-
662- // Resize the scroll view
663- aFrame.origin.y += aFrame.size.height;
664- aFrame.origin.x += rulerWidth;
665- aFrame.size.width -= rulerWidth;
666- scrollView = [records[i].client enclosingScrollView];
667- if (i == 1) {
668- aFrame.size.height = frame.origin.y - aFrame.origin.y;
669- } else {
670- newHeight = floor([scrollView frame].size.height * (1 + amountToResize / totalHeight) + 0.5);
671- aFrame.size.height = newHeight;
672- }
673- aFrame.size.width = frame.size.width;
674- if (![records[i].client hasVerticalScroller])
675- aFrame.size.width -= scrollerWidth;
676- [scrollView setFrame: aFrame];
677-
678- // Resize the ruler view
679- /* rFrame.origin.y = aFrame.origin.y;
680- rFrame.size.height = aFrame.size.height;
681- if (records[i].ruler != nil) {
682- [records[i].ruler setFrame: rFrame];
683- } */
684-
685-// [records[i].client reloadData];
686-
687- aFrame.origin.y += aFrame.size.height;
688- }
689-
690- [self setNeedsReloadClientViews];
589+ // Calculate the total client size (except for the TimeChartView)
590+ totalHeight = 0.0;
591+ for (i = 1; i < myClientViewsCount; i++) {
592+ containerView = records[i].container;
593+ totalHeight += [containerView frame].size.height;
594+ }
595+ proportion = (aHeight - frame.size.height) / totalHeight;
596+
597+ // Resize other views
598+ for (i = 1; i < myClientViewsCount; i++) {
599+ containerView = records[i].container;
600+ frame.size.height = floor([containerView frame].size.height * proportion + 0.5);
601+ frame.origin.y = frame.origin.y - frame.size.height;
602+ if (i == myClientViewsCount - 1) {
603+ frame.size.height += (frame.origin.y - aFrame.origin.y);
604+ frame.origin.y = aFrame.origin.y;
605+ }
606+ [containerView setFrame:frame];
607+ }
608+ [self setNeedsReloadClientViews];
691609 }
692610
693611 - (void)updateTrackingRect
@@ -842,6 +760,7 @@
842760 - (void)reloadClientViews
843761 {
844762 int i;
763+ id firstResponder = [[self window] firstResponder];
845764 for (i = 0; i < myClientViewsCount; i++) {
846765 [records[i].client reloadData];
847766 }
@@ -848,7 +767,12 @@
848767 [self reflectClientViews];
849768
850769 /* Redraw focus ring */
851- [myMainView setKeyboardFocusRingNeedsDisplayInRect: [myMainView bounds]];
770+ for (i = 0; i < myClientViewsCount; i++) {
771+ if (firstResponder == records[i].container) {
772+ [firstResponder setKeyboardFocusRingNeedsDisplayInRect:[firstResponder bounds]];
773+ break;
774+ }
775+ }
852776
853777 /* Remove "NeedsReloadClientView" notifications */
854778 [[NSNotificationQueue defaultQueue] dequeueNotificationsMatching: [NSNotification notificationWithName: sNeedsReloadClientViewNotification object: self] coalesceMask: NSNotificationCoalescingOnName | NSNotificationCoalescingOnSender];
@@ -886,155 +810,16 @@
886810 }
887811 }
888812
889-/*
890-// Adjust the client view frame when the enclosing scroll view is resized
891-- (void)superFrameDidChange: (NSNotification *)aNotification
892-{
893- NSRect rect, newRect;
894- int i;
895- GraphicClientView *aView;
896- id object = [aNotification object];
897- return;
898-// NSLog(@"superFrameDidChange from %@", object);
899- for (i = 0; i < myClientViewsCount; i++) {
900- aView = records[i].client;
901- if ([aView superview] == object) {
902- if (![aView hasVerticalScroller]) {
903- rect = [object frame];
904- newRect = [aView frame];
905- newRect.size.height = rect.size.height;
906- [aView setFrame: newRect];
907- [aView reloadData];
908- break;
909- }
910- }
911- }
912- // Invalidate the cached image under the time indicator (if necessary)
913- [self invalidateTimeIndicatorCachedImage];
914- // Update the tracking rect
915- [self updateTrackingRect];
916-}
917-*/
918-
919-/*
920-// Adjust the scroll positions
921-- (void)superBoundsDidChange: (NSNotification *)aNotification
922-{
923- NSRect rect, newRect;
924- int i;
925- GraphicClientView *aView;
926- id object = [aNotification object];
927- rect = [object bounds];
928- for (i = 0; i < myClientViewsCount; i++) {
929- aView = records[i].client;
930- if (aView == nil)
931- continue;
932- if ([aView superview] != object) {
933- newRect = [[aView superview] bounds];
934- newRect.origin.x = rect.origin.x;
935- [aView scrollPoint: newRect.origin];
936- }
937- }
938- [self reflectClientViews];
939-
940- // Invalidate the cached image under the time indicator (if necessary)
941- [self invalidateTimeIndicatorCachedImage];
942-}
943-*/
944-
945813 /* Customized autoresizing of clientviews */
946-- (void)resizeClientViewsWithOldMainViewSize: (NSSize)oldSize
814+- (BOOL)backgroundView:(NSView *)aView resizedWithOldSize:(NSSize)oldSize
947815 {
948- NSSize newSize = [myMainView bounds].size;
949-// NSLog(@"resizeClientViewsWithOldMainViewSize: newSize=%@, oldSize=%@", NSStringFromSize(newSize), NSStringFromSize(oldSize));
950- [self adjustClientViewsInHeight: newSize.height];
816+ if (aView == myMainView) {
817+ NSSize newSize = [myMainView bounds].size;
818+ [self adjustClientViewsInHeight: newSize.height];
819+ return YES;
820+ } else return NO;
951821 }
952822
953-/*
954-// myMainView has changed size
955-- (void)myMainViewFrameDidChange: (NSNotification *)aNotification
956-{
957- // Vertical
958-
959- // Horizontal
960- // Resize the client views if necessary
961-// [self reloadClientViews];
962-}
963-*/
964-
965-/*
966-// Adjust the content frame sizes
967-- (void)frameDidChange: (NSNotification *)aNotification
968-{
969- NSRect rect, newRect;
970- int i;
971-// float newXScale;
972- GraphicClientView *aView;
973- id object = [aNotification object];
974-// NSLog(@"frameDidChange");
975- rect = [object bounds];
976-// if ([object respondsToSelector: @selector(xScale)])
977-// newXScale = [object xScale];
978-// else newXScale = -1;
979- for (i = 0; i < myClientViewsCount; i++) {
980- aView = records[i].client;
981- if (aView != nil && object != aView) {
982- // if (newXScale != -1 && [aView xScale] != newXScale)
983- // [aView setXScale: newXScale];
984- newRect = [aView frame];
985- newRect.size.width = rect.size.width;
986- [aView setFrame: newRect];
987- }
988- }
989- [self reflectClientViews];
990-}
991-*/
992-
993-/*
994-// Register notification with a client view
995-- (void)registerNotificationWithView: (GraphicClientView *)view
996-{
997- return;
998- [[NSNotificationCenter defaultCenter]
999- addObserver: self
1000- selector: @selector(superBoundsDidChange:)
1001- name: NSViewBoundsDidChangeNotification
1002- object: [view superview]];
1003- [[NSNotificationCenter defaultCenter]
1004- addObserver: self
1005- selector: @selector(superFrameDidChange:)
1006- name: NSViewFrameDidChangeNotification
1007- object: [view superview]];
1008- [[NSNotificationCenter defaultCenter]
1009- addObserver: self
1010- selector: @selector(frameDidChange:)
1011- name: NSViewFrameDidChangeNotification
1012- object: view];
1013-
1014- [[view superview] setPostsBoundsChangedNotifications: YES];
1015-// [[view superview] setPostsFrameChangedNotifications: YES];
1016- [view setPostsFrameChangedNotifications: YES];
1017-}
1018-*/
1019-
1020-/*
1021-// Unregister notification with a client view
1022-- (void)unregisterNotificationWithView: (GraphicClientView *)view
1023-{
1024- return;
1025-#if 0
1026- [[NSNotificationCenter defaultCenter]
1027- removeObserver: self
1028- name: nil
1029- object: [view superview]];
1030- [[NSNotificationCenter defaultCenter]
1031- removeObserver: self
1032- name: nil
1033- object: view];
1034-#endif
1035-}
1036-*/
1037-
1038823 - (void)limitWindowSize
1039824 {
1040825 float windowHeight, currentHeight, limitHeight;
@@ -1059,6 +844,7 @@
1059844 GraphicClientView *clientView;
1060845 GraphicRulerView *rulerView;
1061846 GraphicSplitterView *splitterView;
847+ GraphicBackgroundView *containerView;
1062848 NSRect aRect, rect;
1063849 float scrollerWidth, rulerWidth, height, splitterHeight, minHeight;
1064850 unsigned int mask;
@@ -1075,14 +861,16 @@
1075861 aRect.origin.y += (aRect.size.height - height);
1076862 aRect.size.height = height;
1077863 mask = NSViewMinYMargin;
864+ splitterHeight = 0.0;
1078865 } else {
1079- scrollView = [records[myClientViewsCount - 1].client enclosingScrollView];
866+ rect = [records[myClientViewsCount - 1].container frame];
867+ // scrollView = [records[myClientViewsCount - 1].client enclosingScrollView];
1080868 if (myClientViewsCount == 1) {
1081- rect = [scrollView frame];
869+ // rect = [scrollView frame];
1082870 splitterHeight = 4.0;
1083871 mask = NSViewHeightSizable;
1084872 } else {
1085- rect = [records[myClientViewsCount - 1].splitter frame];
873+ // rect = [records[myClientViewsCount - 1].splitter frame];
1086874 splitterHeight = 16.0;
1087875 mask = NSViewMaxYMargin;
1088876 }
@@ -1091,25 +879,32 @@
1091879 height = minHeight;
1092880 [self adjustClientViewsInHeight: aRect.size.height - (height + splitterHeight)];
1093881 }
1094- aRect.size.height = height;
1095- aRect.origin.y += splitterHeight;
882+ aRect.size.height = height + splitterHeight;
1096883 }
1097884
885+ // Create the container view
886+ rect = aRect;
887+ // Don't autorelease, since we are going to retain it
888+ containerView = [[GraphicBackgroundView allocWithZone:[self zone]] initWithFrame:rect];
889+ [myMainView addSubview:containerView];
890+ [containerView setAutoresizingMask: (NSViewWidthSizable | mask)];
891+ [containerView setAutoresizesSubviews:YES];
892+ records[myClientViewsCount].container = containerView;
893+
1098894 // Create the chart view
1099895 // NSScrollView
896+ mask = NSViewWidthSizable | NSViewHeightSizable;
1100897 rulerWidth = [self rulerWidth];
1101- rect = aRect;
1102- rect.size.width -= rulerWidth;
1103- rect.origin.x += rulerWidth;
898+ rect.origin = NSMakePoint(rulerWidth, splitterHeight);
899+ rect.size.width = aRect.size.width - rulerWidth;
900+ rect.size.height = aRect.size.height - splitterHeight;
1104901 scrollView = [[[NSScrollView allocWithZone: [self zone]] initWithFrame: rect] autorelease];
1105- [myMainView addSubview: scrollView];
1106- [scrollView setAutoresizingMask: (NSViewWidthSizable | mask)];
902+ [containerView addSubview: scrollView];
903+ [scrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
1107904 [scrollView setHasHorizontalScroller: NO];
1108-// [scrollView setHorizontalScroller: myScroller];
1109905
1110906 // The chart view
1111907 rect.origin.x = rect.origin.y = 0.0;
1112-// rect.size.height -= scrollerWidth;
1113908 // Don't autorelease, since we are going to retain it
1114909 clientView = [[chartClass allocWithZone: [self zone]] initWithFrame: rect];
1115910 [scrollView setDocumentView: clientView];
@@ -1122,23 +917,17 @@
1122917 [scrollView setFrame: rect];
1123918 }
1124919 [clientView setDataSource: self];
1125-// if (myClientViewsCount == 0)
1126-// [clientView setXScale: 72 / 2.54]; /* 1 cm per quarter note */
1127-// else
1128-// [clientView setXScale: [records[0].client xScale]];
1129-// [self registerNotificationWithView: clientView];
1130920 records[myClientViewsCount].client = clientView;
1131921
1132922 if (myClientViewsCount > 0 && rulerClass != nil) {
1133923 // Create the ruler view
1134924 // NSClipView
1135- rect = aRect;
1136- rect.size.width = rulerWidth;
1137- // rect.origin.y += scrollerWidth;
1138- // rect.size.height -= scrollerWidth;
925+ rect.origin = NSMakePoint(0, splitterHeight);
926+ rect.size.width = rulerWidth;
927+ rect.size.height = aRect.size.height - splitterHeight;
1139928 clipView = [[[NSClipView allocWithZone: [self zone]] initWithFrame: rect] autorelease];
1140- [myMainView addSubview: clipView];
1141- [clipView setAutoresizingMask: (NSViewMaxXMargin | mask)];
929+ [containerView addSubview: clipView];
930+ [clipView setAutoresizingMask:NSViewMaxXMargin | NSViewHeightSizable];
1142931
1143932 // The chart view
1144933 rect.origin.x = rect.origin.y = 0.0;
@@ -1150,24 +939,15 @@
1150939
1151940 if (myClientViewsCount > 0) {
1152941 // Create the splitter view
1153- rect = aRect;
1154- rect.origin.y -= splitterHeight;
1155- rect.size.height = splitterHeight;
942+ rect.origin = NSMakePoint(0, 0);
943+ rect.size.width = aRect.size.width;
944+ rect.size.height = splitterHeight;
1156945 splitterView = [[GraphicSplitterView allocWithZone: [self zone]] initWithFrame: rect];
1157- [myMainView addSubview: splitterView];
946+ [containerView addSubview: splitterView];
1158947 [splitterView setAutoresizingMask: (NSViewWidthSizable | NSViewMaxYMargin)];
1159948 records[myClientViewsCount].splitter = splitterView;
1160949 }
1161950
1162-/*
1163- if ([clientView isKindOfClass: [TimeChartView class]]) {
1164- records[myClientViewsCount].calib =
1165- MDCalibratorNew([[[self document] myMIDISequence] mySequence], NULL, kMDEventTimeSignature, -1);
1166- } else {
1167- records[myClientViewsCount].calib = NULL;
1168- }
1169-*/
1170-
1171951 myClientViewsCount++;
1172952
1173953 if ([clientView isKindOfClass: [StripChartView class]]) {
@@ -1184,17 +964,16 @@
1184964 int i;
1185965 NSRect frame;
1186966 float y;
1187- frame = [[records[index].client enclosingScrollView] frame];
967+ frame = [records[index].container frame];
1188968 y = frame.origin.y + frame.size.height;
1189969 [[records[index].client enclosingScrollView] removeFromSuperview];
1190970 [[records[index].ruler superview] removeFromSuperview];
1191971 [records[index].splitter removeFromSuperview];
1192-// [self unregisterNotificationWithView: records[index].client];
972+ [records[index].container removeFromSuperview];
1193973 [records[index].client autorelease];
1194974 [records[index].ruler autorelease];
1195975 [records[index].splitter autorelease];
1196-/* if (records[index].calib != NULL)
1197- MDCalibratorRelease(records[index].calib); */
976+ [records[index].container autorelease];
1198977 for (i = index; i < myClientViewsCount - 1; i++) {
1199978 records[i] = records[i + 1];
1200979 }
@@ -1201,19 +980,14 @@
1201980 memset(&records[i], 0, sizeof(records[i]));
1202981 myClientViewsCount--;
1203982 if (index < myClientViewsCount) {
1204- frame = [[records[index].client enclosingScrollView] frame];
983+ frame = [records[index].container frame];
1205984 frame.size.height = y - frame.origin.y;
1206- [[records[index].client enclosingScrollView] setFrame: frame];
985+ [records[index].container setFrame:frame];
1207986 } else if (index > 1) {
1208- y = [myMainView bounds].origin.y;
1209- frame = [records[index - 1].splitter frame];
1210- frame.origin.y = y;
1211- [records[index - 1].splitter setFrame: frame];
1212- y += frame.size.height;
1213- frame = [[records[index - 1].client enclosingScrollView] frame];
1214- frame.size.height = frame.origin.y + frame.size.height - y;
1215- frame.origin.y = y;
1216- [[records[index - 1].client enclosingScrollView] setFrame: frame];
987+ frame = [records[index - 1].container frame];
988+ frame.size.height += frame.origin.y;
989+ frame.origin.y = 0;
990+ [records[index - 1].container setFrame:frame];
1217991 }
1218992 [self setNeedsReloadClientViews];
1219993 [myMainView setNeedsDisplay: YES];
@@ -1236,7 +1010,8 @@
12361010 - (void)splitterView: (GraphicSplitterView *)theView isDraggedTo: (float)y confirm: (BOOL)confirm
12371011 {
12381012 int index;
1239- NSScrollView *scrollView;
1013+// NSScrollView *scrollView;
1014+ GraphicBackgroundView *containerView = nil;
12401015 NSRect frame_above, frame_self, frame_below;
12411016 float ymax, ymin;
12421017 for (index = 1; index < myClientViewsCount; index++) {
@@ -1244,12 +1019,11 @@
12441019 break;
12451020 }
12461021 if (index == myClientViewsCount) {
1247- // NSLog(@"splitterView:isDraggedBy:confirm: theView (%@) not found", theView);
12481022 return;
12491023 }
1250-// [self setInfoText: [NSString stringWithFormat: @"y = %g", y]];
1251- frame_above = [[records[index].client enclosingScrollView] frame];
1024+ frame_above = [records[index].container frame];
12521025 frame_self = [records[index].splitter frame];
1026+ y = floor(y + 0.5); /* New position of the container frame */
12531027 ymax = frame_above.origin.y + frame_above.size.height - frame_self.size.height;
12541028 if (index == 1) {
12551029 // Piano roll view cannot be collapsed
@@ -1271,11 +1045,12 @@
12711045 y = ymax - 32.0;
12721046 }
12731047 if (index < myClientViewsCount - 1) {
1274- scrollView = [records[index + 1].client enclosingScrollView];
1275- frame_below = [scrollView frame];
1276- ymin = frame_below.origin.y;
1048+ containerView = records[index + 1].container;
1049+ frame_below = [containerView frame];
1050+ ymin = frame_below.origin.y;
1051+ if (records[index + 1].splitter != nil)
1052+ ymin += [records[index + 1].splitter frame].size.height;
12771053 } else {
1278- scrollView = nil;
12791054 ymin = [myMainView bounds].origin.y;
12801055 }
12811056 if (y <= ymin) {
@@ -1293,18 +1068,18 @@
12931068 // Avoid too narrow strip chart
12941069 y = ymin + 32.0;
12951070 }
1296- frame_above.origin.y = y + frame_self.size.height;
1297- frame_above.size.height = ymax - y;
1298- [[records[index].client enclosingScrollView] setFrame: frame_above];
1299- [[records[index].client enclosingScrollView] setNeedsDisplay: YES];
1071+ frame_above.size.height += frame_above.origin.y - y;
1072+ frame_above.origin.y = y;
1073+ [records[index].container setFrame:frame_above];
1074+ [records[index].container setNeedsDisplay:YES];
13001075 [records[index].client reloadData];
1301- frame_self.origin.y = y;
1076+/* frame_self.origin.y = y;
13021077 [records[index].splitter setFrame: frame_self];
1303- [records[index].splitter setNeedsDisplay: YES];
1304- if (scrollView != nil) {
1305- frame_below.size.height = y - ymin;
1306- [scrollView setFrame: frame_below];
1307- [scrollView setNeedsDisplay: YES];
1078+ [records[index].splitter setNeedsDisplay: YES]; */
1079+ if (containerView != nil) {
1080+ frame_below.size.height = y - frame_below.origin.y;
1081+ [containerView setFrame:frame_below];
1082+ [containerView setNeedsDisplay:YES];
13081083 [records[index + 1].client reloadData];
13091084 } else if (confirm && y > ymin) {
13101085 // Create a new client view
@@ -1311,10 +1086,6 @@
13111086 [self createClientViewWithClasses: [StripChartView class] : [StripChartRulerView class]];
13121087 // Scroll to the current position
13131088 [self scrollClientViewsToPosition: [self scrollPositionOfClientViews]];
1314- // [self superBoundsDidChange:
1315- // [NSNotification notificationWithName: NSViewBoundsDidChangeNotification
1316- // object: [records[0].client superview]]];
1317- // Simulate scroll to force recalculation of the scroll position
13181089 }
13191090 if (confirm) {
13201091 // Restore the visible range of this and the next clients
@@ -1324,7 +1095,7 @@
13241095 [records[index + 1].client restoreVisibleRange];
13251096 [myMainView display];
13261097 } else {
1327- if (scrollView == nil) {
1098+ if (containerView == nil) {
13281099 NSRect theRect = [myMainView bounds];
13291100 theRect.size.height = y - ymin;
13301101 [myMainView lockFocus];
@@ -1413,11 +1184,9 @@
14131184 - (IBAction)codeMenuItemSelected: (id)sender
14141185 {
14151186 int i, code;
1416- NSView *focus;
1417- code = (int)[sender tag];
1418- focus = [NSView focusView];
14191187 for (i = 1; i < myClientViewsCount; i++) {
1420- if ([focus isDescendantOf: records[i].splitter]) {
1188+ if (records[i].splitter == (GraphicSplitterView *)[sender superview]) {
1189+ code = (int)[[sender selectedItem] tag];
14211190 [self setStripChartAtIndex: i kind: -1 code: code];
14221191 break;
14231192 }
@@ -1500,6 +1269,17 @@
15001269 else return nil;
15011270 }
15021271
1272+- (GraphicBackgroundView *)enclosingContainerForClientView:(id)view
1273+{
1274+ int i;
1275+ for (i = 0; i < myClientViewsCount; i++) {
1276+ if (records[i].client == view || records[i].ruler == view || records[i].splitter == view)
1277+ return records[i].container;
1278+ }
1279+ return nil;
1280+}
1281+
1282+
15031283 /* Used by GraphicBackgroundView to send key events to the active client view */
15041284 - (void)mouseEvent:(NSEvent *)theEvent receivedByClientView:(GraphicClientView *)cView
15051285 {
@@ -1624,20 +1404,8 @@
16241404 selector:@selector(windowDidResize:)
16251405 name:NSWindowDidResizeNotification object:[self window]];
16261406
1627-// [[NSNotificationCenter defaultCenter]
1628-// addObserver: self
1629-// selector: @selector(myMainViewFrameDidChange:)
1630-// name: NSViewFrameDidChangeNotification
1631-// object: myMainView];
16321407 [myMainView setPostsFrameChangedNotifications: YES];
16331408
1634-/* [[NSNotificationCenter defaultCenter]
1635- addObserver:self
1636- selector:@selector(showPlayPosition:)
1637- name:MyDocumentStopPlayingNotification
1638- object:[self document]];
1639-*/
1640-
16411409 [[NSNotificationCenter defaultCenter]
16421410 addObserver:self
16431411 selector:@selector(midiSetupDidChange:)
@@ -1914,7 +1682,7 @@
19141682
19151683 - (void)changeFirstResponderWithEvent: (NSEvent *)theEvent
19161684 {
1917- /* myTableView, myMainView, or myPlayerView will be the first responder */
1685+ /* myTableView, one of the container views, or myPlayerView can be the first responder */
19181686 NSPoint pt = [theEvent locationInWindow];
19191687 NSWindow *theWindow = [self window];
19201688 id obj = [theWindow firstResponder];
@@ -1924,46 +1692,23 @@
19241692 } else if (obj == [theWindow fieldEditor: NO forObject: nil]) {
19251693 obj = [obj delegate];
19261694 }
1927-/* if ([obj isKindOfClass: [NSView class]]) {
1928- frame = [[obj superview] convertRect: [obj frame] toView: nil];
1929- // Don't change focus if clicked on itself
1930- if (NSPointInRect(pt, frame))
1931- return;
1932- } */
19331695
19341696 if (NSPointInRect(pt, [[myMainView superview] convertRect: [myMainView frame] toView: nil])) {
1935- [theWindow makeFirstResponder: myMainView];
1697+ /* Look for the container view */
1698+ int i;
1699+ for (i = 0; i < myClientViewsCount; i++) {
1700+ GraphicBackgroundView *view = records[i].container;
1701+ if (NSPointInRect(pt, [[view superview] convertRect:[view frame] toView:nil])) {
1702+ if (i > 0) /* The time chart view does not accept first responder */
1703+ [theWindow makeFirstResponder:view];
1704+ return;
1705+ }
1706+ }
19361707 } else if (NSPointInRect(pt, [[myPlayerView superview] convertRect: [myPlayerView frame] toView: nil])) {
19371708 [theWindow makeFirstResponder: myPlayerView];
19381709 }
19391710 }
19401711
1941-/*
1942-- (BOOL)shouldResignFirstResponderInWindow: (NSWindow *)theWindow withEvent: (NSEvent *)theEvent
1943-{
1944- // Unfocus TextField when myMainView or myPlayerView is clicked
1945- NSPoint pt = [theEvent locationInWindow];
1946- id obj = [theWindow firstResponder];
1947- NSRect frame;
1948- if ([obj isKindOfClass: [NSTextFieldCell class]]) {
1949- obj = [obj controlView];
1950- } else if (![obj isKindOfClass: [NSTextField class]] && ![obj isKindOfClass: [NSTextView class]]) {
1951- return NO;
1952- }
1953- frame = [[obj superview] convertRect: [obj frame] toView: nil];
1954-
1955- // Don't unfocus if clicked on itself
1956- if (NSPointInRect(pt, frame))
1957- return NO;
1958-
1959- if (NSPointInRect(pt, [[myMainView superview] convertRect: [myMainView frame] toView: nil])
1960- || NSPointInRect(pt, [[myPlayerView superview] convertRect: [myPlayerView frame] toView: nil])
1961- || NSPointInRect(pt, [[myToolbarView superview] convertRect: [myToolbarView frame] toView: nil]))
1962- return YES;
1963- else return NO;
1964-}
1965-*/
1966-
19671712 - (id)playingViewController
19681713 {
19691714 return playingViewController;
@@ -2722,20 +2467,6 @@
27222467 return YES;
27232468 }
27242469
2725-/*
2726-- (void)splitViewDidResizeSubviews:(NSNotification *)aNotification
2727-{
2728- NSView *theView = [myMainView superview];
2729- NSRect rect1 = [theView frame];
2730- NSView *theSuperOfScrollView = [myScroller superview];
2731- NSRect rect2 = [theSuperOfScrollView frame];
2732- rect2.origin.x = rect2.origin.x + rect2.size.width - rect1.size.width;
2733- rect2.size.width = rect1.size.width;
2734- [theSuperOfScrollView setFrame: rect2];
2735- [theSuperOfScrollView setNeedsDisplay: YES];
2736-}
2737-*/
2738-
27392470 #pragma mark ==== Responding to notification from other windows ====
27402471
27412472 - (void)trackModified: (NSNotification *)notification {
@@ -2806,11 +2537,17 @@
28062537 int numberOfTracks = [[doc myMIDISequence] trackCount];
28072538 id firstResponder = [[self window] firstResponder];
28082539
2809- if (firstResponder == myMainView) {
2540+ if ([firstResponder isKindOfClass:[GraphicBackgroundView class]]) {
28102541 int focusTrack;
2811- GraphicClientView *client = [self clientViewAtIndex:lastMouseClientViewIndex];
2542+ GraphicClientView *client = nil;
2543+ /* Look for the client view contained in the firstResponder container view */
2544+ for (i = 0; i < myClientViewsCount; i++) {
2545+ if (records[i].container == firstResponder) {
2546+ client = records[i].client;
2547+ break;
2548+ }
2549+ }
28122550 focusTrack = [client focusTrack];
2813-
28142551 /* Copy all selected events in editable tracks */
28152552 numberOfSelectedTracks = 0;
28162553 for (i = 0; i < numberOfTracks; i++) {
@@ -2868,8 +2605,10 @@
28682605 return;
28692606
28702607 numberOfSelectedTracks = [self countTracksToCopyWithSelectionList: selArray rangeStart: &startTick rangeEnd: &endTick];
2871- if (numberOfSelectedTracks == 0)
2872- return;
2608+ if (numberOfSelectedTracks == 0) {
2609+ free(selArray);
2610+ return;
2611+ }
28732612
28742613 if (copyFlag)
28752614 [doc copyWithSelections: selArray rangeStart: startTick rangeEnd: endTick];
@@ -2879,13 +2618,12 @@
28792618 for (i = numberOfTracks - 1; i >= 0; i--) {
28802619 if (selArray[i] == nil)
28812620 continue;
2882- if (firstResponder == myMainView) {
2621+ if (firstResponder == myTableView) {
2622+ [doc deleteTrackAt: i];
2623+ } else {
28832624 sel = [doc selectionOfTrack: i];
28842625 [doc deleteMultipleEventsAt: sel fromTrack: i deletedEvents: NULL];
2885- } else if (firstResponder == myTableView) {
2886- [doc deleteTrackAt: i];
28872626 }
2888-
28892627 }
28902628 }
28912629
@@ -2892,18 +2630,27 @@
28922630 free(selArray);
28932631 }
28942632
2633+/* Paste multiple tracks to multiple tracks
2634+ Rules:
2635+ (1) Events from the conductor track should go to the conductor track,
2636+ and those from non-conductor tracks should go to non-conductor tracks.
2637+ (2) If the number of tracks in the pasteboard is larger than the number of
2638+ editable tracks, then new tracks are created after the last track.
2639+ (3) If the first responder is strip chart view, then only the event type that
2640+ is visible are pasted. The exception to this is when the TEMPO event is
2641+ selected, in which all conductor events are pasted. */
28952642 - (void)doPasteWithMergeFlag: (BOOL)mergeFlag
28962643 {
2897-//- (BOOL)getPasteboardSequence: (MDSequence **)outSequence catalog: (MDCatalog **)outCatalog;
28982644 MyDocument *doc = (MyDocument *)[self document];
28992645 MDSequence *seq;
29002646 MDCatalog *catalog;
2901- int i, j, numberOfTracks, trackCount;
2647+ int i, j, numberOfTracks, trackCount, hasConductorTrack;
29022648 int *trackList;
29032649 id firstResponder;
29042650
29052651 if (![doc getPasteboardSequence: &seq catalog: &catalog])
29062652 return;
2653+ hasConductorTrack = (catalog->catTrack[0].originalTrackNo == 0);
29072654 trackCount = [[doc myMIDISequence] trackCount];
29082655 numberOfTracks = MDSequenceGetNumberOfTracks(seq);
29092656 trackList = (int *)calloc(sizeof(int), numberOfTracks);
@@ -2912,16 +2659,86 @@
29122659
29132660 firstResponder = [[self window] firstResponder];
29142661
2915- if (firstResponder == myMainView) {
2662+ if ([firstResponder isKindOfClass:[GraphicBackgroundView class]]) {
29162663
2664+ int focusTrack, kind, code;
2665+ GraphicClientView *client = nil;
2666+ /* Look for the client view contained in the firstResponder container view */
2667+ for (i = 0; i < myClientViewsCount; i++) {
2668+ if (records[i].container == firstResponder) {
2669+ client = records[i].client;
2670+ break;
2671+ }
2672+ }
2673+ focusTrack = [client focusTrack];
2674+ if ([client isKindOfClass:[StripChartView class]]) {
2675+ /* Filter the events */
2676+ IntGroup *ig;
2677+ int32_t kindAndCode = [(StripChartView *)client kindAndCode];
2678+ kind = (kindAndCode >> 16) & 65535;
2679+ code = kindAndCode & 65535;
2680+ if (kind == kMDEventTempo) {
2681+ /* Only conductor events can be pasted */
2682+ if (!hasConductorTrack)
2683+ return; /* Do nothing */
2684+ while (MDSequenceGetNumberOfTracks(seq) > 1)
2685+ MDSequenceDeleteTrack(seq, 1);
2686+ numberOfTracks = 1;
2687+ } else {
2688+ /* Conductor track should be ignored */
2689+ if (hasConductorTrack) {
2690+ MDSequenceDeleteTrack(seq, 0);
2691+ numberOfTracks--;
2692+ if (numberOfTracks == 0)
2693+ return; /* Do nothing */
2694+ hasConductorTrack = 0;
2695+ }
2696+ /* Delete events that do not match the kind and code */
2697+ ig = IntGroupNew();
2698+ if (kind == kMDEventInternalNoteOff || kind == kMDEventInternalDuration)
2699+ kind = kMDEventNote;
2700+ for (i = 0; i < numberOfTracks; i++) {
2701+ MDTrack *track = MDSequenceGetTrack(seq, i);
2702+ MDPointer *pt = MDPointerNew(track);
2703+ MDEvent *ep;
2704+ while ((ep = MDPointerForward(pt)) != NULL) {
2705+ if (MDGetKind(ep) == kind && (code == 65535 || MDGetCode(ep) == code))
2706+ continue;
2707+ IntGroupAdd(ig, MDPointerGetPosition(pt), 1);
2708+ }
2709+ if (IntGroupGetCount(ig) > 0)
2710+ MDTrackUnmerge(track, NULL, ig);
2711+ IntGroupClear(ig);
2712+ MDPointerRelease(pt);
2713+ }
2714+ IntGroupRelease(ig);
2715+ }
2716+ }
2717+
29172718 /* Look for the "editing" tracks */
29182719 for (i = j = 0; i < trackCount; i++) {
2919- MDTrackAttribute attr = [doc trackAttributeForTrack: i];
2920- if (attr & kMDTrackAttributeEditable) {
2921- trackList[j++] = i;
2922- if (j >= numberOfTracks)
2923- break;
2924- }
2720+ MDTrackAttribute attr = [doc trackAttributeForTrack: i];
2721+ if (focusTrack >= 0) {
2722+ if (i != focusTrack)
2723+ continue;
2724+ } else {
2725+ if ((attr & kMDTrackAttributeEditable) == 0)
2726+ continue;
2727+ }
2728+ if (j == 0) {
2729+ /* The first editable track: we need to check for the conductor track */
2730+ if (!hasConductorTrack && i == 0)
2731+ continue; /* We should not target the conductor track */
2732+ if (hasConductorTrack && i != 0) {
2733+ /* We should target the conductor track */
2734+ trackList[j++] = 0;
2735+ if (j >= numberOfTracks)
2736+ break;
2737+ }
2738+ }
2739+ trackList[j++] = i;
2740+ if (j >= numberOfTracks)
2741+ break;
29252742 }
29262743 while (j < numberOfTracks) {
29272744 trackList[j++] = i++;
@@ -2938,7 +2755,7 @@
29382755 }
29392756 }
29402757 while (j < numberOfTracks) {
2941- trackList[j++] = i++;
2758+ trackList[j++] = i++;
29422759 }
29432760
29442761 } else return;
@@ -2996,7 +2813,7 @@
29962813 else return NO;
29972814 } else if (sel == @selector(paste:) || sel == @selector(pasteWithReplace:) || sel == @selector(merge:)) {
29982815 firstResponder = [[self window] firstResponder];
2999- if (firstResponder == myMainView || firstResponder == myTableView) {
2816+ if ([firstResponder isKindOfClass:[GraphicBackgroundView class]] || firstResponder == myTableView) {
30002817 if ([[self document] isSequenceInPasteboard])
30012818 return YES;
30022819 }
--- trunk/Classes/MyDocument.m (revision 142)
+++ trunk/Classes/MyDocument.m (revision 143)
@@ -3284,7 +3284,7 @@
32843284 track = MDSequenceGetTrack(seq, 0);
32853285 n = MDTrackGetNumberOfEvents(track);
32863286 if (MDTrackGetNumberOfNonMIDIEvents(track) < n)
3287- return 1; /* Try to insert non-MIDI events to the conductor track */
3287+ return 1; /* Try to insert MIDI events to the conductor track */
32883288 } else {
32893289 /* The first target track is the non-conductor track */
32903290 IntGroup *pset;
@@ -3303,7 +3303,7 @@
33033303 /* Delete existing events in the 'editing range' */
33043304 if (!mergeFlag) {
33053305 for (i = 0; i < numberOfTracks; i++) {
3306- if (trackList[i] >= trackCount)
3306+ if (trackList[i] < 0 || trackList[i] >= trackCount)
33073307 continue;
33083308 sel = [self eventSetInTrack: trackList[i] eventKind: -1 eventCode: -1 fromTick: startTick + tickOffset toTick: endTick + tickOffset fromData: -32768 toData: 32768 inPointSet: nil];
33093309 if (sel != nil)
Show on old repository browser