Skip to content

Commit a5b37db

Browse files
committed
Merged revision(s) 25218-25219 from trunk/OpenMPT:
[Ref] Move last input device detection from CModControlDlg to DialogBase so that it can be used in more places. ........ [Fix] Resampling Dialog: Don't force-enable resampling to specified frequency just because keyboard focus is set to the frequency input field. Instead, this is now only done when its contents are changed, or with a mouse click as before. ........ git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.32@25220 56274372-70c3-4bfc-bfc3-4c3a0b034d27
1 parent a306523 commit a5b37db

File tree

6 files changed

+32
-25
lines changed

6 files changed

+32
-25
lines changed

mptrack/DialogBase.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,16 @@ BOOL DialogBase::OnInitDialog()
3535

3636
BOOL DialogBase::PreTranslateMessage(MSG *pMsg)
3737
{
38-
if(pMsg && HandleGlobalKeyMessage(*pMsg))
39-
return TRUE;
38+
if(pMsg)
39+
{
40+
if(pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
41+
m_lastInputDevice = InputDevice::Keyboard;
42+
else if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST)
43+
m_lastInputDevice = InputDevice::Mouse;
44+
45+
if(HandleGlobalKeyMessage(*pMsg))
46+
return TRUE;
47+
}
4048

4149
return CDialog::PreTranslateMessage(pMsg);
4250
}

mptrack/DialogBase.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ OPENMPT_NAMESPACE_BEGIN
1818
class DialogBase : public CDialog
1919
{
2020
public:
21+
enum class InputDevice : uint8
22+
{
23+
Unknown,
24+
Mouse,
25+
Keyboard,
26+
};
27+
2128
using CDialog::CDialog;
2229

2330
BOOL OnInitDialog() override;
@@ -44,6 +51,8 @@ class DialogBase : public CDialog
4451
private:
4552
CString m_tooltipText;
4653
int m_dpi = 0;
54+
protected:
55+
InputDevice m_lastInputDevice = InputDevice::Unknown;
4756
};
4857

4958
OPENMPT_NAMESPACE_END

mptrack/Globals.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,6 @@ CModControlDlg::~CModControlDlg()
6767
}
6868

6969

70-
BOOL CModControlDlg::PreTranslateMessage(MSG *pMsg)
71-
{
72-
if(pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
73-
m_lastInputDevice = InputDevice::Keyboard;
74-
else if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST)
75-
m_lastInputDevice = InputDevice::Mouse;
76-
77-
return DialogBase::PreTranslateMessage(pMsg);
78-
}
79-
80-
8170
void CModControlDlg::OnSize(UINT nType, int cx, int cy)
8271
{
8372
DialogBase::OnSize(nType, cx, cy);

mptrack/Globals.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,12 @@ class CModControlBar: public CToolBarCtrl
3838
class CModControlDlg : public DialogBase
3939
{
4040
protected:
41-
enum class InputDevice : uint8
42-
{
43-
Unknown,
44-
Mouse,
45-
Keyboard,
46-
};
47-
4841
CModDoc &m_modDoc;
4942
CSoundFile &m_sndFile;
5043
CModControlView &m_parent;
5144
HWND m_hWndView = nullptr;
5245
HWND m_lastFocusItem = nullptr;
5346
int m_nLockCount = 0;
54-
InputDevice m_lastInputDevice = InputDevice::Unknown;
5547
bool m_initialized = false;
5648

5749
public:
@@ -87,7 +79,6 @@ class CModControlDlg : public DialogBase
8779
afx_msg void OnSwitchToView();
8880

8981
//{{AFX_VIRTUAL(CModControlDlg)
90-
BOOL PreTranslateMessage(MSG *pMsg) override;
9182
void OnOK() override {}
9283
void OnCancel() override {}
9384
void OnDPIChanged() override { RecalcLayout(); }

mptrack/SampleEditorDialogs.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,14 +490,14 @@ BOOL AddSilenceDlg::OnInitDialog()
490490
{
491491
DialogBase::OnInitDialog();
492492

493-
CSpinButtonCtrl *spin = (CSpinButtonCtrl *)GetDlgItem(IDC_SPIN_ADDSILENCE);
493+
CSpinButtonCtrl *spin = static_cast<CSpinButtonCtrl *>(GetDlgItem(IDC_SPIN_ADDSILENCE));
494494
if(spin)
495495
{
496496
spin->SetRange32(0, int32_max);
497497
spin->SetPos32(m_numSamples);
498498
}
499499

500-
CComboBox *box = (CComboBox *)GetDlgItem(IDC_COMBO1);
500+
CComboBox *box = static_cast<CComboBox *>(GetDlgItem(IDC_COMBO1));
501501
if(box)
502502
{
503503
box->AddString(_T("samples"));
@@ -790,6 +790,7 @@ bool CResamplingDlg::m_updatePatternNotes = false;
790790

791791
BEGIN_MESSAGE_MAP(CResamplingDlg, DialogBase)
792792
ON_EN_SETFOCUS(IDC_EDIT1, &CResamplingDlg::OnFocusEdit)
793+
ON_EN_CHANGE(IDC_EDIT1, &CResamplingDlg::OnEditChanged)
793794
END_MESSAGE_MAP()
794795

795796

@@ -891,7 +892,15 @@ void CResamplingDlg::OnOK()
891892

892893
void CResamplingDlg::OnFocusEdit()
893894
{
894-
CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO3);
895+
if(m_lastInputDevice == InputDevice::Mouse)
896+
CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO3);
897+
}
898+
899+
900+
void CResamplingDlg::OnEditChanged()
901+
{
902+
if(m_lastInputDevice != InputDevice::Unknown)
903+
CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO3);
895904
}
896905

897906

mptrack/SampleEditorDialogs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ class CResamplingDlg : public DialogBase
246246
void OnOK() override;
247247

248248
afx_msg void OnFocusEdit();
249+
afx_msg void OnEditChanged();
249250

250251
DECLARE_MESSAGE_MAP()
251252
};

0 commit comments

Comments
 (0)