ktsu.ImGuiWidgets 1.0.15-pre.5

Prefix Reserved
This is a prerelease version of ktsu.ImGuiWidgets.
There is a newer version of this package available.
See the version list below for details.
dotnet add package ktsu.ImGuiWidgets --version 1.0.15-pre.5                
NuGet\Install-Package ktsu.ImGuiWidgets -Version 1.0.15-pre.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ktsu.ImGuiWidgets" Version="1.0.15-pre.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ktsu.ImGuiWidgets --version 1.0.15-pre.5                
#r "nuget: ktsu.ImGuiWidgets, 1.0.15-pre.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ktsu.ImGuiWidgets as a Cake Addin
#addin nuget:?package=ktsu.ImGuiWidgets&version=1.0.15-pre.5&prerelease

// Install ktsu.ImGuiWidgets as a Cake Tool
#tool nuget:?package=ktsu.ImGuiWidgets&version=1.0.15-pre.5&prerelease                

ktsu.ImGuiWidgets

ImGuiWidgets is a library of custom widgets using ImGui.NET. This library provides a variety of widgets and utilities to enhance your ImGui-based applications.

Features

  • Knobs: Ported to .NET from imgui-works/imgui-knobs-dial-gauge-meter
  • Resizable Layout Dividers: Draggable layout dividers for resizable layouts
  • Icons: Customizable icons with various alignment options and event delegates
  • Grid: Flexible grid layout for displaying items
  • Color Indicator: An indicator that displays a color when enabled
  • Image: An image widget with alignment options
  • Text: A text widget with alignment options
  • Tree: A tree widget for displaying hierarchical data
  • Scoped Id: A utility class for creating scoped IDs

Installation

To install ImGuiWidgets, you can add the library to your .NET project using the following command:

dotnet add package ktsu.ImGuiWidgets

Usage

To use ImGuiWidgets, you need to include the ktsu.ImGuiWidgets namespace in your code:

using ktsu.ImGuiWidgets;

Then, you can start using the widgets provided by ImGuiWidgets in your ImGui-based applications.

Examples

Here are some examples of using ImGuiWidgets:

Knobs

Knobs are useful for creating dial-like controls:

float value = 0.5f;
float minValue = 0.0f;

ImGuiWidgets.Knob("Knob", ref value, minValue);

Icons

Icons can be used to display images with various alignment options and event delegates:

float iconWidthEms = 7.5f;
float iconWidthPx = ImGuiApp.EmsToPx(iconWidthEms);

uint textureId = ImGuiApp.GetOrLoadTexture("icon.png");

ImGuiWidgets.Icon("Click Me", textureId, iconWidthPx, Color.White.Value, ImGuiWidgets.IconAlignment.Vertical, new ImGuiWidgets.IconDelegates()
{
	OnClick = () => MessageOK.Open("Click", "You clicked")
});

ImGui.SameLine();
ImGuiWidgets.Icon("Double Click Me", textureId, iconWidthPx, Color.White.Value, ImGuiWidgets.IconAlignment.Vertical, new ImGuiWidgets.IconDelegates()
{
	OnDoubleClick = () => MessageOK.Open("Double Click", "You clicked twice")
});

ImGui.SameLine();
ImGuiWidgets.Icon("Right Click Me", textureId, iconWidthPx, Color.White.Value, ImGuiWidgets.IconAlignment.Vertical, new ImGuiWidgets.IconDelegates()
{
	OnContextMenu = () =>
	{
		ImGui.MenuItem("Context Menu Item 1");
		ImGui.MenuItem("Context Menu Item 2");
		ImGui.MenuItem("Context Menu Item 3");
	},
});

Grid

The grid layout allows you to display items in a flexible grid:

float iconSizeEms = 7.5f;
float iconSizePx = ImGuiApp.EmsToPx(iconSizeEms);

uint textureId = ImGuiApp.GetOrLoadTexture("icon.png");

ImGuiWidgets.Grid(items, i => ImGuiWidgets.CalcIconSize(i, iconSizePx), (item, cellSize, itemSize) =>
{
	ImGuiWidgets.Icon(item, textureId, iconSizePx, Color.White.Value);
});

Color Indicator

The color indicator widget displays a color when enabled:

bool enabled = true;
Color color = Color.Red;

ImGuiWidgets.ColorIndicator("Color Indicator", enabled, color);

Image

The image widget allows you to display images with alignment options:

uint textureId = ImGuiApp.GetOrLoadTexture("image.png");

ImGuiWidgets.Image(textureId, new Vector2(100, 100));

Text

The text widget allows you to display text with alignment options:

ImGuiWidgets.Text("Hello, ImGuiWidgets!");
ImGuiWidgets.TextCentered("Hello, ImGuiWidgets!");
ImGuiWidgets.TextCenteredWithin("Hello, ImGuiWidgets!", new Vector2(100, 100));

Tree

The tree widget allows you to display hierarchical data:

using (var tree = new ImGuiWidgets.Tree())
{
	for (int i = 0; i < 5; i++)
	{
		using (tree.Child)
		{
			ImGui.Button($"Hello, Child {i}!");
			using (var subtree = new ImGuiWidgets.Tree())
			{
				using (subtree.Child)
				{
					ImGui.Button($"Hello, Grandchild!");
				}
			}
		}
	}
}

Scoped Id

The scoped ID utility class helps in creating scoped IDs for ImGui elements and ensuring they get popped appropriatley:

using (new ImGuiWidgets.ScopedId())
{
    ImGui.Button("Hello, Scoped ID!");
}

Contributing

Contributions are welcome! For feature requests, bug reports, or questions, please open an issue on the GitHub repository. If you would like to contribute code, please open a pull request with your changes.

