Class ImGuiHelpers
Class containing various helper methods for use with ImGui inside Dalamud.
Assembly: Dalamud.dll
View Source
public static class ImGuiHelpers
Properties
MainViewport
Gets the main viewport.
View Source
public static ImGuiViewportPtr MainViewport { get; }
GlobalScale
Gets the global Dalamud scale.
View Source
public static float GlobalScale { get; }
IsImGuiInitialized
Gets a value indicating whether ImGui is initialized and ready for use.
This does not necessarily mean you can call drawing functions.
View Source
public static bool IsImGuiInitialized { get; }
GlobalScaleSafe
Gets the global Dalamud scale; even available before drawing is ready.
If you are sure that drawing is ready, at the point of using this, use Dalamud.Interface.Utility.ImGuiHelpers.GlobalScale instead.
View Source
public static float GlobalScaleSafe { get; }
Methods
CheckIsWindowOnMainViewport()
Check if the current ImGui window is on the main viewport. Only valid within a window.
View Source
public static bool CheckIsWindowOnMainViewport()
Returns
System.Boolean
: Whether the window is on the main viewport.### ScaledVector2(float)
Gets a System.Numerics.Vector2
that is pre-scaled with the Dalamud.Interface.Utility.ImGuiHelpers.GlobalScale multiplier.
View Source
public static Vector2 ScaledVector2(float x)
Returns
System.Numerics.Vector2
: A scaled Vector2.
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | Vector2 X/Y parameter. |
ScaledVector2(float, float)
Gets a System.Numerics.Vector2
that is pre-scaled with the Dalamud.Interface.Utility.ImGuiHelpers.GlobalScale multiplier.
View Source
public static Vector2 ScaledVector2(float x, float y)
Returns
System.Numerics.Vector2
: A scaled Vector2.
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | Vector2 X parameter. |
System.Single | y | Vector2 Y parameter. |
ScaledVector4(float, float, float, float)
Gets a System.Numerics.Vector4
that is pre-scaled with the Dalamud.Interface.Utility.ImGuiHelpers.GlobalScale multiplier.
View Source
public static Vector4 ScaledVector4(float x, float y, float z, float w)
Returns
System.Numerics.Vector4
: A scaled Vector2.
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | Vector4 X parameter. |
System.Single | y | Vector4 Y parameter. |
System.Single | z | Vector4 Z parameter. |
System.Single | w | Vector4 W parameter. |
ForceNextWindowMainViewport()
Force the next ImGui window to stay inside the main game window.
View Source
public static void ForceNextWindowMainViewport()
ScaledDummy(float)
Create a dummy scaled by the global Dalamud scale.
View Source
public static void ScaledDummy(float size)
Parameters
Type | Name | Description |
---|---|---|
System.Single | size | The size of the dummy. |
ScaledDummy(float, float)
Create a dummy scaled by the global Dalamud scale.
View Source
public static void ScaledDummy(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | Vector2 X parameter. |
System.Single | y | Vector2 Y parameter. |
ScaledDummy(Vector2)
Create a dummy scaled by the global Dalamud scale.
View Source
public static void ScaledDummy(Vector2 size)
Parameters
Type | Name | Description |
---|---|---|
System.Numerics.Vector2 | size | The size of the dummy. |
ScaledIndent(float)
Create an indent scaled by the global Dalamud scale.
View Source
public static void ScaledIndent(float size)
Parameters
Type | Name | Description |
---|---|---|
System.Single | size | The size of the indent. |
ScaledRelativeSameLine(float, float)
Use a relative ImGui.SameLine() from your current cursor position, scaled by the Dalamud global scale.
View Source
public static void ScaledRelativeSameLine(float offset, float spacing = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Single | offset | The offset from your current cursor position. |
System.Single | spacing | The spacing to use. |
SetNextWindowPosRelativeMainViewport(Vector2, ImGuiCond, Vector2)
Set the position of the next window relative to the main viewport.
View Source
public static void SetNextWindowPosRelativeMainViewport(Vector2 position, ImGuiCond condition = ImGuiCond.None, Vector2 pivot = default)
Parameters
Type | Name | Description |
---|---|---|
System.Numerics.Vector2 | position | The position of the next window. |
ImGuiNET.ImGuiCond | condition | When to set the position. |
System.Numerics.Vector2 | pivot | The pivot to set the position around. |
SetWindowPosRelativeMainViewport(string, Vector2, ImGuiCond)
Set the position of a window relative to the main viewport.
View Source
public static void SetWindowPosRelativeMainViewport(string name, Vector2 position, ImGuiCond condition = ImGuiCond.None)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name/ID of the window. |
System.Numerics.Vector2 | position | The position of the window. |
ImGuiNET.ImGuiCond | condition | When to set the position. |
DefaultColorPalette(int)
Creates default color palette for use with color pickers.
View Source
public static List<Vector4> DefaultColorPalette(int swatchCount = 32)
Returns
System.Collections.Generic.List<System.Numerics.Vector4>
: Default color palette.
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | swatchCount | The total number of swatches to use. |
GetButtonSize(string)
Get the size of a button considering the default frame padding.
View Source
public static Vector2 GetButtonSize(string text)
Returns
System.Numerics.Vector2
: System.Numerics.Vector2
with the size of the button.
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Text in the button. |
ClickToCopyText(string, string?)
Print out text that can be copied when clicked.
View Source
public static void ClickToCopyText(string text, string? textCopy = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to show. |
System.String | textCopy | The text to copy when clicked. |
SeStringWrapped(ReadOnlySpan<byte>, scoped in SeStringDrawParams, ImGuiId, ImGuiButtonFlags)
Draws a SeString.
View Source
public static SeStringDrawResult SeStringWrapped(ReadOnlySpan<byte> sss, scoped in SeStringDrawParams style = default, ImGuiId imGuiId = default, ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault)
Returns
Dalamud.Interface.ImGuiSeStringRenderer.SeStringDrawResult: Interaction result of the rendered text.
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Byte> | sss | SeString to draw. |
Dalamud.Interface.ImGuiSeStringRenderer.SeStringDrawParams | style | Initial rendering style. |
Dalamud.Interface.Utility.ImGuiId | imGuiId | ImGui ID, if link functionality is desired. |
ImGuiNET.ImGuiButtonFlags | buttonFlags | Button flags to use on link interaction. |
CompileSeStringWrapped(string, scoped in SeStringDrawParams, ImGuiId, ImGuiButtonFlags)
Creates and caches a SeString from a text macro representation, and then draws it.
View Source
public static SeStringDrawResult CompileSeStringWrapped(string text, scoped in SeStringDrawParams style = default, ImGuiId imGuiId = default, ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault)
Returns
Dalamud.Interface.ImGuiSeStringRenderer.SeStringDrawResult: Interaction result of the rendered text.
Parameters
Type | Name | Description |
---|---|---|
System.String | text | SeString text macro representation. |
Newline characters will be normalized to [Dalamud.Game.Text.SeStringHandling.Payloads.NewLinePayload](../../Dalamud.Game.Text.SeStringHandling.Payloads/Classes/NewLinePayload). |
| Dalamud.Interface.ImGuiSeStringRenderer.SeStringDrawParams | style | Initial rendering style. | | Dalamud.Interface.Utility.ImGuiId | imGuiId | ImGui ID, if link functionality is desired. | | ImGuiNET.ImGuiButtonFlags | buttonFlags | Button flags to use on link interaction. |
SafeTextWrapped(string)
Write unformatted text wrapped.
View Source
public static void SafeTextWrapped(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to write. |
SafeTextColoredWrapped(Vector4, string)
Write unformatted text wrapped.
View Source
public static void SafeTextColoredWrapped(Vector4 color, string text)
Parameters
Type | Name | Description |
---|---|---|
System.Numerics.Vector4 | color | The color of the text. |
System.String | text | The text to write. |
AdjustGlyphMetrics(ImFontPtr, float, float)
Unscales fonts after they have been rendered onto atlas.
View Source
public static void AdjustGlyphMetrics(this ImFontPtr fontPtr, float scale, float round = 0)
Parameters
Type | Name | Description |
---|---|---|
ImGuiNET.ImFontPtr | fontPtr | Font to scale. |
System.Single | scale | Scale. |
System.Single | round | If a positive number is given, numbers will be rounded to this. |
CopyGlyphsAcrossFonts(ImFontPtr?, ImFontPtr?, bool, bool, int, int)
Fills missing glyphs in target font from source font, if both are not null.
View Source
[Obsolete("Use the non-nullable variant.", true)]
public static void CopyGlyphsAcrossFonts(ImFontPtr? source, ImFontPtr? target, bool missingOnly, bool rebuildLookupTable = true, int rangeLow = 32, int rangeHigh = 65534)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<ImGuiNET.ImFontPtr> | source | Source font. |
System.Nullable<ImGuiNET.ImFontPtr> | target | Target font. |
System.Boolean | missingOnly | Whether to copy missing glyphs only. |
System.Boolean | rebuildLookupTable | Whether to call target.BuildLookupTable(). |
System.Int32 | rangeLow | Low codepoint range to copy. |
System.Int32 | rangeHigh | High codepoing range to copy. |
CopyGlyphsAcrossFonts(ImFontPtr, ImFontPtr, bool, bool, int, int)
Fills missing glyphs in target font from source font, if both are not null.
View Source
public static void CopyGlyphsAcrossFonts(ImFontPtr source, ImFontPtr target, bool missingOnly, bool rebuildLookupTable = true, int rangeLow = 32, int rangeHigh = 65534)
Parameters
Type | Name | Description |
---|---|---|
ImGuiNET.ImFontPtr | source | Source font. |
ImGuiNET.ImFontPtr | target | Target font. |
System.Boolean | missingOnly | Whether to copy missing glyphs only. |
System.Boolean | rebuildLookupTable | Whether to call target.BuildLookupTable(). |
System.Int32 | rangeLow | Low codepoint range to copy. |
System.Int32 | rangeHigh | High codepoing range to copy. |
VirtualKeyToImGuiKey(VirtualKey)
Map a VirtualKey keycode to an ImGuiKey enum value.
View Source
public static ImGuiKey VirtualKeyToImGuiKey(VirtualKey key)
Returns
ImGuiNET.ImGuiKey: The ImGuiKey that corresponds to this VirtualKey, or ImGuiKey.None
otherwise.
Parameters
Type | Name | Description |
---|---|---|
Dalamud.Game.ClientState.Keys.VirtualKey | key | The VirtualKey value to retrieve the ImGuiKey counterpart for. |
ImGuiKeyToVirtualKey(ImGuiKey)
Map an ImGuiKey enum value to a VirtualKey code.
View Source
public static VirtualKey ImGuiKeyToVirtualKey(ImGuiKey key)
Returns
Dalamud.Game.ClientState.Keys.VirtualKey: The VirtualKey that corresponds to this ImGuiKey, or VirtualKey.NO_KEY
otherwise.
Parameters
Type | Name | Description |
---|---|---|
ImGuiNET.ImGuiKey | key | The ImGuiKey value to retrieve the VirtualKey counterpart for. |
CenteredText(string)
Show centered text.
View Source
public static void CenteredText(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Text to show. |
CenterCursorForText(string)
Center the ImGui cursor for a certain text.
View Source
public static void CenterCursorForText(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to center for. |
CenterCursorFor(float)
Center the ImGui cursor for an item with a certain width.
View Source
public static void CenterCursorFor(float itemWidth)
Parameters
Type | Name | Description |
---|---|---|
System.Single | itemWidth | The width to center for. |
AllocateMemory(int)
Allocates memory on the heap using ImGuiNET.ImGuiNative.igMemAlloc(uint)
Memory must be freed using ImGuiNET.ImGuiNative.igMemFree(void*).
Note that null is a valid return value when <code class="paramref">length</code> is 0.
View Source
public static void* AllocateMemory(int length)
Returns
System.Void*
: The allocated memory.
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | length | The length of allocated memory. |
Exceptions
System.OutOfMemoryException
If ImGuiNET.ImGuiNative.igMemAlloc(uint) returns null.
NewFontGlyphRangeBuilderPtrScoped(out ImFontGlyphRangesBuilderPtr)
Creates a new instance of ImGuiNET.ImFontGlyphRangesBuilderPtr with a natively backed memory.
View Source
public static IDisposable NewFontGlyphRangeBuilderPtrScoped(out ImFontGlyphRangesBuilderPtr builder)
Returns
System.IDisposable
: Disposable you can call.
Parameters
Type | Name | Description |
---|---|---|
ImGuiNET.ImFontGlyphRangesBuilderPtr | builder | The created instance. |
BuildRangesToArray(ImFontGlyphRangesBuilderPtr, bool, bool)
Builds ImGui Glyph Ranges for use with Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.GlyphRanges.
View Source
public static ushort[] BuildRangesToArray(this ImFontGlyphRangesBuilderPtr builder, bool addFallbackCodepoints = true, bool addEllipsisCodepoints = true)
Returns
System.UInt16[]
: When disposed, the resource allocated for the range will be freed.
Parameters
Type | Name | Description |
---|---|---|
ImGuiNET.ImFontGlyphRangesBuilderPtr | builder | The builder. |
System.Boolean | addFallbackCodepoints | Add fallback codepoints to the range. |
System.Boolean | addEllipsisCodepoints | Add ellipsis codepoints to the range. |
CreateImGuiRangesFrom(params UnicodeRange[])
Creates glyph ranges from System.Text.Unicode.UnicodeRange
.
Use values from System.Text.Unicode.UnicodeRanges
.
View Source
public static ushort[] CreateImGuiRangesFrom(params UnicodeRange[] ranges)
Returns
System.UInt16[]
: The range array that can be used for Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.GlyphRanges.
Parameters
Type | Name | Description |
---|---|---|
System.Text.Unicode.UnicodeRange[] | ranges | The unicode ranges. |
CreateImGuiRangesFrom(IEnumerable<UnicodeRange>)
Creates glyph ranges from System.Text.Unicode.UnicodeRange
.
Use values from System.Text.Unicode.UnicodeRanges
.
View Source
public static ushort[] CreateImGuiRangesFrom(IEnumerable<UnicodeRange> ranges)
Returns
System.UInt16[]
: The range array that can be used for Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.GlyphRanges.
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Text.Unicode.UnicodeRange> | ranges | The unicode ranges. |
IsNull(ImFontPtr)
Determines whether <code class="paramref">ptr</code> is empty.
View Source
public static bool IsNull(this ImFontPtr ptr)
Returns
System.Boolean
: Whether it is empty.
Parameters
Type | Name | Description |
---|---|---|
ImGuiNET.ImFontPtr | ptr | The pointer. |
IsNotNullAndLoaded(ImFontPtr)
Determines whether <code class="paramref">ptr</code> is empty.
View Source
public static bool IsNotNullAndLoaded(this ImFontPtr ptr)
Returns
System.Boolean
: Whether it is empty.
Parameters
Type | Name | Description |
---|---|---|
ImGuiNET.ImFontPtr | ptr | The pointer. |
IsNull(ImFontAtlasPtr)
Determines whether <code class="paramref">ptr</code> is empty.
View Source
public static bool IsNull(this ImFontAtlasPtr ptr)
Returns
System.Boolean
: Whether it is empty.
Parameters
Type | Name | Description |
---|---|---|
ImGuiNET.ImFontAtlasPtr | ptr | The pointer. |
OrElse(ImFontPtr, ImFontPtr)
If <code class="paramref">self</code> is default, then returns <code class="paramref">other</code>.
View Source
public static ImFontPtr OrElse(this ImFontPtr self, ImFontPtr other)
Returns
ImGuiNET.ImFontPtr: <code class="paramref">self</code> if it is not default; otherwise, <code class="paramref">other</code>.
Parameters
Type | Name | Description |
---|---|---|
ImGuiNET.ImFontPtr | self | The self. |
ImGuiNET.ImFontPtr | other | The other. |