window-projector.hpp 2.8 KB

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