Added options to toggle the display of the audio timeline and of the time over the mouse cursor.

Originally committed to SVN as r724.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-06 06:14:35 +00:00
parent d58fba3839
commit 7843e2e89c
5 changed files with 105 additions and 83 deletions

View File

@ -94,7 +94,7 @@ AudioDisplay::AudioDisplay(wxWindow *parent,VideoDisplay *display)
// Init
UpdateTimer.SetOwner(this,Audio_Update_Timer);
GetClientSize(&w,&h);
h -= 20;
h -= Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
SetSamplesPercent(50,false);
// Set cursor
@ -139,7 +139,8 @@ void AudioDisplay::UpdateImage(bool weak) {
if (!loaded || !provider) return;
// Prepare bitmap
int displayH = h+20;
int timelineHeight = Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
int displayH = h+timelineHeight;
if (origImage) {
if (origImage->GetWidth() != w || origImage->GetHeight() != displayH) {
delete origImage;
@ -391,59 +392,61 @@ void AudioDisplay::UpdateImage(bool weak) {
}
// Draw timescale
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(0,h,w,20);
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
dc.DrawLine(0,h,w,h);
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT));
dc.DrawLine(0,h+1,w,h+1);
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
wxFont scaleFont;
scaleFont.SetFaceName(_T("Tahoma"));
scaleFont.SetPointSize(8);
dc.SetFont(scaleFont);
if (timelineHeight) {
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(0,h,w,timelineHeight);
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
dc.DrawLine(0,h,w,h);
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT));
dc.DrawLine(0,h+1,w,h+1);
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
wxFont scaleFont;
scaleFont.SetFaceName(_T("Tahoma"));
scaleFont.SetPointSize(8);
dc.SetFont(scaleFont);
// Timescale ticks
__int64 start = Position*samples;
int rate = provider->GetSampleRate();
for (int i=1;i<32;i*=2) {
int pixBounds = rate / (samples * 4 / i);
if (pixBounds >= 8) {
for (int x=0;x<w;x++) {
__int64 pos = (x*samples)+start;
// Second boundary
if (pos % rate < samples) {
dc.DrawLine(x,h+2,x,h+8);
// Timescale ticks
__int64 start = Position*samples;
int rate = provider->GetSampleRate();
for (int i=1;i<32;i*=2) {
int pixBounds = rate / (samples * 4 / i);
if (pixBounds >= 8) {
for (int x=0;x<w;x++) {
__int64 pos = (x*samples)+start;
// Second boundary
if (pos % rate < samples) {
dc.DrawLine(x,h+2,x,h+8);
// Draw text
wxCoord textW,textH;
int hr = 0;
int m = 0;
int s = pos/rate;
while (s >= 3600) {
s -= 3600;
hr++;
// Draw text
wxCoord textW,textH;
int hr = 0;
int m = 0;
int s = pos/rate;
while (s >= 3600) {
s -= 3600;
hr++;
}
while (s >= 60) {
s -= 60;
m++;
}
wxString text;
if (hr) text = wxString::Format(_T("%i:%02i:%02i"),hr,m,s);
else if (m) text = wxString::Format(_T("%i:%02i"),m,s);
else text = wxString::Format(_T("%i"),s);
dc.GetTextExtent(text,&textW,&textH,NULL,NULL,&scaleFont);
dc.DrawText(text,MAX(0,x-textW/2)+1,h+8);
}
while (s >= 60) {
s -= 60;
m++;
}
wxString text;
if (hr) text = wxString::Format(_T("%i:%02i:%02i"),hr,m,s);
else if (m) text = wxString::Format(_T("%i:%02i"),m,s);
else text = wxString::Format(_T("%i"),s);
dc.GetTextExtent(text,&textW,&textH,NULL,NULL,&scaleFont);
dc.DrawText(text,MAX(0,x-textW/2)+1,h+8);
}
// Other
else if (pos % (rate / 4 * i) < samples) {
dc.DrawLine(x,h+2,x,h+5);
// Other
else if (pos % (rate / 4 * i) < samples) {
dc.DrawLine(x,h+2,x,h+5);
}
}
break;
}
break;
}
}
@ -803,6 +806,17 @@ void AudioDisplay::Update() {
}
//////////////////////
// Recreate the image
void AudioDisplay::RecreateImage() {
GetClientSize(&w,&h);
h -= Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
delete origImage;
origImage = NULL;
UpdateImage(false);
}
/////////////////////////
// Make dialogue visible
void AudioDisplay::MakeDialogueVisible(bool force) {
@ -1287,6 +1301,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
bool karMode = karaoke->enabled;
bool shiftDown = event.m_shiftDown;
bool ctrlDown = event.m_controlDown;
int timelineHeight = Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
// Leaving event
if (event.Leaving()) {
@ -1304,7 +1319,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
// Get focus
if (wxWindow::FindFocus() != this && Options.AsBool(_T("Audio Autofocus"))) SetFocus();
}
else if (y < h+20) onScale = true;
else if (y < h+timelineHeight) onScale = true;
}
// Click type
@ -1350,37 +1365,40 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
dc.SetLogicalFunction(wxINVERT);
dc.DrawLine(x,0,x,h);
// Time string
AssTime time;
time.SetMS(GetMSAtX(x));
wxString text = time.GetASSFormated();
// Time
if (Options.AsBool(_T("Audio Draw Cursor Time"))) {
// Time string
AssTime time;
time.SetMS(GetMSAtX(x));
wxString text = time.GetASSFormated();
// Calculate metrics
wxFont font(10,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Verdana"));
dc.SetFont(font);
int tw,th;
GetTextExtent(text,&tw,&th,NULL,NULL,&font);
// Calculate metrics
wxFont font(10,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Verdana"));
dc.SetFont(font);
int tw,th;
GetTextExtent(text,&tw,&th,NULL,NULL,&font);
// Set inversion
bool left = true;
if (x > w/2) left = false;
// Set inversion
bool left = true;
if (x > w/2) left = false;
// Text coordinates
int dx;
dx = x - tw/2;
if (dx < 4) dx = 4;
int max = w - tw - 4;
if (dx > max) dx = max;
int dy = 4;
// Text coordinates
int dx;
dx = x - tw/2;
if (dx < 4) dx = 4;
int max = w - tw - 4;
if (dx > max) dx = max;
int dy = 4;
// Draw text
dc.SetTextForeground(wxColour(64,64,64));
dc.DrawText(text,dx+1,dy-1);
dc.DrawText(text,dx+1,dy+1);
dc.DrawText(text,dx-1,dy-1);
dc.DrawText(text,dx-1,dy+1);
dc.SetTextForeground(wxColour(255,255,255));
dc.DrawText(text,dx,dy);
// Draw text
dc.SetTextForeground(wxColour(64,64,64));
dc.DrawText(text,dx+1,dy-1);
dc.DrawText(text,dx+1,dy+1);
dc.DrawText(text,dx-1,dy-1);
dc.DrawText(text,dx-1,dy+1);
dc.SetTextForeground(wxColour(255,255,255));
dc.DrawText(text,dx,dy);
}
}
}
@ -1815,7 +1833,7 @@ int AudioDisplay::GetBoundarySnap(int x,int range) {
void AudioDisplay::OnSize(wxSizeEvent &event) {
// Set size
GetClientSize(&w,&h);
h -= 20;
h -= Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
// Update image
UpdateImage();

View File

@ -143,6 +143,7 @@ public:
void AddLead(bool in,bool out);
void UpdateImage(bool weak=false);
void Update();
void RecreateImage();
void SetPosition(int pos);
void SetSamplesPercent(int percent,bool update=true,float pivot=0.5);
void SetScale(float scale);

View File

@ -74,6 +74,7 @@ Please visit http://aegisub.net to download latest version
o The "Play" shortcut will always play, regardless of whether it was already playing or not. There is a new shortcut for "Stop".
o Styles for line start/end markers have changed.
- Fixed loading of SRT and TXT files, which were causing an empty line to appear at the start of the file. (AMZ)
- Added options to toggle the display of the audio timeline and of the time over the mouse cursor. (AMZ)
= 1.10 beta - 2006.08.07 ===========================

View File

@ -469,11 +469,11 @@ DialogOptions::DialogOptions(wxWindow *parent)
wxFlexGridSizer *displaySizer4 = new wxFlexGridSizer(14,2,2,2);
// First sizer
wxString labels1[3] = { _("Spectrum Invert Selection"), _("Draw Secondary Lines"), _("Draw Selection Background") };
wxString options1[3] = { _T("Audio Spectrum invert selection"), _T("Audio Draw Secondary Lines"), _T("Audio Draw Selection Background") };
for (int i=0;i<3;i++) {
wxString labels1[5] = { _("Spectrum Invert Selection"), _("Draw Secondary Lines"), _("Draw Selection Background"), _("Draw Timeline"), _("Draw Cursor Time") };
wxString options1[5] = { _T("Spectrum invert selection"), _T("Draw Secondary Lines"), _T("Draw Selection Background") , _T("Draw Timeline"), _T("Draw Cursor Time")};
for (int i=0;i<5;i++) {
wxCheckBox *control = new wxCheckBox(displayPage,-1,labels1[i]);
Bind(control,options1[i]);
Bind(control,_T("Audio ") + options1[i]);
displaySizer3->Add(control,1,wxEXPAND | wxALL,5);
}
@ -755,7 +755,7 @@ void DialogOptions::WriteToOptions(bool justApply) {
// Audio
if (audio) {
FrameMain *frame = (FrameMain*) GetParent();
frame->audioBox->audioDisplay->UpdateImage();
frame->audioBox->audioDisplay->RecreateImage();
frame->audioBox->audioDisplay->Refresh();
}
}

View File

@ -217,6 +217,8 @@ void OptionsManager::LoadDefaults() {
SetBool(_T("Audio Spectrum invert selection"), true);
SetBool(_T("Audio Draw Secondary Lines"), true);
SetBool(_T("Audio Draw Selection Background"), true);
SetBool(_T("Audio Draw Timeline"),true);
SetBool(_T("Audio Draw Cursor Time"),true);
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));