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));
// Update
parent->SetDisplayMode(0,-1);
parent->SetDisplayMode(0, -1);
Options.SetBool(_T("Detached video"),true);
Options.Save();
@ -119,7 +119,7 @@ void DialogDetachedVideo::OnClose(wxCloseEvent &WXUNUSED(event)) {
Options.SetBool(_T("Detached video"),false);
Destroy();
par->detachedVideo = NULL;
par->SetDisplayMode(-1,-1);
par->SetDisplayMode(1,-1);
}
/// @brief Move window

View File

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

View File

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