diff options
author | Underground78 <underground78@users.sourceforge.net> | 2012-06-10 13:49:36 +0400 |
---|---|---|
committer | Underground78 <underground78@users.sourceforge.net> | 2012-06-10 13:49:36 +0400 |
commit | 45e076bf19beedd18423ccf609f66434ac9eed48 (patch) | |
tree | 50cdf0f22f68d21ac916fa2b8945282071bea761 | |
parent | efd3c28ff8c184d653b81f842b643fce07ad342c (diff) |
Make a distinction between the current state of the GUI controls and the state saved in the settings. Also factorize some code. This makes easier dealing with temporary state changes that shouldn't be saved.
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@5065 10f7b99b-c216-0410-bff0-8a66a9350fd8
-rw-r--r-- | src/mpc-hc/MainFrm.cpp | 324 | ||||
-rw-r--r-- | src/mpc-hc/MainFrm.h | 4 |
2 files changed, 170 insertions, 158 deletions
diff --git a/src/mpc-hc/MainFrm.cpp b/src/mpc-hc/MainFrm.cpp index 541301c3c..bc44bf6e6 100644 --- a/src/mpc-hc/MainFrm.cpp +++ b/src/mpc-hc/MainFrm.cpp @@ -631,6 +631,7 @@ CMainFrame::CMainFrame() : m_fHideCursor(false),
m_lastMouseMove(-1, -1),
m_pLastBar(NULL),
+ m_nCS(0),
m_nLoops(0),
m_iSubtitleSel(-1),
m_ZoomX(1), m_ZoomY(1), m_PosX(0.5), m_PosY(0.5),
@@ -777,7 +778,9 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) AppSettings& s = AfxGetAppSettings();
- ShowControls(s.nCS);
+ // Load the controls
+ m_nCS = s.nCS;
+ ShowControls(m_nCS);
SetAlwaysOnTop(s.iOnTop);
@@ -1815,7 +1818,7 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent) CWnd* pWnd = WindowFromPoint(p);
if (pWnd && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside)) {
if (AfxGetAppSettings().nShowBarsWhenFullScreenTimeOut >= 0) {
- ShowControls(CS_NONE, false);
+ ShowControls(CS_NONE);
}
}
}
@@ -2957,7 +2960,7 @@ void CMainFrame::OnMouseMove(UINT nFlags, CPoint point) if (nTimeOut < 0) {
m_fHideCursor = false;
if (s.fShowBarsWhenFullScreen) {
- ShowControls(s.nCS);
+ ShowControls(m_nCS);
if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && s.iDefaultCaptureDevice == 1) {
m_wndNavigationBar.m_navdlg.UpdateElementList();
m_wndNavigationBar.ShowControls(this, TRUE);
@@ -2975,7 +2978,7 @@ void CMainFrame::OnMouseMove(UINT nFlags, CPoint point) for (int i = 1; pos; i <<= 1) {
CControlBar* pNext = m_bars.GetNext(pos);
CSize size = pNext->CalcFixedLayout(FALSE, TRUE);
- if (s.nCS&i) {
+ if (m_nCS & i) {
r.top -= size.cy;
}
}
@@ -2992,11 +2995,11 @@ void CMainFrame::OnMouseMove(UINT nFlags, CPoint point) if (r.PtInRect(point)) {
if (s.fShowBarsWhenFullScreen) {
- ShowControls(s.nCS);
+ ShowControls(m_nCS);
}
} else {
if (s.fShowBarsWhenFullScreen) {
- ShowControls(CS_NONE, false);
+ ShowControls(CS_NONE);
}
}
@@ -3026,7 +3029,7 @@ void CMainFrame::OnMouseMove(UINT nFlags, CPoint point) } else {
m_fHideCursor = false;
if (s.fShowBarsWhenFullScreen) {
- ShowControls(s.nCS);
+ ShowControls(m_nCS);
}
SetTimer(TIMER_FULLSCREENCONTROLBARHIDER, nTimeOut*1000, NULL);
@@ -6373,13 +6376,18 @@ void CMainFrame::OnUpdateViewCaptionmenu(CCmdUI* pCmdUI) void CMainFrame::OnViewControlBar(UINT nID)
{
nID -= ID_VIEW_SEEKER;
- ShowControls(AfxGetAppSettings().nCS ^ (1<<nID));
+ UINT bitID = (1u << nID);
+
+ // Remember the change
+ AfxGetAppSettings().nCS ^= bitID;
+
+ ShowControls(m_nCS ^ bitID, true);
}
void CMainFrame::OnUpdateViewControlBar(CCmdUI* pCmdUI)
{
UINT nID = pCmdUI->m_nID - ID_VIEW_SEEKER;
- pCmdUI->SetCheck(!!(AfxGetAppSettings().nCS & (1<<nID)));
+ pCmdUI->SetCheck(!!(m_nCS & (1<<nID)));
}
void CMainFrame::OnViewSubresync()
@@ -6513,10 +6521,7 @@ void CMainFrame::OnUpdateViewShaderEditor(CCmdUI* pCmdUI) void CMainFrame::OnViewMinimal()
{
- while (AfxGetAppSettings().iCaptionMenuMode!=MODE_BORDERLESS) {
- SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
- }
- ShowControls(CS_NONE);
+ SetUIPreset(MODE_BORDERLESS, CS_NONE);
}
void CMainFrame::OnUpdateViewMinimal(CCmdUI* pCmdUI)
@@ -6525,10 +6530,7 @@ void CMainFrame::OnUpdateViewMinimal(CCmdUI* pCmdUI) void CMainFrame::OnViewCompact()
{
- while (AfxGetAppSettings().iCaptionMenuMode!=MODE_FRAMEONLY) {
- SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
- }
- ShowControls(CS_SEEKBAR);
+ SetUIPreset(MODE_FRAMEONLY, CS_SEEKBAR);
}
void CMainFrame::OnUpdateViewCompact(CCmdUI* pCmdUI)
@@ -6537,16 +6539,24 @@ void CMainFrame::OnUpdateViewCompact(CCmdUI* pCmdUI) void CMainFrame::OnViewNormal()
{
- while (AfxGetAppSettings().iCaptionMenuMode!=MODE_SHOWCAPTIONMENU) {
- SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
- }
- ShowControls(CS_SEEKBAR|CS_TOOLBAR|CS_STATUSBAR|CS_INFOBAR);
+ SetUIPreset(MODE_SHOWCAPTIONMENU, CS_SEEKBAR|CS_TOOLBAR|CS_STATUSBAR|CS_INFOBAR);
}
void CMainFrame::OnUpdateViewNormal(CCmdUI* pCmdUI)
{
}
+void CMainFrame::SetUIPreset(int iCaptionMenuMode, UINT nCS)
+{
+ while (AfxGetAppSettings().iCaptionMenuMode != iCaptionMenuMode) {
+ SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
+ }
+
+ // Remember the change
+ AfxGetAppSettings().nCS = nCS;
+ ShowControls(nCS, true);
+}
+
void CMainFrame::OnViewFullscreen()
{
ToggleFullscreen(true, true);
@@ -9651,14 +9661,14 @@ void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasT if (s.fShowBarsWhenFullScreen) {
int nTimeOut = s.nShowBarsWhenFullScreenTimeOut;
if (nTimeOut == 0) {
- ShowControls(CS_NONE, false);
+ ShowControls(CS_NONE);
ShowControlBar(&m_wndNavigationBar, false, TRUE);
} else if (nTimeOut > 0) {
SetTimer(TIMER_FULLSCREENCONTROLBARHIDER, nTimeOut*1000, NULL);
SetTimer(TIMER_FULLSCREENMOUSEHIDER, max(nTimeOut*1000, 2000), NULL);
}
} else {
- ShowControls(CS_NONE, false);
+ ShowControls(CS_NONE);
ShowControlBar(&m_wndNavigationBar, false, TRUE);
}
@@ -9672,7 +9682,7 @@ void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasT KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
KillTimer(TIMER_FULLSCREENMOUSEHIDER);
m_fHideCursor = false;
- ShowControls(s.nCS);
+ ShowControls(m_nCS);
if (GetPlaybackMode() == PM_CAPTURE && s.iDefaultCaptureDevice == 1) {
ShowControlBar(&m_wndNavigationBar, !s.fHideNavigation, TRUE);
}
@@ -9788,131 +9798,131 @@ void CMainFrame::AutoChangeMonitorMode() SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes[0].dmFSRes, mf_hmonitor);
}
}
- -void CMainFrame::MoveVideoWindow(bool fShowStats) -{ - if ((m_iMediaLoadState == MLS_LOADED) && !m_fAudioOnly && IsWindowVisible()) { - RECT wr; - // fullscreen - if (m_pFullscreenWnd->IsWindow()) { - m_pFullscreenWnd->GetClientRect(&wr); - } - // windowed Mode - else if (!m_fFullScreen) { - m_wndView.GetClientRect(&wr); - } - // fullscreen on non-primary monitor - else { - GetWindowRect(&wr); - RECT r; - m_wndView.GetWindowRect(&r); - wr.left -= r.left; - wr.right -= r.left; - wr.top -= r.top; - wr.bottom -= r.top; - } - - double dWRWidth = (double)(wr.right - wr.left); - double dWRHeight = (double)(wr.bottom - wr.top); - - RECT vr = {0, 0, 0, 0}; - - OAFilterState fs = GetMediaState(); - if ((fs == State_Paused) || (fs == State_Running) || (fs == State_Stopped) && (m_fShockwaveGraph || m_fQuicktimeGraph)) { - SIZE arxy = GetVideoSize(); - double dARx = (double)(arxy.cx); - double dARy = (double)(arxy.cy); - - dvstype iDefaultVideoSize = static_cast<dvstype>(AfxGetAppSettings().iDefaultVideoSize); - double dVRWidth, dVRHeight; - if (iDefaultVideoSize == DVS_HALF) { - dVRWidth = dARx * 0.5; - dVRHeight = dARy * 0.5; - } - else if (iDefaultVideoSize == DVS_NORMAL) { - dVRWidth = dARx; - dVRHeight = dARy; - } - else if (iDefaultVideoSize == DVS_DOUBLE) { - dVRWidth = dARx * 2.0; - dVRHeight = dARy * 2.0; - } else { - dVRWidth = dWRWidth; - dVRHeight = dWRHeight; - } - - if (!m_fShockwaveGraph) { // && !m_fQuicktimeGraph) - double dCRWidth = dVRHeight * dARx / dARy; - - if (iDefaultVideoSize == DVS_FROMINSIDE) { - if (dVRWidth < dCRWidth) { - dVRHeight = dVRWidth * dARy / dARx; - } else { - dVRWidth = dCRWidth; - } - } - else if (iDefaultVideoSize == DVS_FROMOUTSIDE) { - if (dVRWidth > dCRWidth) { - dVRHeight = dVRWidth * dARy / dARx; - } else { - dVRWidth = dCRWidth; - } - } - else if ((iDefaultVideoSize == DVS_ZOOM1) || (iDefaultVideoSize == DVS_ZOOM2)) { - double minw = dCRWidth; - double maxw = dCRWidth; - - if (dVRWidth < dCRWidth) { - minw = dVRWidth; - } - else { - maxw = dVRWidth; - } - - double scale = (iDefaultVideoSize == DVS_ZOOM1) ? - 1.0 / 3.0 : - 2.0 / 3.0; - dVRWidth = minw + (maxw - minw) * scale; - dVRHeight = dVRWidth * dARy / dARx; - } - } - - // either flooring or ceiling is required here, else the left-to-right and top-to-bottom sizes will get distorted through rounding twice each - double dPPLeft = floor(m_PosX * (dWRWidth * 3.0 - m_ZoomX * dVRWidth) - dWRWidth); - double dPPTop = floor(m_PosY * (dWRHeight * 3.0 - m_ZoomY * dVRHeight) - dWRHeight); - // left and top parts are allowed to be negative - vr.left = (LONG)(dPPLeft); - vr.top = (LONG)(dPPTop); - // right and bottom parts are always at picture center or beyond, so never negative - vr.right = (LONG)(m_ZoomX * dVRWidth + dPPLeft); - vr.bottom = (LONG)(m_ZoomY * dVRHeight + dPPTop); - - if (fShowStats) { - CString info; - info.Format(_T("Pos %.2f %.2f, Zoom %.2f %.2f, AR %.2f"), m_PosX, m_PosY, m_ZoomX, m_ZoomY, dVRWidth / dVRHeight); - SendStatusMessage(info, 3000); - } - } - - if (m_pCAP) { - m_pCAP->SetPosition(wr, vr); - Vector v(DegToRad(m_AngleX), DegToRad(m_AngleY), DegToRad(m_AngleZ)); - m_pCAP->SetVideoAngle(v); - } else { - HRESULT hr; - hr = pBV->SetDefaultSourcePosition(); - hr = pBV->SetDestinationPosition(vr.left, vr.top, vr.right - vr.left, vr.bottom - vr.top); - hr = pVW->SetWindowPosition(wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top); - - if (m_pMFVDC) { - m_pMFVDC->SetVideoPosition(NULL, &wr); - } - } - - m_wndView.SetVideoRect(&wr); - } else { - m_wndView.SetVideoRect(); - } +
+void CMainFrame::MoveVideoWindow(bool fShowStats)
+{
+ if ((m_iMediaLoadState == MLS_LOADED) && !m_fAudioOnly && IsWindowVisible()) {
+ RECT wr;
+ // fullscreen
+ if (m_pFullscreenWnd->IsWindow()) {
+ m_pFullscreenWnd->GetClientRect(&wr);
+ }
+ // windowed Mode
+ else if (!m_fFullScreen) {
+ m_wndView.GetClientRect(&wr);
+ }
+ // fullscreen on non-primary monitor
+ else {
+ GetWindowRect(&wr);
+ RECT r;
+ m_wndView.GetWindowRect(&r);
+ wr.left -= r.left;
+ wr.right -= r.left;
+ wr.top -= r.top;
+ wr.bottom -= r.top;
+ }
+
+ double dWRWidth = (double)(wr.right - wr.left);
+ double dWRHeight = (double)(wr.bottom - wr.top);
+
+ RECT vr = {0, 0, 0, 0};
+
+ OAFilterState fs = GetMediaState();
+ if ((fs == State_Paused) || (fs == State_Running) || (fs == State_Stopped) && (m_fShockwaveGraph || m_fQuicktimeGraph)) {
+ SIZE arxy = GetVideoSize();
+ double dARx = (double)(arxy.cx);
+ double dARy = (double)(arxy.cy);
+
+ dvstype iDefaultVideoSize = static_cast<dvstype>(AfxGetAppSettings().iDefaultVideoSize);
+ double dVRWidth, dVRHeight;
+ if (iDefaultVideoSize == DVS_HALF) {
+ dVRWidth = dARx * 0.5;
+ dVRHeight = dARy * 0.5;
+ }
+ else if (iDefaultVideoSize == DVS_NORMAL) {
+ dVRWidth = dARx;
+ dVRHeight = dARy;
+ }
+ else if (iDefaultVideoSize == DVS_DOUBLE) {
+ dVRWidth = dARx * 2.0;
+ dVRHeight = dARy * 2.0;
+ } else {
+ dVRWidth = dWRWidth;
+ dVRHeight = dWRHeight;
+ }
+
+ if (!m_fShockwaveGraph) { // && !m_fQuicktimeGraph)
+ double dCRWidth = dVRHeight * dARx / dARy;
+
+ if (iDefaultVideoSize == DVS_FROMINSIDE) {
+ if (dVRWidth < dCRWidth) {
+ dVRHeight = dVRWidth * dARy / dARx;
+ } else {
+ dVRWidth = dCRWidth;
+ }
+ }
+ else if (iDefaultVideoSize == DVS_FROMOUTSIDE) {
+ if (dVRWidth > dCRWidth) {
+ dVRHeight = dVRWidth * dARy / dARx;
+ } else {
+ dVRWidth = dCRWidth;
+ }
+ }
+ else if ((iDefaultVideoSize == DVS_ZOOM1) || (iDefaultVideoSize == DVS_ZOOM2)) {
+ double minw = dCRWidth;
+ double maxw = dCRWidth;
+
+ if (dVRWidth < dCRWidth) {
+ minw = dVRWidth;
+ }
+ else {
+ maxw = dVRWidth;
+ }
+
+ double scale = (iDefaultVideoSize == DVS_ZOOM1) ?
+ 1.0 / 3.0 :
+ 2.0 / 3.0;
+ dVRWidth = minw + (maxw - minw) * scale;
+ dVRHeight = dVRWidth * dARy / dARx;
+ }
+ }
+
+ // either flooring or ceiling is required here, else the left-to-right and top-to-bottom sizes will get distorted through rounding twice each
+ double dPPLeft = floor(m_PosX * (dWRWidth * 3.0 - m_ZoomX * dVRWidth) - dWRWidth);
+ double dPPTop = floor(m_PosY * (dWRHeight * 3.0 - m_ZoomY * dVRHeight) - dWRHeight);
+ // left and top parts are allowed to be negative
+ vr.left = (LONG)(dPPLeft);
+ vr.top = (LONG)(dPPTop);
+ // right and bottom parts are always at picture center or beyond, so never negative
+ vr.right = (LONG)(m_ZoomX * dVRWidth + dPPLeft);
+ vr.bottom = (LONG)(m_ZoomY * dVRHeight + dPPTop);
+
+ if (fShowStats) {
+ CString info;
+ info.Format(_T("Pos %.2f %.2f, Zoom %.2f %.2f, AR %.2f"), m_PosX, m_PosY, m_ZoomX, m_ZoomY, dVRWidth / dVRHeight);
+ SendStatusMessage(info, 3000);
+ }
+ }
+
+ if (m_pCAP) {
+ m_pCAP->SetPosition(wr, vr);
+ Vector v(DegToRad(m_AngleX), DegToRad(m_AngleY), DegToRad(m_AngleZ));
+ m_pCAP->SetVideoAngle(v);
+ } else {
+ HRESULT hr;
+ hr = pBV->SetDefaultSourcePosition();
+ hr = pBV->SetDestinationPosition(vr.left, vr.top, vr.right - vr.left, vr.bottom - vr.top);
+ hr = pVW->SetWindowPosition(wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top);
+
+ if (m_pMFVDC) {
+ m_pMFVDC->SetVideoPosition(NULL, &wr);
+ }
+ }
+
+ m_wndView.SetVideoRect(&wr);
+ } else {
+ m_wndView.SetVideoRect();
+ }
UpdateThumbarButton();
}
@@ -13362,9 +13372,9 @@ void CMainFrame::SetupShadersSubMenu() /////////////
-void CMainFrame::ShowControls(int nCS, bool fSave)
+void CMainFrame::ShowControls(int nCS, bool fSave /*= false*/)
{
- int nCSprev = AfxGetAppSettings().nCS;
+ int nCSprev = m_nCS;
int hbefore = 0, hafter = 0;
m_pLastBar = NULL;
@@ -13372,16 +13382,16 @@ void CMainFrame::ShowControls(int nCS, bool fSave) POSITION pos = m_bars.GetHeadPosition();
for (int i = 1; pos; i <<= 1) {
CControlBar* pNext = m_bars.GetNext(pos);
- ShowControlBar(pNext, !!(nCS&i), TRUE);
- if (nCS&i) {
+ ShowControlBar(pNext, !!(nCS & i), TRUE);
+ if (nCS & i) {
m_pLastBar = pNext;
}
CSize s = pNext->CalcFixedLayout(FALSE, TRUE);
- if (nCSprev&i) {
+ if (nCSprev & i) {
hbefore += s.cy;
}
- if (nCS&i) {
+ if (nCS & i) {
hafter += s.cy;
}
}
@@ -13393,11 +13403,11 @@ void CMainFrame::ShowControls(int nCS, bool fSave) if (wp.showCmd != SW_SHOWMAXIMIZED && !m_fFullScreen) {
CRect r;
GetWindowRect(r);
- MoveWindow(r.left, r.top, r.Width(), r.Height()+(hafter-hbefore));
+ MoveWindow(r.left, r.top, r.Width(), r.Height() + hafter - hbefore);
}
if (fSave) {
- AfxGetAppSettings().nCS = nCS;
+ m_nCS = nCS;
}
RecalcLayout();
diff --git a/src/mpc-hc/MainFrm.h b/src/mpc-hc/MainFrm.h index f91d019cc..35f8a8634 100644 --- a/src/mpc-hc/MainFrm.h +++ b/src/mpc-hc/MainFrm.h @@ -237,7 +237,8 @@ class CMainFrame : public CFrameWnd, public CDropTarget CRect m_rcDesktop;
- void ShowControls(int nCS, bool fSave = true);
+ void ShowControls(int nCS, bool fSave = false);
+ void SetUIPreset(int iCaptionMenuMode, UINT nCS);
void SetDefaultWindowRect(int iMonitor = 0);
void SetDefaultFullscreenState();
@@ -524,6 +525,7 @@ protected: // control bar embedded members CChildView m_wndView;
+ UINT m_nCS;
CPlayerSeekBar m_wndSeekBar;
CPlayerToolBar m_wndToolBar;
CPlayerInfoBar m_wndInfoBar;
|