Jelajahi Sumber

Make alpha visible in property color

Show a light/dark pattern so alpha in the selected color is evident.
Justin Love 7 tahun lalu
induk
melakukan
a4b2b6f3bf
1 mengubah file dengan 18 tambahan dan 1 penghapusan
  1. 18 1
      UI/properties-view.cpp

+ 18 - 1
UI/properties-view.cpp

@@ -1,4 +1,5 @@
 #include <QFormLayout>
+#include <QStackedLayout>
 #include <QScrollBar>
 #include <QLabel>
 #include <QCheckBox>
@@ -650,10 +651,26 @@ void OBSPropertiesView::AddColor(obs_property_t *prop, QFormLayout *layout,
 	colorLabel->setAlignment(Qt::AlignCenter);
 	colorLabel->setToolTip(QT_UTF8(obs_property_long_description(prop)));
 
+	QFrame *backdrop = new QLabel;
+	backdrop->setFrameStyle(QFrame::Sunken | QFrame::Panel);
+	backdrop->setPalette(palette);
+	backdrop->setStyleSheet(
+		"background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
+			"stop:0 #cccccc, stop:0.45 #cccccc,"
+			"stop:0.55 #444444, stop:1 #444444)");
+	backdrop->setAutoFillBackground(true);
+
+	QStackedLayout *stackLayout = new QStackedLayout;
+	stackLayout->setContentsMargins(0, 0, 0, 0);
+	stackLayout->setStackingMode(QStackedLayout::StackAll);
+
+	stackLayout->addWidget(backdrop);
+	stackLayout->addWidget(colorLabel);
+
 	QHBoxLayout *subLayout = new QHBoxLayout;
 	subLayout->setContentsMargins(0, 0, 0, 0);
 
-	subLayout->addWidget(colorLabel);
+	subLayout->addItem(stackLayout);
 	subLayout->addWidget(button);
 
 	WidgetInfo *info = new WidgetInfo(this, prop, colorLabel);