Implement ledger lines

This commit is contained in:
Matthias Neeracher 2007-04-21 22:34:55 +00:00
parent 75a06d832c
commit ad307e2e75
2 changed files with 31 additions and 3 deletions

View File

@ -42,4 +42,5 @@ const float kHalfRestY = 15.0f;
const float kTieDepth = 10.0f; const float kTieDepth = 10.0f;
const float kCodaX =-10.0f; const float kCodaX =-10.0f;
const float kCodaY = 5.0f; const float kCodaY = 5.0f;
const int kMaxLedgers = 3; const float kLedgerX =-10.0f;
const float kLedgerW = 20.0f;

View File

@ -45,6 +45,28 @@
} }
} }
- (void) drawLedgerLinesWithPitch:(int)pitch at:(NSPoint)p
{
p.x += kLedgerX;
int octave = (pitch / 12) - 5;
int step = (octave*7+[self stepWithPitch:pitch]-2)/2;
for (int i=0; i-- > step; ) {
NSPoint p0 = p;
p0.y += i*kLineH;
NSPoint p1 = p0;
p1.x += kLedgerW;
[NSBezierPath strokeLineFromPoint:p0 toPoint:p1];
}
for (int i=4; i++ < step; ) {
NSPoint p0 = p;
p0.y += i*kLineH;
NSPoint p1 = p0;
p1.x += kLedgerW;
[NSBezierPath strokeLineFromPoint:p0 toPoint:p1];
}
}
- (void) drawNoteCursor - (void) drawNoteCursor
{ {
int cursorX; int cursorX;
@ -52,7 +74,7 @@
VLMusicElement accidental; VLMusicElement accidental;
VLMusicElement cursorElt; VLMusicElement cursorElt;
cursorX = [self noteXInMeasure:fCursorMeasure at:fCursorAt]-kNoteX; cursorX = [self noteXInMeasure:fCursorMeasure at:fCursorAt];
switch (fClickMode) { switch (fClickMode) {
default: default:
cursorY = cursorY =
@ -60,6 +82,9 @@
withPitch:fCursorPitch withPitch:fCursorPitch
accidental:&accidental] accidental:&accidental]
-kNoteY; -kNoteY;
[self drawLedgerLinesWithPitch:fCursorPitch
at:NSMakePoint(cursorX,
[self systemY:fCursorMeasure/fMeasPerSystem])];
cursorElt = kMusicNoteCursor; cursorElt = kMusicNoteCursor;
break; break;
case 'r': case 'r':
@ -76,7 +101,7 @@
break; break;
} }
NSPoint at = NSMakePoint(cursorX, cursorY); NSPoint at = NSMakePoint(cursorX-kNoteX, cursorY);
[[self musicElement:cursorElt] [[self musicElement:cursorElt]
compositeToPoint:at compositeToPoint:at
operation: NSCompositeSourceOver]; operation: NSCompositeSourceOver];
@ -279,6 +304,8 @@
prop.VisualNote(at, partialDur, triplet, &noteDur, &triplet); prop.VisualNote(at, partialDur, triplet, &noteDur, &triplet);
prevDur = partialDur; prevDur = partialDur;
if (pitch != VLNote::kNoPitch) { if (pitch != VLNote::kNoPitch) {
[self drawLedgerLinesWithPitch:pitch
at:NSMakePoint([self noteXInMeasure:m at:at], kSystemY)];
VLMusicElement accidental; VLMusicElement accidental;
NSPoint pos = NSPoint pos =
NSMakePoint([self noteXInMeasure:m at:at], NSMakePoint([self noteXInMeasure:m at:at],