window-projector.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. };
  18. class OBSProjector : public OBSQTDisplay {
  19. Q_OBJECT
  20. private:
  21. OBSSource source;
  22. OBSSignal removedSignal;
  23. static void OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy);
  24. static void OBSRender(void *data, uint32_t cx, uint32_t cy);
  25. static void OBSSourceRemoved(void *data, calldata_t *params);
  26. void mousePressEvent(QMouseEvent *event) override;
  27. void mouseDoubleClickEvent(QMouseEvent *event) override;
  28. int savedMonitor;
  29. bool isWindow;
  30. QString projectorTitle;
  31. ProjectorType type = ProjectorType::Source;
  32. OBSWeakSource multiviewScenes[8];
  33. OBSSource multiviewLabels[10];
  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. float lineLength = 0.1f;
  41. // Rec. ITU-R BT.1848-1 / EBU R 95
  42. float actionSafePercentage = 0.035f; // 3.5%
  43. float graphicsSafePercentage = 0.05f; // 5.0%
  44. float fourByThreeSafePercentage = 0.1625f; // 16.25%
  45. bool ready = false;
  46. // argb colors
  47. static const uint32_t outerColor = 0xFFD0D0D0;
  48. static const uint32_t labelColor = 0xD91F1F1F;
  49. static const uint32_t backgroundColor = 0xFF000000;
  50. static const uint32_t previewColor = 0xFF00D000;
  51. static const uint32_t programColor = 0xFFD00000;
  52. void UpdateMultiview();
  53. void UpdateProjectorTitle(QString name);
  54. private slots:
  55. void EscapeTriggered();
  56. public:
  57. OBSProjector(QWidget *widget, obs_source_t *source_, int monitor,
  58. QString title, ProjectorType type_);
  59. ~OBSProjector();
  60. OBSSource GetSource();
  61. ProjectorType GetProjectorType();
  62. int GetMonitor();
  63. static void UpdateMultiviewProjectors();
  64. static void RenameProjector(QString oldName, QString newName);
  65. };