1
0
mirror of synced 2025-02-26 06:18:05 +01:00

ui: Improved borderless window resizing and moving

This commit is contained in:
WerWolv 2021-09-26 21:16:49 +02:00
parent 7da8a5b1d8
commit 7799bbb57a

View File

@ -99,8 +99,8 @@
POINT cursor = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; POINT cursor = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
const POINT border{ const POINT border{
static_cast<LONG>((::GetSystemMetrics(SM_CXFRAME) + ::GetSystemMetrics(SM_CXPADDEDBORDER)) * SharedData::globalScale / 2.0F), static_cast<LONG>((::GetSystemMetrics(SM_CXFRAME) + ::GetSystemMetrics(SM_CXPADDEDBORDER)) * SharedData::globalScale / 1.5F),
static_cast<LONG>((::GetSystemMetrics(SM_CYFRAME) + ::GetSystemMetrics(SM_CXPADDEDBORDER)) * SharedData::globalScale / 2.0F) static_cast<LONG>((::GetSystemMetrics(SM_CYFRAME) + ::GetSystemMetrics(SM_CXPADDEDBORDER)) * SharedData::globalScale / 1.5F)
}; };
RECT window; RECT window;
@ -120,6 +120,9 @@
RegionTop * (cursor.y < (window.top + border.y)) | RegionTop * (cursor.y < (window.top + border.y)) |
RegionBottom * (cursor.y >= (window.bottom - border.y)); RegionBottom * (cursor.y >= (window.bottom - border.y));
if (result != 0 && (ImGui::IsItemHovered() || ImGui::IsPopupOpen(nullptr, ImGuiPopupFlags_AnyPopupId)))
break;
switch (result) { switch (result) {
case RegionLeft: case RegionLeft:
return HTLEFT; return HTLEFT;
@ -139,7 +142,7 @@
return HTBOTTOMRIGHT; return HTBOTTOMRIGHT;
case RegionClient: case RegionClient:
default: default:
if ((cursor.y < (window.top + titleBarHeight)) && !(ImGui::IsAnyItemHovered() || ImGui::IsAnyItemFocused())) if ((cursor.y < (window.top + titleBarHeight * 2)) && !(ImGui::IsAnyItemHovered() || ImGui::IsPopupOpen(nullptr, ImGuiPopupFlags_AnyPopupId)))
return HTCAPTION; return HTCAPTION;
else break; else break;
} }