• R/O
  • SSH
  • HTTPS

alchemusica: 提交


Commit MetaInfo

修订版8 (tree)
时间2011-10-02 01:24:49
作者toshinagata1964

Log Message

Solo track capability is implemented.

更改概述

差异

--- trunk/Classes/MyDocument.m (revision 7)
+++ trunk/Classes/MyDocument.m (revision 8)
@@ -908,7 +908,7 @@
908908 if (MDSequenceSetMuteFlagOnTrack(sequence, trackNo, flag)) {
909909 [[[self undoManager] prepareWithInvocationTarget: self]
910910 setTrackAttributes: attr];
911- [self enqueueTrackModifiedNotification: trackNo];
911+ // [self enqueueTrackModifiedNotification: trackNo];
912912 [self updateTrackDestinations];
913913 return YES;
914914 }
@@ -924,7 +924,7 @@
924924 if (MDSequenceSetSoloFlagOnTrack(sequence, trackNo, flag)) {
925925 [[[self undoManager] prepareWithInvocationTarget: self]
926926 setTrackAttributes: attr];
927- [self enqueueTrackModifiedNotification: trackNo];
927+ // [self enqueueTrackModifiedNotification: trackNo];
928928 [self updateTrackDestinations];
929929 return YES;
930930 }
--- trunk/Classes/GraphicWindowController.h (revision 7)
+++ trunk/Classes/GraphicWindowController.h (revision 8)
@@ -129,6 +129,9 @@
129129 // Zoom/unzoom buffer and current position
130130 NSMutableArray *zoomUndoBuffer;
131131 int zoomUndoIndex;
132+
133+ // Selected tracks when the selection changed last
134+ NSIndexSet *lastSelectedTracks;
132135 }
133136
134137 //+ (NSCursor *)horizontalMoveCursor;
--- trunk/Classes/GraphicWindowController.m (revision 7)
+++ trunk/Classes/GraphicWindowController.m (revision 8)
@@ -66,7 +66,7 @@
6666
6767 /* IDs for track list tableView */
6868 static NSString *sTableColumnIDs[] = {
69- @"number", @"edit", @"visible", @"name", @"ch", @"mute", @"device"
69+ @"number", @"edit", @"visible", @"name", @"ch", @"solo", @"mute", @"device"
7070 };
7171
7272 enum {
@@ -75,8 +75,9 @@
7575 kVisibleID = 2,
7676 kTrackNameID = 3,
7777 kChannelID = 4,
78- kMuteID = 5,
79- kDeviceNameID = 6
78+ kSoloID = 5,
79+ kMuteID = 6,
80+ kDeviceNameID = 7
8081 };
8182
8283 static NSImage *sPencilSmallImage = NULL;
@@ -83,6 +84,11 @@
8384 static NSImage *sEyeOpenImage = NULL;
8485 static NSImage *sEyeCloseImage = NULL;
8586 static NSImage *sSpeakerImage = NULL;
87+static NSImage *sSpeakerGrayImage = NULL;
88+static NSImage *sMuteImage = NULL;
89+static NSImage *sMuteNonImage = NULL;
90+static NSImage *sSoloImage = NULL;
91+static NSImage *sSoloNonImage = NULL;
8692
8793 static NSString *sNeedsReloadClientViewNotification = @"reload client views";
8894
@@ -1755,16 +1761,30 @@
17551761 sEyeCloseImage = [[NSImage imageNamed: @"eye_close.png"] retain];
17561762 if (sSpeakerImage == NULL)
17571763 sSpeakerImage = [[NSImage imageNamed: @"speaker.png"] retain];
1758-
1759- for (i = 0; i < 3; i++) {
1760- static int s[] = {kEditableID, kVisibleID, kMuteID};
1764+ if (sSpeakerGrayImage == NULL)
1765+ sSpeakerGrayImage = [[NSImage imageNamed: @"speaker_gray.png"] retain];
1766+ if (sMuteImage == NULL)
1767+ sMuteImage = [[NSImage imageNamed: @"mute.png"] retain];
1768+ if (sMuteNonImage == NULL)
1769+ sMuteNonImage = [[NSImage imageNamed: @"mute_non.png"] retain];
1770+ if (sSoloImage == NULL)
1771+ sSoloImage = [[NSImage imageNamed: @"solo.png"] retain];
1772+ if (sSoloNonImage == NULL)
1773+ sSoloNonImage = [[NSImage imageNamed: @"solo_non.png"] retain];
1774+
1775+ for (i = 0; i < 4; i++) {
1776+ static int s[] = {kEditableID, kVisibleID, kSoloID, kMuteID};
17611777 // static NSString *n[] = {@"pencil_small.png", @"eye_open.png", @"speaker.png"};
1762- NSImage *im[] = {sPencilSmallImage, sEyeOpenImage, sSpeakerImage};
1778+ NSImage *im[] = {sPencilSmallImage, sEyeOpenImage, sSoloImage, sSpeakerImage};
17631779 tableColumn = [myTableView tableColumnWithIdentifier: sTableColumnIDs[s[i]]];
17641780 cell = [[[ColorCell alloc] init] autorelease];
17651781 [cell setTarget: self];
17661782 // [cell setAction: @selector(trackTableAction:)];
17671783 [cell setImage: im[i]];
1784+ if (s[i] == kSoloID) {
1785+ [cell setRepresentedObject:[NSColor colorWithDeviceRed:1.0 green:1.0 blue:0.3 alpha:1.0]];
1786+ [(ColorCell *)cell setStrokesColor:NO];
1787+ }
17681788 [tableColumn setDataCell: cell];
17691789 [[tableColumn headerCell] setImage: im[i]];
17701790 }
@@ -2337,13 +2357,22 @@
23372357 return [[[self document] myMIDISequence] deviceName: rowIndex];
23382358 case kEditableID:
23392359 case kVisibleID:
2360+ case kSoloID:
23402361 case kMuteID: {
23412362 MDTrackAttribute attr;
23422363 attr = [[[self document] myMIDISequence] trackAttributeAtIndex: rowIndex];
23432364 if (idnum == kEditableID) {
23442365 return (attr & kMDTrackAttributeEditable ? sPencilSmallImage : nil);
2366+ } else if (idnum == kSoloID) {
2367+ // return (attr & kMDTrackAttributeMute ? nil : sSpeakerImage);
2368+ return (attr & kMDTrackAttributeSolo ? sSoloImage : sSoloNonImage);
23452369 } else if (idnum == kMuteID) {
2346- return (attr & kMDTrackAttributeMute ? nil : sSpeakerImage);
2370+ // return (attr & kMDTrackAttributeMute ? nil : sSpeakerImage);
2371+ if (attr & kMDTrackAttributeMute)
2372+ return nil;
2373+ else if (attr & kMDTrackAttributeMuteBySolo)
2374+ return sSpeakerGrayImage;
2375+ else return sSpeakerImage;
23472376 } else if (idnum == kVisibleID) {
23482377 return (attr & kMDTrackAttributeHidden ? sEyeCloseImage : sEyeOpenImage);
23492378 } else return nil;
@@ -2378,16 +2407,15 @@
23782407
23792408 - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
23802409 {
2410+ MDTrackAttribute attr;
23812411 int idnum = sTableColumnIDToInt([aTableColumn identifier]);
23822412 if (idnum == kEditableID) {
2383- MDTrackAttribute attr;
23842413 [aCell setRepresentedObject: [self colorForTrack: rowIndex enabled: YES]];
23852414 attr = [[[self document] myMIDISequence] trackAttributeAtIndex: rowIndex];
2386- if (attr & kMDTrackAttributeHidden) {
2387- [aCell setFillsColor: NO];
2388- } else {
2389- [aCell setFillsColor: YES];
2390- }
2415+ [aCell setFillsColor:(attr & kMDTrackAttributeHidden) == 0];
2416+ } else if (idnum == kSoloID) {
2417+ attr = [[[self document] myMIDISequence] trackAttributeAtIndex: rowIndex];
2418+ [aCell setFillsColor: (attr & kMDTrackAttributeSolo) != 0];
23912419 } else if (idnum == kChannelID || idnum == kDeviceNameID) {
23922420 if (rowIndex == 0)
23932421 [aCell setEnabled: NO];
@@ -2472,6 +2500,7 @@
24722500 int idnum;
24732501 NSRect frame;
24742502 BOOL editableTrackWasHidden = NO;
2503+ BOOL shiftFlag = (([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask) != 0);
24752504
24762505 row = [myTableView clickedRow];
24772506 column = [myTableView clickedColumn];
@@ -2494,6 +2523,9 @@
24942523 case kEditableID:
24952524 attrMask = kMDTrackAttributeEditable;
24962525 break;
2526+ case kSoloID:
2527+ attrMask = kMDTrackAttributeSolo;
2528+ break;
24972529 case kMuteID:
24982530 attrMask = kMDTrackAttributeMute;
24992531 break;
@@ -2543,7 +2575,6 @@
25432575 return;
25442576 switch (idnum) {
25452577 case kEditableID: {
2546- BOOL shiftFlag = (([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask) != 0);
25472578 attr = [seq trackAttributeAtIndex: row];
25482579 if (attr & kMDTrackAttributeHidden)
25492580 break;
@@ -2557,6 +2588,9 @@
25572588 case kMuteID:
25582589 [doc setMuteFlagOnTrack: row flag: -1];
25592590 break;
2591+ case kSoloID:
2592+ [doc setSoloFlagOnTrack: row flag: -1];
2593+ break;
25602594 case kVisibleID:
25612595 attr = [seq trackAttributeAtIndex: row];
25622596 if (attr & kMDTrackAttributeHidden) {
@@ -2636,6 +2670,8 @@
26362670 } */
26372671 /* Rebuild sortedTrackNumbers later */
26382672 visibleTrackCount = -1;
2673+ [lastSelectedTracks release];
2674+ lastSelectedTracks = [[NSIndexSet alloc] initWithIndexSet:[myTableView selectedRowIndexes]];
26392675 [self setNeedsReloadClientViews];
26402676 }
26412677
--- trunk/Classes/ColorCell.h (revision 7)
+++ trunk/Classes/ColorCell.h (revision 8)
@@ -19,8 +19,10 @@
1919
2020 @interface ColorCell : NSActionCell {
2121 BOOL noFillsColor;
22+ BOOL noStrokesColor;
2223 }
2324 - (BOOL)fillsColor;
2425 - (void)setFillsColor: (BOOL)flag;
25-
26+- (BOOL)strokesColor;
27+- (void)setStrokesColor: (BOOL)flag;
2628 @end
--- trunk/Classes/ColorCell.m (revision 7)
+++ trunk/Classes/ColorCell.m (revision 8)
@@ -36,10 +36,10 @@
3636 rep = [self representedObject];
3737 if (rep != nil && [rep isKindOfClass: [NSColor class]]) {
3838 [rep set];
39- if (noFillsColor)
39+ if (!noFillsColor)
40+ NSRectFill(cellFrame);
41+ else if (!noStrokesColor)
4042 NSFrameRect(cellFrame);
41- else
42- NSRectFill(cellFrame);
4343 }
4444 image = [self objectValue];
4545 if (image != nil && [image isKindOfClass: [NSImage class]]) {
@@ -63,4 +63,14 @@
6363 noFillsColor = !flag;
6464 }
6565
66+- (BOOL)strokesColor
67+{
68+ return !noStrokesColor;
69+}
70+
71+- (void)setStrokesColor: (BOOL)flag
72+{
73+ noStrokesColor = !flag;
74+}
75+
6676 @end
--- trunk/Classes/MyMIDISequence.m (revision 7)
+++ trunk/Classes/MyMIDISequence.m (revision 8)
@@ -241,7 +241,10 @@
241241 if (mySequence != NULL) {
242242 MDTrack *track = MDSequenceGetTrack(mySequence, index);
243243 if (track != NULL) {
244+ MDTrackAttribute oldAttr = MDTrackGetAttribute(track);
244245 MDTrackSetAttribute(track, attribute);
246+ if ((oldAttr & kMDTrackAttributeSolo) != (attribute & kMDTrackAttributeSolo))
247+ MDSequenceUpdateMuteBySoloFlag(mySequence);
245248 }
246249 }
247250 }
--- trunk/MD_package/MDSequence.h (revision 7)
+++ trunk/MD_package/MDSequence.h (revision 8)
@@ -105,6 +105,9 @@
105105 /* index 番目のトラックの Mute フラグをセットする。flag = 0: OFF, 1: ON, -1: toggle */
106106 int MDSequenceSetMuteFlagOnTrack(MDSequence *inSequence, long index, int flag);
107107
108+/* MuteBySolo フラグを更新する。Solo フラグを変更したあと呼び出す。 */
109+void MDSequenceUpdateMuteBySoloFlag(MDSequence *inSequence);
110+
108111 /* Record フラグが立っているトラックの番号を得る。なければ -1 を返す。 */
109112 long MDSequenceGetIndexOfRecordingTrack(MDSequence *inSequence);
110113
--- trunk/MD_package/MDPlayer_MacOSX.c (revision 7)
+++ trunk/MD_package/MDPlayer_MacOSX.c (revision 8)
@@ -1511,10 +1511,6 @@
15111511 if (inPlayer == NULL || inPlayer->merger == NULL || (sequence = MDMergerGetSequence(inPlayer->merger)) == NULL)
15121512 return kMDNoError;
15131513
1514- oldTick = MDCalibratorTimeToTick(inPlayer->calib, inPlayer->time);
1515-
1516- MDMergerReset(inPlayer->merger);
1517-
15181514 num = MDSequenceGetNumberOfTracks(sequence);
15191515 inPlayer->trackNum = num;
15201516 inPlayer->destIndex = (long *)re_malloc(inPlayer->destIndex, num * sizeof(long));
@@ -1531,12 +1527,12 @@
15311527 if (temp == NULL)
15321528 return kMDErrorOutOfMemory;
15331529
1534- MDSequenceLock(sequence);
1535-
15361530 for (i = 0; i < inPlayer->destNum; i++)
15371531 temp[i] = inPlayer->destInfo[i]->dev;
15381532 origDestNum = inPlayer->destNum;
15391533
1534+ MDSequenceLock(sequence);
1535+
15401536 /* Update destIndex[] and destChannel[] */
15411537 for (n = 0; n < num; n++) {
15421538 MDTrack *track;
@@ -1571,10 +1567,11 @@
15711567 if (inPlayer->destInfo == NULL) {
15721568 status = kMDErrorOutOfMemory;
15731569 } else {
1570+ oldTick = MDCalibratorTimeToTick(inPlayer->calib, inPlayer->time);
1571+ /* MDMergerReset(inPlayer->merger); */
15741572 for (i = origDestNum; i < inPlayer->destNum; i++)
15751573 inPlayer->destInfo[i] = MDPlayerNewDestinationInfo(temp[i]);
1576-
1577- MDPlayerJumpToTick(inPlayer, oldTick);
1574+ /* MDPlayerJumpToTick(inPlayer, oldTick); */
15781575 status = kMDNoError;
15791576 }
15801577
@@ -1589,8 +1586,8 @@
15891586 MDStatus
15901587 MDPlayerJumpToTick(MDPlayer *inPlayer, MDTickType inTick)
15911588 {
1592- if (inPlayer->status == kMDPlayer_playing || inPlayer->status == kMDPlayer_exhausted)
1593- MDPlayerStop(inPlayer);
1589+/* if (inPlayer->status == kMDPlayer_playing || inPlayer->status == kMDPlayer_exhausted)
1590+ MDPlayerStop(inPlayer); */
15941591 MDMergerJumpToTick(inPlayer->merger, inTick);
15951592 MDCalibratorJumpToTick(inPlayer->calib, inTick);
15961593 /* inPlayer->tick = inTick; */
--- trunk/MD_package/MDSequence.c (revision 7)
+++ trunk/MD_package/MDSequence.c (revision 8)
@@ -258,7 +258,7 @@
258258 #pragma mark ====== MDTrack attribute manipulations ======
259259 #endif
260260
261-static void
261+void
262262 MDSequenceUpdateMuteBySoloFlag(MDSequence *inSequence)
263263 {
264264 MDTrack *track;
@@ -682,17 +682,19 @@
682682 void
683683 MDSequenceLock(MDSequence *inSequence)
684684 {
685+ int n;
685686 if (inSequence == NULL || inSequence->mutex == NULL)
686687 return;
687- pthread_mutex_lock(inSequence->mutex);
688+ n = pthread_mutex_lock(inSequence->mutex);
688689 }
689690
690691 void
691692 MDSequenceUnlock(MDSequence *inSequence)
692693 {
694+ int n;
693695 if (inSequence == NULL || inSequence->mutex == NULL)
694696 return;
695- pthread_mutex_unlock(inSequence->mutex);
697+ n = pthread_mutex_unlock(inSequence->mutex);
696698 }
697699
698700 int
Show on old repository browser