UI: Fix scaling in viewport when source flipped

Fixes bug 617 on mantis.  Scaling the source manually in the viewport
wouldn't work properly when the source is flipped horizontally or
vertically.

Closes jp9000/obs-studio#751
master
EpicCoder 2017-01-06 17:07:24 +01:00 committed by jp9000
parent 21584fa2c0
commit 73a1bf9236
1 changed files with 23 additions and 6 deletions

View File

@ -740,18 +740,35 @@ void OBSBasicPreview::ClampAspect(vec3 &tl, vec3 &br, vec2 &size,
stretchHandle == ItemHandle::TopRight || stretchHandle == ItemHandle::TopRight ||
stretchHandle == ItemHandle::BottomLeft || stretchHandle == ItemHandle::BottomLeft ||
stretchHandle == ItemHandle::BottomRight) { stretchHandle == ItemHandle::BottomRight) {
if (aspect < baseAspect) if (aspect < baseAspect) {
if ((size.y >= 0.0f && size.x >= 0.0f) ||
(size.y <= 0.0f && size.x <= 0.0f))
size.x = size.y * baseAspect; size.x = size.y * baseAspect;
else else
size.x = size.y * baseAspect * -1.0f;
} else {
if ((size.y >= 0.0f && size.x >= 0.0f) ||
(size.y <= 0.0f && size.x <= 0.0f))
size.y = size.x / baseAspect; size.y = size.x / baseAspect;
else
size.y = size.x / baseAspect * -1.0f;
}
} else if (stretchHandle == ItemHandle::TopCenter || } else if (stretchHandle == ItemHandle::TopCenter ||
stretchHandle == ItemHandle::BottomCenter) { stretchHandle == ItemHandle::BottomCenter) {
if ((size.y >= 0.0f && size.x >= 0.0f) ||
(size.y <= 0.0f && size.x <= 0.0f))
size.x = size.y * baseAspect; size.x = size.y * baseAspect;
else
size.x = size.y * baseAspect * -1.0f;
} else if (stretchHandle == ItemHandle::CenterLeft || } else if (stretchHandle == ItemHandle::CenterLeft ||
stretchHandle == ItemHandle::CenterRight) { stretchHandle == ItemHandle::CenterRight) {
if ((size.y >= 0.0f && size.x >= 0.0f) ||
(size.y <= 0.0f && size.x <= 0.0f))
size.y = size.x / baseAspect; size.y = size.x / baseAspect;
else
size.y = size.x / baseAspect * -1.0f;
} }
size.x = std::round(size.x); size.x = std::round(size.x);