diff options
| author | thejch <66577496+thejch@users.noreply.github.com> | 2024-03-16 07:49:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-16 14:49:34 +0000 |
| commit | c942ce6dce7f01415f71e5207da69b6989d3818c (patch) | |
| tree | fcb8064234100b716770877fe61eb8c3851cc83d /src/helpers/Box.cpp | |
| parent | 5e5d7e2abcd91c83058ba80ec64ec5054cae5bfa (diff) | |
renderer: add better multi monitor animations (#5126)
Diffstat (limited to 'src/helpers/Box.cpp')
| -rw-r--r-- | src/helpers/Box.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/helpers/Box.cpp b/src/helpers/Box.cpp index 59578f23..e9e0eeeb 100644 --- a/src/helpers/Box.cpp +++ b/src/helpers/Box.cpp @@ -116,6 +116,24 @@ CBox& CBox::noNegativeSize() { return *this; } +CBox& CBox::intersection(const CBox other) { + const float newTop = std::max(y, other.y); + const float newBottom = std::min(y + h, other.y + other.h); + const float newLeft = std::max(x, other.x); + const float newRight = std::min(x + w, other.x + other.w); + y = newTop; + x = newLeft; + w = newRight - newLeft; + h = newBottom - newTop; + + if (w <= 0 || h <= 0) { + w = 0; + h = 0; + } + + return *this; +} + CBox CBox::roundInternal() { float newW = x + w - std::floor(x); float newH = y + h - std::floor(y); |
