瀏覽代碼

UI: Add "18 Scenes" multiview option

Adds a "18 Scenes" multiview option. The 18 scene view leaves the
preview and program sized to the upper half of the window

Settings index in combobox may not match up with enum index. Settings
in the dropdown can now be ordered separately from the enum order.
Delta 4 年之前
父節點
當前提交
a64328da56
共有 4 個文件被更改,包括 51 次插入5 次删除
  1. 1 0
      UI/data/locale/en-US.ini
  2. 6 2
      UI/window-basic-settings.cpp
  3. 43 3
      UI/window-projector.cpp
  4. 1 0
      UI/window-projector.hpp

+ 1 - 0
UI/data/locale/en-US.ini

@@ -781,6 +781,7 @@ Basic.Settings.General.MultiviewLayout.Horizontal.Top="Horizontal, Top (8 Scenes
 Basic.Settings.General.MultiviewLayout.Horizontal.Bottom="Horizontal, Bottom (8 Scenes)"
 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 mode 'stream' settings

+ 6 - 2
UI/window-basic-settings.cpp

@@ -1350,12 +1350,16 @@ void OBSBasicSettings::LoadGeneralSettings()
 	ui->multiviewLayout->addItem(
 		QTStr("Basic.Settings.General.MultiviewLayout.Vertical.Right"),
 		static_cast<int>(MultiviewLayout::VERTICAL_RIGHT_8_SCENES));
+	ui->multiviewLayout->addItem(
+		QTStr("Basic.Settings.General.MultiviewLayout.Horizontal.18Scene.Top"),
+		static_cast<int>(MultiviewLayout::HORIZONTAL_TOP_18_SCENES));
 	ui->multiviewLayout->addItem(
 		QTStr("Basic.Settings.General.MultiviewLayout.Horizontal.Extended.Top"),
 		static_cast<int>(MultiviewLayout::HORIZONTAL_TOP_24_SCENES));
 
-	ui->multiviewLayout->setCurrentIndex(config_get_int(
-		GetGlobalConfig(), "BasicWindow", "MultiviewLayout"));
+	ui->multiviewLayout->setCurrentIndex(
+		ui->multiviewLayout->findData(
+			config_get_int(GetGlobalConfig(), "BasicWindow", "MultiviewLayout")));
 
 	prevLangIndex = ui->language->currentIndex();
 

+ 43 - 3
UI/window-projector.cpp

@@ -246,6 +246,9 @@ static inline uint32_t labelOffset(obs_source_t *label, uint32_t cx)
 
 	int n; // Number of scenes per row
 	switch (multiviewLayout) {
+	case MultiviewLayout::HORIZONTAL_TOP_18_SCENES:
+		n = 6;
+		break;
 	case MultiviewLayout::HORIZONTAL_TOP_24_SCENES:
 		n = 6;
 		break;
@@ -338,6 +341,11 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
 
 	auto calcBaseSource = [&](size_t i) {
 		switch (multiviewLayout) {
+		case MultiviewLayout::HORIZONTAL_TOP_18_SCENES:
+			window->sourceX = (i % 6) * window->scenesCX;
+			window->sourceY =
+				window->pvwprgCY + (i / 6) * window->scenesCY;
+			break;
 		case MultiviewLayout::HORIZONTAL_TOP_24_SCENES:
 			window->sourceX = (i % 6) * window->scenesCX;
 			window->sourceY =
@@ -423,7 +431,7 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
 				window->labelX += window->pvwprgCX;
 			}
 			break;
-		default: // MultiviewLayout::HORIZONTAL_TOP_8_SCENES:
+		default: // MultiviewLayout::HORIZONTAL_TOP_8_SCENES and 18_SCENES
 			window->sourceX = window->thickness;
 			window->sourceY = window->thickness;
 			window->labelX = window->offset;
@@ -703,6 +711,24 @@ static int getSourceByPosition(int x, int y, float ratio)
 	int maxY = cy;
 
 	switch (multiviewLayout) {
+	case MultiviewLayout::HORIZONTAL_TOP_18_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;
+
+		if (x < minX || x > maxX || y < minY || y > maxY)
+			break;
+
+		pos = (x - minX) / ((maxX - minX) / 6);
+		pos += ((y - minY) / ((maxY - minY) / 3)) * 6;
+
+		break;
 	case MultiviewLayout::HORIZONTAL_TOP_24_SCENES:
 		if (float(cx) / float(cy) > ratio) {
 			int validX = cy * ratio;
@@ -929,6 +955,12 @@ void OBSProjector::UpdateMultiview()
 		GetGlobalConfig(), "BasicWindow", "TransitionOnDoubleClick");
 
 	switch (multiviewLayout) {
+	case MultiviewLayout::HORIZONTAL_TOP_18_SCENES:
+		pvwprgCX = fw / 2;
+		pvwprgCY = fh / 2;
+
+		maxSrcs = 18;
+		break;
 	case MultiviewLayout::HORIZONTAL_TOP_24_SCENES:
 		pvwprgCX = fw / 3;
 		pvwprgCY = fh / 3;
@@ -947,8 +979,16 @@ void OBSProjector::UpdateMultiview()
 	ppiScaleX = (pvwprgCX - thicknessx2) / fw;
 	ppiScaleY = (pvwprgCY - thicknessx2) / fh;
 
-	scenesCX = pvwprgCX / 2;
-	scenesCY = pvwprgCY / 2;
+	switch (multiviewLayout) {
+	case MultiviewLayout::HORIZONTAL_TOP_18_SCENES:
+		scenesCX = pvwprgCX / 3;
+		scenesCY = pvwprgCY / 3;
+		break;
+	default:
+		scenesCX = pvwprgCX / 2;
+		scenesCY = pvwprgCY / 2;
+	}
+
 	siCX = scenesCX - thicknessx2;
 	siCY = scenesCY - thicknessx2;
 	siScaleX = (scenesCX - thicknessx2) / fw;

+ 1 - 0
UI/window-projector.hpp

@@ -19,6 +19,7 @@ enum class MultiviewLayout : uint8_t {
 	VERTICAL_LEFT_8_SCENES = 2,
 	VERTICAL_RIGHT_8_SCENES = 3,
 	HORIZONTAL_TOP_24_SCENES = 4,
+	HORIZONTAL_TOP_18_SCENES = 5,
 };
 
 class OBSProjector : public OBSQTDisplay {