// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef QSSGQMLUTILITIES_P_H
#define QSSGQMLUTILITIES_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include <QtQuick3DAssetUtils/private/qtquick3dassetutilsglobal_p.h>

#include <QString>
#include <QColor>
#include <QVariant>
#include <QHash>
#include <QTextStream>

QT_BEGIN_NAMESPACE

namespace QSSGSceneDesc {
struct Scene;
struct Node;
struct Animation;
}

namespace QSSGMesh {
class Mesh;
}

class QDir;

namespace QSSGQmlUtilities {

class PropertyMap
{
public:
    enum Type {
        Node,
        Model,
        Joint,
        PerspectiveCamera,
        OrthographicCamera,
        DirectionalLight,
        PointLight,
        SpotLight,
        DefaultMaterial,
        PrincipledMaterial,
        SpecularGlossyMaterial,
        Texture,
    };

    typedef QHash<QString, QVariant> PropertiesMap;

    static PropertyMap *instance();

    PropertiesMap *propertiesForType(Type type);
    QVariant getDefaultValue(Type type, const QString &property);
    bool isDefaultValue(Type type, const QString &property, const QVariant &value);


private:
    PropertyMap();
    ~PropertyMap();

    QHash<Type, PropertiesMap *> m_properties;

};

QString Q_QUICK3DASSETUTILS_EXPORT insertTabs(int n);
QString Q_QUICK3DASSETUTILS_EXPORT qmlComponentName(const QString &name);
QString Q_QUICK3DASSETUTILS_EXPORT colorToQml(const QColor &color);
QString Q_QUICK3DASSETUTILS_EXPORT variantToQml(const QVariant &variant);
QString Q_QUICK3DASSETUTILS_EXPORT sanitizeQmlId(const QString &id);
QString Q_QUICK3DASSETUTILS_EXPORT sanitizeQmlSourcePath(const QString &source, bool removeParentDirectory = false);
QString Q_QUICK3DASSETUTILS_EXPORT stripParentDirectory(const QString &filePath);

void Q_QUICK3DASSETUTILS_EXPORT writeQmlPropertyHelper(QTextStream &output, int tabLevel, PropertyMap::Type type, const QString &propertyName, const QVariant &value);

void Q_QUICK3DASSETUTILS_EXPORT writeQml(const QSSGSceneDesc::Scene &scene, QTextStream &stream, const QDir &outdir);
void Q_QUICK3DASSETUTILS_EXPORT writeQmlComponent(const QSSGSceneDesc::Node &node, QTextStream &stream, const QDir &outDir);

Q_REQUIRED_RESULT QString Q_QUICK3DASSETUTILS_EXPORT getMeshSourceName(const QByteArrayView &name);

void Q_QUICK3DASSETUTILS_EXPORT createTimelineAnimation(const QSSGSceneDesc::Animation &anim, QObject *parent, bool isEnabled = true, bool useBinaryKeyframe = true);

}


QT_END_NAMESPACE

#endif // QSSGQMLUTILITIES_P_H
