yolobs-studio/UI/window-projector.hpp

95 lines
2.6 KiB
C++
Raw Normal View History

2016-02-23 23:16:51 +00:00
#pragma once
#include <obs.hpp>
#include "qt-display.hpp"
2018-12-16 16:14:58 +00:00
enum class ProjectorType {
Source,
Scene,
Preview,
StudioProgram,
2019-09-22 21:19:10 +00:00
Multiview,
2018-12-16 16:14:58 +00:00
};
2016-02-23 23:16:51 +00:00
class QMouseEvent;
2018-12-16 16:14:58 +00:00
enum class MultiviewLayout : uint8_t {
HORIZONTAL_TOP_8_SCENES = 0,
HORIZONTAL_BOTTOM_8_SCENES = 1,
VERTICAL_LEFT_8_SCENES = 2,
VERTICAL_RIGHT_8_SCENES = 3,
2019-09-22 21:19:10 +00:00
HORIZONTAL_TOP_24_SCENES = 4,
2018-12-16 16:14:58 +00:00
};
2016-02-23 23:16:51 +00:00
class OBSProjector : public OBSQTDisplay {
Q_OBJECT
private:
OBSSource source;
OBSSignal removedSignal;
2018-02-19 19:54:37 +00:00
static void OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy);
2016-02-23 23:16:51 +00:00
static void OBSRender(void *data, uint32_t cx, uint32_t cy);
static void OBSSourceRemoved(void *data, calldata_t *params);
void mousePressEvent(QMouseEvent *event) override;
2018-02-19 19:54:37 +00:00
void mouseDoubleClickEvent(QMouseEvent *event) override;
2020-03-25 08:07:22 +00:00
void closeEvent(QCloseEvent *event) override;
2016-02-23 23:16:51 +00:00
2020-03-25 08:07:22 +00:00
int savedMonitor = -1;
2018-02-19 19:54:37 +00:00
ProjectorType type = ProjectorType::Source;
2018-12-16 16:14:58 +00:00
std::vector<OBSWeakSource> multiviewScenes;
std::vector<OBSSource> multiviewLabels;
2019-09-22 21:19:10 +00:00
gs_vertbuffer_t *actionSafeMargin = nullptr;
gs_vertbuffer_t *graphicsSafeMargin = nullptr;
2018-12-16 16:14:58 +00:00
gs_vertbuffer_t *fourByThreeSafeMargin = nullptr;
2019-09-22 21:19:10 +00:00
gs_vertbuffer_t *leftLine = nullptr;
gs_vertbuffer_t *topLine = nullptr;
gs_vertbuffer_t *rightLine = nullptr;
2018-12-16 16:14:58 +00:00
gs_effect_t *solid = nullptr;
gs_eparam_t *color = nullptr;
// Multiview position helpers
float thickness = 4;
2019-09-22 21:19:10 +00:00
float offset, thicknessx2 = thickness * 2, pvwprgCX, pvwprgCY, sourceX,
sourceY, labelX, labelY, scenesCX, scenesCY, ppiCX, ppiCY,
siX, siY, siCX, siCY, ppiScaleX, ppiScaleY, siScaleX,
siScaleY, fw, fh, ratio;
2018-12-16 16:14:58 +00:00
2019-09-22 21:19:10 +00:00
float lineLength = 0.1f;
2018-12-16 16:14:58 +00:00
// Rec. ITU-R BT.1848-1 / EBU R 95
2019-09-22 21:19:10 +00:00
float actionSafePercentage = 0.035f; // 3.5%
float graphicsSafePercentage = 0.05f; // 5.0%
2018-12-16 16:14:58 +00:00
float fourByThreeSafePercentage = 0.1625f; // 16.25%
2018-02-19 19:54:37 +00:00
bool ready = false;
2018-12-16 16:14:58 +00:00
// argb colors
2019-09-22 21:19:10 +00:00
static const uint32_t outerColor = 0xFFD0D0D0;
static const uint32_t labelColor = 0xD91F1F1F;
2018-12-16 16:14:58 +00:00
static const uint32_t backgroundColor = 0xFF000000;
2019-09-22 21:19:10 +00:00
static const uint32_t previewColor = 0xFF00D000;
static const uint32_t programColor = 0xFFD00000;
2018-12-16 16:14:58 +00:00
2018-02-19 19:54:37 +00:00
void UpdateMultiview();
2018-12-16 16:14:58 +00:00
void UpdateProjectorTitle(QString name);
2017-04-19 19:54:15 +00:00
2020-03-25 08:07:22 +00:00
QRect prevGeometry;
void SetHideCursor();
void SetMonitor(int monitor);
2016-02-23 23:16:51 +00:00
private slots:
void EscapeTriggered();
2020-03-25 08:07:22 +00:00
void OpenFullScreenProjector();
void OpenWindowedProjector();
2016-02-23 23:16:51 +00:00
public:
2018-12-16 16:14:58 +00:00
OBSProjector(QWidget *widget, obs_source_t *source_, int monitor,
2020-03-25 08:07:22 +00:00
ProjectorType type_);
2016-02-23 23:16:51 +00:00
~OBSProjector();
2018-12-16 16:14:58 +00:00
OBSSource GetSource();
ProjectorType GetProjectorType();
int GetMonitor();
2018-02-19 19:54:37 +00:00
static void UpdateMultiviewProjectors();
2020-03-25 08:07:22 +00:00
void RenameProjector(QString oldName, QString newName);
2016-02-23 23:16:51 +00:00
};