mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-23 03:34:00 +00:00
Implement ledger lines
This commit is contained in:
parent
75a06d832c
commit
ad307e2e75
|
@ -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;
|
||||||
|
|
|
@ -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, ¬eDur, &triplet);
|
prop.VisualNote(at, partialDur, triplet, ¬eDur, &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],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user