mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 11:14:00 +00:00
Fix selection behavior
This commit is contained in:
parent
46b56bbf4a
commit
0ddfe26ffb
|
@ -88,6 +88,7 @@ enum VLCursorVisual {
|
||||||
size_t fCursorStanza;
|
size_t fCursorStanza;
|
||||||
int fSelStart;
|
int fSelStart;
|
||||||
int fSelEnd;
|
int fSelEnd;
|
||||||
|
int fSelAnchor;
|
||||||
int fNumTopLedgers;
|
int fNumTopLedgers;
|
||||||
int fNumBotLedgers;
|
int fNumBotLedgers;
|
||||||
int fNumStanzas;
|
int fNumStanzas;
|
||||||
|
|
|
@ -111,47 +111,39 @@ VLSequenceCallback(
|
||||||
|
|
||||||
- (void)editSelection
|
- (void)editSelection
|
||||||
{
|
{
|
||||||
fSelStart = fSelEnd = fCursorMeasure;
|
fSelStart = fSelEnd = fSelAnchor = fCursorMeasure;
|
||||||
[self updateMenus];
|
[self updateMenus];
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)adjustSelection:(NSEvent *)event
|
- (void)adjustSelection:(NSEvent *)event
|
||||||
{
|
{
|
||||||
int prevMeasure = fCursorMeasure;
|
|
||||||
switch ([self findRegionForEvent:event]) {
|
switch ([self findRegionForEvent:event]) {
|
||||||
case kRegionNote:
|
case kRegionNote:
|
||||||
case kRegionChord:
|
case kRegionChord:
|
||||||
case kRegionLyrics:
|
case kRegionLyrics:
|
||||||
if (fCursorAt.fNum)
|
if (fCursorAt.fNum > 0 && fCursorMeasure >= fSelAnchor)
|
||||||
++fCursorMeasure;
|
++fCursorMeasure;
|
||||||
//
|
//
|
||||||
// Fall through
|
// Fall through
|
||||||
//
|
//
|
||||||
case kRegionMeasure:
|
case kRegionMeasure:
|
||||||
fCursorMeasure =
|
fCursorMeasure =
|
||||||
std::max(0, std::min<int>(fCursorMeasure, [self song]->CountMeasures()));
|
std::max(0, std::min<int>(fCursorMeasure, [self song]->CountMeasures()));
|
||||||
if (fCursorMeasure > fSelEnd) {
|
if (fCursorMeasure >= fSelAnchor) {
|
||||||
|
fSelStart = fSelAnchor;
|
||||||
fSelEnd = fCursorMeasure;
|
fSelEnd = fCursorMeasure;
|
||||||
[self updateMenus];
|
[self updateMenus];
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
} else if (fCursorMeasure < fSelStart) {
|
} else {
|
||||||
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) {
|
|
||||||
fSelStart = fCursorMeasure;
|
fSelStart = fCursorMeasure;
|
||||||
|
fSelEnd = fSelAnchor;
|
||||||
[self updateMenus];
|
[self updateMenus];
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fCursorMeasure = prevMeasure;
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
fCursorRegion = kRegionMeasure;
|
fCursorRegion = kRegionMeasure;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user