提交 54218515 编写于 作者: S Scratch 提交者: jp9000

UI: Add window projector option "fit to content"

Adds an option to the context menu of a windowed projector to allow
resizing the aspect ratio of the client area of the window to the
contents of what's being projected (so that there's no extra space).
上级 695f3c1f
......@@ -42,6 +42,7 @@ SceneWindow="Windowed Projector (Scene)"
SourceWindow="Windowed Projector (Source)"
MultiviewProjector="Multiview (Fullscreen)"
MultiviewWindowed="Multiview (Windowed)"
ResizeProjectorWindowToContent="Fit window to content"
Clear="Clear"
Revert="Revert"
Show="Show"
......
......@@ -828,10 +828,15 @@ void OBSProjector::mousePressEvent(QMouseEvent *event)
SLOT(OpenFullScreenProjector()));
popup.addMenu(projectorMenu);
if (GetMonitor() > -1)
if (GetMonitor() > -1) {
popup.addAction(QTStr("Windowed"), this,
SLOT(OpenWindowedProjector()));
} else if (!this->isMaximized()) {
popup.addAction(QTStr("ResizeProjectorWindowToContent"),
this, SLOT(ResizeToContent()));
}
popup.addAction(QTStr("Close"), this, SLOT(EscapeTriggered()));
popup.exec(QCursor::pos());
}
......@@ -1055,6 +1060,33 @@ void OBSProjector::OpenWindowedProjector()
UpdateProjectorTitle(QT_UTF8(obs_source_get_name(source)));
}
void OBSProjector::ResizeToContent()
{
OBSSource source = GetSource();
uint32_t targetCX;
uint32_t targetCY;
int x, y, newX, newY;
float scale;
if (source) {
targetCX = std::max(obs_source_get_width(source), 1u);
targetCY = std::max(obs_source_get_height(source), 1u);
} else {
struct obs_video_info ovi;
obs_get_video_info(&ovi);
targetCX = ovi.base_width;
targetCY = ovi.base_height;
}
QSize size = this->size();
GetScaleAndCenterPos(targetCX, targetCY, size.width(), size.height(), x,
y, scale);
newX = size.width() - (x * 2);
newY = size.height() - (y * 2);
resize(newX, newY);
}
void OBSProjector::closeEvent(QCloseEvent *event)
{
EscapeTriggered();
......
......@@ -78,6 +78,7 @@ private:
private slots:
void EscapeTriggered();
void OpenFullScreenProjector();
void ResizeToContent();
void OpenWindowedProjector();
public:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册