Fix some minor quirks with detached video and the display mode.

Originally committed to SVN as r3688.
This commit is contained in:
Thomas Goyne 2009-10-11 22:10:08 +00:00
parent 5cf7724698
commit 68de84b427
3 changed files with 33 additions and 44 deletions

View file

@ -91,7 +91,7 @@ DialogDetachedVideo::DialogDetachedVideo(FrameMain *par, const wxSize &initialDi
SetMinSize(wxSize(1,1)); SetMinSize(wxSize(1,1));
// Update // Update
parent->SetDisplayMode(0,-1); parent->SetDisplayMode(0, -1);
Options.SetBool(_T("Detached video"),true); Options.SetBool(_T("Detached video"),true);
Options.Save(); Options.Save();
@ -119,7 +119,7 @@ void DialogDetachedVideo::OnClose(wxCloseEvent &WXUNUSED(event)) {
Options.SetBool(_T("Detached video"),false); Options.SetBool(_T("Detached video"),false);
Destroy(); Destroy();
par->detachedVideo = NULL; par->detachedVideo = NULL;
par->SetDisplayMode(-1,-1); par->SetDisplayMode(1,-1);
} }
/// @brief Move window /// @brief Move window

View file

@ -867,27 +867,25 @@ int FrameMain::TryToCloseSubs(bool enableCancel) {
/// @brief Set display mode /// @brief Set the video and audio display visibilty
/// @param _showVid /// @param video -1: leave unchanged; 0: hide; 1: show
/// @param _showAudio /// @param audio -1: leave unchanged; 0: hide; 1: show
/// @return void FrameMain::SetDisplayMode(int video, int audio) {
/// if (!IsShownOnScreen()) return;
void FrameMain::SetDisplayMode(int _showVid,int _showAudio) {
// Shown?
static bool firstRun = true;
if (!IsShownOnScreen() && !firstRun) return;
firstRun = false;
// Automatic bool sv = false, sa = false;
if (_showVid == -1) _showVid = (VideoContext::Get()->IsLoaded() && !detachedVideo) ? 1 : 0;
else if (_showVid == -2) _showVid = showVideo?1:0; if (video == -1) sv = showVideo;
if (_showAudio == -1) _showAudio = audioBox->loaded ? 1 : 0; else if (video) sv = VideoContext::Get()->IsLoaded() && !detachedVideo;
else if (_showAudio == -2) _showAudio = showAudio?1:0;
if (audio == -1) sa = showAudio;
else if (audio) sa = audioBox->loaded;
// See if anything changed // See if anything changed
if (_showVid == (showVideo?1:0) && _showAudio == (showAudio?1:0)) return; if (sv == showVideo && sa == showAudio) return;
showAudio = _showAudio == 1;
showVideo = _showVid == 1; showVideo = sv;
showAudio = sa;
// Stop // Stop
Freeze(); Freeze();
@ -902,7 +900,6 @@ void FrameMain::SetDisplayMode(int _showVid,int _showAudio) {
EditBox->SetSplitLineMode(); EditBox->SetSplitLineMode();
MainSizer->CalcMin(); MainSizer->CalcMin();
MainSizer->RecalcSizes(); MainSizer->RecalcSizes();
//videoBox->VideoSizer->Layout();
MainSizer->Layout(); MainSizer->Layout();
Layout(); Layout();
Show(true); Show(true);
@ -1072,7 +1069,7 @@ void FrameMain::SynchronizeProject(bool fromSubs) {
} }
// Display // Display
SetDisplayMode(-1,-1); SetDisplayMode(1,1);
} }
// Store data on subs // Store data on subs
@ -1163,9 +1160,7 @@ void FrameMain::LoadVideo(wxString file,bool autoload) {
VFR_Output.Unload(); VFR_Output.Unload();
} }
} }
SetDisplayMode(1,-1);
VideoContext::Get()->SetVideo(file); VideoContext::Get()->SetVideo(file);
SetDisplayMode(0,-1);
} }
catch (const wchar_t *error) { catch (const wchar_t *error) {
wxString err(error); wxString err(error);
@ -1203,7 +1198,7 @@ void FrameMain::LoadVideo(wxString file,bool autoload) {
} }
SubsBox->CommitChanges(true); SubsBox->CommitChanges(true);
SetDisplayMode(-1,-1); SetDisplayMode(1,-1);
EditBox->UpdateFrameTiming(); EditBox->UpdateFrameTiming();
DetachVideo(VideoContext::Get()->IsLoaded() && Options.AsBool(_T("Detached Video"))); DetachVideo(VideoContext::Get()->IsLoaded() && Options.AsBool(_T("Detached Video")));
@ -1222,7 +1217,7 @@ void FrameMain::LoadAudio(wxString filename,bool FromVideo) {
VideoContext::Get()->Stop(); VideoContext::Get()->Stop();
try { try {
audioBox->SetFile(filename,FromVideo); audioBox->SetFile(filename,FromVideo);
SetDisplayMode(-1,-1); SetDisplayMode(-1,1);
} }
catch (const wchar_t *error) { catch (const wchar_t *error) {
wxString err(error); wxString err(error);
@ -1295,7 +1290,6 @@ void FrameMain::OpenHelp(wxString page) {
/// @brief Detach video window /// @brief Detach video window
/// @param detach /// @param detach
///
void FrameMain::DetachVideo(bool detach) { void FrameMain::DetachVideo(bool detach) {
if (detach) { if (detach) {
if (!detachedVideo) { if (!detachedVideo) {
@ -1303,12 +1297,10 @@ void FrameMain::DetachVideo(bool detach) {
detachedVideo->Show(); detachedVideo->Show();
} }
} }
else { else if (detachedVideo) {
if (detachedVideo) { detachedVideo->Destroy();
detachedVideo->Destroy(); detachedVideo = NULL;
SetDisplayMode(-1,-1); SetDisplayMode(1,-1);
detachedVideo = NULL;
}
} }
UpdateToolbar(); UpdateToolbar();
} }

View file

@ -295,7 +295,7 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
else if (curMenu == viewMenu) { else if (curMenu == viewMenu) {
// Flags // Flags
bool aud = audioBox->audioDisplay->loaded; bool aud = audioBox->audioDisplay->loaded;
bool vid = VideoContext::Get()->IsLoaded(); bool vid = VideoContext::Get()->IsLoaded() && !detachedVideo;
// Set states // Set states
MenuBar->Enable(Menu_View_Audio,aud); MenuBar->Enable(Menu_View_Audio,aud);
@ -329,7 +329,7 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
MenuBar->Enable(Menu_Video_AR_Wide,attached); MenuBar->Enable(Menu_Video_AR_Wide,attached);
MenuBar->Enable(Menu_Video_AR_235,attached); MenuBar->Enable(Menu_Video_AR_235,attached);
MenuBar->Enable(Menu_Video_AR_Custom,attached); MenuBar->Enable(Menu_Video_AR_Custom,attached);
MenuBar->Enable(Menu_Video_Detach,state && !detachedVideo); MenuBar->Enable(Menu_Video_Detach,state);
MenuBar->Enable(Menu_File_Save_VFR,VFR_Output.GetFrameRateType() == VFR); MenuBar->Enable(Menu_File_Save_VFR,VFR_Output.GetFrameRateType() == VFR);
MenuBar->Enable(Menu_File_Close_VFR,VFR_Output.GetFrameRateType() == VFR); MenuBar->Enable(Menu_File_Close_VFR,VFR_Output.GetFrameRateType() == VFR);
MenuBar->Enable(Menu_Video_Close_Keyframes,VideoContext::Get()->OverKeyFramesLoaded()); MenuBar->Enable(Menu_Video_Close_Keyframes,VideoContext::Get()->OverKeyFramesLoaded());
@ -1016,7 +1016,7 @@ void FrameMain::OnSetZoom(wxCommandEvent &event) {
/// @param event /// @param event
/// ///
void FrameMain::OnDetachVideo(wxCommandEvent &event) { void FrameMain::OnDetachVideo(wxCommandEvent &event) {
DetachVideo(); DetachVideo(!detachedVideo);
} }
@ -1505,7 +1505,7 @@ void FrameMain::OnReplace(wxCommandEvent &event) {
void FrameMain::OnSetARDefault (wxCommandEvent &event) { void FrameMain::OnSetARDefault (wxCommandEvent &event) {
VideoContext::Get()->Stop(); VideoContext::Get()->Stop();
VideoContext::Get()->SetAspectRatio(0); VideoContext::Get()->SetAspectRatio(0);
SetDisplayMode(-1,-2); SetDisplayMode(1,-1);
} }
@ -1516,7 +1516,7 @@ void FrameMain::OnSetARDefault (wxCommandEvent &event) {
void FrameMain::OnSetARFull (wxCommandEvent &event) { void FrameMain::OnSetARFull (wxCommandEvent &event) {
VideoContext::Get()->Stop(); VideoContext::Get()->Stop();
VideoContext::Get()->SetAspectRatio(1); VideoContext::Get()->SetAspectRatio(1);
SetDisplayMode(-1,-2); SetDisplayMode(1,-1);
} }
@ -1527,7 +1527,7 @@ void FrameMain::OnSetARFull (wxCommandEvent &event) {
void FrameMain::OnSetARWide (wxCommandEvent &event) { void FrameMain::OnSetARWide (wxCommandEvent &event) {
VideoContext::Get()->Stop(); VideoContext::Get()->Stop();
VideoContext::Get()->SetAspectRatio(2); VideoContext::Get()->SetAspectRatio(2);
SetDisplayMode(-1,-2); SetDisplayMode(1,-1);
} }
@ -1538,7 +1538,7 @@ void FrameMain::OnSetARWide (wxCommandEvent &event) {
void FrameMain::OnSetAR235 (wxCommandEvent &event) { void FrameMain::OnSetAR235 (wxCommandEvent &event) {
VideoContext::Get()->Stop(); VideoContext::Get()->Stop();
VideoContext::Get()->SetAspectRatio(3); VideoContext::Get()->SetAspectRatio(3);
SetDisplayMode(-1,-2); SetDisplayMode(1,-1);
} }
@ -1591,7 +1591,7 @@ void FrameMain::OnSetARCustom (wxCommandEvent &event) {
// Set value // Set value
else { else {
VideoContext::Get()->SetAspectRatio(4,numval); VideoContext::Get()->SetAspectRatio(4,numval);
SetDisplayMode(-1,-1); SetDisplayMode(1,-1);
} }
} }
@ -1953,7 +1953,6 @@ void FrameMain::OnPickAssociations(wxCommandEvent &event) {
/// @return /// @return
/// ///
void FrameMain::OnViewStandard (wxCommandEvent &event) { void FrameMain::OnViewStandard (wxCommandEvent &event) {
if (!audioBox->audioDisplay->loaded || !VideoContext::Get()->IsLoaded()) return;
SetDisplayMode(1,1); SetDisplayMode(1,1);
} }
@ -1964,7 +1963,6 @@ void FrameMain::OnViewStandard (wxCommandEvent &event) {
/// @return /// @return
/// ///
void FrameMain::OnViewVideo (wxCommandEvent &event) { void FrameMain::OnViewVideo (wxCommandEvent &event) {
if (!VideoContext::Get()->IsLoaded()) return;
SetDisplayMode(1,0); SetDisplayMode(1,0);
} }
@ -1975,7 +1973,6 @@ void FrameMain::OnViewVideo (wxCommandEvent &event) {
/// @return /// @return
/// ///
void FrameMain::OnViewAudio (wxCommandEvent &event) { void FrameMain::OnViewAudio (wxCommandEvent &event) {
if (!audioBox->audioDisplay->loaded) return;
SetDisplayMode(0,1); SetDisplayMode(0,1);
} }