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 // 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,9 +392,10 @@ void AudioDisplay::UpdateImage(bool weak) {
} }
// Draw timescale // Draw timescale
if (timelineHeight) {
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(0,h,w,20); dc.DrawRectangle(0,h,w,timelineHeight);
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT)); dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
dc.DrawLine(0,h,w,h); dc.DrawLine(0,h,w,h);
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT)); dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT));
@ -446,6 +448,7 @@ void AudioDisplay::UpdateImage(bool weak) {
break; break;
} }
} }
}
// Done // Done
Refresh(false); Refresh(false);
@ -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,6 +1365,8 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
dc.SetLogicalFunction(wxINVERT); dc.SetLogicalFunction(wxINVERT);
dc.DrawLine(x,0,x,h); dc.DrawLine(x,0,x,h);
// Time
if (Options.AsBool(_T("Audio Draw Cursor Time"))) {
// Time string // Time string
AssTime time; AssTime time;
time.SetMS(GetMSAtX(x)); time.SetMS(GetMSAtX(x));
@ -1383,6 +1400,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
dc.DrawText(text,dx,dy); dc.DrawText(text,dx,dy);
} }
} }
}
// Scale dragging // Scale dragging
if ((hold == 0 && onScale) || draggingScale) { if ((hold == 0 && onScale) || draggingScale) {
@ -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();

View File

@ -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);

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 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 ===========================

View File

@ -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();
} }
} }

View File

@ -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));