internal static bool DoTreeNode(int id, string text, ref bool open) { Window window = GetCurrentWindow(); if (window.SkipItems) { return(false); } window.TempData.LastItemId = id; //get or create the root node var container = window.RenderTree.CurrentContainer; var node = container.GetNodeById(id); text = Utility.FindRenderedText(text); if (node == null) { //create nodes node = new Node(id, $"TreeNode<{text}>"); node.AttachLayoutEntry(); node.UseBoxModel = true; node.RuleSet.Replace(GUISkin.Current[GUIControlName.TreeNode]); } container.AppendChild(node); var lineHeight = node.RuleSet.GetLineHeight(); node.RuleSet.ApplyOptions(Height(lineHeight)); node.ActiveSelf = true; // rect Rect rect = window.GetRect(id); // interact var pressed = GUIBehavior.ButtonBehavior(rect, id, out var hovered, out var held, ButtonFlags.PressedOnClickRelease); node.State = (hovered && held) ? GUIState.Active : hovered ? GUIState.Hover : GUIState.Normal; if (pressed) { open = !open; } // last item state window.TempData.LastItemState = node.State; using (var dc = node.RenderOpen()) { dc.DrawRectangle(new Brush(node.RuleSet.BackgroundColor), null, rect); dc.DrawGlyphRun(node.RuleSet, text, node.ContentRect.TopLeft + new Vector(rect.Height + node.PaddingLeft, 0)); dc.RenderArrow(rect.Min + new Vector(node.RuleSet.PaddingTop, lineHeight * 0.15), node.Height, node.RuleSet.FontColor, open ? Internal.Direcion.Down : Internal.Direcion.Right, 0.7); } if (open) { window.CheckStackSize(id, true); PushID(id); BeginHorizontal("#TreeContent"); Space("Space", 20); BeginVertical("#Items"); var cpId = HashCode.Combine(id, 23); window.CheckStackSize(cpId, true); PushID(cpId); } return(open); }