mirror of https://github.com/odrling/Aegisub
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:
parent
d58fba3839
commit
7843e2e89c
|
@ -94,7 +94,7 @@ AudioDisplay::AudioDisplay(wxWindow *parent,VideoDisplay *display)
|
||||||
// Init
|
// Init
|
||||||
UpdateTimer.SetOwner(this,Audio_Update_Timer);
|
UpdateTimer.SetOwner(this,Audio_Update_Timer);
|
||||||
GetClientSize(&w,&h);
|
GetClientSize(&w,&h);
|
||||||
h -= 20;
|
h -= Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
|
||||||
SetSamplesPercent(50,false);
|
SetSamplesPercent(50,false);
|
||||||
|
|
||||||
// Set cursor
|
// Set cursor
|
||||||
|
@ -139,7 +139,8 @@ void AudioDisplay::UpdateImage(bool weak) {
|
||||||
if (!loaded || !provider) return;
|
if (!loaded || !provider) return;
|
||||||
|
|
||||||
// Prepare bitmap
|
// Prepare bitmap
|
||||||
int displayH = h+20;
|
int timelineHeight = Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
|
||||||
|
int displayH = h+timelineHeight;
|
||||||
if (origImage) {
|
if (origImage) {
|
||||||
if (origImage->GetWidth() != w || origImage->GetHeight() != displayH) {
|
if (origImage->GetWidth() != w || origImage->GetHeight() != displayH) {
|
||||||
delete origImage;
|
delete origImage;
|
||||||
|
@ -391,59 +392,61 @@ void AudioDisplay::UpdateImage(bool weak) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw timescale
|
// Draw timescale
|
||||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
if (timelineHeight) {
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
||||||
dc.DrawRectangle(0,h,w,20);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
|
dc.DrawRectangle(0,h,w,timelineHeight);
|
||||||
dc.DrawLine(0,h,w,h);
|
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
|
||||||
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT));
|
dc.DrawLine(0,h,w,h);
|
||||||
dc.DrawLine(0,h+1,w,h+1);
|
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT));
|
||||||
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
dc.DrawLine(0,h+1,w,h+1);
|
||||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
||||||
wxFont scaleFont;
|
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
||||||
scaleFont.SetFaceName(_T("Tahoma"));
|
wxFont scaleFont;
|
||||||
scaleFont.SetPointSize(8);
|
scaleFont.SetFaceName(_T("Tahoma"));
|
||||||
dc.SetFont(scaleFont);
|
scaleFont.SetPointSize(8);
|
||||||
|
dc.SetFont(scaleFont);
|
||||||
|
|
||||||
// Timescale ticks
|
// Timescale ticks
|
||||||
__int64 start = Position*samples;
|
__int64 start = Position*samples;
|
||||||
int rate = provider->GetSampleRate();
|
int rate = provider->GetSampleRate();
|
||||||
for (int i=1;i<32;i*=2) {
|
for (int i=1;i<32;i*=2) {
|
||||||
int pixBounds = rate / (samples * 4 / i);
|
int pixBounds = rate / (samples * 4 / i);
|
||||||
if (pixBounds >= 8) {
|
if (pixBounds >= 8) {
|
||||||
for (int x=0;x<w;x++) {
|
for (int x=0;x<w;x++) {
|
||||||
__int64 pos = (x*samples)+start;
|
__int64 pos = (x*samples)+start;
|
||||||
// Second boundary
|
// Second boundary
|
||||||
if (pos % rate < samples) {
|
if (pos % rate < samples) {
|
||||||
dc.DrawLine(x,h+2,x,h+8);
|
dc.DrawLine(x,h+2,x,h+8);
|
||||||
|
|
||||||
// Draw text
|
// Draw text
|
||||||
wxCoord textW,textH;
|
wxCoord textW,textH;
|
||||||
int hr = 0;
|
int hr = 0;
|
||||||
int m = 0;
|
int m = 0;
|
||||||
int s = pos/rate;
|
int s = pos/rate;
|
||||||
while (s >= 3600) {
|
while (s >= 3600) {
|
||||||
s -= 3600;
|
s -= 3600;
|
||||||
hr++;
|
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
|
// Other
|
||||||
else if (pos % (rate / 4 * i) < samples) {
|
else if (pos % (rate / 4 * i) < samples) {
|
||||||
dc.DrawLine(x,h+2,x,h+5);
|
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
|
// Make dialogue visible
|
||||||
void AudioDisplay::MakeDialogueVisible(bool force) {
|
void AudioDisplay::MakeDialogueVisible(bool force) {
|
||||||
|
@ -1287,6 +1301,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
|
||||||
bool karMode = karaoke->enabled;
|
bool karMode = karaoke->enabled;
|
||||||
bool shiftDown = event.m_shiftDown;
|
bool shiftDown = event.m_shiftDown;
|
||||||
bool ctrlDown = event.m_controlDown;
|
bool ctrlDown = event.m_controlDown;
|
||||||
|
int timelineHeight = Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
|
||||||
|
|
||||||
// Leaving event
|
// Leaving event
|
||||||
if (event.Leaving()) {
|
if (event.Leaving()) {
|
||||||
|
@ -1304,7 +1319,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
|
||||||
// Get focus
|
// Get focus
|
||||||
if (wxWindow::FindFocus() != this && Options.AsBool(_T("Audio Autofocus"))) SetFocus();
|
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
|
// Click type
|
||||||
|
@ -1350,37 +1365,40 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
|
||||||
dc.SetLogicalFunction(wxINVERT);
|
dc.SetLogicalFunction(wxINVERT);
|
||||||
dc.DrawLine(x,0,x,h);
|
dc.DrawLine(x,0,x,h);
|
||||||
|
|
||||||
// Time string
|
// Time
|
||||||
AssTime time;
|
if (Options.AsBool(_T("Audio Draw Cursor Time"))) {
|
||||||
time.SetMS(GetMSAtX(x));
|
// Time string
|
||||||
wxString text = time.GetASSFormated();
|
AssTime time;
|
||||||
|
time.SetMS(GetMSAtX(x));
|
||||||
|
wxString text = time.GetASSFormated();
|
||||||
|
|
||||||
// Calculate metrics
|
// Calculate metrics
|
||||||
wxFont font(10,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Verdana"));
|
wxFont font(10,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Verdana"));
|
||||||
dc.SetFont(font);
|
dc.SetFont(font);
|
||||||
int tw,th;
|
int tw,th;
|
||||||
GetTextExtent(text,&tw,&th,NULL,NULL,&font);
|
GetTextExtent(text,&tw,&th,NULL,NULL,&font);
|
||||||
|
|
||||||
// Set inversion
|
// Set inversion
|
||||||
bool left = true;
|
bool left = true;
|
||||||
if (x > w/2) left = false;
|
if (x > w/2) left = false;
|
||||||
|
|
||||||
// Text coordinates
|
// Text coordinates
|
||||||
int dx;
|
int dx;
|
||||||
dx = x - tw/2;
|
dx = x - tw/2;
|
||||||
if (dx < 4) dx = 4;
|
if (dx < 4) dx = 4;
|
||||||
int max = w - tw - 4;
|
int max = w - tw - 4;
|
||||||
if (dx > max) dx = max;
|
if (dx > max) dx = max;
|
||||||
int dy = 4;
|
int dy = 4;
|
||||||
|
|
||||||
// Draw text
|
// Draw text
|
||||||
dc.SetTextForeground(wxColour(64,64,64));
|
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.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.SetTextForeground(wxColour(255,255,255));
|
||||||
dc.DrawText(text,dx,dy);
|
dc.DrawText(text,dx,dy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1815,7 +1833,7 @@ int AudioDisplay::GetBoundarySnap(int x,int range) {
|
||||||
void AudioDisplay::OnSize(wxSizeEvent &event) {
|
void AudioDisplay::OnSize(wxSizeEvent &event) {
|
||||||
// Set size
|
// Set size
|
||||||
GetClientSize(&w,&h);
|
GetClientSize(&w,&h);
|
||||||
h -= 20;
|
h -= Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
|
||||||
|
|
||||||
// Update image
|
// Update image
|
||||||
UpdateImage();
|
UpdateImage();
|
||||||
|
|
|
@ -143,6 +143,7 @@ public:
|
||||||
void AddLead(bool in,bool out);
|
void AddLead(bool in,bool out);
|
||||||
void UpdateImage(bool weak=false);
|
void UpdateImage(bool weak=false);
|
||||||
void Update();
|
void Update();
|
||||||
|
void RecreateImage();
|
||||||
void SetPosition(int pos);
|
void SetPosition(int pos);
|
||||||
void SetSamplesPercent(int percent,bool update=true,float pivot=0.5);
|
void SetSamplesPercent(int percent,bool update=true,float pivot=0.5);
|
||||||
void SetScale(float scale);
|
void SetScale(float scale);
|
||||||
|
|
|
@ -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 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.
|
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)
|
- 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 ===========================
|
= 1.10 beta - 2006.08.07 ===========================
|
||||||
|
|
|
@ -469,11 +469,11 @@ DialogOptions::DialogOptions(wxWindow *parent)
|
||||||
wxFlexGridSizer *displaySizer4 = new wxFlexGridSizer(14,2,2,2);
|
wxFlexGridSizer *displaySizer4 = new wxFlexGridSizer(14,2,2,2);
|
||||||
|
|
||||||
// First sizer
|
// First sizer
|
||||||
wxString labels1[3] = { _("Spectrum Invert Selection"), _("Draw Secondary Lines"), _("Draw Selection Background") };
|
wxString labels1[5] = { _("Spectrum Invert Selection"), _("Draw Secondary Lines"), _("Draw Selection Background"), _("Draw Timeline"), _("Draw Cursor Time") };
|
||||||
wxString options1[3] = { _T("Audio Spectrum invert selection"), _T("Audio Draw Secondary Lines"), _T("Audio Draw Selection Background") };
|
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<3;i++) {
|
for (int i=0;i<5;i++) {
|
||||||
wxCheckBox *control = new wxCheckBox(displayPage,-1,labels1[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);
|
displaySizer3->Add(control,1,wxEXPAND | wxALL,5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,7 +755,7 @@ void DialogOptions::WriteToOptions(bool justApply) {
|
||||||
// Audio
|
// Audio
|
||||||
if (audio) {
|
if (audio) {
|
||||||
FrameMain *frame = (FrameMain*) GetParent();
|
FrameMain *frame = (FrameMain*) GetParent();
|
||||||
frame->audioBox->audioDisplay->UpdateImage();
|
frame->audioBox->audioDisplay->RecreateImage();
|
||||||
frame->audioBox->audioDisplay->Refresh();
|
frame->audioBox->audioDisplay->Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,6 +217,8 @@ void OptionsManager::LoadDefaults() {
|
||||||
SetBool(_T("Audio Spectrum invert selection"), true);
|
SetBool(_T("Audio Spectrum invert selection"), true);
|
||||||
SetBool(_T("Audio Draw Secondary Lines"), true);
|
SetBool(_T("Audio Draw Secondary Lines"), true);
|
||||||
SetBool(_T("Audio Draw Selection Background"), 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 Modified"),wxColour(92,0,0));
|
||||||
SetColour(_T("Audio Selection Background"),wxColour(64,64,64));
|
SetColour(_T("Audio Selection Background"),wxColour(64,64,64));
|
||||||
SetColour(_T("Audio Seconds Boundaries"),wxColour(0,100,255));
|
SetColour(_T("Audio Seconds Boundaries"),wxColour(0,100,255));
|
||||||
|
|
Loading…
Reference in New Issue