aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/effectcomposer/shadereditordata.h
blob: bcb1533b8cd610a0eae2853f156cca0405ecfc9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#pragma once

#include "effectcodeeditorwidget.h"

#include <texteditor/textdocument.h>
#include <texteditor/texteditor.h>
#include <utils/uniqueobjectptr.h>

namespace EffectComposer {

class EffectComposerUniformsTableModel;

struct ShaderEditorData
{
    using Creator = std::function<
        ShaderEditorData *(const QString &fragmentShader, const QString &vertexShader)>;

    EffectComposerUniformsTableModel *tableModel = nullptr;
    std::function<QStringList()> uniformsCallback = nullptr;
    std::function<void()> exitEditorCallback = nullptr;

    TextEditor::TextDocumentPtr fragmentDocument;
    TextEditor::TextDocumentPtr vertexDocument;

    ~ShaderEditorData()
    {
        if (exitEditorCallback)
            exitEditorCallback();
    }

private:
    friend class EffectShadersCodeEditor;
    Utils::UniqueObjectLatePtr<EffectCodeEditorWidget> fragmentEditor;
    Utils::UniqueObjectLatePtr<EffectCodeEditorWidget> vertexEditor;

    ShaderEditorData() = default;
};

} // namespace EffectComposer