Fix TreeNode not rendering all nodes properly with invisible children
This commit is contained in:
@@ -730,12 +730,15 @@ namespace FlaxEditor.GUI.Tree
|
|||||||
// Try to estimate the rough location of the first node, assuming the node height is constant
|
// Try to estimate the rough location of the first node, assuming the node height is constant
|
||||||
var firstChildGlobalRect = GetChildGlobalRectangle(children[0], ref globalTransform);
|
var firstChildGlobalRect = GetChildGlobalRectangle(children[0], ref globalTransform);
|
||||||
var firstVisibleChild = Math.Clamp((int)Math.Floor((globalClipping.Y - firstChildGlobalRect.Top) / firstChildGlobalRect.Height) + 1, 0, children.Count - 1);
|
var firstVisibleChild = Math.Clamp((int)Math.Floor((globalClipping.Y - firstChildGlobalRect.Top) / firstChildGlobalRect.Height) + 1, 0, children.Count - 1);
|
||||||
if (GetChildGlobalRectangle(children[firstVisibleChild], ref globalTransform).Top > globalClipping.Top)
|
if (GetChildGlobalRectangle(children[firstVisibleChild], ref globalTransform).Top > globalClipping.Top || !children[firstVisibleChild].Visible)
|
||||||
{
|
{
|
||||||
// Overshoot...
|
// Estimate overshoot, either it's partially visible or hidden in the tree
|
||||||
for (; firstVisibleChild > 0; firstVisibleChild--)
|
for (; firstVisibleChild > 0; firstVisibleChild--)
|
||||||
{
|
{
|
||||||
var child = children[firstVisibleChild];
|
var child = children[firstVisibleChild];
|
||||||
|
if (!child.Visible)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (GetChildGlobalRectangle(child, ref globalTransform).Top < globalClipping.Top)
|
if (GetChildGlobalRectangle(child, ref globalTransform).Top < globalClipping.Top)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -744,18 +747,16 @@ namespace FlaxEditor.GUI.Tree
|
|||||||
for (int i = firstVisibleChild; i < children.Count; i++)
|
for (int i = firstVisibleChild; i < children.Count; i++)
|
||||||
{
|
{
|
||||||
var child = children[i];
|
var child = children[i];
|
||||||
if (child.Visible)
|
if (!child.Visible)
|
||||||
{
|
continue;
|
||||||
var childGlobalRect = GetChildGlobalRectangle(child, ref globalTransform);
|
|
||||||
if (globalClipping.Intersects(ref childGlobalRect))
|
var childGlobalRect = GetChildGlobalRectangle(child, ref globalTransform);
|
||||||
{
|
if (!globalClipping.Intersects(ref childGlobalRect))
|
||||||
Render2D.PushTransform(ref child._cachedTransform);
|
break;
|
||||||
child.Draw();
|
|
||||||
Render2D.PopTransform();
|
Render2D.PushTransform(ref child._cachedTransform);
|
||||||
}
|
child.Draw();
|
||||||
else
|
Render2D.PopTransform();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Rectangle GetChildGlobalRectangle(Control control, ref Matrix3x3 globalTransform)
|
static Rectangle GetChildGlobalRectangle(Control control, ref Matrix3x3 globalTransform)
|
||||||
|
|||||||
Reference in New Issue
Block a user