mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
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).
This commit is contained in:
parent
695f3c1f33
commit
5421851526
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user