From ab6e2c89d541afc9a475d20d5b3639933a24f0d1 Mon Sep 17 00:00:00 2001 From: Quantum Date: Tue, 23 Sep 2025 02:03:41 -0400 Subject: [PATCH] [idd] helper: add basic group box around mode config --- idd/LGIddHelper/CConfigWindow.cpp | 10 +++++++--- idd/LGIddHelper/CConfigWindow.h | 2 ++ idd/LGIddHelper/CGroupBox.cpp | 10 ++++++++++ idd/LGIddHelper/CGroupBox.h | 9 +++++++++ idd/LGIddHelper/LGIddHelper.vcxproj | 2 ++ idd/LGIddHelper/LGIddHelper.vcxproj.filters | 9 +++++++++ 6 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 idd/LGIddHelper/CGroupBox.cpp create mode 100644 idd/LGIddHelper/CGroupBox.h diff --git a/idd/LGIddHelper/CConfigWindow.cpp b/idd/LGIddHelper/CConfigWindow.cpp index c8b7f9fe..c641c287 100644 --- a/idd/LGIddHelper/CConfigWindow.cpp +++ b/idd/LGIddHelper/CConfigWindow.cpp @@ -1,5 +1,6 @@ #include "CConfigWindow.h" #include "CListBox.h" +#include "CGroupBox.h" #include #include #include @@ -28,7 +29,7 @@ CConfigWindow::CConfigWindow() : m_scale(1) m_modes = m_settings.getModes(); if (!CreateWindowEx(0, MAKEINTATOM(s_atom), L"Looking Glass IDD Configuration", - WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 500, 400, + WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 400, NULL, NULL, hInstance, this)) { DEBUG_ERROR_HR(GetLastError(), "Failed to create window"); @@ -52,7 +53,7 @@ void CConfigWindow::updateFont() return; } - for (HWND child : std::initializer_list({ *m_version, *m_modeBox })) + for (HWND child : std::initializer_list({ *m_version, *m_modeGroup, *m_modeBox })) SendMessage(child, WM_SETFONT, (WPARAM)m_font.Get(), 1); } @@ -83,6 +84,8 @@ LRESULT CConfigWindow::onCreate() m_scale = GetDpiForWindow(m_hwnd) / 96.0; m_version.reset(new CStaticWidget(L"Looking Glass IDD " LG_VERSION_STR, WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd)); + m_modeGroup.reset(new CGroupBox(L"Custom modes", WS_CHILD | WS_VISIBLE, m_hwnd)); + m_modeBox.reset(new CListBox(WS_CHILD | WS_VISIBLE | LBS_NOTIFY, m_hwnd)); if (m_modes) { @@ -106,6 +109,7 @@ LRESULT CConfigWindow::onResize(DWORD width, DWORD height) { WidgetPositioner pos(m_scale, width, height); pos.pinTopLeftRight(*m_version, 12, 12, 12, 20); - pos.pinLeftTopBottom(*m_modeBox, 12, 40, 200, 12); + pos.pinLeftTopBottom(*m_modeGroup, 12, 40, 200, 12); + pos.pinLeftTopBottom(*m_modeBox, 24, 64, 176, 24); return 0; } diff --git a/idd/LGIddHelper/CConfigWindow.h b/idd/LGIddHelper/CConfigWindow.h index 598b800e..c77cc807 100644 --- a/idd/LGIddHelper/CConfigWindow.h +++ b/idd/LGIddHelper/CConfigWindow.h @@ -9,12 +9,14 @@ #include "UIHelpers.h" class CListBox; +class CGroupBox; class CConfigWindow : public CWindow { static ATOM s_atom; std::unique_ptr m_version; + std::unique_ptr m_modeGroup; std::unique_ptr m_modeBox; std::function m_onDestroy; diff --git a/idd/LGIddHelper/CGroupBox.cpp b/idd/LGIddHelper/CGroupBox.cpp new file mode 100644 index 00000000..da9d042b --- /dev/null +++ b/idd/LGIddHelper/CGroupBox.cpp @@ -0,0 +1,10 @@ +#include "CGroupBox.h" +#include +#include + +CGroupBox::CGroupBox(LPCWSTR title, DWORD style, HWND parent) +{ + m_hwnd = createWindowSimple(WC_BUTTON, title, style | BS_GROUPBOX, parent); + if (!m_hwnd) + DEBUG_ERROR_HR(GetLastError(), "Failed to create static widget"); +} diff --git a/idd/LGIddHelper/CGroupBox.h b/idd/LGIddHelper/CGroupBox.h new file mode 100644 index 00000000..23988aab --- /dev/null +++ b/idd/LGIddHelper/CGroupBox.h @@ -0,0 +1,9 @@ +#pragma once + +#include "CWidget.h" + +class CGroupBox : public CWidget +{ +public: + CGroupBox(LPCWSTR title, DWORD style, HWND parent); +}; diff --git a/idd/LGIddHelper/LGIddHelper.vcxproj b/idd/LGIddHelper/LGIddHelper.vcxproj index e68840ad..ae9ca051 100644 --- a/idd/LGIddHelper/LGIddHelper.vcxproj +++ b/idd/LGIddHelper/LGIddHelper.vcxproj @@ -180,6 +180,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd + @@ -193,6 +194,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd + diff --git a/idd/LGIddHelper/LGIddHelper.vcxproj.filters b/idd/LGIddHelper/LGIddHelper.vcxproj.filters index 37b9f8ab..f9146e12 100644 --- a/idd/LGIddHelper/LGIddHelper.vcxproj.filters +++ b/idd/LGIddHelper/LGIddHelper.vcxproj.filters @@ -49,6 +49,10 @@ Source Files + + + Source Files + @@ -85,6 +89,11 @@ Header Files + + + + Header Files +