Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Close button in toolbar UI for physically disabled persons (ticket #4328) #144

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/mpc-hc/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_UPDATE_COMMAND_UI(ID_PLAY_STOP, OnUpdatePlayPauseStop)
ON_COMMAND_RANGE(ID_PLAY_FRAMESTEP, ID_PLAY_FRAMESTEPCANCEL, OnPlayFramestep)
ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_FRAMESTEP, ID_PLAY_FRAMESTEPCANCEL, OnUpdatePlayFramestep)
ON_COMMAND(ID_PLAY_CLOSE, OnPlayClose)
ON_UPDATE_COMMAND_UI(ID_PLAY_CLOSE, OnUpdatePlayClose)
ON_COMMAND_RANGE(ID_PLAY_SEEKBACKWARDSMALL, ID_PLAY_SEEKFORWARDLARGE, OnPlaySeek)
ON_COMMAND(ID_PLAY_SEEKSET, OnPlaySeekSet)
ON_COMMAND_RANGE(ID_PLAY_SEEKKEYBACKWARD, ID_PLAY_SEEKKEYFORWARD, OnPlaySeekKey)
Expand Down Expand Up @@ -7280,6 +7282,19 @@ void CMainFrame::OnUpdatePlayFramestep(CCmdUI* pCmdUI)
pCmdUI->Enable(fEnable);
}

void CMainFrame::OnPlayClose()
{
CMPlayerCApp* pApp = AfxGetMyApp();
if (pApp)
pApp->Exit();
}

void CMainFrame::OnUpdatePlayClose(CCmdUI* pCmdUI)
{
if (pCmdUI)
pCmdUI->Enable(true);
}

void CMainFrame::OnPlaySeek(UINT nID)
{
const auto& s = AfxGetAppSettings();
Expand Down
2 changes: 2 additions & 0 deletions src/mpc-hc/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,8 @@ class CMainFrame : public CFrameWnd, public CDropTarget
afx_msg void OnUpdatePlayPauseStop(CCmdUI* pCmdUI);
afx_msg void OnPlayFramestep(UINT nID);
afx_msg void OnUpdatePlayFramestep(CCmdUI* pCmdUI);
afx_msg void OnPlayClose();
afx_msg void OnUpdatePlayClose(CCmdUI* pCmdUI);
afx_msg void OnPlaySeek(UINT nID);
afx_msg void OnPlaySeekSet();
afx_msg void OnPlaySeekKey(UINT nID); // no menu item
Expand Down
23 changes: 13 additions & 10 deletions src/mpc-hc/PlayerToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ BOOL CPlayerToolBar::Create(CWnd* pParentWnd)
TBBS_SEPARATOR,
TBBS_BUTTON,
TBBS_SEPARATOR,
TBBS_BUTTON,
TBBS_SEPARATOR,
TBBS_SEPARATOR,
TBBS_CHECKBOX,
};
Expand Down Expand Up @@ -151,7 +153,7 @@ void CPlayerToolBar::ArrangeControls()
CRect br = GetBorders();

CRect r10;
GetItemRect(10, &r10);
GetItemRect(m_nVolumeSeparatorIndex - 1, &r10);

CRect vr(r.right + br.right - 60, r.top - 2, r.right + br.right + 6, r.bottom);
m_volctrl.MoveWindow(vr);
Expand All @@ -166,8 +168,8 @@ void CPlayerToolBar::ArrangeControls()
UINT nID;
UINT nStyle;
int iImage;
GetButtonInfo(12, nID, nStyle, iImage);
SetButtonInfo(11, GetItemID(11), TBBS_SEPARATOR, vr.left - iImage - r10.right - (r10.bottom - r10.top) + 11);
GetButtonInfo(m_nVolumeOnImageIndex, nID, nStyle, iImage);
SetButtonInfo(m_nVolumeSeparatorIndex, GetItemID(m_nVolumeSeparatorIndex), TBBS_SEPARATOR, vr.left - iImage - r10.right - (r10.bottom - r10.top) + 11);
}

void CPlayerToolBar::SetMute(bool fMute)
Expand All @@ -176,7 +178,7 @@ void CPlayerToolBar::SetMute(bool fMute)
TBBUTTONINFO bi;
bi.cbSize = sizeof(bi);
bi.dwMask = TBIF_IMAGE;
bi.iImage = fMute ? 13 : 12;
bi.iImage = fMute ? m_nVolumeOffImageIndex : m_nVolumeOnImageIndex;
tb.SetButtonInfo(ID_VOLUME_MUTE, &bi);

AfxGetAppSettings().fMute = fMute;
Expand All @@ -189,7 +191,7 @@ bool CPlayerToolBar::IsMuted() const
bi.cbSize = sizeof(bi);
bi.dwMask = TBIF_IMAGE;
tb.GetButtonInfo(ID_VOLUME_MUTE, &bi);
return (bi.iImage == 13);
return (bi.iImage == m_nVolumeOffImageIndex);
}

int CPlayerToolBar::GetVolume() const
Expand All @@ -206,7 +208,7 @@ int CPlayerToolBar::GetVolume() const

int CPlayerToolBar::GetMinWidth() const
{
return m_nButtonHeight * 9 + 155 + m_volumeMinSizeInc;
return m_nButtonHeight * (m_nVolumeSeparatorIndex - 2) + 155 + m_volumeMinSizeInc;
}

void CPlayerToolBar::SetVolume(int volume)
Expand Down Expand Up @@ -260,7 +262,7 @@ void CPlayerToolBar::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
CDC dc;
dc.Attach(pTBCD->nmcd.hdc);
RECT r;
GetItemRect(11, &r);
GetItemRect(m_nVolumeSeparatorIndex, &r);
dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE));
dc.Detach();
lr |= CDRF_SKIPDEFAULT;
Expand Down Expand Up @@ -391,11 +393,12 @@ BOOL CPlayerToolBar::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
tb.GetButtonInfo(ID_VOLUME_MUTE, &bi);

static CString strTipText;
if (bi.iImage == 12) {
if (bi.iImage == m_nVolumeOnImageIndex) {
strTipText.LoadString(ID_VOLUME_MUTE);
} else if (bi.iImage == 13) {
} else if (bi.iImage == m_nVolumeOffImageIndex) {
strTipText.LoadString(ID_VOLUME_MUTE_ON);
} else if (bi.iImage == 14) {
}
else if (bi.iImage == m_nVolumeDisabledImageIndex) {
strTipText.LoadString(ID_VOLUME_MUTE_DISABLED);
} else {
return FALSE;
Expand Down
5 changes: 5 additions & 0 deletions src/mpc-hc/PlayerToolBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class CPlayerToolBar : public CToolBar
DECLARE_DYNAMIC(CPlayerToolBar)

private:
const int m_nVolumeSeparatorIndex = 13;
const int m_nVolumeOnImageIndex = 14;
const int m_nVolumeOffImageIndex = 15;
const int m_nVolumeDisabledImageIndex = 16;

CMainFrame* m_pMainFrame;

bool IsMuted() const;
Expand Down
3 changes: 3 additions & 0 deletions src/mpc-hc/mpc-hc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,8 @@ BEGIN
BUTTON ID_BUTTONSEP
BUTTON ID_PLAY_FRAMESTEP
BUTTON ID_BUTTONSEP
BUTTON ID_PLAY_CLOSE
BUTTON ID_BUTTONSEP
BUTTON ID_DUMMYSEPARATOR
BUTTON ID_VOLUME_MUTE
BUTTON ID_VOLUME_MUTE_ON
Expand Down Expand Up @@ -2430,6 +2432,7 @@ BEGIN
ID_PLAY_PAUSE "Pause\nPause"
ID_PLAY_STOP "Stop\nStop"
ID_PLAY_FRAMESTEP "Step\nStep"
ID_PLAY_CLOSE "Close\nClose"
ID_PLAY_DECRATE "Decrease speed\nDecrease speed"
ID_PLAY_INCRATE "Increase speed\nIncrease speed"
END
Expand Down
9 changes: 7 additions & 2 deletions src/mpc-hc/mplayerc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,12 @@ bool CMPlayerCApp::SendCommandLine(HWND hWnd)
return !!SendMessage(hWnd, WM_COPYDATA, (WPARAM)nullptr, (LPARAM)&cds);
}

void CMPlayerCApp::Exit()
{
m_fClosingState = true;
OnAppExit();
}

// CMPlayerCApp initialization

// This hook prevents the program from reporting that a debugger is attached
Expand Down Expand Up @@ -2012,8 +2018,7 @@ void CMPlayerCApp::OnAppAbout()

void CMPlayerCApp::OnFileExit()
{
m_fClosingState = true;
OnAppExit();
Exit();
}

void CMPlayerCApp::OnHelpShowcommandlineswitches()
Expand Down
1 change: 1 addition & 0 deletions src/mpc-hc/mplayerc.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class CMPlayerCApp : public CWinApp
bool IsIniValid() const;
bool ChangeSettingsLocation(bool useIni);
bool ExportSettings(CString savePath, CString subKey = _T(""));
void Exit();

private:
std::map<CString, std::map<CString, CString, CStringUtils::IgnoreCaseLess>, CStringUtils::IgnoreCaseLess> m_ProfileMap;
Expand Down
Binary file modified src/mpc-hc/res/toolbar.bmp
Binary file not shown.
1 change: 1 addition & 0 deletions src/mpc-hc/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
#define ID_NORMALIZE 994
#define ID_REGAIN_VOLUME 995
#define ID_PLAY_SEEKSET 996
#define ID_PLAY_CLOSE 997
#define ID_FILTERS_COPY_TO_CLIPBOARD 1999
#define ID_FILTERS_SUBITEM_START 2000
#define ID_FILTERS_SUBITEM_END 2099
Expand Down