ShaderNodes: Add TextureEdit dialog

This commit is contained in:
Jérôme Leclercq
2020-07-04 22:52:17 +02:00
parent 33d94c05f3
commit 5164294bec
11 changed files with 200 additions and 17 deletions

View File

@@ -9,19 +9,23 @@ TextureValue::TextureValue(ShaderGraph& graph) :
ShaderNode(graph)
{
m_onTextureListUpdateSlot.Connect(GetGraph().OnTextureListUpdate, [&](ShaderGraph*) { OnTextureListUpdate(); });
m_onTexturePreviewUpdateSlot.Connect(GetGraph().OnTexturePreviewUpdate, [&](ShaderGraph*, std::size_t textureIndex)
auto HandleTextureUpdate = [&](ShaderGraph*, std::size_t textureIndex)
{
if (m_currentTextureIndex == textureIndex)
{
UpdatePreview();
Q_EMIT dataUpdated(0);
}
});
};
m_onTexturePreviewUpdateSlot.Connect(GetGraph().OnTexturePreviewUpdate, HandleTextureUpdate);
m_onTextureUpdateSlot.Connect(GetGraph().OnTextureUpdate, HandleTextureUpdate);
if (graph.GetTextureCount() > 0)
{
m_currentTextureIndex = 0;
UpdateOutputTexture();
UpdateTexture();
}
DisableCustomVariableName();
@@ -56,7 +60,7 @@ void TextureValue::OnTextureListUpdate()
}
}
void TextureValue::UpdateOutputTexture()
void TextureValue::UpdateTexture()
{
if (m_currentTextureIndex)
{
@@ -97,7 +101,7 @@ void TextureValue::BuildNodeEdition(QFormLayout* layout)
else
m_currentTextureIndex.reset();
UpdateOutputTexture();
UpdateTexture();
UpdatePreview();
Q_EMIT dataUpdated(0);

View File

@@ -35,13 +35,14 @@ class TextureValue : public ShaderNode
protected:
bool ComputePreview(QPixmap& pixmap) override;
void OnTextureListUpdate();
void UpdateOutputTexture();
void UpdateTexture();
void restore(const QJsonObject& data) override;
QJsonObject save() const override;
NazaraSlot(ShaderGraph, OnTextureListUpdate, m_onTextureListUpdateSlot);
NazaraSlot(ShaderGraph, OnTexturePreviewUpdate, m_onTexturePreviewUpdateSlot);
NazaraSlot(ShaderGraph, OnTextureUpdate, m_onTextureUpdateSlot);
std::optional<std::size_t> m_currentTextureIndex;
std::string m_currentTextureText;