mirror of
https://github.com/microtherion/VocalEasel.git
synced 2025-01-22 01:53:59 +00:00
Refactor lyrics selection system
This commit is contained in:
parent
5dbd60e9d4
commit
5468cf0394
|
@ -95,11 +95,12 @@ enum VLCursorVisual {
|
|||
size_t fVolta;
|
||||
size_t fVoltaOK;
|
||||
VLLayout * fLayout;
|
||||
int fHighlightMeasure;
|
||||
VLFract fHighlightAt;
|
||||
int fHighlightStartMeasure;
|
||||
VLFract fHighlightStartAt;
|
||||
int fHighlightEndMeasure;
|
||||
VLFract fHighlightEndAt;
|
||||
size_t fHighlightStanza;
|
||||
bool fHighlightNow;
|
||||
bool fHighlightOne;
|
||||
VLKeyValueUndo * fUndo;
|
||||
|
||||
IBOutlet id fFieldEditor;
|
||||
|
|
|
@ -109,7 +109,6 @@ static float sFlatPos[] = {
|
|||
fNumBotLedgers = 2;
|
||||
fNumStanzas = 2;
|
||||
fLastMeasures = 0;
|
||||
fHighlightOne = false;
|
||||
fUndo = [[VLKeyValueUndo alloc]
|
||||
initWithOwner:self
|
||||
keysAndNames:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
|
@ -922,7 +921,6 @@ const float kSemiFloor = -1.0f*kLineH;
|
|||
default:
|
||||
[editable autorelease];
|
||||
fHighlightStanza = 0xFFFFFFFF;
|
||||
fHighlightOne = false;
|
||||
editable = nil;
|
||||
}
|
||||
[self setEditTarget:editable];
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//
|
||||
// (MN) Matthias Neeracher
|
||||
//
|
||||
// Copyright © 2006-2007 Matthias Neeracher
|
||||
// Copyright © 2006-2011 Matthias Neeracher
|
||||
//
|
||||
|
||||
#import "VLSheetWindow.h"
|
||||
|
@ -39,7 +39,8 @@
|
|||
- (void) editLyrics;
|
||||
- (void) drawLyricsForSystem:(int)system stanza:(size_t)stanza;
|
||||
- (void) highlightLyricsInStanza:(size_t)stanza measure:(int)measure at:(VLFraction)at;
|
||||
- (void) highlightTextInStanza:(size_t)stanza measure:(int)measure at:(VLFraction)at one:(BOOL)one;
|
||||
- (void) highlightTextInStanza:(size_t)stanza startMeasure:(int)startMeasure at:(VLFraction)startAt
|
||||
endMeasure:(int)endMeasure at:(VLFraction)endAt;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -18,6 +18,14 @@
|
|||
|
||||
@implementation VLLyricsEditable
|
||||
|
||||
- (void)highlightWord
|
||||
{
|
||||
size_t endMeas = fMeasure;
|
||||
VLFraction endAt = fAt;
|
||||
fSong->NextWord(fStanza, endMeas, endAt);
|
||||
[fView highlightTextInStanza:fStanza startMeasure:fMeasure at:fAt endMeasure:endMeas at:endAt];
|
||||
}
|
||||
|
||||
- (VLLyricsEditable *)initWithView:(VLSheetView *)view
|
||||
song:(VLSong *)song
|
||||
stanza:(int)stanza
|
||||
|
@ -36,9 +44,7 @@
|
|||
VLFraction At = fAt;
|
||||
fSong->FindWord(fStanza, fMeasure, At);
|
||||
fAt = At;
|
||||
[fView highlightTextInStanza:fStanza measure:fMeasure at:fAt one:NO];
|
||||
|
||||
[fView setNeedsDisplay: YES];
|
||||
[self highlightWord];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -79,7 +85,7 @@
|
|||
}
|
||||
fNextMeas = fMeasure;
|
||||
fNextAt = fAt;
|
||||
[fView highlightTextInStanza:fStanza measure:fMeasure at:fAt one:NO];
|
||||
[self highlightWord];
|
||||
[fView scrollMeasureToVisible:fMeasure];
|
||||
}
|
||||
|
||||
|
@ -94,7 +100,7 @@
|
|||
fAt = at;
|
||||
fNextMeas = fMeasure;
|
||||
fNextAt = fAt;
|
||||
[fView highlightTextInStanza:fStanza measure:fMeasure at:fAt one:NO];
|
||||
[self highlightWord];
|
||||
[fView scrollMeasureToVisible:fMeasure];
|
||||
}
|
||||
|
||||
|
@ -188,19 +194,21 @@ float VLCocoaFontHandler::Width(const char * utf8Text)
|
|||
} else {
|
||||
if (!fHighlightNow) {
|
||||
fHighlightNow = stanza == fHighlightStanza
|
||||
&& measIdx == fHighlightMeasure
|
||||
&& at == fHighlightAt;
|
||||
&& measIdx == fHighlightStartMeasure
|
||||
&& at == fHighlightStartAt;
|
||||
if (fHighlightNow && !sHighlightColor)
|
||||
sHighlightColor =
|
||||
[[self textBackgroundColorForSystem:system]
|
||||
shadowWithLevel:0.2];
|
||||
} else {
|
||||
fHighlightNow = fHighlightNow && stanza == fHighlightStanza
|
||||
&& (measIdx < fHighlightEndMeasure
|
||||
||(measIdx == fHighlightEndMeasure && at < fHighlightEndAt));
|
||||
}
|
||||
|
||||
text.AddSyllable(note->fLyrics[stanza-1],
|
||||
[self noteXInMeasure:measIdx at:at],
|
||||
fHighlightNow);
|
||||
fHighlightNow = fHighlightNow && !fHighlightOne &&
|
||||
note->fLyrics[stanza-1].fKind & VLSyllable::kHasNext;
|
||||
}
|
||||
at += note->fDuration;
|
||||
}
|
||||
|
@ -233,13 +241,15 @@ float VLCocoaFontHandler::Width(const char * utf8Text)
|
|||
NSRectFillUsingOperation(r, NSCompositePlusDarker);
|
||||
}
|
||||
|
||||
- (void) highlightTextInStanza:(size_t)stanza measure:(int)measure at:(VLFraction)at one:(BOOL)one
|
||||
- (void) highlightTextInStanza:(size_t)stanza startMeasure:(int)startMeasure at:(VLFraction)startAt
|
||||
endMeasure:(int)endMeasure at:(VLFraction)endAt
|
||||
{
|
||||
fHighlightStanza = stanza;
|
||||
fHighlightMeasure= measure;
|
||||
fHighlightAt = at;
|
||||
fHighlightStartMeasure = startMeasure;
|
||||
fHighlightStartAt = startAt;
|
||||
fHighlightEndMeasure = endMeasure;
|
||||
fHighlightEndAt = endAt;
|
||||
fHighlightNow = false;
|
||||
fHighlightOne = one;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -58,7 +58,9 @@
|
|||
else
|
||||
fNoteVert = VLPitchToGrid(event->fPitch, fNoteVisual, [fView song]->Properties(fNoteMeasure).fKey);
|
||||
fStanza = event->fStanza;
|
||||
[fView highlightTextInStanza:fStanza measure:fNoteMeasure at:fNoteAt one:YES];
|
||||
VLFraction endAt= fNoteAt+VLFraction(1,128);
|
||||
[fView highlightTextInStanza:fStanza startMeasure:fNoteMeasure at:fNoteAt
|
||||
endMeasure:fNoteMeasure at:endAt];
|
||||
} else {
|
||||
fChordMeasure = event->fMeasure;
|
||||
fChordAt = event->fAt;
|
||||
|
|
Loading…
Reference in New Issue
Block a user