UI: Add mulitiview layout options without program

master
Exeldro 2021-12-15 10:45:10 +01:00 committed by Jim
parent 8886091793
commit f8c2ccc2c3
4 changed files with 158 additions and 0 deletions

View File

@ -824,6 +824,10 @@ Basic.Settings.General.MultiviewLayout.Vertical.Left="Vertical, Left (8 Scenes)"
Basic.Settings.General.MultiviewLayout.Vertical.Right="Vertical, Right (8 Scenes)"
Basic.Settings.General.MultiviewLayout.Horizontal.18Scene.Top="Horizontal, Top (18 Scenes)"
Basic.Settings.General.MultiviewLayout.Horizontal.Extended.Top="Horizontal, Top (24 Scenes)"
Basic.Settings.General.MultiviewLayout.4Scene="Scenes only (4 Scenes)"
Basic.Settings.General.MultiviewLayout.9Scene="Scenes only (9 Scenes)"
Basic.Settings.General.MultiviewLayout.16Scene="Scenes only (16 Scenes)"
Basic.Settings.General.MultiviewLayout.25Scene="Scenes only (25 Scenes)"
# basic mode 'stream' settings
Basic.Settings.Stream="Stream"

View File

@ -1387,6 +1387,18 @@ void OBSBasicSettings::LoadGeneralSettings()
ui->multiviewLayout->addItem(
QTStr("Basic.Settings.General.MultiviewLayout.Horizontal.Extended.Top"),
static_cast<int>(MultiviewLayout::HORIZONTAL_TOP_24_SCENES));
ui->multiviewLayout->addItem(
QTStr("Basic.Settings.General.MultiviewLayout.4Scene"),
static_cast<int>(MultiviewLayout::SCENES_ONLY_4_SCENES));
ui->multiviewLayout->addItem(
QTStr("Basic.Settings.General.MultiviewLayout.9Scene"),
static_cast<int>(MultiviewLayout::SCENES_ONLY_9_SCENES));
ui->multiviewLayout->addItem(
QTStr("Basic.Settings.General.MultiviewLayout.16Scene"),
static_cast<int>(MultiviewLayout::SCENES_ONLY_16_SCENES));
ui->multiviewLayout->addItem(
QTStr("Basic.Settings.General.MultiviewLayout.25Scene"),
static_cast<int>(MultiviewLayout::SCENES_ONLY_25_SCENES));
ui->multiviewLayout->setCurrentIndex(ui->multiviewLayout->findData(
QVariant::fromValue(config_get_int(

View File

@ -205,6 +205,15 @@ static inline uint32_t labelOffset(obs_source_t *label, uint32_t cx)
case MultiviewLayout::HORIZONTAL_TOP_24_SCENES:
n = 6;
break;
case MultiviewLayout::SCENES_ONLY_25_SCENES:
n = 5;
break;
case MultiviewLayout::SCENES_ONLY_9_SCENES:
n = 3;
break;
case MultiviewLayout::SCENES_ONLY_4_SCENES:
n = 2;
break;
default:
n = 4;
break;
@ -308,6 +317,22 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
window->sourceY = window->scenesCY;
}
break;
case MultiviewLayout::SCENES_ONLY_4_SCENES:
window->sourceX = (i % 2) * window->scenesCX;
window->sourceY = (i / 2) * window->scenesCY;
break;
case MultiviewLayout::SCENES_ONLY_9_SCENES:
window->sourceX = (i % 3) * window->scenesCX;
window->sourceY = (i / 3) * window->scenesCY;
break;
case MultiviewLayout::SCENES_ONLY_16_SCENES:
window->sourceX = (i % 4) * window->scenesCX;
window->sourceY = (i / 4) * window->scenesCY;
break;
case MultiviewLayout::SCENES_ONLY_25_SCENES:
window->sourceX = (i % 5) * window->scenesCX;
window->sourceY = (i / 5) * window->scenesCY;
break;
default: // MultiviewLayout::HORIZONTAL_TOP_8_SCENES:
if (i < 4) {
window->sourceX = (float(i) * window->scenesCX);
@ -366,6 +391,13 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
window->labelX += window->pvwprgCX;
}
break;
case MultiviewLayout::SCENES_ONLY_4_SCENES:
case MultiviewLayout::SCENES_ONLY_9_SCENES:
case MultiviewLayout::SCENES_ONLY_16_SCENES:
window->sourceX = window->thickness;
window->sourceY = window->thickness;
window->labelX = window->offset;
break;
default: // MultiviewLayout::HORIZONTAL_TOP_8_SCENES and 18_SCENES
window->sourceX = window->thickness;
window->sourceY = window->thickness;
@ -462,6 +494,13 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
obs_source_video_render(label);
gs_matrix_pop();
}
if (multiviewLayout == MultiviewLayout::SCENES_ONLY_4_SCENES ||
multiviewLayout == MultiviewLayout::SCENES_ONLY_9_SCENES ||
multiviewLayout == MultiviewLayout::SCENES_ONLY_16_SCENES ||
multiviewLayout == MultiviewLayout::SCENES_ONLY_25_SCENES) {
endRegion();
return;
}
/* ----------------------------- */
/* draw preview */
@ -742,6 +781,78 @@ static int getSourceByPosition(int x, int y, float ratio)
if (y > minY + ((maxY - minY) / 2))
pos += 4;
break;
case MultiviewLayout::SCENES_ONLY_4_SCENES:
if (float(cx) / float(cy) > ratio) {
int validX = cy * ratio;
minX = (cx / 2) - (validX / 2);
maxX = (cx / 2) + (validX / 2);
} else {
int validY = cx / ratio;
maxY = (cy / 2) + (validY / 2);
minY = (cy / 2) - (validY / 2);
}
if (x < minX || x > maxX || y < minY || y > maxY)
break;
pos = (x - minX) / ((maxX - minX) / 2);
pos += ((y - minY) / ((maxY - minY) / 2)) * 2;
break;
case MultiviewLayout::SCENES_ONLY_9_SCENES:
if (float(cx) / float(cy) > ratio) {
int validX = cy * ratio;
minX = (cx / 2) - (validX / 2);
maxX = (cx / 2) + (validX / 2);
} else {
int validY = cx / ratio;
maxY = (cy / 2) + (validY / 2);
minY = (cy / 2) - (validY / 2);
}
if (x < minX || x > maxX || y < minY || y > maxY)
break;
pos = (x - minX) / ((maxX - minX) / 3);
pos += ((y - minY) / ((maxY - minY) / 3)) * 3;
break;
case MultiviewLayout::SCENES_ONLY_16_SCENES:
if (float(cx) / float(cy) > ratio) {
int validX = cy * ratio;
minX = (cx / 2) - (validX / 2);
maxX = (cx / 2) + (validX / 2);
} else {
int validY = cx / ratio;
maxY = (cy / 2) + (validY / 2);
minY = (cy / 2) - (validY / 2);
}
if (x < minX || x > maxX || y < minY || y > maxY)
break;
pos = (x - minX) / ((maxX - minX) / 4);
pos += ((y - minY) / ((maxY - minY) / 4)) * 4;
break;
case MultiviewLayout::SCENES_ONLY_25_SCENES:
if (float(cx) / float(cy) > ratio) {
int validX = cy * ratio;
minX = (cx / 2) - (validX / 2);
maxX = (cx / 2) + (validX / 2);
} else {
int validY = cx / ratio;
maxY = (cy / 2) + (validY / 2);
minY = (cy / 2) - (validY / 2);
}
if (x < minX || x > maxX || y < minY || y > maxY)
break;
pos = (x - minX) / ((maxX - minX) / 5);
pos += ((y - minY) / ((maxY - minY) / 5)) * 5;
break;
default: // MultiviewLayout::HORIZONTAL_TOP_8_SCENES
if (float(cx) / float(cy) > ratio) {
int validX = cy * ratio;
@ -904,6 +1015,26 @@ void OBSProjector::UpdateMultiview()
maxSrcs = 24;
break;
case MultiviewLayout::SCENES_ONLY_4_SCENES:
pvwprgCX = fw / 2;
pvwprgCY = fh / 2;
maxSrcs = 4;
break;
case MultiviewLayout::SCENES_ONLY_9_SCENES:
pvwprgCX = fw / 3;
pvwprgCY = fh / 3;
maxSrcs = 9;
break;
case MultiviewLayout::SCENES_ONLY_16_SCENES:
pvwprgCX = fw / 4;
pvwprgCY = fh / 4;
maxSrcs = 16;
break;
case MultiviewLayout::SCENES_ONLY_25_SCENES:
pvwprgCX = fw / 5;
pvwprgCY = fh / 5;
maxSrcs = 25;
break;
default:
pvwprgCX = fw / 2;
pvwprgCY = fh / 2;
@ -921,6 +1052,13 @@ void OBSProjector::UpdateMultiview()
scenesCX = pvwprgCX / 3;
scenesCY = pvwprgCY / 3;
break;
case MultiviewLayout::SCENES_ONLY_4_SCENES:
case MultiviewLayout::SCENES_ONLY_9_SCENES:
case MultiviewLayout::SCENES_ONLY_16_SCENES:
case MultiviewLayout::SCENES_ONLY_25_SCENES:
scenesCX = pvwprgCX;
scenesCY = pvwprgCY;
break;
default:
scenesCX = pvwprgCX / 2;
scenesCY = pvwprgCY / 2;

View File

@ -20,6 +20,10 @@ enum class MultiviewLayout : uint8_t {
VERTICAL_RIGHT_8_SCENES = 3,
HORIZONTAL_TOP_24_SCENES = 4,
HORIZONTAL_TOP_18_SCENES = 5,
SCENES_ONLY_4_SCENES = 6,
SCENES_ONLY_9_SCENES = 7,
SCENES_ONLY_16_SCENES = 8,
SCENES_ONLY_25_SCENES = 9,
};
class OBSProjector : public OBSQTDisplay {