/// <summary> /// Create a label with a little bullet. /// </summary> /// <param name="text">The text to display.</param> public static void BulletText(string text) { Window window = GetCurrentWindow(); if (window.SkipItems) { return; } //get or create the root node int id = window.GetID(text); var container = window.RenderTree.CurrentContainer; Node node = container.GetNodeById(id); text = Utility.FindRenderedText(text); if (node == null) { node = new Node(id, $"BulletText<{text}>"); node.UseBoxModel = true; node.RuleSet.Replace(GUISkin.Current[GUIControlName.Label]); var size = node.RuleSet.CalcContentBoxSize(text, GUIState.Normal); var lineHeight = node.RuleSet.GetLineHeight(); size += new Vector(lineHeight, 0); node.AttachLayoutEntry(size); } container.AppendChild(node); node.ActiveSelf = true; // rect node.Rect = window.GetRect(id); // last item state window.TempData.LastItemState = node.State; using (var dc = node.RenderOpen()) { var lineHeight = node.RuleSet.GetLineHeight(); var bulletPosition = node.Rect.TopLeft + new Vector(lineHeight * 0.5f, lineHeight * 0.5f); GUIAppearance.RenderBullet(dc, bulletPosition, lineHeight, node.RuleSet.FontColor); var rect = node.Rect; rect.Offset(lineHeight, 0); dc.DrawGlyphRun(node.RuleSet, text, rect.TopLeft); } }
/// <summary> /// Create an auto-layout bullet mark. /// </summary> public static void Bullet(string str_id) { Window window = GetCurrentWindow(); if (window.SkipItems) { return; } //get or create the root node int id = window.GetID(str_id); var container = window.RenderTree.CurrentContainer; Node node = container.GetNodeById(id); if (node == null) { node = new Node(id, $"Bullet<{str_id}>"); node.UseBoxModel = true; node.RuleSet.Replace(GUISkin.Current[GUIControlName.Label]); var lineheight = node.RuleSet.GetLineHeight(); var size = new Size(lineheight, lineheight); node.AttachLayoutEntry(size); } container.AppendChild(node); node.ActiveSelf = true; // rect node.Rect = window.GetRect(id); // last item state window.TempData.LastItemState = node.State; using (var dc = node.RenderOpen()) { var bulletPosition = node.Rect.TopLeft + new Vector(node.Rect.Height * 0.5f, node.Rect.Height * 0.5f); var lineheight = node.RuleSet.GetLineHeight(); GUIAppearance.RenderBullet(dc, bulletPosition, lineheight, node.RuleSet.FontColor); } }