Fixed drawing of inactive lines in audio display to prevent it from being drawn over selection.

Originally committed to SVN as r1066.
This commit is contained in:
Rodrigo Braz Monteiro 2007-04-13 01:29:05 +00:00
parent 58c7a6f4e8
commit c014c93c4c
4 changed files with 77 additions and 48 deletions

View file

@ -260,53 +260,7 @@ void AudioDisplay::UpdateImage(bool weak) {
}
// Draw previous line
int shadeType = Options.AsInt(_T("Audio Inactive Lines Display Mode"));
if (shadeType == 1 || shadeType == 2) {
dc.SetBrush(wxBrush(Options.AsColour(_T("Audio Line boundary inactive line"))));
int selWidth = Options.AsInt(_T("Audio Line boundaries Thickness"));
AssDialogue *shade;
int shadeX1,shadeX2;
int shadeFrom,shadeTo;
// Only previous
if (shadeType == 1) {
shadeFrom = this->line_n-1;
shadeTo = shadeFrom+1;
}
// All
else {
shadeFrom = 0;
shadeTo = grid->GetRows();
}
for (int j=shadeFrom;j<shadeTo;j++) {
if (j == line_n) continue;
shade = grid->GetDialogue(j);
if (shade) {
// Get coordinates
shadeX1 = GetXAtMS(shade->Start.GetMS());
shadeX2 = GetXAtMS(shade->End.GetMS());
if (shadeX2 < 0 || shadeX1 > w) continue;
// Draw over waveform
if (!spectrum) {
int x1 = MAX(0,shadeX1);
int x2 = MIN(w,shadeX2);
dc.SetPen(wxPen(Options.AsColour(_T("Audio Waveform Inactive"))));
for (__int64 i=x1;i<x2;i++) {
dc.DrawLine(i,peak[i],i,min[i]-1);
}
}
// Draw boundaries
dc.SetPen(wxPen(Options.AsColour(_T("Audio Line boundary inactive line"))));
dc.DrawRectangle(shadeX1-selWidth/2+1,0,selWidth,h);
dc.DrawRectangle(shadeX2-selWidth/2+1,0,selWidth,h);
}
}
}
DrawInactiveLines(dc);
if (hasSel) {
// Draw boundaries
@ -400,6 +354,79 @@ void AudioDisplay::UpdateImage(bool weak) {
}
///////////////////////
// Draw Inactive Lines
void AudioDisplay::DrawInactiveLines(wxDC &dc) {
// Check if there is anything to do
int shadeType = Options.AsInt(_T("Audio Inactive Lines Display Mode"));
if (shadeType == 0) return;
// Spectrum?
bool spectrum = false;
if (provider && Options.AsBool(_T("Audio Spectrum"))) {
spectrum = true;
}
// Set options
dc.SetBrush(wxBrush(Options.AsColour(_T("Audio Line boundary inactive line"))));
int selWidth = Options.AsInt(_T("Audio Line boundaries Thickness"));
AssDialogue *shade;
int shadeX1,shadeX2;
int shadeFrom,shadeTo;
// Only previous
if (shadeType == 1) {
shadeFrom = this->line_n-1;
shadeTo = shadeFrom+1;
}
// All
else {
shadeFrom = 0;
shadeTo = grid->GetRows();
}
for (int j=shadeFrom;j<shadeTo;j++) {
if (j == line_n) continue;
shade = grid->GetDialogue(j);
if (shade) {
// Get coordinates
shadeX1 = GetXAtMS(shade->Start.GetMS());
shadeX2 = GetXAtMS(shade->End.GetMS());
if (shadeX2 < 0 || shadeX1 > w) continue;
// Draw over waveform
if (!spectrum) {
// Selection
int selX1 = MAX(0,GetXAtMS(curStartMS));
int selX2 = MIN(w,GetXAtMS(curEndMS));
// Get ranges (x1->x2, x3->x4).
int x1 = MAX(0,shadeX1);
int x2 = MIN(w,shadeX2);
int x3 = MAX(x1,selX2);
int x4 = MAX(x2,selX2);
// Clip first range
x1 = MIN(x1,selX1);
x2 = MIN(x2,selX1);
// Set pen and draw
dc.SetPen(wxPen(Options.AsColour(_T("Audio Waveform Inactive"))));
for (int i=x1;i<x2;i++) dc.DrawLine(i,peak[i],i,min[i]-1);
for (int i=x3;i<x4;i++) dc.DrawLine(i,peak[i],i,min[i]-1);
}
// Draw boundaries
dc.SetPen(wxPen(Options.AsColour(_T("Audio Line boundary inactive line"))));
dc.DrawRectangle(shadeX1-selWidth/2+1,0,selWidth,h);
dc.DrawRectangle(shadeX2-selWidth/2+1,0,selWidth,h);
}
}
}
//////////////////
// Draw keyframes
void AudioDisplay::DrawKeyframes(wxDC &dc) {

View file

@ -119,6 +119,7 @@ private:
void Reset();
void DrawTimescale(wxDC &dc);
void DrawKeyframes(wxDC &dc);
void DrawInactiveLines(wxDC &dc);
void DrawWaveform(wxDC &dc,bool weak);
void DrawSpectrum(wxDC &dc,bool weak);
void GetDialoguePos(__int64 &start,__int64 &end,bool cap);

View file

@ -113,6 +113,7 @@ Please visit http://aegisub.net to download latest version
- Instead of falling back to your local charset, Aegisub will now use the "universalchardet" library (the one used by the Mozilla project) to autodetect the character set of non-Unicode files. (AMZ)
- Added option to disable automatic grabbing of times from selected lines on the audio display. Also, it will never pick the times from 0:00:00.00 -> 0:00:00.00 lines. (AMZ)
- Added a "Scale Border and Shadow" check box to script properties dialog. (AMZ)
- Fixed drawing of inactive lines in audio display to prevent it from being drawn over selection. (AMZ)
= 1.10 beta - 2006.08.07 ===========================

View file

@ -250,7 +250,7 @@ void OptionsManager::LoadDefaults() {
SetColour(_T("Audio Selection Background Modified"),wxColour(92,0,0));
SetColour(_T("Audio Selection Background"),wxColour(64,64,64));
SetColour(_T("Audio Seconds Boundaries"),wxColour(0,100,255));
SetColour(_T("Audio Waveform Modified"),wxColour(255,200,200));
SetColour(_T("Audio Waveform Modified"),wxColour(255,230,230));
SetColour(_T("Audio Waveform Selected"),wxColour(255,255,255));
SetColour(_T("Audio Waveform Inactive"),wxColour(0,80,0));
SetColour(_T("Audio Waveform"),wxColour(0,200,0));