diff --git a/deps/cimgui/win7-x64/cimgui.dll b/deps/cimgui/win7-x64/cimgui.dll index a8e39e0..8fb8a83 100644 Binary files a/deps/cimgui/win7-x64/cimgui.dll and b/deps/cimgui/win7-x64/cimgui.dll differ diff --git a/src/ImGui.NET/Font.cs b/src/ImGui.NET/Font.cs index 5f19f76..5313abe 100644 --- a/src/ImGui.NET/Font.cs +++ b/src/ImGui.NET/Font.cs @@ -21,8 +21,16 @@ namespace ImGuiNET [StructLayout(LayoutKind.Sequential)] public unsafe struct NativeFont { - // Members: Settings + [StructLayout(LayoutKind.Sequential)] + public struct Glyph + { + public ushort Codepoint; + public float XAdvance; + public float X0, Y0, X1, Y1; + public float U0, V0, U1, V1; // Texture coordinates + }; + // Members: Hot ~62/78 bytes /// /// Height of characters, set during loading (don't change after loading). /// Default value: [user-set] @@ -39,55 +47,49 @@ namespace ImGuiNET /// public Vector2 DisplayOffset; /// - /// Replacement glyph if one isn't found. Only set via SetFallbackChar() - /// Default value: '?' + /// ImVector(Glyph) /// - public ushort FallbackChar; + public ImVector Glyphs; /// - /// ImFontConfig*. Pointer within ImFontAtlas->ConfigData + /// Sparse. Glyphs->XAdvance directly indexable (more cache-friendly that reading from Glyphs, + /// for CalcTextSize functions which are often bottleneck in large UI). /// - public IntPtr ConfigData; - public int ConfigDataCount; - - // Members: Runtime data - [StructLayout(LayoutKind.Sequential)] - public struct Glyph - { - public ushort Codepoint; - public float XAdvance; - public float X0, Y0, X1, Y1; - public float U0, V0, U1, V1; // Texture coordinates - }; + public ImVector IndexXAdvance; /// - /// Ascent: distance from top to bottom of e.g. 'A' [0..FontSize] + /// Sparse. Index glyphs by Unicode code-point. /// - public float Ascent, Descent; + public ImVector IndexLookup; /// - /// ImFontAtlas* + /// Equivalent to FindGlyph(FontFallbackChar) /// - public IntPtr ContainerAtlas; // What we has been loaded into + public Glyph* FallbackGlyph; + public float FallbackXAdvance; /// - /// ImVector(Glyph) + /// Replacement glyph if one isn't found. Only set via SetFallbackChar() + /// Default value: '?' /// - public ImVector Glyphs; + public ushort FallbackChar; + + // Members: Cold ~18/26 bytes + public int ConfigDataCount; + /// - /// Equivalent to FindGlyph(FontFallbackChar) + /// ImFontConfig*. Pointer within ImFontAtlas->ConfigData /// - public Glyph* FallbackGlyph; - public float FallbackXAdvance; + public IntPtr ConfigData; /// - /// Sparse. Glyphs->XAdvance directly indexable (more cache-friendly that reading from Glyphs, - /// for CalcTextSize functions which are often bottleneck in large UI). + /// ImFontAtlas* /// - public ImVector IndexXAdvance; + public IntPtr ContainerAtlas; // What we has been loaded into + /// - /// Sparse. Index glyphs by Unicode code-point. + /// Ascent: distance from top to bottom of e.g. 'A' [0..FontSize] /// - public ImVector IndexLookup; + public float Ascent, Descent; }; } diff --git a/src/ImGui.NET/ImGui.NET.Net46.csproj b/src/ImGui.NET/ImGui.NET.Net46.csproj index 9fcb15d..b3d3970 100644 --- a/src/ImGui.NET/ImGui.NET.Net46.csproj +++ b/src/ImGui.NET/ImGui.NET.Net46.csproj @@ -15,6 +15,7 @@ + diff --git a/src/ImGui.NET/ImGui.NET.csproj b/src/ImGui.NET/ImGui.NET.csproj index e8c992e..288d36e 100644 --- a/src/ImGui.NET/ImGui.NET.csproj +++ b/src/ImGui.NET/ImGui.NET.csproj @@ -13,6 +13,7 @@ + diff --git a/src/ImGui.NET/ImGui.cs b/src/ImGui.NET/ImGui.cs index 894cf32..0e24902 100644 --- a/src/ImGui.NET/ImGui.cs +++ b/src/ImGui.NET/ImGui.cs @@ -140,9 +140,16 @@ namespace ImGuiNET return ImGuiNative.igImageButton(userTextureID, size, uv0, uv1, framePadding, backgroundColor, tintColor); } + //obsolete! public static bool CollapsingHeader(string label, string id, bool displayFrame, bool defaultOpen) { - return ImGuiNative.igCollapsingHeader(label, id, displayFrame, defaultOpen); + TreeNodeFlags default_open_flags = TreeNodeFlags.DefaultOpen; + return ImGuiNative.igCollapsingHeader(label, (defaultOpen ? default_open_flags : 0)); + } + + public static bool CollapsingHeader(string label, TreeNodeFlags flags) + { + return ImGuiNative.igCollapsingHeader(label, flags); } public static bool Checkbox(string label, ref bool value) diff --git a/src/ImGui.NET/ImGuiNative.cs b/src/ImGui.NET/ImGuiNative.cs index 8f33416..0552238 100644 --- a/src/ImGui.NET/ImGuiNative.cs +++ b/src/ImGui.NET/ImGuiNative.cs @@ -71,10 +71,6 @@ namespace ImGuiNET [DllImport(cimguiLib)] public static extern DrawList* igGetWindowDrawList(); [DllImport(cimguiLib)] - public static extern NativeFont* igGetWindowFont(); - [DllImport(cimguiLib)] - public static extern float igGetWindowFontSize(); - [DllImport(cimguiLib)] public static extern void igSetWindowFontScale(float scale); [DllImport(cimguiLib)] public static extern void igGetWindowPos(out Vector2 @out); @@ -102,14 +98,14 @@ namespace ImGuiNET public static extern void igSetNextWindowCollapsed(bool collapsed, SetCondition cond); [DllImport(cimguiLib)] public static extern void igSetNextWindowFocus(); + [DllImport(cimguiLib)] + public static extern void igSetWindowPos(Vector2 pos, SetCondition cond); //(not recommended) [DllImport(cimguiLib)] - public static extern void igSetWindowPos(Vector2 pos, SetCondition cond); + public static extern void igSetWindowSize(Vector2 size, SetCondition cond); //(not recommended) [DllImport(cimguiLib)] - public static extern void igSetWindowSize(Vector2 size, SetCondition cond); + public static extern void igSetWindowCollapsed(bool collapsed, SetCondition cond); //(not recommended) [DllImport(cimguiLib)] - public static extern void igSetWindowCollapsed(bool collapsed, SetCondition cond); - [DllImport(cimguiLib)] - public static extern void igSetWindowFocus(); + public static extern void igSetWindowFocus(); //(not recommended) [DllImport(cimguiLib)] public static extern void igSetWindowPosByName(string name, Vector2 pos, SetCondition cond); [DllImport(cimguiLib)] @@ -160,6 +156,10 @@ namespace ImGuiNET public static extern void igPushStyleVarVec(StyleVar idx, Vector2 val); [DllImport(cimguiLib)] public static extern void igPopStyleVar(int count); + [DllImport(cimguiLib)] + public static extern NativeFont* igGetFont(); + [DllImport(cimguiLib)] + public static extern float igGetFontSize(); // Parameters stacks (current window) [DllImport(cimguiLib)] @@ -183,10 +183,6 @@ namespace ImGuiNET // Layout [DllImport(cimguiLib)] - public static extern void igBeginGroup(); - [DllImport(cimguiLib)] - public static extern void igEndGroup(); - [DllImport(cimguiLib)] public static extern void igSeparator(); [DllImport(cimguiLib)] public static extern void igSameLine(float local_pos_x, float spacing_w); @@ -195,23 +191,13 @@ namespace ImGuiNET [DllImport(cimguiLib)] public static extern void igDummy(Vector2* size); [DllImport(cimguiLib)] - public static extern void igIndent(); + public static extern void igIndent(float indent_w = 0.0f); [DllImport(cimguiLib)] - public static extern void igUnindent(); - [DllImport(cimguiLib)] - public static extern void igColumns(int count, string id, bool border); + public static extern void igUnindent(float indent_w = 0.0f); [DllImport(cimguiLib)] - public static extern void igNextColumn(); - [DllImport(cimguiLib)] - public static extern int igGetColumnIndex(); - [DllImport(cimguiLib)] - public static extern float igGetColumnOffset(int column_index); - [DllImport(cimguiLib)] - public static extern void igSetColumnOffset(int column_index, float offset_x); - [DllImport(cimguiLib)] - public static extern float igGetColumnWidth(int column_index); + public static extern void igBeginGroup(); [DllImport(cimguiLib)] - public static extern int igGetColumnsCount(); + public static extern void igEndGroup(); [DllImport(cimguiLib)] public static extern void igGetCursorPos(Vector2* pOut); [DllImport(cimguiLib)] @@ -239,6 +225,23 @@ namespace ImGuiNET [DllImport(cimguiLib)] public static extern float igGetItemsLineHeightWithSpacing(); + // Columns + [DllImport(cimguiLib)] + public static extern void igColumns(int count, string id, bool border); + [DllImport(cimguiLib)] + public static extern void igNextColumn(); + [DllImport(cimguiLib)] + public static extern int igGetColumnIndex(); + [DllImport(cimguiLib)] + public static extern float igGetColumnOffset(int column_index); + [DllImport(cimguiLib)] + public static extern void igSetColumnOffset(int column_index, float offset_x); + [DllImport(cimguiLib)] + public static extern float igGetColumnWidth(int column_index); + [DllImport(cimguiLib)] + public static extern int igGetColumnsCount(); + + // ID scopes // If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them // You can also use "##extra" within your widget name to distinguish them from each others (see 'Programmer Guide') @@ -298,9 +301,6 @@ namespace ImGuiNET public static extern bool igImageButton(IntPtr user_texture_id, Vector2 size, Vector2 uv0, Vector2 uv1, int frame_padding, Vector4 bg_col, Vector4 tint_col); [DllImport(cimguiLib)] [return: MarshalAs(UnmanagedType.I1)] - public static extern bool igCollapsingHeader(string label, string str_id, bool display_frame, bool default_open); - [DllImport(cimguiLib)] - [return: MarshalAs(UnmanagedType.I1)] public static extern bool igCheckbox(string label, ref bool v); [DllImport(cimguiLib)] [return: MarshalAs(UnmanagedType.I1)] @@ -471,6 +471,12 @@ namespace ImGuiNET public static extern void igTreePop(); [DllImport(cimguiLib)] public static extern void igSetNextTreeNodeOpened(bool opened, SetCondition cond); + [DllImport(cimguiLib)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool igCollapsingHeader(string label, TreeNodeFlags flags = 0); + [DllImport(cimguiLib)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool igCollapsingHeader(string label, ref bool p_open, TreeNodeFlags flags = 0); // Widgets: Selectable / Lists [DllImport(cimguiLib)] @@ -645,12 +651,6 @@ namespace ImGuiNET public static extern float igGetTime(); [DllImport(cimguiLib)] public static extern int igGetFrameCount(); - - internal static void igPushFont(object nativeFont) - { - throw new NotImplementedException(); - } - [DllImport(cimguiLib)] public static extern string igGetStyleColName(ColorTarget idx); [DllImport(cimguiLib)] @@ -738,12 +738,12 @@ namespace ImGuiNET // public state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself [DllImport(cimguiLib)] public static extern string igGetVersion(); - [DllImport(cimguiLib)] - public static extern void* igGetpublicState(); - [DllImport(cimguiLib)] - public static extern uint igGetpublicStateSize(); - [DllImport(cimguiLib)] - public static extern void igSetpublicState(void* state, bool construct); + /* + CIMGUI_API struct ImGuiContext* igCreateContext(void* (*malloc_fn)(size_t), void (*free_fn)(void*)); + CIMGUI_API void igDestroyContext(struct ImGuiContext* ctx); + CIMGUI_API struct ImGuiContext* igGetCurrentContext(); + CIMGUI_API void igSetCurrentContext(struct ImGuiContext* ctx); + */ [DllImport(cimguiLib)] diff --git a/src/ImGui.NET/NativeIO.cs b/src/ImGui.NET/NativeIO.cs index 28ff962..63b34b7 100644 --- a/src/ImGui.NET/NativeIO.cs +++ b/src/ImGui.NET/NativeIO.cs @@ -105,6 +105,12 @@ namespace ImGuiNET /// public Vector2 DisplayVisibleMax; // (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize + public byte WordMovementUsesAltKey; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl + public byte ShortcutsUseSuperKey; // = defined(__APPLE__) // OS X style: Shortcuts using Cmd/Super instead of Ctrl + public byte DoubleClickSelectsWord; // = defined(__APPLE__) // OS X style: Double click selects by word instead of selecting whole text + public byte MultiSelectUsesSuperKey; // = defined(__APPLE__) // OS X style: Multi-selection in lists uses Cmd/Super instead of Ctrl [unused yet] + + //------------------------------------------------------------------ // User Functions //------------------------------------------------------------------ @@ -181,6 +187,7 @@ namespace ImGuiNET /// Keyboard modifier pressed: Alt /// public byte KeyAlt; + public byte KeySuper; /// /// Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data) /// diff --git a/src/ImGui.NET/NativeStyle.cs b/src/ImGui.NET/NativeStyle.cs index 112b122..63a85c6 100644 --- a/src/ImGui.NET/NativeStyle.cs +++ b/src/ImGui.NET/NativeStyle.cs @@ -51,10 +51,6 @@ namespace ImGuiNET /// public Vector2 TouchExtraPadding; /// - /// Default alpha of window background, if not specified in ImGui::Begin(). - /// - public float WindowFillAlphaDefault; - /// /// Horizontal indentation when e.g. entering a tree node /// public float IndentSpacing; diff --git a/src/ImGui.NET/Style.cs b/src/ImGui.NET/Style.cs index d0ebfa7..142f6a2 100644 --- a/src/ImGui.NET/Style.cs +++ b/src/ImGui.NET/Style.cs @@ -110,15 +110,6 @@ namespace ImGuiNET set { _stylePtr->TouchExtraPadding = value; } } - /// - /// Default alpha of window background, if not specified in ImGui::Begin(). - /// - public float WindowFillAlphaDefault - { - get { return _stylePtr->WindowFillAlphaDefault; } - set { _stylePtr->WindowFillAlphaDefault = value; } - } - /// /// Horizontal indentation when e.g. entering a tree node /// diff --git a/src/ImGui.NET/TextEditCallbackData.cs b/src/ImGui.NET/TextEditCallbackData.cs index b67af9a..b7306d4 100644 --- a/src/ImGui.NET/TextEditCallbackData.cs +++ b/src/ImGui.NET/TextEditCallbackData.cs @@ -39,6 +39,8 @@ namespace ImGuiNET /// Current text. Read-write (pointed data only). char* in native code. /// public IntPtr Buf; + + public int BufTextLen; /// /// Read-only. /// diff --git a/src/ImGui.NET/TreeNodeFlags.cs b/src/ImGui.NET/TreeNodeFlags.cs new file mode 100644 index 0000000..933a683 --- /dev/null +++ b/src/ImGui.NET/TreeNodeFlags.cs @@ -0,0 +1,51 @@ +using System; + +namespace ImGuiNET +{ + [Flags] + public enum TreeNodeFlags : int + { + /// + /// Draw as selected + /// + Selected = 1 << 0, + /// + /// Full colored frame (e.g. for CollapsingHeader) + /// + Framed = 1 << 1, + /// + /// Hit testing to allow subsequent widgets to overlap this one + /// + AllowOverlapMode = 1 << 2, + /// + /// Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack + /// + NoTreePushOnOpen = 1 << 3, + /// + /// Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack + /// + NoAutoOpenOnLog = 1 << 4, + /// + /// Default node to be open + /// + DefaultOpen = 1 << 5, + /// + /// Need double-click to open node + /// + OpenOnDoubleClick = 1 << 6, + /// + /// Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open. + /// + OpenOnArrow = 1 << 7, + /// + /// No collapsing, no arrow (use as a convenience for leaf nodes). + /// + Leaf = 1 << 8, + /// + /// Display a bullet instead of arrow + /// + Bullet = 1 << 9, + + CollapsingHeader = Framed | NoAutoOpenOnLog + }; +}