window-projector.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. int savedMonitor;
  30. bool isWindow;
  31. QString projectorTitle;
  32. ProjectorType type = ProjectorType::Source;
  33. std::vector<OBSWeakSource> multiviewScenes;
  34. std::vector<OBSSource> multiviewLabels;
  35. gs_vertbuffer_t *actionSafeMargin = nullptr;
  36. gs_vertbuffer_t *graphicsSafeMargin = nullptr;
  37. gs_vertbuffer_t *fourByThreeSafeMargin = nullptr;
  38. gs_vertbuffer_t *leftLine = nullptr;
  39. gs_vertbuffer_t *topLine = nullptr;
  40. gs_vertbuffer_t *rightLine = nullptr;
  41. gs_effect_t *solid = nullptr;
  42. gs_eparam_t *color = nullptr;
  43. // Multiview position helpers
  44. float thickness = 4;
  45. float offset, thicknessx2 = thickness * 2, pvwprgCX, pvwprgCY, sourceX,
  46. sourceY, labelX, labelY, scenesCX, scenesCY, ppiCX, ppiCY,
  47. siX, siY, siCX, siCY, ppiScaleX, ppiScaleY, siScaleX,
  48. siScaleY, fw, fh, ratio;
  49. float lineLength = 0.1f;
  50. // Rec. ITU-R BT.1848-1 / EBU R 95
  51. float actionSafePercentage = 0.035f; // 3.5%
  52. float graphicsSafePercentage = 0.05f; // 5.0%
  53. float fourByThreeSafePercentage = 0.1625f; // 16.25%
  54. bool ready = false;
  55. // argb colors
  56. static const uint32_t outerColor = 0xFFD0D0D0;
  57. static const uint32_t labelColor = 0xD91F1F1F;
  58. static const uint32_t backgroundColor = 0xFF000000;
  59. static const uint32_t previewColor = 0xFF00D000;
  60. static const uint32_t programColor = 0xFFD00000;
  61. void UpdateMultiview();
  62. void UpdateProjectorTitle(QString name);
  63. private slots:
  64. void EscapeTriggered();
  65. public:
  66. OBSProjector(QWidget *widget, obs_source_t *source_, int monitor,
  67. QString title, ProjectorType type_);
  68. ~OBSProjector();
  69. OBSSource GetSource();
  70. ProjectorType GetProjectorType();
  71. int GetMonitor();
  72. static void UpdateMultiviewProjectors();
  73. static void RenameProjector(QString oldName, QString newName);
  74. };