Skip to content

Commit

Permalink
[Imp] Song Properties: Render warning icon at requested DPI.
Browse files Browse the repository at this point in the history
git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22135 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Nov 10, 2024
1 parent 1d1b819 commit d2713eb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
1 change: 1 addition & 0 deletions mptrack/ChannelManagerDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ void CChannelManagerDlg::OnDPIChanged()
{
m_font.DeleteObject();
ResizeWindow();
DialogBase::OnDPIChanged();
}


Expand Down
47 changes: 35 additions & 12 deletions mptrack/dlg_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ BOOL CModTypeDlg::OnInitDialog()
m_nChannels = sndFile.GetNumChannels();
m_tempoSwing = sndFile.m_tempoSwing;
m_playBehaviour = sndFile.m_playBehaviour;
initialized = false;
m_initialized = false;

// Mod types

Expand Down Expand Up @@ -112,17 +112,39 @@ BOOL CModTypeDlg::OnInitDialog()
if(sndFile.m_dwCreatedWithVersion) SetDlgItemText(IDC_EDIT_CREATEDWITH, _T("OpenMPT ") + FormatVersionNumber(sndFile.m_dwCreatedWithVersion));
SetDlgItemText(IDC_EDIT_SAVEDWITH, mpt::ToCString(sndFile.m_modFormat.madeWithTracker.empty() ? sndFile.m_modFormat.formatName : sndFile.m_modFormat.madeWithTracker));

const int iconSize = HighDPISupport::ScalePixels(32, m_hWnd);
m_warnIcon = (HICON)::LoadImage(NULL, IDI_EXCLAMATION, IMAGE_ICON, iconSize, iconSize, LR_SHARED);

OnDPIChanged();
UpdateDialog();

initialized = true;
m_initialized = true;
EnableToolTips(TRUE);
return TRUE;
}


void CModTypeDlg::OnDPIChanged()
{
DialogBase::OnDPIChanged();

const int iconSize = HighDPISupport::ScalePixels(32, m_hWnd);
DestroyIcon(m_warnIcon);
m_warnIcon = nullptr;

mpt::Library comctl32(mpt::LibraryPath::System(P_("Comctl32")));
if(comctl32.IsValid())
{
using PLOADICONWITHSCALEDOWN = HRESULT(WINAPI *)(HINSTANCE, PCWSTR, int, int, HICON *);
PLOADICONWITHSCALEDOWN LoadIconWithScaleDown = nullptr;
if(comctl32.Bind(LoadIconWithScaleDown, "LoadIconWithScaleDown"))
LoadIconWithScaleDown(NULL, IDI_EXCLAMATION, iconSize, iconSize, &m_warnIcon);
}
if(!m_warnIcon)
m_warnIcon = reinterpret_cast<HICON>(::LoadImage(NULL, IDI_EXCLAMATION, IMAGE_ICON, iconSize, iconSize, LR_SHARED));

if(m_showWarning)
static_cast<CStatic *>(GetDlgItem(IDC_STATIC1))->SetIcon(m_warnIcon);
}


