Files
hrynco-kswitcher/src/ui_geometry.h
T

15 lines
529 B
C++

#pragma once
#include "core.h"
#include <algorithm>
namespace ks
{
inline RECT fitWindowRect(RECT desired, RECT work)
{
LONG width = std::clamp<LONG>(desired.right - desired.left, 1, std::max<LONG>(1, work.right - work.left));
LONG height = std::clamp<LONG>(desired.bottom - desired.top, 1, std::max<LONG>(1, work.bottom - work.top));
LONG x = std::clamp(desired.left, work.left, work.right - width);
LONG y = std::clamp(desired.top, work.top, work.bottom - height);
return {x, y, x + width, y + height};
}
}