public static bool BuildContextMenuButton(this ImGui gui, string text, string rightText = null) { using (gui.EnterGroup(DefaultButtonPadding, RectAllocator.LeftRow, SchemeColor.BackgroundText)) { gui.BuildText(text, Font.text, wrap: true); if (rightText != null) { gui.allocator = RectAllocator.RightRow; gui.BuildText(rightText, align: RectAlignment.MiddleRight); } } return(gui.BuildButton(gui.lastRect, SchemeColor.None, SchemeColor.Grey) == Event.Click); }
public static bool BuildLink(this ImGui gui, string text) { gui.BuildText(text, color: SchemeColor.Link); var rect = gui.lastRect; switch (gui.action) { case ImGuiAction.MouseMove: gui.ConsumeMouseOver(rect, RenderingUtils.cursorHand); break; case ImGuiAction.MouseDown: if (gui.actionParameter == SDL.SDL_BUTTON_LEFT) { gui.ConsumeMouseDown(rect); } break; case ImGuiAction.MouseUp: if (gui.ConsumeMouseUp(rect)) { return(true); } break; case ImGuiAction.Build: if (gui.IsMouseOver(rect)) { gui.DrawRectangle(new Rect(rect.X, rect.Bottom - 0.2f, rect.Width, 0.1f), SchemeColor.Link); } break; } return(false); }
public static bool BuildRadioButton(this ImGui gui, string option, bool selected, SchemeColor color = SchemeColor.None) { using (gui.EnterRow()) { gui.BuildIcon(selected ? Icon.RadioCheck : Icon.RadioEmpty, 1.5f, color); gui.BuildText(option, Font.text, color: color, wrap: true); } return(!selected && gui.OnClick(gui.lastRect)); }
public static bool BuildButton(this ImGui gui, string text, SchemeColor color = SchemeColor.Primary, Padding?padding = null, bool active = true) { if (!active) { color = SchemeColor.Grey; } using (gui.EnterGroup(padding ?? DefaultButtonPadding, active ? color + 2 : color + 3)) gui.BuildText(text, Font.text, align: RectAlignment.Middle); return(gui.BuildButton(gui.lastRect, color, color + 1) == Event.Click && active); }
public void BuildHeader(ImGui gui) { var spacing = innerPadding.left + innerPadding.right; var x = 0f; var topSeparator = gui.AllocateRect(0f, 0.1f); var y = gui.statePosition.Y; using (var group = gui.EnterFixedPositioning(0f, 1f, innerPadding)) { foreach (var column in columns) { if (column.width < column.minWidth) { column.width = column.minWidth; } var rect = new Rect(x, y, column.width, 0f); group.SetManualRectRaw(rect, RectAllocator.LeftRow); gui.BuildText(column.header); rect.Bottom = gui.statePosition.Y; x += column.width + spacing; if (!column.isFixedSize) { BuildHeaderResizer(gui, column, new Rect(x - 0.7f, y, 1f, 2.2f)); } if (column.menuBuilder != null) { var menuRect = new Rect(rect.Right - 1.7f, rect.Y + 0.3f, 1.5f, 1.5f); if (gui.isBuilding) { gui.DrawIcon(menuRect, Icon.DropDown, SchemeColor.BackgroundText); } if (gui.BuildButton(menuRect, SchemeColor.None, SchemeColor.Grey) == ImGuiUtils.Event.Click) { gui.ShowDropDown(menuRect, column.menuBuilder, new Padding(1f)); } } } } width = x + 0.2f - spacing; var separator = gui.AllocateRect(x, 0.1f); if (gui.isBuilding) { topSeparator.Width = separator.Width = width; gui.DrawRectangle(topSeparator, SchemeColor.GreyAlt); gui.DrawRectangle(separator, SchemeColor.GreyAlt); //DrawVerticalGrid(gui, topSeparator.Bottom, separator.Top, SchemeColor.GreyAlt); } }
protected override void BuildContents(ImGui gui) { gui.BuildText(ex.GetType().Name, Font.header); gui.BuildText(ex.Message, Font.subheader, true); gui.BuildText(ex.StackTrace, Font.text, true); using (gui.EnterRow(0.5f, RectAllocator.RightRow)) { if (gui.BuildButton("Close")) { Close(); } if (gui.BuildButton("Ignore future errors", SchemeColor.Grey)) { ignoreAll = true; Close(); } if (gui.BuildButton("Copy to clipboard", SchemeColor.Grey)) { SDL.SDL_SetClipboardText(ex.Message + "\n\n" + ex.StackTrace); } } }
public static bool BuildCheckBox(this ImGui gui, string text, bool value, out bool newValue, SchemeColor color = SchemeColor.None) { using (gui.EnterRow()) { gui.BuildIcon(value ? Icon.CheckBoxCheck : Icon.CheckBoxEmpty, 1.5f, color); gui.BuildText(text, Font.text, color: color); } if (gui.OnClick(gui.lastRect)) { newValue = !value; return(true); } newValue = value; return(false); }