CString CModTypeDlg::FormatVersionNumber(Version version)
{
return mpt::ToCString(version.ToUString() + (version.IsTestVersion() ? U_(" (test build)") : U_("")));
Expand Down Expand Up @@ -186,7 +208,7 @@ void CModTypeDlg::UpdateDialog()
if(allowedFlags[SONG_PT_MODE]) OnPTModeChanged();

// Tempo modes
const TempoMode oldTempoMode = initialized ? static_cast<TempoMode>(m_TempoModeBox.GetItemData(m_TempoModeBox.GetCurSel())) : sndFile.m_nTempoMode;
const TempoMode oldTempoMode = m_initialized ? static_cast<TempoMode>(m_TempoModeBox.GetItemData(m_TempoModeBox.GetCurSel())) : sndFile.m_nTempoMode;
m_TempoModeBox.ResetContent();

m_TempoModeBox.SetItemData(m_TempoModeBox.AddString(_T("Classic")), static_cast<DWORD_PTR>(TempoMode::Classic));
Expand All @@ -206,7 +228,7 @@ void CModTypeDlg::UpdateDialog()
OnTempoModeChanged();

// Mix levels
const MixLevels oldMixLevels = initialized ? static_cast<MixLevels>(m_PlugMixBox.GetItemData(m_PlugMixBox.GetCurSel())) : sndFile.GetMixLevels();
const MixLevels oldMixLevels = m_initialized ? static_cast<MixLevels>(m_PlugMixBox.GetItemData(m_PlugMixBox.GetCurSel())) : sndFile.GetMixLevels();
m_PlugMixBox.ResetContent();
if(m_nType == MOD_TYPE_MPT || sndFile.GetMixLevels() == MixLevels::v1_17RC3) // In XM/IT, this is only shown for backwards compatibility with existing tunes
m_PlugMixBox.SetItemData(m_PlugMixBox.AddString(_T("OpenMPT 1.17RC3")), static_cast<DWORD_PTR>(MixLevels::v1_17RC3));
Expand Down Expand Up @@ -252,7 +274,8 @@ void CModTypeDlg::UpdateDialog()
// Compatibility settings
const PlayBehaviourSet defaultBehaviour = CSoundFile::GetDefaultPlaybackBehaviour(m_nType);
const PlayBehaviourSet supportedBehaviour = CSoundFile::GetSupportedPlaybackBehaviour(m_nType);
bool enableSetDefaults = false, showWarning = false;
bool enableSetDefaults = false;
m_showWarning = false;
if(m_nType & (MOD_TYPE_MPT | MOD_TYPE_IT | MOD_TYPE_XM))
{
for(size_t i = 0; i < m_playBehaviour.size(); i++)
Expand All @@ -265,21 +288,21 @@ void CModTypeDlg::UpdateDialog()
enableSetDefaults = true;
if(!isMPTM)
{
showWarning = true;
m_showWarning = true;
break;
}
}
if(isMPTM && m_playBehaviour[i] && !supportedBehaviour[i])
{

enableSetDefaults = true;
showWarning = true;
m_showWarning = true;
break;
}
}
}
static_cast<CStatic *>(GetDlgItem(IDC_STATIC1))->SetIcon(showWarning ? m_warnIcon : nullptr);
GetDlgItem(IDC_STATIC2)->SetWindowText(showWarning
static_cast<CStatic *>(GetDlgItem(IDC_STATIC1))->SetIcon(m_showWarning ? m_warnIcon : nullptr);
GetDlgItem(IDC_STATIC2)->SetWindowText(m_showWarning
? _T("Playback settings have been set to legacy compatibility mode. Click \"Set Defaults\" to use the recommended settings instead.")
: _T("Compatibility settings are currently optimal. It is advised to not edit them."));
GetDlgItem(IDC_BUTTON3)->EnableWindow(enableSetDefaults ? TRUE : FALSE);
Expand Down
4 changes: 3 additions & 1 deletion mptrack/dlg_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class CModTypeDlg : public DialogBase
PlayBehaviourSet m_playBehaviour;
CHANNELINDEX m_nChannels = 0;
MODTYPE m_nType = MOD_TYPE_NONE;
bool initialized = false;
bool m_showWarning = false;
bool m_initialized = false;

public:
CModTypeDlg(CSoundFile &sf, CWnd *parent);
Expand All @@ -56,6 +57,7 @@ class CModTypeDlg : public DialogBase
//{{AFX_VIRTUAL(CModTypeDlg)
void DoDataExchange(CDataExchange* pDX) override;
BOOL OnInitDialog() override;
void OnDPIChanged() override;
void OnOK() override;
//}}AFX_VIRTUAL

Expand Down
1 change: 1 addition & 0 deletions mptrack/view_com.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ void CViewComments::OnDPIChanged()
m_ToolBar.SetButtonSize(CSize(btnSizeX, btnSizeY));
m_ToolBar.SetBitmapSize(CSize(imgSize, imgSize));
RecalcLayout();
CModScrollView::OnDPIChanged();
}


Expand Down

0 comments on commit d2713eb

Please sign in to comment.