ShaderNodes: Add TextureEdit dialog
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user