Compare commits

...

2 commits

3 changed files with 7 additions and 23 deletions

View file

@ -23,23 +23,6 @@ QHash<int, QByteArray> UntypedObjectModel::roleNames() const {
return {{Qt::UserRole, "modelData"}}; return {{Qt::UserRole, "modelData"}};
} }
QQmlListProperty<QObject> UntypedObjectModel::values() {
return QQmlListProperty<QObject>(
this,
nullptr,
&UntypedObjectModel::valuesCount,
&UntypedObjectModel::valueAt
);
}
qsizetype UntypedObjectModel::valuesCount(QQmlListProperty<QObject>* property) {
return static_cast<UntypedObjectModel*>(property->object)->valuesList.count(); // NOLINT
}
QObject* UntypedObjectModel::valueAt(QQmlListProperty<QObject>* property, qsizetype index) {
return static_cast<UntypedObjectModel*>(property->object)->valuesList.at(index); // NOLINT
}
void UntypedObjectModel::insertObject(QObject* object, qsizetype index) { void UntypedObjectModel::insertObject(QObject* object, qsizetype index) {
auto iindex = index == -1 ? this->valuesList.length() : index; auto iindex = index == -1 ? this->valuesList.length() : index;
emit this->objectInsertedPre(object, iindex); emit this->objectInsertedPre(object, iindex);

View file

@ -42,7 +42,7 @@ class UntypedObjectModel: public QAbstractListModel {
Q_OBJECT; Q_OBJECT;
/// The content of the object model, as a QML list. /// The content of the object model, as a QML list.
/// The values of this property will always be of the type of the model. /// The values of this property will always be of the type of the model.
Q_PROPERTY(QQmlListProperty<QObject> values READ values NOTIFY valuesChanged); Q_PROPERTY(QList<QObject*> values READ values NOTIFY valuesChanged);
QML_NAMED_ELEMENT(ObjectModel); QML_NAMED_ELEMENT(ObjectModel);
QML_UNCREATABLE("ObjectModels cannot be created directly."); QML_UNCREATABLE("ObjectModels cannot be created directly.");
@ -53,7 +53,7 @@ public:
[[nodiscard]] QVariant data(const QModelIndex& index, qint32 role) const override; [[nodiscard]] QVariant data(const QModelIndex& index, qint32 role) const override;
[[nodiscard]] QHash<int, QByteArray> roleNames() const override; [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
[[nodiscard]] QQmlListProperty<QObject> values(); [[nodiscard]] QList<QObject*> values() const { return this->valuesList; };
void removeAt(qsizetype index); void removeAt(qsizetype index);
Q_INVOKABLE qsizetype indexOf(QObject* object); Q_INVOKABLE qsizetype indexOf(QObject* object);

View file

@ -14,11 +14,12 @@ layout(binding = 2) uniform sampler2D content;
vec4 overlay(vec4 base, vec4 overlay) { vec4 overlay(vec4 base, vec4 overlay) {
if (overlay.a == 0.0) return base; if (overlay.a == 0.0) return base;
if (base.a == 0.0) return overlay;
float baseMul = 1.0 - overlay.a; vec3 rgb = overlay.rgb + base.rgb * (1.0 - overlay.a);
float newAlpha = overlay.a + base.a * baseMul; float a = overlay.a + base.a * (1.0 - overlay.a);
vec3 rgb = (overlay.rgb * overlay.a + base.rgb * base.a * baseMul) / newAlpha;
return vec4(rgb, newAlpha); return vec4(rgb, a);
} }
void main() { void main() {