Add newly added variables to start of variables list

* But all variables added in a single step still remain in the order they're
  reported in as changes.
This commit is contained in:
baldurk
2020-04-23 11:09:54 +01:00
parent e90461c065
commit aae3a75f6e
+11 -3
View File
@@ -1574,6 +1574,8 @@ void ShaderViewer::applyBackwardsChange()
{
if(!IsFirstState())
{
rdcarray<ShaderVariable> newVariables;
for(const ShaderVariableChange &c : GetCurrentState().changes)
{
// if the before name is empty, this is a variable that came into scope/was created
@@ -1604,10 +1606,12 @@ void ShaderViewer::applyBackwardsChange()
if(v)
*v = c.before;
else
m_Variables.push_back(c.before);
newVariables.push_back(c.before);
}
}
m_Variables.insert(0, newVariables);
m_CurrentStateIdx--;
}
}
@@ -1618,6 +1622,8 @@ void ShaderViewer::applyForwardsChange()
{
m_CurrentStateIdx++;
rdcarray<ShaderVariable> newVariables;
for(const ShaderVariableChange &c : GetCurrentState().changes)
{
// if the after name is empty, this is a variable going out of scope/being deleted
@@ -1648,9 +1654,11 @@ void ShaderViewer::applyForwardsChange()
if(v)
*v = c.after;
else
m_Variables.push_back(c.after);
newVariables.push_back(c.after);
}
}
m_Variables.insert(0, newVariables);
}
}
@@ -1866,7 +1874,7 @@ void ShaderViewer::combineStructures(RDTreeWidgetItem *root, int skipPrefixLengt
// move all the children back from the temp object into the parameter
while(temp.childCount() > 0)
root->addChild(temp.takeChild(temp.childCount() - 1));
root->addChild(temp.takeChild(0));
}
RDTreeWidgetItem *ShaderViewer::findVarInTree(RDTreeWidgetItem *root, QString name, bool fullmatch,