From 86456c84226ecca55f8c3761150e9a01d873b948 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Sat, 19 May 2012 22:37:58 +0200 Subject: [PATCH] Centralize drawing method (tried to switch to drawAtPoint, but that does the wrong thing) --- .DS_Store | Bin 6148 -> 6148 bytes Sources/VLSheetView.h | 9 ++++++++- Sources/VLSheetView.mm | 34 +++++++++++++++++++--------------- Sources/VLSheetViewNotes.mm | 20 ++++++-------------- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/.DS_Store b/.DS_Store index 0d55d6a5edfa36b20d8a24e2d5f459e181c81103..780ac67805d418289c4a93e6670e990bd95d1e5d 100644 GIT binary patch delta 46 ycmZoMXfc@J&&W72z#2&O=<=r<1}Ep|7BGMSlj4=lf{fqTCMz&{Zf58B%MSo8fDGOM delta 61 zcmZoMXfc@J&&V_}zv+{_+C=Ed&yw diff --git a/Sources/VLSheetView.h b/Sources/VLSheetView.h index d8a122d..5052935 100644 --- a/Sources/VLSheetView.h +++ b/Sources/VLSheetView.h @@ -5,7 +5,7 @@ // // (MN) Matthias Neeracher // -// Copyright © 2005-2011 Matthias Neeracher +// Copyright © 2005-2012 Matthias Neeracher // #import @@ -161,6 +161,13 @@ const uint32_t kNoMeasure = (uint32_t)-1; @end +@interface NSImage (VLSheetViewDrawing) + +- (void) drawAllAtPoint:(NSPoint)p operation:(NSCompositingOperation)op; +- (void) drawAllAtPoint:(NSPoint)p; + +@end + // Local Variables: // mode:ObjC // End: diff --git a/Sources/VLSheetView.mm b/Sources/VLSheetView.mm index 21aad1a..9ab247d 100644 --- a/Sources/VLSheetView.mm +++ b/Sources/VLSheetView.mm @@ -457,9 +457,7 @@ const char * sBreak[3] = {"", "\xE2\xA4\xBE", "\xE2\x8E\x98"}; [bz setLineWidth:2.0]; } if (song->fGoToCoda == m || song->fCoda == m) - [[self musicElement:kMusicCoda] - compositeToPoint: NSMakePoint(x+kCodaX, yy+kCodaY) - operation: NSCompositeSourceOver]; + [[self musicElement:kMusicCoda] drawAllAtPoint:NSMakePoint(x+kCodaX, yy+kCodaY)]; } } @@ -485,9 +483,7 @@ const char * sBreak[3] = {"", "\xE2\xA4\xBE", "\xE2\x8E\x98"}; // // Draw clef // - [[self musicElement:kMusicGClef] - compositeToPoint: NSMakePoint(kClefX, kSystemY+kClefY) - operation: NSCompositeSourceOver]; + [[self musicElement:kMusicGClef] drawAllAtPoint:NSMakePoint(kClefX, kSystemY+kClefY)]; // // Draw measure # // @@ -500,19 +496,13 @@ const char * sBreak[3] = {"", "\xE2\xA4\xBE", "\xE2\x8E\x98"}; if (kProp.fKey > 0) { float x = kClefX+kClefW; for (int i=0; ikProp.fKey; ++i) { - [[self musicElement: kMusicFlat] - compositeToPoint: - NSMakePoint(x, kSystemY+sFlatPos[i]+kFlatY) - operation: NSCompositeSourceOver]; + [[self musicElement: kMusicFlat] drawAllAtPoint:NSMakePoint(x, kSystemY+sFlatPos[i]+kFlatY)]; x += kAccW; } } @@ -1050,4 +1040,18 @@ const float kSemiFloor = -1.0f*kLineH; } @end - + +@implementation NSImage (VLSheetViewDrawing) + +- (void) drawAllAtPoint:(NSPoint)p operation:(NSCompositingOperation)op +{ + [self compositeToPoint:p operation:op]; +} + +- (void) drawAllAtPoint:(NSPoint)p +{ + [self compositeToPoint:p operation:NSCompositeSourceOver]; +} + +@end + diff --git a/Sources/VLSheetViewNotes.mm b/Sources/VLSheetViewNotes.mm index 76522ad..0ec795f 100644 --- a/Sources/VLSheetViewNotes.mm +++ b/Sources/VLSheetViewNotes.mm @@ -127,9 +127,7 @@ } NSPoint xy = NSMakePoint(cursorX-kNoteX, cursorY); - [[self musicElement:cursorElt] - compositeToPoint:xy - operation: NSCompositeSourceOver]; + [[self musicElement:cursorElt] drawAllAtPoint:xy]; if (accidental) { xy.y += kNoteY; @@ -156,9 +154,7 @@ xy.y += kNaturalY; break; } - [[self musicElement:accidental] - compositeToPoint:xy - operation: NSCompositeSourceOver]; + [[self musicElement:accidental] drawAllAtPoint:xy]; } } @@ -198,8 +194,7 @@ s.x -= 2.0f; break; } - [head compositeToPoint:p - operation: NSCompositePlusDarker]; + [head drawAllAtPoint:p operation:NSCompositePlusDarker]; // // Draw accidental // @@ -230,8 +225,7 @@ default: break; } - [[self musicElement:accidental] - compositeToPoint:at operation: NSCompositeSourceOver]; + [[self musicElement:accidental] drawAllAtPoint:at]; } // // Draw stem @@ -261,8 +255,7 @@ [bz lineToPoint:s1]; [bz stroke]; if (flag) - [flag compositeToPoint:s - operation: NSCompositePlusDarker]; + [flag drawAllAtPoint:s operation:NSCompositePlusDarker]; } // // Draw tie @@ -319,8 +312,7 @@ p.x -= kNoteX; break; } - [head compositeToPoint:p - operation: NSCompositeSourceOver]; + [head drawAllAtPoint:p]; } - (void) drawTuplet:(uint16_t)tuplet bracketFrom:(int)startX to:(int)endX atY:(int)y