mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-12-02 22:28:14 +00:00
[idd] helper: add mode save button
This commit is contained in:
10
idd/LGIddHelper/CButton.cpp
Normal file
10
idd/LGIddHelper/CButton.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include "CButton.h"
|
||||||
|
#include <commctrl.h>
|
||||||
|
#include <CDebug.h>
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
9
idd/LGIddHelper/CButton.h
Normal file
9
idd/LGIddHelper/CButton.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CWidget.h"
|
||||||
|
|
||||||
|
class CButton : public CWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CButton(LPCWSTR title, DWORD style, HWND parent);
|
||||||
|
};
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "CListBox.h"
|
#include "CListBox.h"
|
||||||
#include "CGroupBox.h"
|
#include "CGroupBox.h"
|
||||||
#include "CEditWidget.h"
|
#include "CEditWidget.h"
|
||||||
|
#include "CButton.h"
|
||||||
#include <CDebug.h>
|
#include <CDebug.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
@@ -56,7 +57,7 @@ void CConfigWindow::updateFont()
|
|||||||
|
|
||||||
for (HWND child : std::initializer_list<HWND>({
|
for (HWND child : std::initializer_list<HWND>({
|
||||||
*m_version, *m_modeGroup, *m_modeBox, *m_widthLabel, *m_heightLabel, *m_refreshLabel,
|
*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);
|
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_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_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();
|
updateFont();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -125,13 +128,14 @@ LRESULT CConfigWindow::onResize(DWORD width, DWORD height)
|
|||||||
WidgetPositioner pos(m_scale, width, height);
|
WidgetPositioner pos(m_scale, width, height);
|
||||||
pos.pinTopLeftRight(*m_version, 12, 12, 12, 20);
|
pos.pinTopLeftRight(*m_version, 12, 12, 12, 20);
|
||||||
pos.pinLeftTopBottom(*m_modeGroup, 12, 40, 200, 12);
|
pos.pinLeftTopBottom(*m_modeGroup, 12, 40, 200, 12);
|
||||||
pos.pinLeftTopBottom(*m_modeBox, 24, 64, 176, 96);
|
pos.pinLeftTopBottom(*m_modeBox, 24, 64, 176, 120);
|
||||||
pos.pinBottomLeft(*m_widthLabel, 24, 72, 50, 20);
|
pos.pinBottomLeft(*m_widthLabel, 24, 96, 50, 20);
|
||||||
pos.pinBottomLeft(*m_heightLabel, 24, 48, 50, 20);
|
pos.pinBottomLeft(*m_heightLabel, 24, 72, 50, 20);
|
||||||
pos.pinBottomLeft(*m_refreshLabel, 24, 24, 50, 20);
|
pos.pinBottomLeft(*m_refreshLabel, 24, 48, 50, 20);
|
||||||
pos.pinBottomLeft(*m_modeWidth, 75, 72, 50, 20);
|
pos.pinBottomLeft(*m_modeWidth, 75, 96, 50, 20);
|
||||||
pos.pinBottomLeft(*m_modeHeight, 75, 48, 50, 20);
|
pos.pinBottomLeft(*m_modeHeight, 75, 72, 50, 20);
|
||||||
pos.pinBottomLeft(*m_modeRefresh, 75, 24, 50, 20);
|
pos.pinBottomLeft(*m_modeRefresh, 75, 48, 50, 20);
|
||||||
|
pos.pinBottomLeft(*m_modeUpdate, 24, 20, 50, 24);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,5 +148,13 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
|||||||
m_modeHeight->setNumericValue(mode.height);
|
m_modeHeight->setNumericValue(mode.height);
|
||||||
m_modeRefresh->setNumericValue(mode.refresh);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
class CListBox;
|
class CListBox;
|
||||||
class CGroupBox;
|
class CGroupBox;
|
||||||
class CEditWidget;
|
class CEditWidget;
|
||||||
|
class CButton;
|
||||||
|
|
||||||
class CConfigWindow : public CWindow
|
class CConfigWindow : public CWindow
|
||||||
{
|
{
|
||||||
@@ -28,6 +29,8 @@ class CConfigWindow : public CWindow
|
|||||||
std::unique_ptr<CEditWidget> m_modeHeight;
|
std::unique_ptr<CEditWidget> m_modeHeight;
|
||||||
std::unique_ptr<CEditWidget> m_modeRefresh;
|
std::unique_ptr<CEditWidget> m_modeRefresh;
|
||||||
|
|
||||||
|
std::unique_ptr<CButton> m_modeUpdate;
|
||||||
|
|
||||||
std::function<void()> m_onDestroy;
|
std::function<void()> m_onDestroy;
|
||||||
double m_scale;
|
double m_scale;
|
||||||
Microsoft::WRL::Wrappers::HandleT<FontTraits> m_font;
|
Microsoft::WRL::Wrappers::HandleT<FontTraits> m_font;
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp" />
|
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp" />
|
||||||
|
<ClCompile Include="CButton.cpp" />
|
||||||
<ClCompile Include="CConfigWindow.cpp" />
|
<ClCompile Include="CConfigWindow.cpp" />
|
||||||
<ClCompile Include="CEditWidget.cpp" />
|
<ClCompile Include="CEditWidget.cpp" />
|
||||||
<ClCompile Include="CGroupBox.cpp" />
|
<ClCompile Include="CGroupBox.cpp" />
|
||||||
@@ -194,6 +195,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||||
|
<ClInclude Include="CButton.h" />
|
||||||
<ClInclude Include="CConfigWindow.h" />
|
<ClInclude Include="CConfigWindow.h" />
|
||||||
<ClInclude Include="CEditWidget.h" />
|
<ClInclude Include="CEditWidget.h" />
|
||||||
<ClInclude Include="CGroupBox.h" />
|
<ClInclude Include="CGroupBox.h" />
|
||||||
|
|||||||
Reference in New Issue
Block a user