window-projector.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 *outerBox = nullptr;
  35. gs_vertbuffer_t *innerBox = nullptr;
  36. gs_vertbuffer_t *leftVLine = nullptr;
  37. gs_vertbuffer_t *rightVLine = nullptr;
  38. gs_vertbuffer_t *leftLine = nullptr;
  39. gs_vertbuffer_t *topLine = nullptr;
  40. gs_vertbuffer_t *rightLine = nullptr;
  41. bool ready = false;
  42. // argb colors
  43. static const uint32_t outerColor = 0xFFD0D0D0;
  44. static const uint32_t labelColor = 0xD91F1F1F;
  45. static const uint32_t backgroundColor = 0xFF000000;
  46. static const uint32_t previewColor = 0xFF00FF00;
  47. static const uint32_t programColor = 0xFFFF0000;
  48. void UpdateMultiview();
  49. void UpdateProjectorTitle(QString name);
  50. private slots:
  51. void EscapeTriggered();
  52. public:
  53. OBSProjector(QWidget *widget, obs_source_t *source_, int monitor,
  54. QString title, ProjectorType type_);
  55. ~OBSProjector();
  56. void Init();
  57. OBSSource GetSource();
  58. ProjectorType GetProjectorType();
  59. int GetMonitor();
  60. static void UpdateMultiviewProjectors();
  61. static void RenameProjector(QString oldName, QString newName);
  62. };