mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Fixed caption button positions, sizes and hit boxes
This commit is contained in:
parent
4dbc7d4204
commit
0a39f17089
@ -220,6 +220,7 @@
|
|||||||
<ClInclude Include="Gdi\Dc.h" />
|
<ClInclude Include="Gdi\Dc.h" />
|
||||||
<ClInclude Include="Gdi\DcCache.h" />
|
<ClInclude Include="Gdi\DcCache.h" />
|
||||||
<ClInclude Include="Gdi\DcFunctions.h" />
|
<ClInclude Include="Gdi\DcFunctions.h" />
|
||||||
|
<ClInclude Include="Gdi\Metrics.h" />
|
||||||
<ClInclude Include="Gdi\PresentationWindow.h" />
|
<ClInclude Include="Gdi\PresentationWindow.h" />
|
||||||
<ClInclude Include="Gdi\User32WndProcs.h" />
|
<ClInclude Include="Gdi\User32WndProcs.h" />
|
||||||
<ClInclude Include="Gdi\Palette.h" />
|
<ClInclude Include="Gdi\Palette.h" />
|
||||||
@ -293,6 +294,7 @@
|
|||||||
<ClCompile Include="Gdi\Dc.cpp" />
|
<ClCompile Include="Gdi\Dc.cpp" />
|
||||||
<ClCompile Include="Gdi\DcCache.cpp" />
|
<ClCompile Include="Gdi\DcCache.cpp" />
|
||||||
<ClCompile Include="Gdi\DcFunctions.cpp" />
|
<ClCompile Include="Gdi\DcFunctions.cpp" />
|
||||||
|
<ClCompile Include="Gdi\Metrics.cpp" />
|
||||||
<ClCompile Include="Gdi\PresentationWindow.cpp" />
|
<ClCompile Include="Gdi\PresentationWindow.cpp" />
|
||||||
<ClCompile Include="Gdi\User32WndProcs.cpp" />
|
<ClCompile Include="Gdi\User32WndProcs.cpp" />
|
||||||
<ClCompile Include="Gdi\Palette.cpp" />
|
<ClCompile Include="Gdi\Palette.cpp" />
|
||||||
|
@ -399,6 +399,9 @@
|
|||||||
<ClInclude Include="Gdi\PresentationWindow.h">
|
<ClInclude Include="Gdi\PresentationWindow.h">
|
||||||
<Filter>Header Files\Gdi</Filter>
|
<Filter>Header Files\Gdi</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Gdi\Metrics.h">
|
||||||
|
<Filter>Header Files\Gdi</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Gdi\Gdi.cpp">
|
<ClCompile Include="Gdi\Gdi.cpp">
|
||||||
@ -614,5 +617,8 @@
|
|||||||
<ClCompile Include="Gdi\PresentationWindow.cpp">
|
<ClCompile Include="Gdi\PresentationWindow.cpp">
|
||||||
<Filter>Source Files\Gdi</Filter>
|
<Filter>Source Files\Gdi</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Gdi\Metrics.cpp">
|
||||||
|
<Filter>Source Files\Gdi</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -5,6 +5,7 @@
|
|||||||
#include <Gdi/DcFunctions.h>
|
#include <Gdi/DcFunctions.h>
|
||||||
#include <Gdi/Font.h>
|
#include <Gdi/Font.h>
|
||||||
#include <Gdi/Gdi.h>
|
#include <Gdi/Gdi.h>
|
||||||
|
#include <Gdi/Metrics.h>
|
||||||
#include <Gdi/Palette.h>
|
#include <Gdi/Palette.h>
|
||||||
#include <Gdi/PresentationWindow.h>
|
#include <Gdi/PresentationWindow.h>
|
||||||
#include <Gdi/ScrollFunctions.h>
|
#include <Gdi/ScrollFunctions.h>
|
||||||
@ -39,6 +40,7 @@ namespace Gdi
|
|||||||
DisableProcessWindowsGhosting();
|
DisableProcessWindowsGhosting();
|
||||||
|
|
||||||
DcFunctions::installHooks();
|
DcFunctions::installHooks();
|
||||||
|
Metrics::installHooks();
|
||||||
Palette::installHooks();
|
Palette::installHooks();
|
||||||
PresentationWindow::installHooks();
|
PresentationWindow::installHooks();
|
||||||
ScrollFunctions::installHooks();
|
ScrollFunctions::installHooks();
|
||||||
|
43
DDrawCompat/Gdi/Metrics.cpp
Normal file
43
DDrawCompat/Gdi/Metrics.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
#include <Common/Hook.h>
|
||||||
|
#include <Common/Log.h>
|
||||||
|
#include <Gdi/Metrics.h>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
decltype(&GetSystemMetricsForDpi) g_origGetSystemMetricsForDpi = nullptr;
|
||||||
|
|
||||||
|
int WINAPI getSystemMetrics(int nIndex)
|
||||||
|
{
|
||||||
|
LOG_FUNC("GetSystemMetrics", nIndex);
|
||||||
|
if (SM_CXSIZE == nIndex)
|
||||||
|
{
|
||||||
|
nIndex = SM_CYSIZE;
|
||||||
|
}
|
||||||
|
return LOG_RESULT(CALL_ORIG_FUNC(GetSystemMetrics)(nIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI getSystemMetricsForDpi(int nIndex, UINT dpi)
|
||||||
|
{
|
||||||
|
LOG_FUNC("GetSystemMetricsForDpi", nIndex, dpi);
|
||||||
|
if (SM_CXSIZE == nIndex)
|
||||||
|
{
|
||||||
|
nIndex = SM_CYSIZE;
|
||||||
|
}
|
||||||
|
return LOG_RESULT(g_origGetSystemMetricsForDpi(nIndex, dpi));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Gdi
|
||||||
|
{
|
||||||
|
namespace Metrics
|
||||||
|
{
|
||||||
|
void installHooks()
|
||||||
|
{
|
||||||
|
HOOK_FUNCTION(user32, GetSystemMetrics, getSystemMetrics);
|
||||||
|
Compat::hookFunction("user32", "GetSystemMetricsForDpi",
|
||||||
|
reinterpret_cast<void*&>(g_origGetSystemMetricsForDpi), getSystemMetricsForDpi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
DDrawCompat/Gdi/Metrics.h
Normal file
9
DDrawCompat/Gdi/Metrics.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Gdi
|
||||||
|
{
|
||||||
|
namespace Metrics
|
||||||
|
{
|
||||||
|
void installHooks();
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
#include "Common/Hook.h"
|
#include <Common/Hook.h>
|
||||||
#include "Gdi/Gdi.h"
|
#include <Gdi/Gdi.h>
|
||||||
#include "Gdi/Region.h"
|
#include <Gdi/Region.h>
|
||||||
#include "Gdi/TitleBar.h"
|
#include <Gdi/TitleBar.h>
|
||||||
#include "Gdi/VirtualScreen.h"
|
#include <Gdi/VirtualScreen.h>
|
||||||
#include "Win32/DisplayMode.h"
|
#include <Win32/DisplayMode.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ namespace Gdi
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_tbi.cbSize = sizeof(m_tbi);
|
m_tbi.cbSize = sizeof(m_tbi);
|
||||||
SendMessage(hwnd, WM_GETTITLEBARINFOEX, 0, reinterpret_cast<LPARAM>(&m_tbi));
|
CALL_ORIG_FUNC(DefWindowProcA)(hwnd, WM_GETTITLEBARINFOEX, 0, reinterpret_cast<LPARAM>(&m_tbi));
|
||||||
m_hasTitleBar = !IsRectEmpty(&m_tbi.rcTitleBar);
|
m_hasTitleBar = !IsRectEmpty(&m_tbi.rcTitleBar);
|
||||||
if (!m_hasTitleBar)
|
if (!m_hasTitleBar)
|
||||||
{
|
{
|
||||||
@ -62,19 +62,19 @@ namespace Gdi
|
|||||||
if (isVisible(i))
|
if (isVisible(i))
|
||||||
{
|
{
|
||||||
OffsetRect(&m_tbi.rgrect[i], -m_windowRect.left, -m_windowRect.top);
|
OffsetRect(&m_tbi.rgrect[i], -m_windowRect.left, -m_windowRect.top);
|
||||||
adjustButtonSize(m_tbi.rgrect[i]);
|
InflateRect(&m_tbi.rgrect[i], -3, -3);
|
||||||
|
if (TBII_MINIMIZE_BUTTON == i)
|
||||||
|
{
|
||||||
|
m_tbi.rgrect[i].right += 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_tbi.rgrect[i].left -= 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleBar::adjustButtonSize(RECT& rect) const
|
|
||||||
{
|
|
||||||
rect.left += (rect.right - rect.left - m_buttonWidth) / 2;
|
|
||||||
rect.top += (rect.bottom - rect.top - m_buttonHeight) / 2;
|
|
||||||
rect.right = rect.left + m_buttonWidth;
|
|
||||||
rect.bottom = rect.top + m_buttonHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TitleBar::drawAll() const
|
void TitleBar::drawAll() const
|
||||||
{
|
{
|
||||||
drawCaption();
|
drawCaption();
|
||||||
|
@ -17,7 +17,6 @@ namespace Gdi
|
|||||||
void excludeFromClipRegion() const;
|
void excludeFromClipRegion() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void adjustButtonSize(RECT& rect) const;
|
|
||||||
void drawButton(std::size_t tbiIndex, UINT dfcState) const;
|
void drawButton(std::size_t tbiIndex, UINT dfcState) const;
|
||||||
bool isVisible(std::size_t tbiIndex) const;
|
bool isVisible(std::size_t tbiIndex) const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user