2023-08-17 18:38:40 +03:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
2023-08-18 15:39:40 +03:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QJsonObject)
|
|
|
|
|
|
2023-08-17 18:38:40 +03:00
|
|
|
namespace QmlDesigner {
|
|
|
|
|
|
|
|
|
|
class Uniform : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
2023-08-21 11:52:11 +03:00
|
|
|
Q_PROPERTY(QString uniformName MEMBER m_name CONSTANT)
|
|
|
|
|
Q_PROPERTY(Type uniformType MEMBER m_type CONSTANT)
|
|
|
|
|
Q_PROPERTY(QVariant uniformValue MEMBER m_value CONSTANT)
|
2023-08-21 14:38:50 +03:00
|
|
|
Q_PROPERTY(QVariant uniformMinValue MEMBER m_minValue CONSTANT)
|
|
|
|
|
Q_PROPERTY(QVariant uniformMaxValue MEMBER m_maxValue CONSTANT)
|
2023-08-21 11:52:11 +03:00
|
|
|
|
2023-08-17 18:38:40 +03:00
|
|
|
public:
|
|
|
|
|
enum class Type
|
|
|
|
|
{
|
|
|
|
|
Bool,
|
|
|
|
|
Int,
|
|
|
|
|
Float,
|
|
|
|
|
Vec2,
|
|
|
|
|
Vec3,
|
|
|
|
|
Vec4,
|
|
|
|
|
Color,
|
|
|
|
|
Sampler,
|
|
|
|
|
Define
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Uniform(const QJsonObject &props);
|
|
|
|
|
|
2023-08-18 11:47:16 +03:00
|
|
|
Type type() const;
|
|
|
|
|
|
|
|
|
|
QVariant value() const;
|
|
|
|
|
void setValue(const QVariant &newValue);
|
|
|
|
|
|
|
|
|
|
QVariant defaultValue() const;
|
|
|
|
|
|
|
|
|
|
QVariant minValue() const;
|
|
|
|
|
QVariant maxValue() const;
|
|
|
|
|
|
|
|
|
|
QString name() const;
|
|
|
|
|
QString description() const;
|
|
|
|
|
|
|
|
|
|
QString customValue() const;
|
|
|
|
|
void setCustomValue(const QString &newCustomValue);
|
|
|
|
|
bool useCustomValue() const;
|
|
|
|
|
|
|
|
|
|
bool enabled() const;
|
|
|
|
|
void setEnabled(bool newEnabled);
|
|
|
|
|
|
|
|
|
|
bool enableMipmap() const;
|
2023-08-17 18:38:40 +03:00
|
|
|
|
|
|
|
|
private:
|
2023-08-18 15:39:40 +03:00
|
|
|
QString mipmapPropertyName(const QString &name) const;
|
|
|
|
|
|
|
|
|
|
Uniform::Type typeFromString(const QString &typeString) const;
|
|
|
|
|
bool getBoolValue(const QJsonValue &jsonValue, bool defaultValue);
|
|
|
|
|
QString getResourcePath(const QString &value) const;
|
|
|
|
|
|
2023-08-17 18:38:40 +03:00
|
|
|
Type m_type;
|
|
|
|
|
QVariant m_value;
|
|
|
|
|
QVariant m_defaultValue;
|
|
|
|
|
QVariant m_minValue;
|
|
|
|
|
QVariant m_maxValue;
|
|
|
|
|
QString m_name;
|
|
|
|
|
QString m_description;
|
|
|
|
|
QString m_customValue;
|
|
|
|
|
bool m_useCustomValue = false;
|
2023-08-18 11:47:16 +03:00
|
|
|
bool m_enabled = true;
|
2023-08-17 18:38:40 +03:00
|
|
|
bool m_enableMipmap = false;
|
|
|
|
|
|
2023-08-21 11:52:11 +03:00
|
|
|
bool operator==(const Uniform &rhs) const noexcept
|
2023-08-17 18:38:40 +03:00
|
|
|
{
|
|
|
|
|
return this->m_name == rhs.m_name;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace QmlDesigner
|