window-projector.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #pragma once
  2. #include <obs.hpp>
  3. #include "qt-display.hpp"
  4. enum class ProjectorType {
  5. Source,
  6. Scene,
  7. Preview,
  8. StudioProgram,
  9. Multiview,
  10. };
  11. class QMouseEvent;
  12. enum class MultiviewLayout : uint8_t {
  13. HORIZONTAL_TOP_8_SCENES = 0,
  14. HORIZONTAL_BOTTOM_8_SCENES = 1,
  15. VERTICAL_LEFT_8_SCENES = 2,
  16. VERTICAL_RIGHT_8_SCENES = 3,
  17. HORIZONTAL_TOP_24_SCENES = 4,
  18. };
  19. class OBSProjector : public OBSQTDisplay {
  20. Q_OBJECT
  21. private:
  22. OBSSource source;
  23. OBSSignal removedSignal;
  24. static void OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy);
  25. static void OBSRender(void *data, uint32_t cx, uint32_t cy);
  26. static void OBSSourceRemoved(void *data, calldata_t *params);
  27. void mousePressEvent(QMouseEvent *event) override;
  28. void mouseDoubleClickEvent(QMouseEvent *event) override;
  29. void closeEvent(QCloseEvent *event) override;
  30. int savedMonitor = -1;
  31. ProjectorType type = ProjectorType::Source;
  32. std::vector<OBSWeakSource> multiviewScenes;
  33. std::vector<OBSSource> multiviewLabels;
  34. gs_vertbuffer_t *actionSafeMargin = nullptr;
  35. gs_vertbuffer_t *graphicsSafeMargin = nullptr;
  36. gs_vertbuffer_t *fourByThreeSafeMargin = nullptr;
  37. gs_vertbuffer_t *leftLine = nullptr;
  38. gs_vertbuffer_t *topLine = nullptr;
  39. gs_vertbuffer_t *rightLine = nullptr;
  40. gs_effect_t *solid = nullptr;
  41. gs_eparam_t *color = nullptr;
  42. // Multiview position helpers
  43. float thickness = 4;
  44. float offset, thicknessx2 = thickness * 2, pvwprgCX, pvwprgCY, sourceX,
  45. sourceY, labelX, labelY, scenesCX, scenesCY, ppiCX, ppiCY,
  46. siX, siY, siCX, siCY, ppiScaleX, ppiScaleY, siScaleX,
  47. siScaleY, fw, fh, ratio;
  48. float lineLength = 0.1f;
  49. // Rec. ITU-R BT.1848-1 / EBU R 95
  50. float actionSafePercentage = 0.035f; // 3.5%
  51. float graphicsSafePercentage = 0.05f; // 5.0%
  52. float fourByThreeSafePercentage = 0.1625f; // 16.25%
  53. bool ready = false;
  54. // argb colors
  55. static const uint32_t outerColor = 0xFFD0D0D0;
  56. static const uint32_t labelColor = 0xD91F1F1F;
  57. static const uint32_t backgroundColor = 0xFF000000;
  58. static const uint32_t previewColor = 0xFF00D000;
  59. static const uint32_t programColor = 0xFFD00000;
  60. void UpdateMultiview();
  61. void UpdateProjectorTitle(QString name);
  62. QRect prevGeometry;
  63. void SetHideCursor();
  64. void SetMonitor(int monitor);
  65. private slots:
  66. void EscapeTriggered();
  67. void OpenFullScreenProjector();
  68. void OpenWindowedProjector();
  69. public:
  70. OBSProjector(QWidget *widget, obs_source_t *source_, int monitor,
  71. ProjectorType type_);
  72. ~OBSProjector();
  73. OBSSource GetSource();
  74. ProjectorType GetProjectorType();
  75. int GetMonitor();
  76. static void UpdateMultiviewProjectors();
  77. void RenameProjector(QString oldName, QString newName);
  78. };