mirror of
https://github.com/microtherion/VocalEasel.git
synced 2025-01-03 17:04:00 +00:00
Implement alternate colors
This commit is contained in:
parent
25d151d5af
commit
ee87f6a76b
|
@ -492,18 +492,36 @@ const char * sBreak[3] = {"", "\xE2\xA4\xBE", "\xE2\x8E\x98"};
|
||||||
|
|
||||||
- (void)drawBackgroundForSystem:(int)system
|
- (void)drawBackgroundForSystem:(int)system
|
||||||
{
|
{
|
||||||
|
const VLSong * song = [self song];
|
||||||
const float kSystemY = [self systemY:system];
|
const float kSystemY = [self systemY:system];
|
||||||
const float kLineW = (*fLayout)[system].SystemWidth();
|
const float kLineW = (*fLayout)[system].SystemWidth();
|
||||||
|
const bool kAltColors = song->fMeasures[fLayout->FirstMeasure(system)].fPropIdx & 1;
|
||||||
|
|
||||||
NSArray * colors = [NSColor controlAlternatingRowBackgroundColors];
|
NSArray * colors = [NSColor controlAlternatingRowBackgroundColors];
|
||||||
|
NSColor * bgColor= [colors objectAtIndex:0];
|
||||||
|
NSColor * fgColor= [colors objectAtIndex:1];
|
||||||
|
if (kAltColors) {
|
||||||
|
float hue, saturation, brightness, alpha;
|
||||||
|
|
||||||
|
[[fgColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getHue:&hue saturation:&saturation
|
||||||
|
brightness:&brightness alpha:&alpha];
|
||||||
|
|
||||||
|
if (saturation) // Color
|
||||||
|
hue = fmod(hue-0.5f, 1.0f);
|
||||||
|
else // Black & white
|
||||||
|
brightness -= 0.05f;
|
||||||
|
|
||||||
|
fgColor = [NSColor colorWithCalibratedHue:hue saturation:saturation
|
||||||
|
brightness:brightness alpha:alpha];
|
||||||
|
}
|
||||||
[NSGraphicsContext saveGraphicsState];
|
[NSGraphicsContext saveGraphicsState];
|
||||||
[[colors objectAtIndex:1] setFill];
|
[fgColor setFill];
|
||||||
[NSBezierPath fillRect:
|
[NSBezierPath fillRect:
|
||||||
NSMakeRect(kLineX, kSystemY-kSystemBaseline,
|
NSMakeRect(kLineX, kSystemY-kSystemBaseline,
|
||||||
kLineW, fNumStanzas*kLyricsH)];
|
kLineW, fNumStanzas*kLyricsH)];
|
||||||
[NSBezierPath fillRect:
|
[NSBezierPath fillRect:
|
||||||
NSMakeRect(kLineX, kSystemY+kChordY, kLineW, kChordH)];
|
NSMakeRect(kLineX, kSystemY+kChordY, kLineW, kChordH)];
|
||||||
[[colors objectAtIndex:0] setFill];
|
[bgColor setFill];
|
||||||
[NSBezierPath fillRect:
|
[NSBezierPath fillRect:
|
||||||
NSMakeRect(kLineX, kSystemY-kSystemBaseline+fNumStanzas*kLyricsH,
|
NSMakeRect(kLineX, kSystemY-kSystemBaseline+fNumStanzas*kLyricsH,
|
||||||
kLineW, kSystemBaseline+kChordY-fNumStanzas*kLyricsH)];
|
kLineW, kSystemBaseline+kChordY-fNumStanzas*kLyricsH)];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user