From bf771280538a289e156c5d410c512b66cab8e0e5 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sat, 4 Oct 2025 03:47:17 -0400 Subject: [PATCH] [idd] helper: add mode save button --- idd/LGIddHelper/CButton.cpp | 10 ++++++++++ idd/LGIddHelper/CButton.h | 9 +++++++++ idd/LGIddHelper/CConfigWindow.cpp | 28 ++++++++++++++++++++-------- idd/LGIddHelper/CConfigWindow.h | 3 +++ idd/LGIddHelper/LGIddHelper.vcxproj | 2 ++ 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 idd/LGIddHelper/CButton.cpp create mode 100644 idd/LGIddHelper/CButton.h diff --git a/idd/LGIddHelper/CButton.cpp b/idd/LGIddHelper/CButton.cpp new file mode 100644 index 00000000..a68fbd72 --- /dev/null +++ b/idd/LGIddHelper/CButton.cpp @@ -0,0 +1,10 @@ +#include "CButton.h" +#include +#include + +CButton::CButton(LPCWSTR title, DWORD style, HWND parent) +{ + m_hwnd = createWindowSimple(WC_BUTTON, title, style, parent); + if (!m_hwnd) + DEBUG_ERROR_HR(GetLastError(), "Failed to create button"); +} diff --git a/idd/LGIddHelper/CButton.h b/idd/LGIddHelper/CButton.h new file mode 100644 index 00000000..2f440d7b --- /dev/null +++ b/idd/LGIddHelper/CButton.h @@ -0,0 +1,9 @@ +#pragma once + +#include "CWidget.h" + +class CButton : public CWidget +{ +public: + CButton(LPCWSTR title, DWORD style, HWND parent); +}; diff --git a/idd/LGIddHelper/CConfigWindow.cpp b/idd/LGIddHelper/CConfigWindow.cpp index 9963d533..2faea601 100644 --- a/idd/LGIddHelper/CConfigWindow.cpp +++ b/idd/LGIddHelper/CConfigWindow.cpp @@ -2,6 +2,7 @@ #include "CListBox.h" #include "CGroupBox.h" #include "CEditWidget.h" +#include "CButton.h" #include #include #include @@ -56,7 +57,7 @@ void CConfigWindow::updateFont() for (HWND child : std::initializer_list({ *m_version, *m_modeGroup, *m_modeBox, *m_widthLabel, *m_heightLabel, *m_refreshLabel, - *m_modeWidth, *m_modeHeight, *m_modeRefresh, + *m_modeWidth, *m_modeHeight, *m_modeRefresh, *m_modeUpdate, })) SendMessage(child, WM_SETFONT, (WPARAM)m_font.Get(), 1); } @@ -108,6 +109,8 @@ LRESULT CConfigWindow::onCreate() m_modeHeight.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd)); m_modeRefresh.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd)); + m_modeUpdate.reset(new CButton(L"Save", WS_CHILD | WS_VISIBLE, m_hwnd)); + updateFont(); return 0; @@ -125,13 +128,14 @@ LRESULT CConfigWindow::onResize(DWORD width, DWORD height) WidgetPositioner pos(m_scale, width, height); pos.pinTopLeftRight(*m_version, 12, 12, 12, 20); pos.pinLeftTopBottom(*m_modeGroup, 12, 40, 200, 12); - pos.pinLeftTopBottom(*m_modeBox, 24, 64, 176, 96); - pos.pinBottomLeft(*m_widthLabel, 24, 72, 50, 20); - pos.pinBottomLeft(*m_heightLabel, 24, 48, 50, 20); - pos.pinBottomLeft(*m_refreshLabel, 24, 24, 50, 20); - pos.pinBottomLeft(*m_modeWidth, 75, 72, 50, 20); - pos.pinBottomLeft(*m_modeHeight, 75, 48, 50, 20); - pos.pinBottomLeft(*m_modeRefresh, 75, 24, 50, 20); + pos.pinLeftTopBottom(*m_modeBox, 24, 64, 176, 120); + pos.pinBottomLeft(*m_widthLabel, 24, 96, 50, 20); + pos.pinBottomLeft(*m_heightLabel, 24, 72, 50, 20); + pos.pinBottomLeft(*m_refreshLabel, 24, 48, 50, 20); + pos.pinBottomLeft(*m_modeWidth, 75, 96, 50, 20); + pos.pinBottomLeft(*m_modeHeight, 75, 72, 50, 20); + pos.pinBottomLeft(*m_modeRefresh, 75, 48, 50, 20); + pos.pinBottomLeft(*m_modeUpdate, 24, 20, 50, 24); return 0; } @@ -144,5 +148,13 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd) m_modeHeight->setNumericValue(mode.height); m_modeRefresh->setNumericValue(mode.refresh); } + else if (hwnd == *m_modeUpdate && code == BN_CLICKED && m_modes) + { + auto &mode = (*m_modes)[m_modeBox->getSelData()]; + mode.width = m_modeWidth->getNumericValue(); + mode.height = m_modeHeight->getNumericValue(); + mode.refresh = m_modeRefresh->getNumericValue(); + DEBUG_INFO(L"Updated mode to %s", mode.toString().c_str()); + } return 0; } diff --git a/idd/LGIddHelper/CConfigWindow.h b/idd/LGIddHelper/CConfigWindow.h index c652a024..e0c40a29 100644 --- a/idd/LGIddHelper/CConfigWindow.h +++ b/idd/LGIddHelper/CConfigWindow.h @@ -11,6 +11,7 @@ class CListBox; class CGroupBox; class CEditWidget; +class CButton; class CConfigWindow : public CWindow { @@ -28,6 +29,8 @@ class CConfigWindow : public CWindow std::unique_ptr m_modeHeight; std::unique_ptr m_modeRefresh; + std::unique_ptr m_modeUpdate; + std::function m_onDestroy; double m_scale; Microsoft::WRL::Wrappers::HandleT m_font; diff --git a/idd/LGIddHelper/LGIddHelper.vcxproj b/idd/LGIddHelper/LGIddHelper.vcxproj index 20e1ca63..08c39fce 100644 --- a/idd/LGIddHelper/LGIddHelper.vcxproj +++ b/idd/LGIddHelper/LGIddHelper.vcxproj @@ -179,6 +179,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd + @@ -194,6 +195,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd +