mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-12-03 06:38:14 +00:00
[idd] helper/resize: move logic to .cpp and add error checking
This commit is contained in:
@@ -187,6 +187,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
|||||||
<ClCompile Include="CWidget.cpp" />
|
<ClCompile Include="CWidget.cpp" />
|
||||||
<ClCompile Include="CWindow.cpp" />
|
<ClCompile Include="CWindow.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
|
<ClCompile Include="UIHelpers.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||||
|
|||||||
@@ -43,6 +43,9 @@
|
|||||||
<ClCompile Include="CRegistrySettings.cpp">
|
<ClCompile Include="CRegistrySettings.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="UIHelpers.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||||
|
|||||||
17
idd/LGIddHelper/UIHelpers.cpp
Normal file
17
idd/LGIddHelper/UIHelpers.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include "UIHelpers.h"
|
||||||
|
#include <CDebug.h>
|
||||||
|
|
||||||
|
WidgetPositioner::~WidgetPositioner()
|
||||||
|
{
|
||||||
|
if (!EndDeferWindowPos(hdwp))
|
||||||
|
DEBUG_ERROR_HR(GetLastError(), "EndDeferWindowPos");
|
||||||
|
}
|
||||||
|
|
||||||
|
void WidgetPositioner::move(HWND child, int x, int y, int cx, int cy)
|
||||||
|
{
|
||||||
|
HDWP next = DeferWindowPos(hdwp, child, nullptr, x, y, cx, cy, SWP_NOACTIVATE | SWP_NOZORDER);
|
||||||
|
if (next)
|
||||||
|
hdwp = next;
|
||||||
|
else
|
||||||
|
DEBUG_ERROR_HR(GetLastError(), "DeferWindowPos");
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <cmath>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
struct FontTraits
|
struct FontTraits
|
||||||
@@ -13,19 +14,16 @@ class WidgetPositioner
|
|||||||
HDWP hdwp;
|
HDWP hdwp;
|
||||||
double m_scale;
|
double m_scale;
|
||||||
DWORD width, height;
|
DWORD width, height;
|
||||||
inline int scale(int value) { return (int)round(value * m_scale); }
|
inline int scale(int value) { return (int)std::round(value * m_scale); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WidgetPositioner(double scale, DWORD width, DWORD height) :
|
WidgetPositioner(double scale, DWORD width, DWORD height) :
|
||||||
m_scale(scale), width(width), height(height),
|
m_scale(scale), width(width), height(height),
|
||||||
hdwp(BeginDeferWindowPos(10)) {}
|
hdwp(BeginDeferWindowPos(10)) {}
|
||||||
|
|
||||||
~WidgetPositioner() { EndDeferWindowPos(hdwp); }
|
~WidgetPositioner();
|
||||||
|
|
||||||
void move(HWND child, int x, int y, int cx, int cy)
|
void move(HWND child, int x, int y, int cx, int cy);
|
||||||
{
|
|
||||||
hdwp = DeferWindowPos(hdwp, child, nullptr, x, y, cx, cy, SWP_NOACTIVATE | SWP_NOZORDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pinTopLeft(HWND child, int x, int y, int cx, int cy)
|
void pinTopLeft(HWND child, int x, int y, int cx, int cy)
|
||||||
{
|
{
|
||||||
@@ -44,6 +42,6 @@ public:
|
|||||||
|
|
||||||
void pinLeftTopBottom(HWND child, int x, int y, int cx, int by)
|
void pinLeftTopBottom(HWND child, int x, int y, int cx, int by)
|
||||||
{
|
{
|
||||||
move(child, scale(x), scale(y), cx, height - scale(y + by));
|
move(child, scale(x), scale(y), scale(cx), height - scale(y + by));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user