diff --git a/English.lproj/VLDocument.xib b/English.lproj/VLDocument.xib index afd9ea9..8b922ec 100644 --- a/English.lproj/VLDocument.xib +++ b/English.lproj/VLDocument.xib @@ -2,10 +2,10 @@ 1070 - 11C48 + 11B26 1617 - 1138.18 - 567.00 + 1138 + 566.00 com.apple.InterfaceBuilder.CocoaPlugin 1617 @@ -1584,7 +1584,7 @@ - {{0, 0}, {1440, 878}} + {{0, 0}, {2560, 1418}} {890, 428} {10000000000000, 10000000000000} 128 @@ -1800,7 +1800,7 @@ {338, 127} - {{0, 0}, {1440, 878}} + {{0, 0}, {2560, 1418}} {213, 129} {10000000000000, 10000000000000} YES @@ -2385,7 +2385,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA {372, 142} - {{0, 0}, {1440, 878}} + {{0, 0}, {2560, 1418}} {213, 129} {10000000000000, 10000000000000} YES @@ -2403,7 +2403,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA {213, 107} - + 256 @@ -2411,6 +2411,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA256 {{334, 12}, {82, 32}} + 1001 YES @@ -2435,6 +2436,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA256 {{416, 12}, {113, 32}} + + 1000 YES @@ -2466,6 +2469,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA256 {{109, 72}, {69, 17}} + YES @@ -2483,6 +2487,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA256 {{164, 66}, {65, 26}} + YES @@ -2575,6 +2580,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA256 {{109, 46}, {62, 17}} + YES @@ -2592,6 +2598,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA256 {{164, 40}, {65, 26}} + YES @@ -2684,6 +2691,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA256 {{15, 72}, {92, 17}} + YES @@ -2701,6 +2709,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA256 {{15, 14}, {114, 17}} + YES @@ -2718,6 +2727,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA256 {{164, 8}, {65, 26}} + YES @@ -2853,11 +2863,13 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA {{1, 1}, {244, 100}} + {{17, 200}, {246, 116}} + {0, 0} @@ -2890,6 +2902,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{156, 153}, {60, 26}} + YES @@ -2972,6 +2985,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{99, 158}, {54, 17}} + YES @@ -2989,6 +3003,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{97, 214}, {54, 17}} + YES @@ -3006,6 +3021,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{15, 185}, {69, 17}} + YES @@ -3023,6 +3039,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{99, 185}, {54, 17}} + YES @@ -3040,6 +3057,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{156, 181}, {60, 26}} + YES @@ -3121,6 +3139,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{76, 103}, {77, 17}} + YES @@ -3138,6 +3157,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{15, 130}, {55, 17}} + YES @@ -3155,6 +3175,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{120, 130}, {33, 17}} + YES @@ -3172,6 +3193,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{156, 126}, {60, 26}} + YES @@ -3254,6 +3276,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{156, 99}, {60, 26}} + YES @@ -3336,6 +3359,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{55, 75}, {98, 17}} + YES @@ -3353,6 +3377,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{156, 71}, {60, 26}} + YES @@ -3435,6 +3460,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{59, 47}, {94, 17}} + YES @@ -3452,6 +3478,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{156, 43}, {60, 26}} + YES @@ -3534,6 +3561,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{65, 19}, {88, 17}} + YES @@ -3551,6 +3579,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{156, 15}, {60, 26}} + YES @@ -3633,6 +3662,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{156, 209}, {60, 26}} + YES @@ -3714,6 +3744,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA268 {{15, 214}, {69, 17}} + YES @@ -3729,11 +3760,13 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA {{1, 1}, {231, 243}} + {{293, 56}, {233, 259}} + {0, 0} @@ -3755,9 +3788,11 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA {537, 336} + + - {{0, 0}, {1440, 878}} + {{0, 0}, {2560, 1418}} {213, 129} {10000000000000, 10000000000000} YES @@ -4077,54 +4112,6 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 265 - - - selectedIndex: editNumTopLedgers - - - - - - selectedIndex: editNumTopLedgers - selectedIndex - editNumTopLedgers - 2 - - - 325 - - - - selectedIndex: editNumBotLedgers - - - - - - selectedIndex: editNumBotLedgers - selectedIndex - editNumBotLedgers - 2 - - - 326 - - - - selectedIndex: editNumStanzas - - - - - - selectedIndex: editNumStanzas - selectedIndex - editNumStanzas - 2 - - - 327 - fDisplaySheet @@ -4469,6 +4456,62 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 100521 + + + selectedIndex: sheetView.numTopLedgers + + + + + + selectedIndex: sheetView.numTopLedgers + selectedIndex + sheetView.numTopLedgers + 2 + + + 100523 + + + + selectedIndex: sheetView.numBotLedgers + + + + + + selectedIndex: sheetView.numBotLedgers + selectedIndex + sheetView.numBotLedgers + 2 + + + 100524 + + + + selectedIndex: sheetView.numStanzas + + + + + + selectedIndex: sheetView.numStanzas + selectedIndex + sheetView.numStanzas + 2 + + + 100525 + + + + displaySheet + + + + 100526 + @@ -6447,7 +6490,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA - 100521 + 100526 @@ -6469,126 +6512,6 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA - - IKImageView - - crop: - id - - - crop: - - crop: - id - - - - IBProjectSource - ./Classes/IKImageView.h - - - - NSDocument - - id - id - id - id - id - id - - - - printDocument: - id - - - revertDocumentToSaved: - id - - - runPageLayout: - id - - - saveDocument: - id - - - saveDocumentAs: - id - - - saveDocumentTo: - id - - - - IBProjectSource - ./Classes/NSDocument.h - - - - VLDocument - NSDocument - - id - id - id - id - id - id - - - - adjustTempo: - id - - - dump: - id - - - play: - id - - - playMusic: - id - - - playStop: - id - - - stop: - id - - - - IBProjectSource - ./Classes/VLDocument.h - - - - VLLogWindow - NSWindowController - - log - id - - - log - - log - id - - - - IBProjectSource - ./Classes/VLLogWindow.h - - VLPDFWindow NSWindowController @@ -6618,7 +6541,6 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAAid id id - id id id id @@ -6632,6 +6554,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAAid id id + id + id @@ -6646,10 +6570,6 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAAdelete: id - - editDisplayOptions: - id - editRepeat: id @@ -6702,9 +6622,16 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAAtransposeOctave: id + + zoomIn: + id + + + zoomOut: + id + - id id id id @@ -6716,10 +6643,6 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAAid - - fDisplaySheet - id - fDivisionMenu id @@ -6766,26 +6689,61 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAAVLSheetWindow NSWindowController + id + id + id id + id id + id + id + + adjustTempo: + id + + + playMusic: + id + + + playStop: + id + showOutput: id + + stop: + id + togglePlayElements: id + + zoomIn: + id + + + zoomOut: + id + + NSWindow VLLogWindow VLPDFWindow NSProgressIndicator VLSheetView + + displaySheet + NSWindow + logWin VLLogWindow @@ -6808,14 +6766,6 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA./Classes/VLSheetWindow.h - - VLToolbarButton - NSButton - - IBProjectSource - ./Classes/VLToolbarButton.h - - 0 diff --git a/Sources/VLDocument.h b/Sources/VLDocument.h index 4ebbced..623853b 100644 --- a/Sources/VLDocument.h +++ b/Sources/VLDocument.h @@ -53,13 +53,13 @@ enum { int playElements; NSURL * tmpURL; NSFileWrapper * vcsWrapper; - NSMutableArray* observers; NSMutableDictionary*validTmpFiles; int repeatVolta; bool brandNew; bool hasMusicSequence; VLSheetWindow * sheetWin; VLKeyValueUndo* undo; + VLKeyValueUndo* staffMetrics; NSRange previewRange; float playRate; float baseTempo; @@ -95,7 +95,6 @@ enum { - (void) changedFileWrapper; - (void) willChangeSong; - (void) didChangeSong; -- (void) addObserver:(id)observer; @end diff --git a/Sources/VLDocument.mm b/Sources/VLDocument.mm index dd98dfc..d422131 100644 --- a/Sources/VLDocument.mm +++ b/Sources/VLDocument.mm @@ -104,7 +104,6 @@ brandNew = true; hasMusicSequence = false; playRate = 1.0; - observers = [[NSMutableArray alloc] init]; validTmpFiles = [[NSMutableDictionary alloc] initWithCapacity:10]; [self setHasUndoManager:YES]; undo = @@ -117,6 +116,22 @@ @"", @"songGroove", @"", @"songTempo", nil]]; + staffMetrics = + [[VLKeyValueUndo alloc] initWithOwner:self + keysAndNames:[NSDictionary dictionaryWithObjectsAndKeys: + @"", @"chordSize", + @"", @"lyricSize", + @"", @"staffSize", + @"", @"topPadding", + @"", @"titlePadding", + @"", @"staffPadding", + @"", @"chordPadding", + @"", @"lyricPadding", + nil] + update:^(NSString *keyPath) { + [validTmpFiles removeObjectForKey:@"ly"]; + [validTmpFiles removeObjectForKey:@"pdf"]; + }]; } return self; } @@ -128,15 +143,8 @@ [super updateChangeCount:changeType]; } -- (void) addObserver:(id)observer -{ - [observers addObject:observer]; -} - - (void) close { - [observers makeObjectsPerformSelector:@selector(removeObservers:) withObject:self]; - [observers removeAllObjects]; [super close]; } @@ -152,8 +160,8 @@ [songComposer release]; [songArranger release]; [vcsWrapper release]; + [staffMetrics release]; [undo release]; - [observers release]; if (tmpURL) { [[NSFileManager defaultManager] removeItemAtURL:tmpURL error:nil]; @@ -266,30 +274,6 @@ [self didChangeSong]; } -- (void) setChordSize:(float)size -{ - [[[self undoManager] prepareWithInvocationTarget:self] setChordSize:chordSize]; - chordSize = size; - [validTmpFiles removeObjectForKey:@"ly"]; - [validTmpFiles removeObjectForKey:@"pdf"]; -} - -- (void) setLyricSize:(float)size -{ - [[[self undoManager] prepareWithInvocationTarget:self] setLyricSize:lyricSize]; - lyricSize = size; - [validTmpFiles removeObjectForKey:@"ly"]; - [validTmpFiles removeObjectForKey:@"pdf"]; -} - -- (void) setStaffSize:(float)size -{ - [[[self undoManager] prepareWithInvocationTarget:self] setStaffSize:staffSize]; - staffSize = size; - [validTmpFiles removeObjectForKey:@"ly"]; - [validTmpFiles removeObjectForKey:@"pdf"]; -} - - (void)setPlayElements:(int)elements { [self willChangeValueForKey:@"playElements"]; diff --git a/Sources/VLKeyValueUndo.h b/Sources/VLKeyValueUndo.h index 04714fa..dbb8e18 100644 --- a/Sources/VLKeyValueUndo.h +++ b/Sources/VLKeyValueUndo.h @@ -6,16 +6,20 @@ // // (MN) Matthias Neeracher // -// Copyright © 2007 Matthias Neeracher +// Copyright © 2007-2011 Matthias Neeracher // #import +typedef void (^VLKeyValueUpdateHook)(NSString * keyPath); + @interface VLKeyValueUndo : NSObject { - id owner; - NSDictionary * keysAndNames; + id owner; + NSDictionary * keysAndNames; + VLKeyValueUpdateHook updateHook; } +- (id)initWithOwner:(id)owner keysAndNames:(NSDictionary *)keysAndNames update:(VLKeyValueUpdateHook)hook; - (id)initWithOwner:(id)owner keysAndNames:(NSDictionary *)keysAndNames; @end diff --git a/Sources/VLKeyValueUndo.mm b/Sources/VLKeyValueUndo.mm index 01295a9..1ad0810 100644 --- a/Sources/VLKeyValueUndo.mm +++ b/Sources/VLKeyValueUndo.mm @@ -14,12 +14,12 @@ @implementation VLKeyValueUndo -- (id)initWithOwner:(id)o keysAndNames:(NSDictionary *)kn +- (id)initWithOwner:(id)o keysAndNames:(NSDictionary *)kn update:(VLKeyValueUpdateHook)hook { owner = o; keysAndNames = [kn retain]; + updateHook = Block_copy(hook); - [owner addObserver:self]; for (NSEnumerator * e = [keysAndNames keyEnumerator]; NSString * key = [e nextObject]; ) @@ -30,17 +30,19 @@ return self; } -- (void)removeObservers:(id)target +- (id)initWithOwner:(id)o keysAndNames:(NSDictionary *)kn { - for (NSEnumerator * e = [keysAndNames keyEnumerator]; - NSString * key = [e nextObject]; - ) - [target removeObserver:self forKeyPath:key]; + return [self initWithOwner:o keysAndNames:kn update:nil]; } - (void) dealloc { + for (NSEnumerator * e = [keysAndNames keyEnumerator]; + NSString * key = [e nextObject]; + ) + [owner removeObserver:self forKeyPath:key]; [keysAndNames release]; + [updateHook release]; [super dealloc]; } @@ -55,6 +57,8 @@ [undo registerUndoWithTarget:owner selector:@selector(setValuesForKeysWithDictionary:) object: [NSDictionary dictionaryWithObjectsAndKeys: oldVal, keyPath, nil]]; [undo setActionName: name]; + if (updateHook) + updateHook(keyPath); } } diff --git a/Sources/VLSheetView.h b/Sources/VLSheetView.h index d512a66..0da0174 100644 --- a/Sources/VLSheetView.h +++ b/Sources/VLSheetView.h @@ -13,6 +13,7 @@ #import "VLModel.h" #import "VLLayout.h" +#import "VLKeyValueUndo.h" @class VLDocument; @@ -98,11 +99,11 @@ enum VLCursorVisual { size_t fHighlightStanza; bool fHighlightNow; bool fHighlightOne; + VLKeyValueUndo * fUndo; IBOutlet id fFieldEditor; IBOutlet id fRepeatSheet; IBOutlet id fEndingSheet; - IBOutlet id fDisplaySheet; IBOutlet id fRepeatMsg; IBOutlet id fEndingMsg; IBOutlet id fGrooveMenu; @@ -111,15 +112,19 @@ enum VLCursorVisual { IBOutlet id fDivisionMenu; } +@property (nonatomic) int numTopLedgers; +@property (nonatomic) int numBotLedgers; +@property (nonatomic) int numStanzas; + - (IBAction) setKey:(id)sender; - (IBAction) setTime:(id)sender; - (IBAction) setDivisions:(id)sender; - (IBAction) hideFieldEditor:(id)sender; - (IBAction) endSheetWithButton:(id)sender; - (IBAction) selectGroove:(id)sender; -- (IBAction) editDisplayOptions:(id)sender; - (IBAction) transposeOctave:(id)sender; - +- (IBAction) zoomIn: (id) sender; +- (IBAction) zoomOut: (id) sender; - (VLDocument *) document; - (VLSong *) song; @@ -133,6 +138,7 @@ enum VLCursorVisual { - (VLMusicElement)accidentalForVisual:(uint16_t)visual; - (float) noteYInMeasure:(int)measure withGrid:(int)vertPos; - (float) noteXInMeasure:(int)measure at:(VLFraction)at; +- (void) needsRecalculation; - (void) scrollMeasureToVisible:(int)measure; @@ -151,6 +157,7 @@ enum VLCursorVisual { - (void) playWithGroove:(NSString *)groove; - (NSColor *)textBackgroundColorForSystem:(int)system; +- (void)removeObservers:(id)target; @end diff --git a/Sources/VLSheetView.mm b/Sources/VLSheetView.mm index f28c7bc..0805a40 100644 --- a/Sources/VLSheetView.mm +++ b/Sources/VLSheetView.mm @@ -25,6 +25,11 @@ @implementation VLSheetView +@synthesize + numTopLedgers = fNumTopLedgers, + numBotLedgers = fNumBotLedgers, + numStanzas = fNumStanzas; + static NSString * sElementNames[kMusicElements] = { @"g-clef", @"flat", @@ -105,10 +110,25 @@ static float sFlatPos[] = { fNumStanzas = 2; fLastMeasures = 0; fHighlightOne = false; + fUndo = [[VLKeyValueUndo alloc] + initWithOwner:self + keysAndNames:[NSDictionary dictionaryWithObjectsAndKeys: + @"", @"numTopLedgers", + @"", @"numBotLedgers", + @"", @"numStanzas", + nil]]; } return self; } +- (void)dealloc +{ + [self removeObservers:[self document]]; + delete [] fMusic; + [fUndo release]; + [super dealloc]; +} + - (BOOL)acceptsFirstResponder { return YES; @@ -292,6 +312,12 @@ static float sFlatPos[] = { fNeedsRecalc = kNoRecalc; } +- (void)needsRecalculation +{ + fNeedsRecalc = kRecalc; + [self setNeedsDisplay:YES]; +} + const char * sBreak[3] = {"", "\xE2\xA4\xBE", "\xE2\x8E\x98"}; - (void)drawGridForSystem:(int)system @@ -934,7 +960,6 @@ const float kSemiFloor = -1.0f*kLineH; { VLDocument * doc = [self document]; - [doc addObserver:self]; [doc addObserver:self forKeyPath:@"song" options:0 context:nil]; [doc addObserver:self forKeyPath:@"songKey" options:0 context:nil]; [doc addObserver:self forKeyPath:@"songTime" options:0 context:nil]; @@ -1004,49 +1029,5 @@ const float kSemiFloor = -1.0f*kLineH; [[self document] playWithGroove:groove inSections:[self sectionsInSelection]]; } -- (IBAction)editDisplayOptions:(id)sender -{ - NSUndoManager * undoMgr = [[self document] undoManager]; - [undoMgr setGroupsByEvent:NO]; - [undoMgr beginUndoGrouping]; - - VLSheetWindow * wc = [[self window] windowController]; - [wc setValue:[NSNumber numberWithInt:fNumTopLedgers] - forKey:@"editNumTopLedgers"]; - [wc setValue:[NSNumber numberWithInt:fNumBotLedgers] - forKey:@"editNumBotLedgers"]; - [wc setValue:[NSNumber numberWithInt:fNumStanzas] - forKey:@"editNumStanzas"]; - - [NSApp beginSheet:fDisplaySheet modalForWindow:[self window] - modalDelegate:self - didEndSelector:@selector(didEndDisplaySheet:returnCode:contextInfo:) - contextInfo:nil]; -} - -- (void)didEndDisplaySheet:(NSWindow *)sheet returnCode:(int)returnCode - contextInfo:(void *)ctx -{ - NSUndoManager * undoMgr = [[self document] undoManager]; - [undoMgr setActionName:@"Display Options"]; - [undoMgr endUndoGrouping]; - [undoMgr setGroupsByEvent:YES]; - - switch (returnCode) { - case NSAlertFirstButtonReturn: { - VLSheetWindow * wc = [[self window] windowController]; - fNumTopLedgers = [[wc valueForKey:@"editNumTopLedgers"] intValue]; - fNumBotLedgers = [[wc valueForKey:@"editNumBotLedgers"] intValue]; - fNumStanzas = [[wc valueForKey:@"editNumStanzas"] intValue]; - fNeedsRecalc = kRecalc; - [self setNeedsDisplay:YES]; - } break; - default: - [undoMgr undo]; - break; - } - [sheet orderOut:self]; -} - @end diff --git a/Sources/VLSheetWindow.h b/Sources/VLSheetWindow.h index 92f6b89..a3e71b8 100644 --- a/Sources/VLSheetWindow.h +++ b/Sources/VLSheetWindow.h @@ -28,11 +28,12 @@ @class VLLogWindow; @class VLPDFWindow; -@interface VLSheetWindow : NSWindowController { +@interface VLSheetWindow : NSWindowController { IBOutlet VLSheetView * sheetView; IBOutlet NSProgressIndicator * progressIndicator; IBOutlet VLLogWindow * logWin; IBOutlet VLPDFWindow * pdfWin; + IBOutlet NSWindow * displaySheet; id soundStartObserver; id soundStopObserver; @@ -52,6 +53,8 @@ - (IBAction) playStop:(id)sender; - (IBAction) playMusic:(id)sender; - (IBAction) adjustTempo:(id)sender; +- (IBAction) zoomIn: (id) sender; +- (IBAction) zoomOut: (id) sender; - (VLEditable *) editTarget; - (void) setEditTarget:(VLEditable *)editable; diff --git a/Sources/VLSheetWindow.mm b/Sources/VLSheetWindow.mm index 404e439..ce87133 100644 --- a/Sources/VLSheetWindow.mm +++ b/Sources/VLSheetWindow.mm @@ -13,6 +13,8 @@ #import "VLPDFWindow.h" #import "VLLogWindow.h" #import "VLSoundOut.h" +#import "VLSheetView.h" +#import "VLSheetViewSelection.h" @implementation VLEditable @@ -189,5 +191,40 @@ [[self document] setSongTempo:[[self document] songTempo]+[sender tag]]; } +- (IBAction)editDisplayOptions:(id)sender +{ + NSUndoManager * undoMgr = [[self document] undoManager]; + [undoMgr setGroupsByEvent:NO]; + [undoMgr beginUndoGrouping]; + + [NSApp beginSheet:displaySheet modalForWindow:[self window] + modalDelegate:self + didEndSelector:@selector(didEndDisplaySheet:returnCode:contextInfo:) + contextInfo:nil]; +} + +- (void)didEndDisplaySheet:(NSWindow *)sheet returnCode:(int)returnCode + contextInfo:(void *)ctx +{ + NSUndoManager * undoMgr = [[self document] undoManager]; + [undoMgr setActionName:@"Display Options"]; + [undoMgr endUndoGrouping]; + [undoMgr setGroupsByEvent:YES]; + + switch (returnCode) { + case NSAlertFirstButtonReturn: + [sheetView needsRecalculation]; + break; + default: + [undoMgr undo]; + break; + } + [sheet orderOut:self]; +} + +- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window +{ + return [[self document] undoManager]; +} @end