Fix selection behavior

This commit is contained in:
Matthias Neeracher 2011-09-08 03:11:33 +02:00
parent 46b56bbf4a
commit 0ddfe26ffb
2 changed files with 10 additions and 17 deletions

View File

@ -88,6 +88,7 @@ enum VLCursorVisual {
size_t fCursorStanza;
int fSelStart;
int fSelEnd;
int fSelAnchor;
int fNumTopLedgers;
int fNumBotLedgers;
int fNumStanzas;

View File

@ -111,47 +111,39 @@ VLSequenceCallback(
- (void)editSelection
{
fSelStart = fSelEnd = fCursorMeasure;
fSelStart = fSelEnd = fSelAnchor = fCursorMeasure;
[self updateMenus];
[self setNeedsDisplay:YES];
}
- (void)adjustSelection:(NSEvent *)event
{
int prevMeasure = fCursorMeasure;
switch ([self findRegionForEvent:event]) {
case kRegionNote:
case kRegionChord:
case kRegionLyrics:
if (fCursorAt.fNum)
++fCursorMeasure;
if (fCursorAt.fNum > 0 && fCursorMeasure >= fSelAnchor)
++fCursorMeasure;
//
// Fall through
//
case kRegionMeasure:
fCursorMeasure =
std::max(0, std::min<int>(fCursorMeasure, [self song]->CountMeasures()));
if (fCursorMeasure > fSelEnd) {
if (fCursorMeasure >= fSelAnchor) {
fSelStart = fSelAnchor;
fSelEnd = fCursorMeasure;
[self updateMenus];
[self setNeedsDisplay:YES];
} else if (fCursorMeasure < fSelStart) {
fSelStart = fCursorMeasure;
[self updateMenus];
[self setNeedsDisplay:YES];
} else if (prevMeasure == fSelEnd && fCursorMeasure<prevMeasure) {
fSelEnd = fCursorMeasure;
[self updateMenus];
[self setNeedsDisplay:YES];
} else if (prevMeasure == fSelStart && fCursorMeasure>prevMeasure) {
} else {
fSelStart = fCursorMeasure;
fSelEnd = fSelAnchor;
[self updateMenus];
[self setNeedsDisplay:YES];
}
break;
default:
fCursorMeasure = prevMeasure;
break;
default:
break;
}
fCursorRegion = kRegionMeasure;
}