/// <summary> /// Adds an appropriately sized highlight box for the range of characters on the given line. /// Does not take into account text clipping or text offset. /// </summary> private void AddHighlightBox(int line, int startCh, int endCh) { if (text[line].Count > 0) { if (startCh < 0 || endCh < 0 || startCh >= text[line].Count || endCh >= text[line].Count) { throw new Exception($"Char out of range. Line: {line} StartCh: {startCh}, EndCh: {endCh}, Count: {text[line].Count}"); } IRichChar left = text[line][startCh], right = text[line][endCh]; var highlightBox = new HighlightBox { size = new Vector2() { X = right.Offset.X - left.Offset.X + (left.Size.X + right.Size.X) * .5f, Y = text[line].Size.Y }, offset = new Vector2() { X = (right.Offset.X + left.Offset.X) * .5f - 2f, Y = text[line].VerticalOffset - text[line].Size.Y * .5f } }; if (highlightBox.size.X > 1f) { highlightBox.size.X += 4f; } highlightList.Add(highlightBox); } }
public SelectionBoxBase(HudParentBase parent) : base(parent) { hudChain = new TChain() { AlignVertical = true, SizingMode = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.ClampMembersAlignAxis | HudChainSizingModes.ClampChainOffAxis, DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding, }; hudChain.Register(this); chainHidesDisabled = hudChain is ScrollBox <TContainer, TElement>; selectionBox = new HighlightBox() { Visible = false }; highlightBox = new HighlightBox() { Visible = false, CanDrawTab = false }; selectionBox.Register(hudChain, true); highlightBox.Register(hudChain, true); listInput = new ListInputElement <TContainer, TElement>(hudChain); HighlightColor = TerminalFormatting.Atomic; FocusColor = TerminalFormatting.Mint; Format = TerminalFormatting.ControlFormat; FocusTextColor = TerminalFormatting.Charcoal; Size = new Vector2(335f, 203f); HighlightPadding = new Vector2(8f, 0f); }
public PropertyListMenu(QuickActionMenu parent) : base(parent) { quickActionMenu = parent; header = new LabelBox() { Format = listHeaderFormat, Text = "Build Vision", AutoResize = false, Size = new Vector2(300f, 34f), Color = headerColor, }; listBody = new ScrollBox <PropertyListEntry, PropertyListEntryElement>(true) { MemberMinSize = new Vector2(300f, 0f), SizingMode = HudChainSizingModes.ClampChainOffAxis | HudChainSizingModes.FitChainAlignAxis, Padding = new Vector2(30f, 16f), Color = bodyColor, EnableScrolling = false, UseSmoothScrolling = false, MinVisibleCount = 10, Visible = false, }; listBody.ScrollBar.Padding = new Vector2(12f, 16f); listBody.ScrollBar.Width = 4f; peekBody = new LabelBox() { AutoResize = false, VertCenterText = false, Color = bodyColor, TextPadding = new Vector2(48f, 16f), BuilderMode = TextBuilderModes.Lined, }; var border = new BorderBox(listBody) { DimAlignment = DimAlignments.Both, Color = new Color(58, 68, 77), Thickness = 1f, }; highlightBox = new HighlightBox(listBody.Background) { Padding = new Vector2(16f, 0f) }; footer = new DoubleLabelBox() { AutoResize = false, TextPadding = new Vector2(48f, 0f), Size = new Vector2(300f, 24f), Color = headerColor, }; layout = new HudChain(true, this) { MemberMinSize = new Vector2(300f, 0f), SizingMode = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth, CollectionContainer = { header, { listBody,true }, { peekBody,true }, footer } }; debugText = new Label(layout) { ParentAlignment = ParentAlignments.Right, BuilderMode = TextBuilderModes.Lined }; peekBuilder = new RichText(); entryPool = new ObjectPool <PropertyListEntry>(() => new PropertyListEntry(), x => x.Reset()); notificationTimer = new Stopwatch(); listWrapTimer = new Stopwatch(); }