Acknowledgements

ImGuiWidgets is inspired by the following projects:

License

ImGuiWidgets is licensed under the MIT License. See LICENSE for more information.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1-pre.1 16 1/8/2025
1.1.0 88 1/5/2025
1.0.15 104 12/27/2024
1.0.15-pre.9 52 1/4/2025
1.0.15-pre.8 45 1/3/2025
1.0.15-pre.7 48 1/3/2025
1.0.15-pre.6 48 1/3/2025
1.0.15-pre.5 52 1/1/2025
1.0.15-pre.4 64 12/31/2024
1.0.15-pre.3 45 12/29/2024
1.0.15-pre.2 39 12/28/2024
1.0.15-pre.1 45 12/27/2024
1.0.14-pre.1 41 12/27/2024
1.0.13 84 12/26/2024
1.0.12 86 12/26/2024
1.0.11 83 12/25/2024
1.0.10 86 12/24/2024
1.0.10-pre.1 40 12/27/2024
1.0.9 85 12/23/2024
1.0.8 71 12/23/2024
1.0.7 87 12/22/2024
1.0.6 74 12/22/2024
1.0.5 83 12/22/2024
1.0.4 84 12/22/2024
1.0.3 90 12/19/2024
1.0.2 90 12/19/2024
1.0.1 76 12/19/2024
1.0.0 81 12/19/2024
1.0.0-alpha.116 54 12/18/2024
1.0.0-alpha.115 144 12/17/2024
1.0.0-alpha.114 69 12/14/2024
1.0.0-alpha.113 62 12/13/2024
1.0.0-alpha.112 60 12/12/2024
1.0.0-alpha.111 70 12/11/2024
1.0.0-alpha.110 68 12/10/2024
1.0.0-alpha.109 75 12/7/2024
1.0.0-alpha.108 54 12/6/2024
1.0.0-alpha.107 76 12/5/2024
1.0.0-alpha.106 72 12/2/2024
1.0.0-alpha.105 43 12/2/2024
1.0.0-alpha.104 46 12/2/2024
1.0.0-alpha.103 47 12/2/2024
1.0.0-alpha.102 52 12/2/2024
1.0.0-alpha.101 44 12/2/2024
1.0.0-alpha.100 68 12/1/2024
1.0.0-alpha.99 53 12/1/2024
1.0.0-alpha.98 53 12/1/2024
1.0.0-alpha.97 47 11/30/2024
1.0.0-alpha.96 46 11/30/2024
1.0.0-alpha.95 62 11/29/2024
1.0.0-alpha.94 70 11/28/2024
1.0.0-alpha.93 66 11/26/2024
1.0.0-alpha.92 57 11/26/2024
1.0.0-alpha.91 71 11/23/2024
1.0.0-alpha.90 70 11/22/2024
1.0.0-alpha.89 65 11/21/2024
1.0.0-alpha.88 73 11/20/2024
1.0.0-alpha.87 52 11/19/2024
1.0.0-alpha.86 52 11/16/2024
1.0.0-alpha.85 50 11/15/2024
1.0.0-alpha.84 54 11/14/2024
1.0.0-alpha.83 59 11/13/2024
1.0.0-alpha.82 56 11/12/2024
1.0.0-alpha.81 68 11/9/2024
1.0.0-alpha.80 51 11/8/2024
1.0.0-alpha.79 53 11/7/2024
1.0.0-alpha.78 47 11/6/2024
1.0.0-alpha.77 66 11/5/2024
1.0.0-alpha.76 215 11/2/2024
1.0.0-alpha.75 49 11/1/2024
1.0.0-alpha.74 122 10/30/2024
1.0.0-alpha.73 60 10/26/2024
1.0.0-alpha.72 60 10/23/2024
1.0.0-alpha.71 54 10/22/2024
1.0.0-alpha.70 80 10/19/2024
1.0.0-alpha.69 77 10/18/2024
1.0.0-alpha.68 78 10/17/2024
1.0.0-alpha.67 57 10/16/2024
1.0.0-alpha.66 59 10/15/2024
1.0.0-alpha.65 62 10/12/2024
1.0.0-alpha.64 51 10/11/2024
1.0.0-alpha.63 59 10/10/2024
1.0.0-alpha.62 67 10/8/2024
1.0.0-alpha.61 64 10/5/2024
1.0.0-alpha.60 50 10/4/2024
1.0.0-alpha.59 180 9/30/2024
1.0.0-alpha.58 117 9/30/2024
1.0.0-alpha.57 69 9/30/2024
1.0.0-alpha.56 52 9/30/2024
1.0.0-alpha.55 57 9/30/2024
1.0.0-alpha.54 57 9/28/2024
1.0.0-alpha.53 50 9/27/2024
1.0.0-alpha.52 64 9/26/2024
1.0.0-alpha.51 66 9/25/2024
1.0.0-alpha.50 70 9/24/2024
1.0.0-alpha.49 66 9/23/2024
1.0.0-alpha.48 68 9/21/2024
1.0.0-alpha.47 62 9/19/2024
1.0.0-alpha.46 55 9/19/2024
1.0.0-alpha.45 47 9/19/2024
1.0.0-alpha.44 64 9/19/2024
1.0.0-alpha.43 108 9/18/2024
1.0.0-alpha.42 57 9/18/2024
1.0.0-alpha.41 58 9/18/2024
1.0.0-alpha.40 53 9/18/2024
1.0.0-alpha.39 72 9/18/2024
1.0.0-alpha.38 91 9/14/2024
1.0.0-alpha.37 66 9/14/2024

##