[idd] helper: add basic group box around mode config

This commit is contained in:
Quantum
2025-09-23 02:03:41 -04:00
committed by Geoffrey McRae
parent 7a3833782c
commit ab6e2c89d5
6 changed files with 39 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
#include "CConfigWindow.h"
#include "CListBox.h"
#include "CGroupBox.h"
#include <CDebug.h>
#include <windowsx.h>
#include <strsafe.h>
@@ -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<HWND>({ *m_version, *m_modeBox }))
for (HWND child : std::initializer_list<HWND>({ *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;
}

View File

@@ -9,12 +9,14 @@
#include "UIHelpers.h"
class CListBox;
class CGroupBox;
class CConfigWindow : public CWindow
{
static ATOM s_atom;
std::unique_ptr<CStaticWidget> m_version;
std::unique_ptr<CGroupBox> m_modeGroup;
std::unique_ptr<CListBox> m_modeBox;
std::function<void()> m_onDestroy;

View File

@@ -0,0 +1,10 @@
#include "CGroupBox.h"
#include <commctrl.h>
#include <CDebug.h>
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");
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include "CWidget.h"
class CGroupBox : public CWidget
{
public:
CGroupBox(LPCWSTR title, DWORD style, HWND parent);
};

View File

@@ -180,6 +180,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
<ItemGroup>
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp" />
<ClCompile Include="CConfigWindow.cpp" />
<ClCompile Include="CGroupBox.cpp" />
<ClCompile Include="CListBox.cpp" />
<ClCompile Include="CNotifyWindow.cpp" />
<ClCompile Include="CPipeClient.cpp" />
@@ -193,6 +194,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
<ItemGroup>
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
<ClInclude Include="CConfigWindow.h" />
<ClInclude Include="CGroupBox.h" />
<ClInclude Include="CListBox.h" />
<ClInclude Include="CNotifyWindow.h" />
<ClInclude Include="CPipeClient.h" />

View File

@@ -49,6 +49,10 @@
<ClCompile Include="UIHelpers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp" />
<ClCompile Include="CGroupBox.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
@@ -85,6 +89,11 @@
<ClInclude Include="CListBox.h">
<Filter>Header Files</Filter>
</ClInclude>
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
<ClInclude Include="CGroupBox.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />