From 9cfeed151da6d5abe908fb2b4d5349749c33c969 Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Wed, 10 Jan 2018 01:32:36 -0800 Subject: [PATCH] Update to imgui 1.53 (no native binary updates). --- src/ImGui.NET.SampleProgram/MemoryEditor.cs | 2 +- src/ImGui.NET.SampleProgram/SampleWindow.cs | 2 + src/ImGui.NET/ColorTarget.cs | 4 +- src/ImGui.NET/ComboFlags.cs | 27 +++++ src/ImGui.NET/DragDropFlags.cs | 43 ++++++++ src/ImGui.NET/DrawList.cs | 22 +++++ src/ImGui.NET/ImGui.cs | 71 +++++++++++-- src/ImGui.NET/ImGuiNative.cs | 83 +++++++++++----- src/ImGui.NET/InputTextFlags.cs | 8 ++ src/ImGui.NET/NativeIO.cs | 2 +- src/ImGui.NET/NativePayload.cs | 16 +++ src/ImGui.NET/NativeStyle.cs | 32 ++++-- src/ImGui.NET/Payload.cs | 13 +++ src/ImGui.NET/Style.cs | 104 ++++++++++---------- src/ImGui.NET/StyleVar.cs | 28 +++++- src/ImGui.NET/TreeNodeFlags.cs | 2 +- src/ImGui.NET/WindowFlags.cs | 21 +++- 17 files changed, 382 insertions(+), 98 deletions(-) create mode 100644 src/ImGui.NET/ComboFlags.cs create mode 100644 src/ImGui.NET/DragDropFlags.cs create mode 100644 src/ImGui.NET/NativePayload.cs create mode 100644 src/ImGui.NET/Payload.cs diff --git a/src/ImGui.NET.SampleProgram/MemoryEditor.cs b/src/ImGui.NET.SampleProgram/MemoryEditor.cs index 9eca8f5..1a60cef 100644 --- a/src/ImGui.NET.SampleProgram/MemoryEditor.cs +++ b/src/ImGui.NET.SampleProgram/MemoryEditor.cs @@ -67,7 +67,7 @@ namespace ImGuiNET int line_total_count = (mem_size + Rows - 1) / Rows; ImGuiNative.igSetNextWindowContentSize(new Vector2(0.0f, line_total_count * line_height)); - ImGui.BeginChild("##scrolling", new Vector2(0, -ImGuiNative.igGetItemsLineHeightWithSpacing()), false, 0); + ImGui.BeginChild("##scrolling", new Vector2(0, -ImGuiNative.igGetFrameHeightWithSpacing()), false, 0); ImGui.PushStyleVar(StyleVar.FramePadding, new Vector2(0, 0)); ImGui.PushStyleVar(StyleVar.ItemSpacing, new Vector2(0, 0)); diff --git a/src/ImGui.NET.SampleProgram/SampleWindow.cs b/src/ImGui.NET.SampleProgram/SampleWindow.cs index 4708bdb..6bd7217 100644 --- a/src/ImGui.NET.SampleProgram/SampleWindow.cs +++ b/src/ImGui.NET.SampleProgram/SampleWindow.cs @@ -224,6 +224,8 @@ namespace ImGuiNET bool leftPressed = ImGui.GetIO().MouseDown[0]; ImGui.Text("Current mouse position: " + pos + ". Pressed=" + leftPressed); + ImGui.ShowStyleSelector("Select style"); + if (ImGui.Button("Increment the counter.")) { _pressCount += 1; diff --git a/src/ImGui.NET/ColorTarget.cs b/src/ImGui.NET/ColorTarget.cs index 87d90eb..26303d8 100644 --- a/src/ImGui.NET/ColorTarget.cs +++ b/src/ImGui.NET/ColorTarget.cs @@ -8,7 +8,7 @@ Text, TextDisabled, WindowBg, - ChildWindowBg, + ChildBg, PopupBg, Border, BorderShadow, @@ -26,7 +26,6 @@ ScrollbarGrab, ScrollbarGrabHovered, ScrollbarGrabActive, - ComboBg, CheckMark, SliderGrab, SliderGrabActive, @@ -54,6 +53,7 @@ /// darken entire screen when a modal window is active /// ModalWindowDarkening, + DragDropTarget, Count, }; } diff --git a/src/ImGui.NET/ComboFlags.cs b/src/ImGui.NET/ComboFlags.cs new file mode 100644 index 0000000..7a49d8a --- /dev/null +++ b/src/ImGui.NET/ComboFlags.cs @@ -0,0 +1,27 @@ +namespace ImGuiNET +{ + public enum ComboFlags + { + /// + /// Align the popup toward the left by default + /// + PopupAlignLeft = 1 << 0, + /// + /// Max ~4 items visible. Tip: If you want your combo popup to be a specific size you can use SetNextWindowSizeConstraints() prior to calling BeginCombo() + /// + HeightSmall = 1 << 1, + /// + /// Max ~8 items visible (default) + /// + HeightRegular = 1 << 2, + /// + /// Max ~20 items visible + /// + HeightLarge = 1 << 3, + /// + /// As many fitting items as possible + /// + HeightLargest = 1 << 4, + HeightMask_ = HeightSmall | HeightRegular | HeightLarge | HeightLargest + } +} diff --git a/src/ImGui.NET/DragDropFlags.cs b/src/ImGui.NET/DragDropFlags.cs new file mode 100644 index 0000000..8d0b6c4 --- /dev/null +++ b/src/ImGui.NET/DragDropFlags.cs @@ -0,0 +1,43 @@ +namespace ImGuiNET +{ + public enum DragDropFlags + { + // BeginDragDropSource() flags + + /// + /// By default, a successful call to BeginDragDropSource opens a tooltip so you can display a preview or description of the source contents. This flag disable this behavior. + /// + SourceNoPreviewTooltip = 1 << 0, + /// + /// By default, when dragging we clear data so that IsItemHovered() will return true, to avoid subsequent user code submitting tooltips. This flag disable this behavior so you can still call IsItemHovered() on the source item. + /// + SourceNoDisableHover = 1 << 1, + /// + /// Disable the behavior that allows to open tree nodes and collapsing header by holding over them while dragging a source item. + /// + SourceNoHoldToOpenOthers = 1 << 2, + /// + /// Allow items such as Text(), Image() that have no unique identifier to be used as drag source, by manufacturing a temporary identifier based on their window-relative position. This is extremely unusual within the dear imgui ecosystem and so we made it explicit. + /// + SourceAllowNullID = 1 << 3, + /// + /// External source (from outside of imgui), won't attempt to read current item/window info. Will always return true. Only one Extern source can be active simultaneously. + /// + SourceExtern = 1 << 4, + + // AcceptDragDropPayload() flags + + /// + /// AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered. + /// + AcceptBeforeDelivery = 1 << 10, + /// + /// Do not draw the default highlight rectangle when hovering over target. + /// + AcceptNoDrawDefaultRect = 1 << 11, + /// + /// For peeking ahead and inspecting the payload before delivery. + /// + AcceptPeekOnly = AcceptBeforeDelivery | AcceptNoDrawDefaultRect + } +} diff --git a/src/ImGui.NET/DrawList.cs b/src/ImGui.NET/DrawList.cs index 1af80b0..1b2736c 100644 --- a/src/ImGui.NET/DrawList.cs +++ b/src/ImGui.NET/DrawList.cs @@ -70,6 +70,28 @@ namespace ImGuiNET ArrayPool.Shared.Return(tempBytes); } + public unsafe void AddImageRounded( + IntPtr userTextureID, + Vector2 a, + Vector2 b, + Vector2 uvA, + Vector2 uvB, + uint color, + float rounding, + int roundingCorners) + { + ImGuiNative.ImDrawList_AddImageRounded( + _nativeDrawList, + userTextureID.ToPointer(), + a, + b, + uvA, + uvB, + color, + rounding, + roundingCorners); + } + public void PushClipRect(Vector2 min, Vector2 max, bool intersectWithCurrentClipRect) { ImGuiNative.ImDrawList_PushClipRect(_nativeDrawList, min, max, intersectWithCurrentClipRect ? (byte)1 : (byte)0); diff --git a/src/ImGui.NET/ImGui.cs b/src/ImGui.NET/ImGui.cs index 6562788..b2ee3c5 100644 --- a/src/ImGui.NET/ImGui.cs +++ b/src/ImGui.NET/ImGui.cs @@ -35,17 +35,17 @@ namespace ImGuiNET public static void PushID(string id) { - ImGuiNative.igPushIdStr(id); + ImGuiNative.igPushIDStr(id); } public static void PushID(int id) { - ImGuiNative.igPushIdInt(id); + ImGuiNative.igPushIDInt(id); } public static void PushIDRange(string idBegin, string idEnd) { - ImGuiNative.igPushIdStrRange(idBegin, idEnd); + ImGuiNative.igPushIDStrRange(idBegin, idEnd); } public static void PushItemWidth(float width) @@ -60,17 +60,17 @@ namespace ImGuiNET public static void PopID() { - ImGuiNative.igPopId(); + ImGuiNative.igPopID(); } public static uint GetID(string id) { - return ImGuiNative.igGetIdStr(id); + return ImGuiNative.igGetIDStr(id); } public static uint GetID(string idBegin, string idEnd) { - return ImGuiNative.igGetIdStrRange(idBegin, idEnd); + return ImGuiNative.igGetIDStrRange(idBegin, idEnd); } public static void Text(string message) @@ -171,6 +171,11 @@ namespace ImGuiNET return ImGuiNative.igRadioButtonBool(label, active); } + public static bool BeginCombo(string label, string previewValue, ComboFlags flags) + => ImGuiNative.igBeginCombo(label, previewValue, flags); + + public static void EndCombo() => ImGuiNative.igEndCombo(); + public unsafe static bool Combo(string label, ref int current_item, string[] items) { return ImGuiNative.igCombo(label, ref current_item, items, items.Length, 5); @@ -286,6 +291,16 @@ namespace ImGuiNET } } + public static void ShowStyleSelector(string label) + { + ImGuiNative.igShowStyleSelector(label); + } + + public static void ShowFontSelector(string label) + { + ImGuiNative.igShowFontSelector(label); + } + public unsafe static void PlotHistogram(string label, float[] values, int valuesOffset, string overlayText, float scaleMin, float scaleMax, Vector2 graphSize, int stride) { fixed (float* valuesBasePtr = values) @@ -821,6 +836,11 @@ namespace ImGuiNET ImGuiNative.igSetCursorScreenPos(pos); } + public static float GetFrameHeightWithSpacing() + { + return ImGuiNative.igGetFrameHeightWithSpacing(); + } + public static void AlignTextToFramePadding() { ImGuiNative.igAlignTextToFramePadding(); @@ -1009,6 +1029,8 @@ namespace ImGuiNET ImGuiNative.igSpacing(); } + public static float GetFrameHeight() => ImGuiNative.igGetFrameHeight(); + public static void Columns(int count, string id, bool border) { ImGuiNative.igColumns(count, id, border); @@ -1059,6 +1081,21 @@ namespace ImGuiNET ImGuiNative.igSameLine(localPositionX, spacingW); } + public static bool BeginDragDropSource(DragDropFlags flags, int mouseButton) + => ImGuiNative.igBeginDragDropSource(flags, mouseButton); + + public static unsafe bool SetDragDropPayload(string type, IntPtr data, uint size, Condition cond) + => ImGuiNative.igSetDragDropPayload(type, data.ToPointer(), size, cond); + + public static void EndDragDropSource() => ImGuiNative.igEndDragDropSource(); + + public static bool BeginDragDropTarget() => ImGuiNative.igBeginDragDropTarget(); + + public static unsafe Payload AcceptDragDropPayload(string type, DragDropFlags flags) + => new Payload(ImGuiNative.igAcceptDragDropPayload(type, flags)); + + public static void EndDragDropTarget() => ImGuiNative.igEndDragDropTarget(); + public static void PushClipRect(Vector2 min, Vector2 max, bool intersectWithCurrentCliRect) { ImGuiNative.igPushClipRect(min, max, intersectWithCurrentCliRect ? (byte)1 : (byte)0); @@ -1069,6 +1106,21 @@ namespace ImGuiNET ImGuiNative.igPopClipRect(); } + public static unsafe void StyleColorsClassic(Style style) + { + ImGuiNative.igStyleColorsClassic(style.NativePtr); + } + + public static unsafe void StyleColorsDark(Style style) + { + ImGuiNative.igStyleColorsDark(style.NativePtr); + } + + public static unsafe void StyleColorsLight(Style style) + { + ImGuiNative.igStyleColorsLight(style.NativePtr); + } + public static bool IsItemHovered(HoveredFlags flags) { return ImGuiNative.igIsItemHovered(flags); @@ -1094,6 +1146,8 @@ namespace ImGuiNET return ImGuiNative.igIsAnyItemActive(); } + public static unsafe DrawList GetOverlayDrawList() => new DrawList(ImGuiNative.igGetOverlayDrawList()); + public static void SetTooltip(string text) { ImGuiNative.igSetTooltip(text); @@ -1160,6 +1214,11 @@ namespace ImGuiNET ImGuiNative.igSetScrollHere(); } + public static void SetItemDefaultFocus() + { + ImGuiNative.igSetItemDefaultFocus(); + } + public static void SetScrollHere(float centerYRatio) { ImGuiNative.igSetScrollHere(centerYRatio); diff --git a/src/ImGui.NET/ImGuiNative.cs b/src/ImGui.NET/ImGuiNative.cs index fc58b1e..1a0b2fc 100644 --- a/src/ImGui.NET/ImGuiNative.cs +++ b/src/ImGui.NET/ImGuiNative.cs @@ -34,10 +34,16 @@ namespace ImGuiNET public static extern void igShowStyleEditor(ref NativeStyle @ref); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern void igShowTestWindow(ref bool opened); + public static extern void igShowDemoWindow(ref bool opened); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern void igShowMetricsWindow(ref bool opened); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern void igShowStyleSelector(string label); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern void igShowFontSelector(string label); + + // Window [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] @@ -98,8 +104,6 @@ namespace ImGuiNET [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern void igSetNextWindowContentSize(Vector2 size); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern void igSetNextWindowContentWidth(float width); - [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern void igSetNextWindowCollapsed(bool collapsed, Condition cond); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern void igSetNextWindowFocus(); @@ -137,6 +141,9 @@ namespace ImGuiNET [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern void igSetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern void igSetItemDefaultFocus(); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern void igSetKeyboardFocusHere(int offset); @@ -234,7 +241,9 @@ namespace ImGuiNET [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern float igGetTextLineHeightWithSpacing(); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern float igGetItemsLineHeightWithSpacing(); + public static extern float igGetFrameHeight(); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern float igGetFrameHeightWithSpacing(); // Columns [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] @@ -259,21 +268,21 @@ namespace ImGuiNET // 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') [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern void igPushIdStr(string str_id); + public static extern void igPushIDStr(string str_id); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern void igPushIdStrRange(string str_begin, string str_end); + public static extern void igPushIDStrRange(string str_begin, string str_end); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern void igPushIdPtr(void* ptr_id); + public static extern void igPushIDPtr(void* ptr_id); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern void igPushIdInt(int int_id); + public static extern void igPushIDInt(int int_id); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern void igPopId(); + public static extern void igPopID(); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern uint igGetIdStr(string str_id); + public static extern uint igGetIDStr(string str_id); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern uint igGetIdStrRange(string str_begin, string str_end); + public static extern uint igGetIDStrRange(string str_begin, string str_end); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern uint igGetIdPtr(void* ptr_id); + public static extern uint igGetIDPtr(void* ptr_id); // Widgets [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] @@ -324,6 +333,13 @@ namespace ImGuiNET [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool igRadioButton(string label, int* v, int v_button); + + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool igBeginCombo(string label, string preview_value, ComboFlags flags); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern void igEndCombo(); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool igCombo(string label, ref int current_item, string[] items, int items_count, int height_in_items); @@ -624,12 +640,38 @@ namespace ImGuiNET //public static extern void igLogText(string fmt, ...); public static extern void igLogText(string fmt); + // Drag-drop + + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool igBeginDragDropSource(DragDropFlags flags, int mouse_button); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool igSetDragDropPayload(string type, void* data, uint size, Condition cond); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern void igEndDragDropSource(); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool igBeginDragDropTarget(); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern NativePayload* igAcceptDragDropPayload(string type, DragDropFlags flags); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern void igEndDragDropTarget(); + // Clipping [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern void igPushClipRect(Vector2 clip_rect_min, Vector2 clip_rect_max, byte intersect_with_current_clip_rect); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern void igPopClipRect(); + // Built-in Styles + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern void igStyleColorsClassic(NativeStyle* dst); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern void igStyleColorsDark(NativeStyle* dst); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern void igStyleColorsLight(NativeStyle* dst); + // Utilities [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] @@ -666,15 +708,6 @@ namespace ImGuiNET public static extern bool igIsWindowFocused(FocusedFlags flags); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] - public static extern bool igIsRootWindowFocused(); - [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - [return: MarshalAs(UnmanagedType.I1)] - public static extern bool igIsRootWindowOrAnyChildFocused(); - [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - [return: MarshalAs(UnmanagedType.I1)] - public static extern bool igIsRootWindowOrAnyChildHovered(); - [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - [return: MarshalAs(UnmanagedType.I1)] public static extern bool igIsRectVisible(Vector2 item_size); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] @@ -684,6 +717,8 @@ namespace ImGuiNET [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern int igGetFrameCount(); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern NativeDrawList* igGetOverlayDrawList(); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern string igGetStyleColorName(ColorTarget idx); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern void igCalcItemRectClosestPoint(out Vector2 pOut, Vector2 pos, bool on_edge, float outward); @@ -892,9 +927,11 @@ namespace ImGuiNET [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern void ImDrawList_AddImageQuad(NativeDrawList* list, void* user_texture_id, Vector2 a, Vector2 b, Vector2 c, Vector2 d, Vector2 uv_a, Vector2 uv_b, Vector2 uv_c, Vector2 uv_d, uint col); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImDrawList_AddPolyline(NativeDrawList* list, Vector2* points, int num_points, uint col, byte closed, float thickness, byte anti_aliased); + public static extern void ImDrawList_AddImageRounded(NativeDrawList* list, void* user_texture_id, Vector2 a, Vector2 b, Vector2 uv_a, Vector2 uv_b, uint col, float rounding, int rounding_corners); + [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImDrawList_AddPolyline(NativeDrawList* list, Vector2* points, int num_points, uint col, byte closed, float thickness); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImDrawList_AddConvexPolyFilled(NativeDrawList* list, Vector2* points, int num_points, uint col, byte anti_aliased); + public static extern void ImDrawList_AddConvexPolyFilled(NativeDrawList* list, Vector2* points, int num_points, uint col); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] public static extern void ImDrawList_AddBezierCurve(NativeDrawList* list, Vector2 pos0, Vector2 cp0, Vector2 cp1, Vector2 pos1, uint col, float thickness, int num_segments); [DllImport(cimguiLib, CallingConvention = CallingConvention.Cdecl)] diff --git a/src/ImGui.NET/InputTextFlags.cs b/src/ImGui.NET/InputTextFlags.cs index 7fc5293..7715ed2 100644 --- a/src/ImGui.NET/InputTextFlags.cs +++ b/src/ImGui.NET/InputTextFlags.cs @@ -67,6 +67,14 @@ /// ReadOnly = 1 << 14, /// + /// Password mode, display all characters as '*' + /// + Password, + /// + /// Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID(). + /// + NoUndoRedo, + /// /// For internal use by InputTextMultiline() /// Multiline = 1 << 20 diff --git a/src/ImGui.NET/NativeIO.cs b/src/ImGui.NET/NativeIO.cs index ae852e4..f0cf507 100644 --- a/src/ImGui.NET/NativeIO.cs +++ b/src/ImGui.NET/NativeIO.cs @@ -117,7 +117,7 @@ namespace ImGuiNET /// Multi-selection in lists uses Cmd/Super instead of Ctrl /// Default value: True on OSX; false otherwise. /// - public byte OSXBehaviors; + public byte OptMacOSXBehaviors; /// /// Enable blinking cursor, for users who consider it annoying. /// Default value: true. diff --git a/src/ImGui.NET/NativePayload.cs b/src/ImGui.NET/NativePayload.cs new file mode 100644 index 0000000..304f0f4 --- /dev/null +++ b/src/ImGui.NET/NativePayload.cs @@ -0,0 +1,16 @@ +namespace ImGuiNET +{ + public unsafe struct NativePayload + { + public void* Data; + public int DataSize; + + // Internal + private uint SourceId; + private uint SourceParentId; + private int DataFrameCount; + private fixed byte DataType[8 + 1]; + private byte Preview; + private byte Delivery; + } +} diff --git a/src/ImGui.NET/NativeStyle.cs b/src/ImGui.NET/NativeStyle.cs index 73edffe..a0cdcb0 100644 --- a/src/ImGui.NET/NativeStyle.cs +++ b/src/ImGui.NET/NativeStyle.cs @@ -15,21 +15,37 @@ namespace ImGuiNET /// public Vector2 WindowPadding; /// - /// Minimum window size. - /// - public Vector2 WindowMinSize; - /// /// Radius of window corners rounding. Set to 0.0f to have rectangular windows. /// public float WindowRounding; /// + /// Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly) + /// + public float WindowBorderSize; + /// + /// Minimum window size. + /// + public Vector2 WindowMinSize; + /// /// Alignment for title bar text. /// public Vector2 WindowTitleAlign; /// /// Radius of child window corners rounding. Set to 0.0f to have rectangular windows. /// - public float ChildWindowRounding; + public float ChildRounding; + /// + /// Thickness of border around child windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly) + /// + public float ChildBorderSize; + /// + /// Radius of popup window corners rounding. + /// + public float PopupRounding; + /// + /// Thickness of border around popup windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly) + /// + public float PopupBorderSize; /// /// Padding within a framed rectangle (used by most widgets). /// @@ -39,6 +55,10 @@ namespace ImGuiNET /// public float FrameRounding; /// + /// Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly) + /// + public float FrameBorderSize; + /// /// Horizontal and vertical spacing between widgets/lines. /// public Vector2 ItemSpacing; @@ -93,7 +113,7 @@ namespace ImGuiNET /// /// Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.) /// - public byte AntiAliasedShapes; + public byte AntiAliasedFill; /// /// Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. /// diff --git a/src/ImGui.NET/Payload.cs b/src/ImGui.NET/Payload.cs new file mode 100644 index 0000000..fb220c8 --- /dev/null +++ b/src/ImGui.NET/Payload.cs @@ -0,0 +1,13 @@ +using System; + +namespace ImGuiNET +{ + public unsafe struct Payload + { + public readonly NativePayload* NativePtr; + public Payload(NativePayload* ptr) => NativePtr = ptr; + + public IntPtr Data => (IntPtr)NativePtr->Data; + public int DataSize => NativePtr->DataSize; + } +} diff --git a/src/ImGui.NET/Style.cs b/src/ImGui.NET/Style.cs index 16d3249..0a2be46 100644 --- a/src/ImGui.NET/Style.cs +++ b/src/ImGui.NET/Style.cs @@ -4,11 +4,11 @@ namespace ImGuiNET { public unsafe class Style { - private readonly NativeStyle* _stylePtr; + public readonly NativeStyle* NativePtr; public Style(NativeStyle* style) { - _stylePtr = style; + NativePtr = style; } /// @@ -16,8 +16,8 @@ namespace ImGuiNET /// public float Alpha { - get { return _stylePtr->Alpha; } - set { _stylePtr->Alpha = value; } + get { return NativePtr->Alpha; } + set { NativePtr->Alpha = value; } } /// @@ -25,8 +25,8 @@ namespace ImGuiNET /// public Vector2 WindowPadding { - get { return _stylePtr->WindowPadding; } - set { _stylePtr->WindowPadding = value; } + get { return NativePtr->WindowPadding; } + set { NativePtr->WindowPadding = value; } } /// @@ -34,8 +34,8 @@ namespace ImGuiNET /// public Vector2 WindowMinSize { - get { return _stylePtr->WindowMinSize; } - set { _stylePtr->WindowMinSize = value; } + get { return NativePtr->WindowMinSize; } + set { NativePtr->WindowMinSize = value; } } /// @@ -43,8 +43,8 @@ namespace ImGuiNET /// public float WindowRounding { - get { return _stylePtr->WindowRounding; } - set { _stylePtr->WindowRounding = value; } + get { return NativePtr->WindowRounding; } + set { NativePtr->WindowRounding = value; } } /// @@ -52,8 +52,8 @@ namespace ImGuiNET /// public Vector2 WindowTitleAlign { - get { return _stylePtr->WindowTitleAlign; } - set { _stylePtr->WindowTitleAlign = value; } + get { return NativePtr->WindowTitleAlign; } + set { NativePtr->WindowTitleAlign = value; } } /// @@ -61,8 +61,8 @@ namespace ImGuiNET /// public float ChildWindowRounding { - get { return _stylePtr->ChildWindowRounding; } - set { _stylePtr->ChildWindowRounding = value; } + get { return NativePtr->ChildRounding; } + set { NativePtr->ChildRounding = value; } } /// @@ -70,8 +70,8 @@ namespace ImGuiNET /// public Vector2 FramePadding { - get { return _stylePtr->FramePadding; } - set { _stylePtr->FramePadding = value; } + get { return NativePtr->FramePadding; } + set { NativePtr->FramePadding = value; } } /// @@ -79,8 +79,8 @@ namespace ImGuiNET /// public float FrameRounding { - get { return _stylePtr->FrameRounding; } - set { _stylePtr->FrameRounding = value; } + get { return NativePtr->FrameRounding; } + set { NativePtr->FrameRounding = value; } } /// @@ -88,8 +88,8 @@ namespace ImGuiNET /// public Vector2 ItemSpacing { - get { return _stylePtr->ItemSpacing; } - set { _stylePtr->ItemSpacing = value; } + get { return NativePtr->ItemSpacing; } + set { NativePtr->ItemSpacing = value; } } /// @@ -97,8 +97,8 @@ namespace ImGuiNET /// public Vector2 ItemInnerSpacing { - get { return _stylePtr->ItemInnerSpacing; } - set { _stylePtr->ItemInnerSpacing = value; } + get { return NativePtr->ItemInnerSpacing; } + set { NativePtr->ItemInnerSpacing = value; } } /// @@ -106,8 +106,8 @@ namespace ImGuiNET /// public Vector2 TouchExtraPadding { - get { return _stylePtr->TouchExtraPadding; } - set { _stylePtr->TouchExtraPadding = value; } + get { return NativePtr->TouchExtraPadding; } + set { NativePtr->TouchExtraPadding = value; } } /// @@ -115,8 +115,8 @@ namespace ImGuiNET /// public float IndentSpacing { - get { return _stylePtr->IndentSpacing; } - set { _stylePtr->IndentSpacing = value; } + get { return NativePtr->IndentSpacing; } + set { NativePtr->IndentSpacing = value; } } /// @@ -124,8 +124,8 @@ namespace ImGuiNET /// public float ColumnsMinSpacing { - get { return _stylePtr->ColumnsMinSpacing; } - set { _stylePtr->ColumnsMinSpacing = value; } + get { return NativePtr->ColumnsMinSpacing; } + set { NativePtr->ColumnsMinSpacing = value; } } /// @@ -133,8 +133,8 @@ namespace ImGuiNET /// public float ScrollbarSize { - get { return _stylePtr->ScrollbarSize; } - set { _stylePtr->ScrollbarSize = value; } + get { return NativePtr->ScrollbarSize; } + set { NativePtr->ScrollbarSize = value; } } /// @@ -142,8 +142,8 @@ namespace ImGuiNET /// public float ScrollbarRounding { - get { return _stylePtr->ScrollbarRounding; } - set { _stylePtr->ScrollbarRounding = value; } + get { return NativePtr->ScrollbarRounding; } + set { NativePtr->ScrollbarRounding = value; } } /// @@ -151,8 +151,8 @@ namespace ImGuiNET /// public float GrabMinSize { - get { return _stylePtr->GrabMinSize; } - set { _stylePtr->GrabMinSize = value; } + get { return NativePtr->GrabMinSize; } + set { NativePtr->GrabMinSize = value; } } /// @@ -160,8 +160,8 @@ namespace ImGuiNET /// public float GrabRounding { - get { return _stylePtr->GrabRounding; } - set { _stylePtr->GrabRounding = value; } + get { return NativePtr->GrabRounding; } + set { NativePtr->GrabRounding = value; } } /// @@ -169,8 +169,8 @@ namespace ImGuiNET /// public Vector2 DisplayWindowPadding { - get { return _stylePtr->DisplayWindowPadding; } - set { _stylePtr->DisplayWindowPadding = value; } + get { return NativePtr->DisplayWindowPadding; } + set { NativePtr->DisplayWindowPadding = value; } } /// @@ -178,8 +178,8 @@ namespace ImGuiNET /// public Vector2 DisplaySafeAreaPadding { - get { return _stylePtr->DisplaySafeAreaPadding; } - set { _stylePtr->DisplaySafeAreaPadding = value; } + get { return NativePtr->DisplaySafeAreaPadding; } + set { NativePtr->DisplaySafeAreaPadding = value; } } /// @@ -187,17 +187,17 @@ namespace ImGuiNET /// public bool AntiAliasedLines { - get { return _stylePtr->AntiAliasedLines == 1; } - set { _stylePtr->AntiAliasedLines = value ? (byte)1 : (byte)0; } + get { return NativePtr->AntiAliasedLines == 1; } + set { NativePtr->AntiAliasedLines = value ? (byte)1 : (byte)0; } } /// /// Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.) /// - public bool AntiAliasedShapes + public bool AntiAliasedFill { - get { return _stylePtr->AntiAliasedShapes == 1; } - set { _stylePtr->AntiAliasedShapes = value ? (byte)1 : (byte)0; } + get { return NativePtr->AntiAliasedFill == 1; } + set { NativePtr->AntiAliasedFill = value ? (byte)1 : (byte)0; } } /// @@ -205,8 +205,8 @@ namespace ImGuiNET /// public float CurveTessellationTolerance { - get { return _stylePtr->CurveTessellationTol; } - set { _stylePtr->CurveTessellationTol = value; } + get { return NativePtr->CurveTessellationTol; } + set { NativePtr->CurveTessellationTol = value; } } /// @@ -214,7 +214,7 @@ namespace ImGuiNET /// /// The type of UI element. /// The element's color as currently configured. - public Vector4 GetColor(ColorTarget target) => *(Vector4*)&_stylePtr->Colors[(int)target * 4]; + public Vector4 GetColor(ColorTarget target) => *(Vector4*)&NativePtr->Colors[(int)target * 4]; /// /// Sets the style color for a particular UI element type. @@ -223,10 +223,10 @@ namespace ImGuiNET /// The new color. public void SetColor(ColorTarget target, Vector4 value) { - _stylePtr->Colors[(int)target * 4 + 0] = value.X; - _stylePtr->Colors[(int)target * 4 + 1] = value.Y; - _stylePtr->Colors[(int)target * 4 + 2] = value.Z; - _stylePtr->Colors[(int)target * 4 + 3] = value.W; + NativePtr->Colors[(int)target * 4 + 0] = value.X; + NativePtr->Colors[(int)target * 4 + 1] = value.Y; + NativePtr->Colors[(int)target * 4 + 2] = value.Z; + NativePtr->Colors[(int)target * 4 + 3] = value.W; } } } diff --git a/src/ImGui.NET/StyleVar.cs b/src/ImGui.NET/StyleVar.cs index d6334d5..23e5498 100644 --- a/src/ImGui.NET/StyleVar.cs +++ b/src/ImGui.NET/StyleVar.cs @@ -19,13 +19,29 @@ /// WindowRounding, /// + /// float + /// + WindowBorderSize, + /// /// System.Numerics.Vector2 /// WindowMinSize, /// /// float /// - ChildWindowRounding, + ChildRounding, + /// + /// float + /// + ChildBorderSize, + /// + /// float + /// + PopupRounding, + /// + /// float + /// + PopupBorderSize, /// /// System.Numerics.Vector2 /// @@ -35,6 +51,10 @@ /// FrameRounding, /// + /// float + /// + FrameBorderSize, + /// /// System.Numerics.Vector2 /// ItemSpacing, @@ -49,6 +69,10 @@ /// /// float /// - GrabMinSize + GrabMinSize, + /// + /// System.Numerics.Vector2 + /// + ButtonTextAlign, }; } diff --git a/src/ImGui.NET/TreeNodeFlags.cs b/src/ImGui.NET/TreeNodeFlags.cs index 6e84d47..5040b99 100644 --- a/src/ImGui.NET/TreeNodeFlags.cs +++ b/src/ImGui.NET/TreeNodeFlags.cs @@ -16,7 +16,7 @@ namespace ImGuiNET /// /// Hit testing to allow subsequent widgets to overlap this one /// - AllowOverlapMode = 1 << 2, + AllowItemOverlap = 1 << 2, /// /// Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack /// diff --git a/src/ImGui.NET/WindowFlags.cs b/src/ImGui.NET/WindowFlags.cs index 7bec1f7..c04fe02 100644 --- a/src/ImGui.NET/WindowFlags.cs +++ b/src/ImGui.NET/WindowFlags.cs @@ -35,10 +35,6 @@ /// AlwaysAutoResize = 1 << 6, /// - /// Show borders around windows and items - /// - ShowBorders = 1 << 7, - /// /// Never load/save settings in .ini file /// NoSavedSettings = 1 << 8, @@ -63,5 +59,22 @@ /// Disable bringing window to front when taking focus (e.g. clicking on it or programatically giving it focus) /// NoBringToFrontOnFocus = 1 << 13, + /// + /// Always show vertical scrollbar (even if ContentSize.y < Size.y) + /// + AlwaysVerticalScrollbar = 1 << 14, + /// + /// Always show horizontal scrollbar (even if ContentSize.x < Size.x) + /// + AlwaysHorizontalScrollbar = 1 << 15, + /// + /// Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient) + /// + AlwaysUseWindowPadding = 1 << 16, + /// + /// Enable resize from any corners and borders. Your back-end needs to honor the different values of io.MouseCursor set by imgui. + /// + ResizeFromAnySide = 1 << 17, + } }