Merge pull request #1461 from cg2121/preview-bgcolor
UI: Add ability to style preview background color
This commit is contained in:
commit
6c42d07751
@ -880,3 +880,9 @@ FocusList::item {
|
|||||||
* [themeID="aboutHLayout"] {
|
* [themeID="aboutHLayout"] {
|
||||||
background-color: rgb(8, 8, 11);
|
background-color: rgb(8, 8, 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Preview background color */
|
||||||
|
|
||||||
|
* [themeID="displayBackgroundColor"] {
|
||||||
|
qproperty-displayBackgroundColor: #28282A;
|
||||||
|
}
|
||||||
|
@ -656,3 +656,9 @@ QLabel#errorLabel {
|
|||||||
* [themeID="aboutHLayout"] {
|
* [themeID="aboutHLayout"] {
|
||||||
background-color: rgb(31, 30, 31); /* veryDark */
|
background-color: rgb(31, 30, 31); /* veryDark */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Preview background color */
|
||||||
|
|
||||||
|
* [themeID="displayBackgroundColor"] {
|
||||||
|
qproperty-displayBackgroundColor: rgb(76, 76, 76);
|
||||||
|
}
|
||||||
|
@ -135,3 +135,9 @@ QLabel#errorLabel {
|
|||||||
* [themeID="aboutHLayout"] {
|
* [themeID="aboutHLayout"] {
|
||||||
background-color: rgb(169, 169, 169);
|
background-color: rgb(169, 169, 169);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Preview background color */
|
||||||
|
|
||||||
|
* [themeID="displayBackgroundColor"] {
|
||||||
|
qproperty-displayBackgroundColor: rgb(76, 76, 76);
|
||||||
|
}
|
||||||
|
@ -1234,3 +1234,9 @@ QToolTip {
|
|||||||
* [themeID="aboutHLayout"] {
|
* [themeID="aboutHLayout"] {
|
||||||
background-color: rgb(35, 38, 41); /* Dark Gray */
|
background-color: rgb(35, 38, 41); /* Dark Gray */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Preview background color */
|
||||||
|
|
||||||
|
* [themeID="displayBackgroundColor"] {
|
||||||
|
qproperty-displayBackgroundColor: rgb(35, 38, 41);
|
||||||
|
}
|
||||||
|
@ -6,6 +6,20 @@
|
|||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
|
|
||||||
|
static inline long long color_to_int(QColor color)
|
||||||
|
{
|
||||||
|
auto shift = [&](unsigned val, int shift)
|
||||||
|
{
|
||||||
|
return ((val & 0xff) << shift);
|
||||||
|
};
|
||||||
|
|
||||||
|
return shift(color.red(), 0) |
|
||||||
|
shift(color.green(), 8) |
|
||||||
|
shift(color.blue(), 16) |
|
||||||
|
shift(color.alpha(), 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags)
|
OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags)
|
||||||
: QWidget(parent, flags)
|
: QWidget(parent, flags)
|
||||||
{
|
{
|
||||||
@ -39,6 +53,14 @@ OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags)
|
|||||||
|
|
||||||
connect(windowHandle(), &QWindow::visibleChanged, windowVisible);
|
connect(windowHandle(), &QWindow::visibleChanged, windowVisible);
|
||||||
connect(windowHandle(), &QWindow::screenChanged, sizeChanged);
|
connect(windowHandle(), &QWindow::screenChanged, sizeChanged);
|
||||||
|
|
||||||
|
this->setProperty("themeID", "displayBackgroundColor");
|
||||||
|
}
|
||||||
|
|
||||||
|
void OBSQTDisplay::SetDisplayBackgroundColor(const QColor &color)
|
||||||
|
{
|
||||||
|
backgroundColor = (uint32_t)color_to_int(color);
|
||||||
|
obs_display_set_background_color(display, backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSQTDisplay::CreateDisplay()
|
void OBSQTDisplay::CreateDisplay()
|
||||||
@ -56,7 +78,7 @@ void OBSQTDisplay::CreateDisplay()
|
|||||||
|
|
||||||
QTToGSWindow(winId(), info.window);
|
QTToGSWindow(winId(), info.window);
|
||||||
|
|
||||||
display = obs_display_create(&info);
|
display = obs_display_create(&info, backgroundColor);
|
||||||
|
|
||||||
emit DisplayCreated(this);
|
emit DisplayCreated(this);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
class OBSQTDisplay : public QWidget {
|
class OBSQTDisplay : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QColor displayBackgroundColor WRITE SetDisplayBackgroundColor
|
||||||
|
NOTIFY SetDisplayBackgroundColor)
|
||||||
|
|
||||||
OBSDisplay display;
|
OBSDisplay display;
|
||||||
|
|
||||||
@ -23,4 +25,9 @@ public:
|
|||||||
virtual QPaintEngine *paintEngine() const override;
|
virtual QPaintEngine *paintEngine() const override;
|
||||||
|
|
||||||
inline obs_display_t *GetDisplay() const {return display;}
|
inline obs_display_t *GetDisplay() const {return display;}
|
||||||
|
|
||||||
|
uint32_t backgroundColor;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void SetDisplayBackgroundColor(const QColor &color);
|
||||||
};
|
};
|
||||||
|
@ -46,17 +46,22 @@ bool obs_display_init(struct obs_display *display,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
display->background_color = 0x4C4C4C;
|
|
||||||
display->enabled = true;
|
display->enabled = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_display_t *obs_display_create(const struct gs_init_data *graphics_data)
|
obs_display_t *obs_display_create(const struct gs_init_data *graphics_data,
|
||||||
|
uint32_t background_color)
|
||||||
{
|
{
|
||||||
struct obs_display *display = bzalloc(sizeof(struct obs_display));
|
struct obs_display *display = bzalloc(sizeof(struct obs_display));
|
||||||
|
|
||||||
gs_enter_context(obs->video.graphics);
|
gs_enter_context(obs->video.graphics);
|
||||||
|
|
||||||
|
if (background_color)
|
||||||
|
display->background_color = background_color;
|
||||||
|
else
|
||||||
|
display->background_color = 0x4c4c4c;
|
||||||
|
|
||||||
if (!obs_display_init(display, graphics_data)) {
|
if (!obs_display_init(display, graphics_data)) {
|
||||||
obs_display_destroy(display);
|
obs_display_destroy(display);
|
||||||
display = NULL;
|
display = NULL;
|
||||||
@ -227,6 +232,10 @@ bool obs_display_enabled(obs_display_t *display)
|
|||||||
|
|
||||||
void obs_display_set_background_color(obs_display_t *display, uint32_t color)
|
void obs_display_set_background_color(obs_display_t *display, uint32_t color)
|
||||||
{
|
{
|
||||||
if (display)
|
if (display) {
|
||||||
display->background_color = color;
|
if (color)
|
||||||
|
display->background_color = color;
|
||||||
|
else
|
||||||
|
display->background_color = 0x4c4c4c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -748,7 +748,8 @@ EXPORT void obs_view_render(obs_view_t *view);
|
|||||||
* @return The new display context, or NULL if failed.
|
* @return The new display context, or NULL if failed.
|
||||||
*/
|
*/
|
||||||
EXPORT obs_display_t *obs_display_create(
|
EXPORT obs_display_t *obs_display_create(
|
||||||
const struct gs_init_data *graphics_data);
|
const struct gs_init_data *graphics_data,
|
||||||
|
uint32_t backround_color);
|
||||||
|
|
||||||
/** Destroys a display context */
|
/** Destroys a display context */
|
||||||
EXPORT void obs_display_destroy(obs_display_t *display);
|
EXPORT void obs_display_destroy(obs_display_t *display);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user