Fixes to bugs #275 and #276, related to audio display.

Originally committed to SVN as r794.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-15 03:50:49 +00:00
parent 4cc3db5426
commit b4d1384c6d
2 changed files with 30 additions and 27 deletions

View file

@ -1279,13 +1279,14 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
bool gotGrab = false; bool gotGrab = false;
bool karTime = karMode && !event.ControlDown(); bool karTime = karMode && !event.ControlDown();
// Grab start // Line timing mode
if (!karTime) { if (!karTime) {
// Grab start
if (abs64 (x - selStart) < 6) { if (abs64 (x - selStart) < 6) {
wxCursor cursor(wxCURSOR_SIZEWE); wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor); SetCursor(cursor);
defCursor = false; defCursor = false;
if (buttonIsDown) { if (buttonClick) {
hold = 1; hold = 1;
gotGrab = true; gotGrab = true;
} }
@ -1296,15 +1297,26 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
wxCursor cursor(wxCURSOR_SIZEWE); wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor); SetCursor(cursor);
defCursor = false; defCursor = false;
if (buttonIsDown) { if (buttonClick) {
hold = 2; hold = 2;
gotGrab = true; gotGrab = true;
} }
} }
// Dragging nothing, time from scratch
else {
if (buttonClick) {
if (leftClick) hold = 3;
else hold = 2;
lastX = x;
gotGrab = true;
}
}
} }
// Grabbing a syllable // Karaoke mode
else { else {
// Look for a syllable
__int64 pos,len,curpos; __int64 pos,len,curpos;
KaraokeSyllable *curSyl; KaraokeSyllable *curSyl;
size_t karn = karaoke->syllables.size(); size_t karn = karaoke->syllables.size();
@ -1314,6 +1326,8 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
curpos = curSyl->position*10; curpos = curSyl->position*10;
if (len != -1) { if (len != -1) {
pos = GetXAtMS(curStartMS+len+curpos); pos = GetXAtMS(curStartMS+len+curpos);
// Grabbing syllable boundary
if (abs64 (x - pos) < 4) { if (abs64 (x - pos) < 4) {
wxCursor cursor(wxCURSOR_SIZEWE); wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor); SetCursor(cursor);
@ -1327,15 +1341,14 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
} }
} }
} }
}
// Dragging nothing, time from scratch // No syllable found, select if possible
if (!gotGrab && !karMode) { if (hold == 0 && leftClick) {
if (buttonIsDown) { int syl = GetSyllableAtX(x);
if (leftIsDown) hold = 3; if (syl != -1) {
else hold = 2; karaoke->SetSyllable(syl);
lastX = x; updated = true;
gotGrab = true; }
} }
} }
} }
@ -1449,18 +1462,6 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
else UpdateImage(true); else UpdateImage(true);
} }
// Single click on nothing
else if (hold == 3) {
// Select syllable
if (karaoke->enabled) {
int syl = GetSyllableAtX(x);
if (syl != -1) {
karaoke->SetSyllable(syl);
UpdateImage(true);
}
}
}
// Update stuff // Update stuff
SetCursor(wxNullCursor); SetCursor(wxNullCursor);
hold = 0; hold = 0;
@ -1471,8 +1472,10 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
if (updated) { if (updated) {
if (diagUpdated) NeedCommit = true; if (diagUpdated) NeedCommit = true;
player->SetEndPosition(GetSampleAtX(selEnd)); player->SetEndPosition(GetSampleAtX(selEnd));
wxCursor cursor(wxCURSOR_SIZEWE); if (hold != 0) {
SetCursor(cursor); wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor);
}
UpdateImage(true); UpdateImage(true);
} }
} }

View file

@ -310,7 +310,7 @@ void DirectSoundPlayer::Stop(bool timerToo) {
/////////// ///////////
// Set end // Set end
void DirectSoundPlayer::SetEndPosition(__int64 pos) { void DirectSoundPlayer::SetEndPosition(__int64 pos) {
endPos = pos; if (playing) endPos = pos;
} }