├── Screens
└── 2-28-17.PNG
├── ImGuiSharp.MonoGame.Windows
├── Icon.ico
├── app.config
├── packages.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── ImGuiSharp.MonoGame.Windows.csproj
├── ImGuiSharp.Shared
├── ImGui.h
│ ├── ImWchar.cs
│ ├── ImDrawIdx.cs.h
│ ├── ImGuiOnceUponAFrame.cs
│ ├── ImDrawCallback.cs
│ ├── ImTextureID.cs
│ ├── ImDrawVert.cs
│ ├── ImDrawChannel.cs.h
│ ├── ImGuiAlign.cs
│ ├── ImFontConfig.cs.cpp
│ ├── ImGuiColorEditMode.cs
│ ├── ImU32.cs
│ ├── ImDrawCallback.cs.h
│ ├── ImDrawVert.cs.h
│ ├── ImDrawIdx.cs
│ ├── ImDrawChannel.cs
│ ├── ImGuiMouseCursor.cs
│ ├── ImVec4.cs.h
│ ├── ImGuiSetCond.cs
│ ├── ImGuiID.cs
│ ├── ImGuiOnceUponAFrame.cs.h
│ ├── ImGuiTextBuffer.cs.h
│ ├── ImGuiSelectableFlags.cs
│ ├── ImDrawCmd.cs.h
│ ├── ImGuiStyleVar.cs
│ ├── ImDrawData.cs.h
│ ├── ImGuiKey.cs
│ ├── ImGuiTextFilter.cs.h
│ ├── ImDrawCmd.cs
│ ├── ImGuiTextBuffer.cs.cpp
│ ├── ImGuiTextFilter.cs
│ ├── ImGuiTextBuffer.cs
│ ├── ImDrawData.cs
│ ├── ImGuiListClipper.cs.h
│ ├── ImFontConfig.cs.h
│ ├── ImDrawData.cs.cpp
│ ├── ImVec2.cs.h
│ ├── ImColor.cs
│ ├── ImGuiCol.cs
│ ├── ImColor.cs.h
│ ├── ImGuiListClipper.cs
│ ├── ImGuiTextEditCallbackData.cs.h
│ ├── ImGuiIO.cs.cpp
│ ├── ImGuiInputTextFlags.cs
│ ├── ImGuiTextFilter.cs.cpp
│ ├── ImFontConfig.cs
│ ├── ImGuiStorage.cs.h
│ ├── ImVec4.cs
│ ├── ImGuiStyle.cs.h
│ ├── ImVec2.cs
│ ├── ImGuiWindowFlags.cs
│ ├── ImFont.cs.h
│ ├── ImVector.cs.h
│ ├── ImGuiStorage.cs.cpp
│ ├── ImGuiTextEditCallbackData.cs
│ ├── ImVector.cs
│ ├── ImFontAtlas.cs.h
│ ├── ImGuiStorage.cs
│ ├── ImGuiStyle.cs.cpp
│ ├── ImDrawList.cs.h
│ └── ImGuiIO.cs.h
├── ImGui_Internal.h
│ ├── ImGuiDataType.cs
│ ├── ImGuiColMod.cs.h
│ ├── ImGuiStyleMod.cs.h
│ ├── ImGuiPlotType.cs
│ ├── ImGuiIniData.cs.h
│ ├── ImGuiSliderFlags.cs
│ ├── ImGuiColumnData.cs.h
│ ├── ImGuiColMod.cs
│ ├── ImGuiStyleMod.cs
│ ├── ImGuiTreeNodeFlags.cs
│ ├── ImGuiLayoutType.cs
│ ├── ImGuiMouseCursorData.cs.h
│ ├── ImGuiColumnData.cs
│ ├── ImGuiIniData.cs
│ ├── ImGuiGroupData.cs.h
│ ├── ImGuiMouseCursorData.cs
│ ├── ImGuiSelectableFlagsPrivate.cs
│ ├── ImGuiGroupData.cs
│ ├── ImGuiSimpleColumns.cs.h
│ ├── ImGuiPopupRef.cs.h
│ ├── ImGuiPopupRef.cs
│ ├── ImGuiButtonFlags.cs
│ ├── ImGuiSimpleColumns.cs.cpp
│ ├── ImGuiTextEditState.cs.h
│ ├── ImGuiSimpleColumns.cs
│ ├── ImGuiWindow.cs.cpp
│ ├── ImRect.cs.h
│ ├── ImRect.cs
│ ├── ImGuiDrawContext.cs.h
│ ├── ImGuiTextEditState.cs
│ ├── ImGuiDrawContext.cs
│ ├── ImGuiWindow.cs.h
│ ├── API.h
│ ├── ImGuiState.cs.h
│ └── ImGuiWindow.cs
├── C.cs
└── ImGuiSharp.Shared.shproj
├── ImGui_CPP
├── .travis.yml
├── LICENSE
└── imconfig.h
├── LICENSE.MD
├── README.md
├── ImGui.NET.sln
├── .gitattributes
└── .gitignore
/Screens/2-28-17.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xposure/ImGuiSharp/HEAD/Screens/2-28-17.PNG
--------------------------------------------------------------------------------
/ImGuiSharp.MonoGame.Windows/Icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xposure/ImGuiSharp/HEAD/ImGuiSharp.MonoGame.Windows/Icon.ico
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImWchar.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | //public struct ImWchar
4 | //{
5 | // // character for keyboard input/display
6 | //}
7 | }
8 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawIdx.cs.h:
--------------------------------------------------------------------------------
1 | // Vertex index (override with, e.g. '#define ImDrawIdx unsigned int' in ImConfig)
2 | #ifndef ImDrawIdx
3 | typedef unsigned short ImDrawIdx;
4 | #endif
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiOnceUponAFrame.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // Simple helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro
4 | }
5 |
--------------------------------------------------------------------------------
/ImGuiSharp.MonoGame.Windows/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiDataType.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | internal enum ImGuiDataType : int
4 | {
5 | ImGuiDataType_Int,
6 | ImGuiDataType_Float
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiColMod.cs.h:
--------------------------------------------------------------------------------
1 | // Stacked color modifier, backup of modified data so we can restore it
2 | struct ImGuiColMod
3 | {
4 | ImGuiCol Col;
5 | ImVec4 PreviousValue;
6 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiStyleMod.cs.h:
--------------------------------------------------------------------------------
1 | // Stacked style modifier, backup of modified data so we can restore it
2 | struct ImGuiStyleMod
3 | {
4 | ImGuiStyleVar Var;
5 | ImVec2 PreviousValue;
6 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiPlotType.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImGui
3 | {
4 | internal enum ImGuiPlotType : int
5 | {
6 | ImGuiPlotType_Lines,
7 | ImGuiPlotType_Histogram
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiIniData.cs.h:
--------------------------------------------------------------------------------
1 | // Data saved in imgui.ini file
2 | struct ImGuiIniData
3 | {
4 | char* Name;
5 | uint ID;
6 | ImVec2 Pos;
7 | ImVec2 Size;
8 | bool Collapsed;
9 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiSliderFlags.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System;
4 |
5 | [Flags]
6 | internal enum ImGuiSliderFlags : int
7 | {
8 | ImGuiSliderFlags_Vertical = 1 << 0
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiColumnData.cs.h:
--------------------------------------------------------------------------------
1 | // Per column data for Columns()
2 | struct ImGuiColumnData
3 | {
4 | float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
5 | //float IndentX;
6 | };
--------------------------------------------------------------------------------
/ImGuiSharp.MonoGame.Windows/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiColMod.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // Stacked color modifier, backup of modified data so we can restore it
4 | internal struct ImGuiColMod
5 | {
6 | public ImGuiCol Col;
7 | public ImVec4 PreviousValue;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawCallback.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImGui
8 | {
9 | public delegate void ImDrawCallback(ImDrawList parent_list, ImDrawCmd cmd);
10 | }
11 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiStyleMod.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // Stacked style modifier, backup of modified data so we can restore it
4 | internal struct ImGuiStyleMod
5 | {
6 | public ImGuiStyleVar Var;
7 | public ImVec2 PreviousValue;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiTreeNodeFlags.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System;
4 |
5 | [Flags]
6 | internal enum ImGuiTreeNodeFlags : int
7 | {
8 | ImGuiTreeNodeFlags_DefaultOpen = 1 << 0,
9 | ImGuiTreeNodeFlags_NoAutoExpandOnLog = 1 << 1
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiLayoutType.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // FIXME: this is in development, not exposed/functional as a generic feature yet.
4 | internal enum ImGuiLayoutType : int
5 | {
6 | ImGuiLayoutType_Vertical,
7 | ImGuiLayoutType_Horizontal
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiMouseCursorData.cs.h:
--------------------------------------------------------------------------------
1 | // Mouse cursor data (used when io.MouseDrawCursor is set)
2 | struct ImGuiMouseCursorData
3 | {
4 | ImGuiMouseCursor Type;
5 | ImVec2 HotOffset;
6 | ImVec2 Size;
7 | ImVec2 TexUvMin[2];
8 | ImVec2 TexUvMax[2];
9 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiColumnData.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // Per column data for Columns()
4 | internal struct ImGuiColumnData
5 | {
6 | public float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
7 | //float IndentX;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiIniData.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImGui
3 | {
4 | // Data saved in imgui.ini file
5 | internal class ImGuiIniData
6 | {
7 | internal string Name;
8 | internal uint ID;
9 | internal ImVec2 Pos;
10 | internal ImVec2 Size;
11 | internal bool Collapsed;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiGroupData.cs.h:
--------------------------------------------------------------------------------
1 | // Stacked data for BeginGroup()/EndGroup()
2 | struct ImGuiGroupData
3 | {
4 | ImVec2 BackupCursorPos;
5 | ImVec2 BackupCursorMaxPos;
6 | float BackupIndentX;
7 | float BackupCurrentLineHeight;
8 | float BackupCurrentLineTextBaseOffset;
9 | float BackupLogLinePosY;
10 | bool AdvanceCursor;
11 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImTextureID.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImGui
3 | {
4 | // user data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp)
5 | public class ImTextureID
6 | {
7 | public object Data { get; private set; }
8 | public ImTextureID(object data)
9 | {
10 | Data = data;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawVert.cs:
--------------------------------------------------------------------------------
1 |
2 | using System.Runtime.InteropServices;
3 |
4 | namespace ImGui
5 | {
6 | // A single vertex (20 bytes by default, override layout with IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT)
7 | [StructLayout(LayoutKind.Sequential, Pack = 1)]
8 | public struct ImDrawVert
9 | {
10 | public ImVec2 pos;
11 | public ImVec2 uv;
12 | public uint col;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawChannel.cs.h:
--------------------------------------------------------------------------------
1 | // Draw channels are used by the Columns API to "split" the render list into different channels while building, so items of each column can be batched together.
2 | // You can also use them to simulate drawing layers and submit primitives in a different order than how they will be rendered.
3 | struct ImDrawChannel
4 | {
5 | ImVector CmdBuffer;
6 | ImVector IdxBuffer;
7 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiMouseCursorData.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // Mouse cursor data (used when io.MouseDrawCursor is set)
4 | internal class ImGuiMouseCursorData
5 | {
6 | public ImGuiMouseCursor Type;
7 | public ImVec2 HotOffset;
8 | public ImVec2 Size;
9 | public ImVec2[] TexUvMin = new ImVec2[2];
10 | public ImVec2[] TexUvMax = new ImVec2[2];
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiAlign.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System;
4 |
5 | // alignment
6 | [Flags]
7 | public enum ImGuiAlign : int
8 | {
9 | ImGuiAlign_Left = 1 << 0,
10 | ImGuiAlign_Center = 1 << 1,
11 | ImGuiAlign_Right = 1 << 2,
12 | ImGuiAlign_Top = 1 << 3,
13 | ImGuiAlign_VCenter = 1 << 4,
14 | ImGuiAlign_Default = ImGuiAlign_Left | ImGuiAlign_Top
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImFontConfig.cs.cpp:
--------------------------------------------------------------------------------
1 | ImFontConfig::ImFontConfig()
2 | {
3 | FontData = NULL;
4 | FontDataSize = 0;
5 | FontDataOwnedByAtlas = true;
6 | FontNo = 0;
7 | SizePixels = 0.0f;
8 | OversampleH = 3;
9 | OversampleV = 1;
10 | PixelSnapH = false;
11 | GlyphExtraSpacing = ImVec2(0.0f, 0.0f);
12 | GlyphRanges = NULL;
13 | MergeMode = false;
14 | MergeGlyphCenterV = false;
15 | DstFont = NULL;
16 | memset(Name, 0, sizeof(Name));
17 | }
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiColorEditMode.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // color edit mode for ColorEdit*()
4 |
5 | // Enumeration for ColorEditMode()
6 | public enum ImGuiColorEditMode : int
7 | {
8 | ImGuiColorEditMode_UserSelect = -2,
9 | ImGuiColorEditMode_UserSelectShowButton = -1,
10 | ImGuiColorEditMode_RGB = 0,
11 | ImGuiColorEditMode_HSV = 1,
12 | ImGuiColorEditMode_HEX = 2
13 | };
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiSelectableFlagsPrivate.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System;
4 |
5 | [Flags]
6 | internal enum ImGuiSelectableFlagsPrivate_ : int
7 | {
8 | // NB: need to be in sync with last value of ImGuiSelectableFlags_
9 | ImGuiSelectableFlags_Menu = 1 << 3,
10 | ImGuiSelectableFlags_MenuItem = 1 << 4,
11 | ImGuiSelectableFlags_Disabled = 1 << 5,
12 | ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiGroupData.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // Stacked data for BeginGroup()/EndGroup()
4 | internal struct ImGuiGroupData
5 | {
6 | public ImVec2 BackupCursorPos;
7 | public ImVec2 BackupCursorMaxPos;
8 | public float BackupIndentX;
9 | public float BackupCurrentLineHeight;
10 | public float BackupCurrentLineTextBaseOffset;
11 | public float BackupLogLinePosY;
12 | public bool AdvanceCursor;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImU32.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | //public struct uint
4 | //{
5 | // public uint Value;
6 |
7 | // public uint(uint val)
8 | // {
9 | // Value = val;
10 | // }
11 |
12 | // public static implicit operator uint(uint val)
13 | // {
14 | // return val.Value;
15 | // }
16 |
17 | // public static implicit operator uint(uint val)
18 | // {
19 | // return new uint(val);
20 | // }
21 | //}
22 | }
23 |
--------------------------------------------------------------------------------
/ImGuiSharp.MonoGame.Windows/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ImGui.MonoGame
4 | {
5 | #if WINDOWS || LINUX
6 | ///
7 | /// The main class.
8 | ///
9 | public static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | using (var game = new Game1())
18 | game.Run();
19 | }
20 | }
21 | #endif
22 | }
23 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/C.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImGui
8 | {
9 | public unsafe static class C
10 | {
11 | public static void memcpy(byte* destination, byte* source, uint length)
12 | {
13 | var index = 0;
14 | while (index < length)
15 | {
16 | destination[index] = source[index];
17 | index++;
18 | }
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiSimpleColumns.cs.h:
--------------------------------------------------------------------------------
1 | // Simple column measurement currently used for MenuItem() only. This is very short-sighted for now and NOT a generic helper.
2 | struct IMGUI_API ImGuiSimpleColumns
3 | {
4 | int Count;
5 | float Spacing;
6 | float Width, NextWidth;
7 | float Pos[8], NextWidths[8];
8 |
9 | ImGuiSimpleColumns();
10 | void Update(int count, float spacing, bool clear);
11 | float DeclColumns(float w0, float w1, float w2);
12 | float CalcExtraSpace(float avail_w);
13 | };
--------------------------------------------------------------------------------
/ImGui_CPP/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 |
3 | os:
4 | - linux
5 | - osx
6 |
7 | compiler:
8 | - gcc
9 | - clang
10 |
11 | before_install:
12 | - if [ $TRAVIS_OS_NAME == linux ]; then sudo add-apt-repository -y ppa:pyglfw/pyglfw && sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends libglfw3-dev libxrandr-dev libxi-dev libxxf86vm-dev; fi
13 | - if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
14 |
15 | script:
16 | - make -C examples/opengl_example
17 | - make -C examples/opengl3_example
18 |
19 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawCallback.cs.h:
--------------------------------------------------------------------------------
1 | // Draw callbacks for advanced uses.
2 | // NB- You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering (you can poke into the draw list for that)
3 | // Draw callback may be useful for example, if you want to render a complex 3D scene inside a UI element, change your GPU render state, etc.
4 | // The expected behavior from your rendering loop is:
5 | // if (cmd.UserCallback != NULL)
6 | // cmd.UserCallback(parent_list, cmd);
7 | // else
8 | // RenderTriangles()
9 | typedef void(*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd);
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawVert.cs.h:
--------------------------------------------------------------------------------
1 | // Vertex layout
2 | #ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
3 | struct ImDrawVert
4 | {
5 | ImVec2 pos;
6 | ImVec2 uv;
7 | uint col;
8 | };
9 | #else
10 | // You can override the vertex format layout by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h
11 | // The code expect ImVec2 pos (8 bytes), ImVec2 uv (8 bytes), uint col (4 bytes), but you can re-order them or add other fields as needed to simplify integration in your engine.
12 | // The type has to be described within the macro (you can either declare the struct or use a typedef)
13 | IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT;
14 | #endif
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawIdx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImGui
8 | {
9 | public struct ImDrawIdx
10 | {
11 | public ushort Value;
12 |
13 | public ImDrawIdx(ushort val)
14 | {
15 | Value = val;
16 | }
17 |
18 | public static implicit operator ushort(ImDrawIdx val)
19 | {
20 | return val.Value;
21 | }
22 |
23 | public static implicit operator ImDrawIdx(ushort val)
24 | {
25 | return new ImDrawIdx(val);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiPopupRef.cs.h:
--------------------------------------------------------------------------------
1 | // Storage for current popup stack
2 | struct ImGuiPopupRef
3 | {
4 | uint PopupID; // Set on OpenPopup()
5 | ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
6 | ImGuiWindow* ParentWindow; // Set on OpenPopup()
7 | uint ParentMenuSet; // Set on OpenPopup()
8 | ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup
9 |
10 | ImGuiPopupRef(uint id, ImGuiWindow* parent_window, uint parent_menu_set, const ImVec2& mouse_pos) { PopupID = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
11 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawChannel.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // Temporary storage for outputting drawing commands out of order, used by ImDrawList::ChannelsSplit()
4 | // Draw channels are used by the Columns API to "split" the render list into different channels while building, so items of each column can be batched together.
5 | // You can also use them to simulate drawing layers and submit primitives in a different order than how they will be rendered.
6 | internal class ImDrawChannel
7 | {
8 | internal ImVector CmdBuffer { get; private set; } = new ImVector();
9 | internal ImVector IdxBuffer { get; private set; } = new ImVector();
10 | };
11 | }
12 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiMouseCursor.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // a mouse cursor identifier
4 |
5 | // Enumeration for GetMouseCursor()
6 | public enum ImGuiMouseCursor : int
7 | {
8 | ImGuiMouseCursor_Arrow = 0,
9 | ImGuiMouseCursor_TextInput, // When hovering over InputText, etc.
10 | ImGuiMouseCursor_Move, // Unused
11 | ImGuiMouseCursor_ResizeNS, // Unused
12 | ImGuiMouseCursor_ResizeEW, // When hovering over a column
13 | ImGuiMouseCursor_ResizeNESW, // Unused
14 | ImGuiMouseCursor_ResizeNWSE, // When hovering over the bottom-right corner of a window
15 | ImGuiMouseCursor_Count_
16 | };
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImVec4.cs.h:
--------------------------------------------------------------------------------
1 | struct ImVec4
2 | {
3 | float x, y, z, w;
4 | ImVec4() { x = y = z = w = 0.0f; }
5 | ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; }
6 | #ifdef IM_VEC4_CLASS_EXTRA // Define constructor and implicit cast operators in imconfig.h to convert back<>forth from your math types and ImVec4.
7 | IM_VEC4_CLASS_EXTRA
8 | #endif
9 | };
10 |
11 | // Helpers: Math
12 | // We are keeping those not leaking to the user by default, in the case the user has implicit cast operators between ImVec2 and its own types (when IM_VEC2_CLASS_EXTRA is defined)
13 | #ifdef IMGUI_DEFINE_MATH_OPERATORS
14 | static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z, lhs.w - rhs.w); }
15 | #endif
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiSetCond.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System;
4 | // condition flags for Set*()
5 |
6 | // Condition flags for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
7 | // All those functions treat 0 as a shortcut to ImGuiSetCond_Always
8 | [Flags]
9 | public enum ImGuiSetCond : int
10 | {
11 | ImGuiSetCond_Always = 1 << 0, // Set the variable
12 | ImGuiSetCond_Once = 1 << 1, // Only set the variable on the first call per runtime session
13 | ImGuiSetCond_FirstUseEver = 1 << 2, // Only set the variable if the window doesn't exist in the .ini file
14 | ImGuiSetCond_Appearing = 1 << 3 // Only set the variable if the window is appearing after being inactive (or the first time)
15 | };
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiID.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImGui
3 | {
4 | //public struct uint //: uint
5 | //{
6 | // public uint Value;
7 |
8 | // public uint(uint val)
9 | // {
10 | // Value = val;
11 | // }
12 |
13 | // public static implicit operator uint(uint val)
14 | // {
15 | // return val.Value;
16 | // }
17 |
18 | // public static implicit operator uint(uint val)
19 | // {
20 | // return new uint(val);
21 | // }
22 |
23 | // //public static implicit operator uint(uint val)
24 | // //{
25 | // // return new uint(val.Value.Value);
26 | // //}
27 |
28 | // //public static implicit operator uint(uint val)
29 | // //{
30 | // // return new uint(val.Value);
31 | // //}
32 | //}
33 | }
34 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiOnceUponAFrame.cs.h:
--------------------------------------------------------------------------------
1 | // Helper: execute a block of code at maximum once a frame
2 | // Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame.
3 | // Usage:
4 | // IMGUI_ONCE_UPON_A_FRAME
5 | // {
6 | // // code block will be executed one per frame
7 | // }
8 | // Attention! the macro expands into 2 statement so make sure you don't use it within e.g. an if() statement without curly braces.
9 | #define IMGUI_ONCE_UPON_A_FRAME static ImGuiOnceUponAFrame imgui_oaf##__LINE__; if (imgui_oaf##__LINE__)
10 | struct ImGuiOnceUponAFrame
11 | {
12 | ImGuiOnceUponAFrame() { RefFrame = -1; }
13 | mutable int RefFrame;
14 | operator bool() const { int current_frame = ImGui::GetFrameCount(); if (RefFrame == current_frame) return false; RefFrame = current_frame; return true; }
15 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiTextBuffer.cs.h:
--------------------------------------------------------------------------------
1 | // Helper: Text buffer for logging/accumulating text
2 | struct ImGuiTextBuffer
3 | {
4 | ImVector Buf;
5 |
6 | ImGuiTextBuffer() { Buf.push_back(0); }
7 | inline char operator[](int i) { return Buf.Data[i]; }
8 | const char* begin() const { return &Buf.front(); }
9 | const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator
10 | int size() const { return Buf.Size - 1; }
11 | bool empty() { return Buf.Size <= 1; }
12 | void clear() { Buf.clear(); Buf.push_back(0); }
13 | const char* c_str() const { return Buf.Data; }
14 | IMGUI_API void append(const char* fmt, ...) IM_PRINTFARGS(2);
15 | IMGUI_API void appendv(const char* fmt, va_list args);
16 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiSelectableFlags.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System;
4 | // flags for Selectable()
5 |
6 | // Flags for ImGui::Selectable()
7 | [Flags]
8 | public enum ImGuiSelectableFlags : int
9 | {
10 | // Default: 0
11 | ImGuiSelectableFlags_DontClosePopups = 1 << 0, // Clicking this don't close parent popup window
12 | ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // Selectable frame can span all columns (text will still fit in current column)
13 | ImGuiSelectableFlags_AllowDoubleClick = 1 << 2, // Generate press events on double clicks too
14 |
15 | ImGuiSelectableFlags_Menu = 1 << 3,
16 | ImGuiSelectableFlags_MenuItem = 1 << 4,
17 | ImGuiSelectableFlags_Disabled = 1 << 5,
18 | ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6
19 | };
20 | }
21 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiPopupRef.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // Storage for current popup stack
4 | internal class ImGuiPopupRef
5 | {
6 | internal uint PopupID; // Set on OpenPopup()
7 | //ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
8 | internal ImGuiWindow Window;
9 | //ImGuiWindow ParentWindow; // Set on OpenPopup()
10 | internal ImGuiWindow ParentWindow;
11 | internal uint ParentMenuSet; // Set on OpenPopup()
12 | internal ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup
13 |
14 | internal ImGuiPopupRef(uint id, ImGuiWindow parent_window, uint parent_menu_set, ImVec2 mouse_pos) { PopupID = id; Window = null; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawCmd.cs.h:
--------------------------------------------------------------------------------
1 | // Typically, 1 command = 1 gpu draw call (unless command is a callback)
2 | struct ImDrawCmd
3 | {
4 | unsigned int ElemCount; // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
5 | ImVec4 ClipRect; // Clipping rectangle (x1, y1, x2, y2)
6 | ImTextureID TextureId; // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
7 | ImDrawCallback UserCallback; // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
8 | void* UserCallbackData; // The draw callback code can access this.
9 |
10 | ImDrawCmd() { ElemCount = 0; ClipRect.x = ClipRect.y = -8192.0f; ClipRect.z = ClipRect.w = +8192.0f; TextureId = NULL; UserCallback = NULL; UserCallbackData = NULL; }
11 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGuiSharp.Shared.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 3bb0f0ac-52a6-4953-8b2e-8c7def3e9745
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiStyleVar.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImGui
8 | {
9 | // a variable identifier for styling
10 |
11 | // Enumeration for PushStyleVar() / PopStyleVar()
12 | // NB: the enum only refers to fields of ImGuiStyle() which makes sense to be pushed/poped in UI code. Feel free to add others.
13 | public enum ImGuiStyleVar : int
14 | {
15 | ImGuiStyleVar_Alpha, // float
16 | ImGuiStyleVar_WindowPadding, // ImVec2
17 | ImGuiStyleVar_WindowRounding, // float
18 | ImGuiStyleVar_WindowMinSize, // ImVec2
19 | ImGuiStyleVar_ChildWindowRounding, // float
20 | ImGuiStyleVar_FramePadding, // ImVec2
21 | ImGuiStyleVar_FrameRounding, // float
22 | ImGuiStyleVar_ItemSpacing, // ImVec2
23 | ImGuiStyleVar_ItemInnerSpacing, // ImVec2
24 | ImGuiStyleVar_IndentSpacing, // float
25 | ImGuiStyleVar_GrabMinSize // float
26 | };
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiButtonFlags.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System;
4 |
5 | [Flags]
6 | internal enum ImGuiButtonFlags : int
7 | {
8 | ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat
9 | ImGuiButtonFlags_PressedOnClick = 1 << 1, // return pressed on click (default requires click+release)
10 | ImGuiButtonFlags_PressedOnRelease = 1 << 2, // return pressed on release (default requires click+release)
11 | ImGuiButtonFlags_PressedOnDoubleClick = 1 << 3, // return pressed on double-click (default requires click+release)
12 | ImGuiButtonFlags_FlattenChilds = 1 << 4, // allow interaction even if a child window is overlapping
13 | ImGuiButtonFlags_DontClosePopups = 1 << 5, // disable automatically closing parent popup on press
14 | ImGuiButtonFlags_Disabled = 1 << 6, // disable interaction
15 | ImGuiButtonFlags_AlignTextBaseLine = 1 << 7, // vertically align button to match text baseline - ButtonEx() only
16 | ImGuiButtonFlags_NoKeyModifiers = 1 << 8 // disable interaction if a key modifier is held
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawData.cs.h:
--------------------------------------------------------------------------------
1 | // All draw data to render an ImGui frame
2 | struct ImDrawData
3 | {
4 | bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
5 | ImDrawList** CmdLists;
6 | int CmdListsCount;
7 | int TotalVtxCount; // For convenience, sum of all cmd_lists vtx_buffer.Size
8 | int TotalIdxCount; // For convenience, sum of all cmd_lists idx_buffer.Size
9 |
10 | // Functions
11 | ImDrawData() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; }
12 | IMGUI_API void DeIndexAllBuffers(); // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
13 | IMGUI_API void ScaleClipRects(const ImVec2& sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
14 | };
--------------------------------------------------------------------------------
/LICENSE.MD:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2015 Omar Cornut and ImGui contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ImGui_CPP/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2015 Omar Cornut and ImGui contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiKey.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImGui
3 | {
4 | // a key identifier (ImGui-side enum)
5 |
6 | // User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
7 | public enum ImGuiKey : int
8 | {
9 | ImGuiKey_Tab, // for tabbing through fields
10 | ImGuiKey_LeftArrow, // for text edit
11 | ImGuiKey_RightArrow,// for text edit
12 | ImGuiKey_UpArrow, // for text edit
13 | ImGuiKey_DownArrow, // for text edit
14 | ImGuiKey_PageUp,
15 | ImGuiKey_PageDown,
16 | ImGuiKey_Home, // for text edit
17 | ImGuiKey_End, // for text edit
18 | ImGuiKey_Delete, // for text edit
19 | ImGuiKey_Backspace, // for text edit
20 | ImGuiKey_Enter, // for text edit
21 | ImGuiKey_Escape, // for text edit
22 | ImGuiKey_A, // for text edit CTRL+A: select all
23 | ImGuiKey_C, // for text edit CTRL+C: copy
24 | ImGuiKey_V, // for text edit CTRL+V: paste
25 | ImGuiKey_X, // for text edit CTRL+X: cut
26 | ImGuiKey_Y, // for text edit CTRL+Y: redo
27 | ImGuiKey_Z, // for text edit CTRL+Z: undo
28 | ImGuiKey_COUNT
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiTextFilter.cs.h:
--------------------------------------------------------------------------------
1 | // Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
2 | struct ImGuiTextFilter
3 | {
4 | struct TextRange
5 | {
6 | const char* b;
7 | const char* e;
8 |
9 | TextRange() { b = e = NULL; }
10 | TextRange(const char* _b, const char* _e) { b = _b; e = _e; }
11 | const char* begin() const { return b; }
12 | const char* end() const { return e; }
13 | bool empty() const { return b == e; }
14 | char front() const { return *b; }
15 | static bool isblank(char c) { return c == ' ' || c == '\t'; }
16 | void trim_blanks() { while (b < e && isblank(*b)) b++; while (e > b && isblank(*(e - 1))) e--; }
17 | IMGUI_API void split(char separator, ImVector& out);
18 | };
19 |
20 | char InputBuf[256];
21 | ImVector Filters;
22 | int CountGrep;
23 |
24 | ImGuiTextFilter(const char* default_filter = "");
25 | void Clear() { InputBuf[0] = 0; Build(); }
26 | bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build
27 | bool PassFilter(const char* text, const char* text_end = NULL) const;
28 | bool IsActive() const { return !Filters.empty(); }
29 | IMGUI_API void Build();
30 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawCmd.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call)
4 | // Typically, 1 command = 1 gpu draw call (unless command is a callback)
5 | public struct ImDrawCmd
6 | {
7 | public uint ElemCount; // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
8 | public ImVec4 ClipRect; // Clipping rectangle (x1, y1, x2, y2)
9 | public ImTextureID TextureId; // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
10 | public ImDrawCallback UserCallback; // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
11 | public object UserCallbackData; // The draw callback code can access this.
12 |
13 | //public ImDrawCmd()
14 | //{
15 | // ElemCount = 0;
16 | // ClipRect.x = ClipRect.y = -8192.0f;
17 | // ClipRect.z = ClipRect.w = +8192.0f;
18 | // TextureId = 0;
19 | // UserCallback = null;
20 | // //UserCallbackData = null;
21 | //}
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiTextBuffer.cs.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // ImGuiTextBuffer
3 | //-----------------------------------------------------------------------------
4 |
5 | // On some platform vsnprintf() takes va_list by reference and modifies it.
6 | // va_copy is the 'correct' way to copy a va_list but Visual Studio prior to 2013 doesn't have it.
7 | #ifndef va_copy
8 | #define va_copy(dest, src) (dest = src)
9 | #endif
10 |
11 | // Helper: Text buffer for logging/accumulating text
12 | void ImGuiTextBuffer::appendv(const char* fmt, va_list args)
13 | {
14 | va_list args_copy;
15 | va_copy(args_copy, args);
16 |
17 | int len = vsnprintf(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass.
18 | if (len <= 0)
19 | return;
20 |
21 | const int write_off = Buf.Size;
22 | const int needed_sz = write_off + len;
23 | if (write_off + len >= Buf.Capacity)
24 | {
25 | int double_capacity = Buf.Capacity * 2;
26 | Buf.reserve(needed_sz > double_capacity ? needed_sz : double_capacity);
27 | }
28 |
29 | Buf.resize(needed_sz);
30 | ImFormatStringV(&Buf[write_off] - 1, len + 1, fmt, args_copy);
31 | }
32 |
33 | void ImGuiTextBuffer::append(const char* fmt, ...)
34 | {
35 | va_list args;
36 | va_start(args, fmt);
37 | appendv(fmt, args);
38 | va_end(args);
39 | }
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiTextFilter.cs:
--------------------------------------------------------------------------------
1 | //namespace ImGui
2 | //{
3 | // // Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
4 | // internal class ImGuiTextFilter
5 | // {
6 | // struct TextRange
7 | // {
8 | // int b;
9 | // int e;
10 |
11 | // //TextRange() { b = e = -1; }
12 | // TextRange(int _b, int _e) { b = _b; e = _e; }
13 | // int begin() { return b; }
14 | // int end() { return e; }
15 | // bool empty() { return b == e; }
16 | // char front() { return *b; }
17 | // static bool isblank(char c) { return c == ' ' || c == '\t'; }
18 | // void trim_blanks() { while (b < e && isblank(*b)) b++; while (e > b && isblank(*(e - 1))) e--; }
19 | // void split(char separator, ImVector @out);
20 | // };
21 |
22 | // char InputBuf[256];
23 | // ImVector Filters;
24 | // int CountGrep;
25 |
26 | // ImGuiTextFilter(int default_filter = "");
27 | // void Clear() { InputBuf[0] = 0; Build(); }
28 | // bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build
29 | // bool PassFilter(const char* text, const char* text_end = NULL) const;
30 | // bool IsActive() const { return !Filters.empty(); }
31 | // void Build();
32 | // }
33 | //}
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiTextBuffer.cs:
--------------------------------------------------------------------------------
1 | //namespace ImGui
2 | //{
3 | // // Helper: Text buffer for logging/accumulating text
4 | // public class ImGuiTextBuffer
5 | // {
6 | // public ImVector Buf;
7 |
8 | // public ImGuiTextBuffer()
9 | // {
10 | // Buf.push_back((char)0);
11 | // }
12 |
13 | // public char this[int i]
14 | // {
15 | // get { return Buf[i]; }
16 | // }
17 | // //const char* begin() const { return &Buf.front(); }
18 | // //const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator
19 | // public int size()
20 | // {
21 | // return Buf.Size - 1;
22 | // }
23 | // public bool empty()
24 | // {
25 | // return Buf.Size <= 1;
26 | // }
27 | // public void clear()
28 | // {
29 | // Buf.clear();
30 | // Buf.push_back((char)0);
31 | // }
32 |
33 | // public string c_str()
34 | // {
35 | // var data = new char[Buf.size()];
36 | // for (var i = 0; i < data.Length; i++)
37 | // data[i] = Buf[i];
38 | // return new string(data);
39 | // }
40 | // //void append(const char* fmt, ...) IM_PRINTFARGS(2);
41 | // //void appendv(const char* fmt, va_list args);
42 | // }
43 | //}
44 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiSimpleColumns.cs.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // ImGuiSimpleColumns
3 | //-----------------------------------------------------------------------------
4 |
5 | ImGuiSimpleColumns::ImGuiSimpleColumns()
6 | {
7 | Count = 0;
8 | Spacing = Width = NextWidth = 0.0f;
9 | memset(Pos, 0, sizeof(Pos));
10 | memset(NextWidths, 0, sizeof(NextWidths));
11 | }
12 |
13 | void ImGuiSimpleColumns::Update(int count, float spacing, bool clear)
14 | {
15 | IM_ASSERT(Count <= IM_ARRAYSIZE(Pos));
16 | Count = count;
17 | Width = NextWidth = 0.0f;
18 | Spacing = spacing;
19 | if (clear) memset(NextWidths, 0, sizeof(NextWidths));
20 | for (int i = 0; i < Count; i++)
21 | {
22 | if (i > 0 && NextWidths[i] > 0.0f)
23 | Width += Spacing;
24 | Pos[i] = (float)(int)Width;
25 | Width += NextWidths[i];
26 | NextWidths[i] = 0.0f;
27 | }
28 | }
29 |
30 | float ImGuiSimpleColumns::DeclColumns(float w0, float w1, float w2) // not using va_arg because they promote float to double
31 | {
32 | NextWidth = 0.0f;
33 | NextWidths[0] = ImMax(NextWidths[0], w0);
34 | NextWidths[1] = ImMax(NextWidths[1], w1);
35 | NextWidths[2] = ImMax(NextWidths[2], w2);
36 | for (int i = 0; i < 3; i++)
37 | NextWidth += NextWidths[i] + ((i > 0 && NextWidths[i] > 0.0f) ? Spacing : 0.0f);
38 | return ImMax(Width, NextWidth);
39 | }
40 |
41 | float ImGuiSimpleColumns::CalcExtraSpace(float avail_w)
42 | {
43 | return ImMax(0.0f, avail_w - Width);
44 | }
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawData.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImGui
3 | {
4 | // All draw command lists required to render the frame
5 | // All draw data to render an ImGui frame
6 | public class ImDrawData
7 | {
8 | public bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
9 | //public ImDrawList** CmdLists;
10 | public ImVector CmdLists;
11 | public int CmdListsCount;
12 | public int TotalVtxCount; // For convenience, sum of all cmd_lists vtx_buffer.Size
13 | public int TotalIdxCount; // For convenience, sum of all cmd_lists idx_buffer.Size
14 |
15 | // Functions
16 | public ImDrawData() {
17 | //CmdLists = new ImDrawList();
18 | Valid = false;
19 | CmdLists = null;
20 | CmdListsCount = TotalVtxCount = TotalIdxCount = 0;
21 | }
22 | //public void DeIndexAllBuffers(); // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
23 | //public void ScaleClipRects(ImVec2 sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ImGuiSharp AS-IS
2 |
3 | - Currently not maintained as the code has been used in another project and heavily modified. This code is put here AS-IS for other developers to use, alter or do whatever they see fit.
4 |
5 | [LICENSE](https://github.com/ocornut/imgui/blob/master/LICENSE) Will retain ImGui's license for the time being.
6 |
7 | Near completion of most of the port for ImGui to .NET. I would say I'm around the 90% mark and I'm currently working on the demo side to finish off any pieces I missed along the way. Here are some random points of interest.
8 | - Currently targeting MonoGame but I will remove this requirement to keep it in line with ImGui
9 | - Ported stb_textedited, may be useful for others looking for text input logic for .NET
10 | - Switched from stb truetype to freetype2
11 | - ~~The screen shot below is rendering around 0.7ms in release mode (albeit on a higher end pc).~~ Now down to <= 1ms in debug mode due to passing raw imgui data straight to buffers.
12 | - Still issues with input editing for sliders
13 | - ~~Pixel snapping issues causing things to appear blurry~~
14 | - ~~Minor issue with treeviews and retaining their state open properties when selecting other nodes~~
15 | - Appears to be an issue with the scaling to the window
16 | - ~~Code will be put up on GitHub in the near future~~
17 | - ~~Can not build for x64 due to SharpFont nuget package hard coding to x86 binaries with a TODO statement to fix it...~~
18 |
19 | 
20 |
--------------------------------------------------------------------------------
/ImGuiSharp.MonoGame.Windows/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ImGui.MonoGame.NET")]
9 | [assembly: AssemblyProduct("ImGui.MonoGame.NET")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("80412449-cbec-4bcd-8e4f-68946f006d05")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiListClipper.cs.h:
--------------------------------------------------------------------------------
1 | // Helper: Manually clip large list of items.
2 | // If you are displaying thousands of even spaced items and you have a random access to the list, you can perform clipping yourself to save on CPU.
3 | // Usage:
4 | // ImGuiListClipper clipper(count, ImGui::GetTextLineHeightWithSpacing());
5 | // for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) // display only visible items
6 | // ImGui::Text("line number %d", i);
7 | // clipper.End();
8 | // NB: 'count' is only used to clamp the result, if you don't know your count you can use INT_MAX
9 | struct ImGuiListClipper
10 | {
11 | float ItemsHeight;
12 | int ItemsCount, DisplayStart, DisplayEnd;
13 |
14 | ImGuiListClipper() { ItemsHeight = 0.0f; ItemsCount = DisplayStart = DisplayEnd = -1; }
15 | ImGuiListClipper(int count, float height) { ItemsCount = -1; Begin(count, height); }
16 | ~ImGuiListClipper() { IM_ASSERT(ItemsCount == -1); } // user forgot to call End()
17 |
18 | void Begin(int count, float height) // items_height: generally pass GetTextLineHeightWithSpacing() or GetItemsLineHeightWithSpacing()
19 | {
20 | IM_ASSERT(ItemsCount == -1);
21 | ItemsCount = count;
22 | ItemsHeight = height;
23 | ImGui::CalcListClipping(ItemsCount, ItemsHeight, &DisplayStart, &DisplayEnd); // calculate how many to clip/display
24 | ImGui::SetCursorPosY(ImGui::GetCursorPosY() + DisplayStart * ItemsHeight); // advance cursor
25 | }
26 | void End()
27 | {
28 | IM_ASSERT(ItemsCount >= 0);
29 | ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (ItemsCount - DisplayEnd) * ItemsHeight); // advance cursor
30 | ItemsCount = -1;
31 | }
32 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImFontConfig.cs.h:
--------------------------------------------------------------------------------
1 | struct ImFontConfig
2 | {
3 | void* FontData; // // TTF data
4 | int FontDataSize; // // TTF data size
5 | bool FontDataOwnedByAtlas; // true // TTF data ownership taken by the container ImFontAtlas (will delete memory itself). Set to true
6 | int FontNo; // 0 // Index of font within TTF file
7 | float SizePixels; // // Size in pixels for rasterizer
8 | int OversampleH, OversampleV; // 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
9 | bool PixelSnapH; // false // Align every character to pixel boundary (if enabled, set OversampleH/V to 1)
10 | ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs
11 | const ImWchar* GlyphRanges; // // List of Unicode range (2 value per range, values are inclusive, zero-terminated list)
12 | bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs).
13 | bool MergeGlyphCenterV; // false // When merging (multiple ImFontInput for one ImFont), vertically center new glyphs instead of aligning their baseline
14 |
15 | // [Internal]
16 | char Name[32]; // Name (strictly for debugging)
17 | ImFont* DstFont;
18 |
19 | IMGUI_API ImFontConfig();
20 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawData.cs.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // ImDrawData
3 | //-----------------------------------------------------------------------------
4 |
5 | // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
6 | void ImDrawData::DeIndexAllBuffers()
7 | {
8 | ImVector new_vtx_buffer;
9 | TotalVtxCount = TotalIdxCount = 0;
10 | for (int i = 0; i < CmdListsCount; i++)
11 | {
12 | ImDrawList* cmd_list = CmdLists[i];
13 | if (cmd_list->IdxBuffer.empty())
14 | continue;
15 | new_vtx_buffer.resize(cmd_list->IdxBuffer.Size);
16 | for (int j = 0; j < cmd_list->IdxBuffer.Size; j++)
17 | new_vtx_buffer[j] = cmd_list->VtxBuffer[cmd_list->IdxBuffer[j]];
18 | cmd_list->VtxBuffer.swap(new_vtx_buffer);
19 | cmd_list->IdxBuffer.resize(0);
20 | TotalVtxCount += cmd_list->VtxBuffer.Size;
21 | }
22 | }
23 |
24 | // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
25 | void ImDrawData::ScaleClipRects(const ImVec2& scale)
26 | {
27 | for (int i = 0; i < CmdListsCount; i++)
28 | {
29 | ImDrawList* cmd_list = CmdLists[i];
30 | for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
31 | {
32 | ImDrawCmd* cmd = &cmd_list->CmdBuffer[cmd_i];
33 | cmd->ClipRect = ImVec4(cmd->ClipRect.x * scale.x, cmd->ClipRect.y * scale.y, cmd->ClipRect.z * scale.x, cmd->ClipRect.w * scale.y);
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImVec2.cs.h:
--------------------------------------------------------------------------------
1 | struct ImVec2
2 | {
3 | float x, y;
4 | ImVec2() { x = y = 0.0f; }
5 | ImVec2(float _x, float _y) { x = _x; y = _y; }
6 | #ifdef IM_VEC2_CLASS_EXTRA // Define constructor and implicit cast operators in imconfig.h to convert back<>forth from your math types and ImVec2.
7 | IM_VEC2_CLASS_EXTRA
8 | #endif
9 | };
10 |
11 | // Helpers: Math
12 | // We are keeping those not leaking to the user by default, in the case the user has implicit cast operators between ImVec2 and its own types (when IM_VEC2_CLASS_EXTRA is defined)
13 | #ifdef IMGUI_DEFINE_MATH_OPERATORS
14 | static inline ImVec2 operator*(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x*rhs, lhs.y*rhs); }
15 | static inline ImVec2 operator/(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x / rhs, lhs.y / rhs); }
16 | static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x + rhs.x, lhs.y + rhs.y); }
17 | static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x - rhs.x, lhs.y - rhs.y); }
18 | static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
19 | static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x / rhs.x, lhs.y / rhs.y); }
20 | static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
21 | static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
22 | static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
23 | static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
24 | #endif
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImColor.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // Helper functions to create a color that can be converted to either u32 or float4
4 | public struct ImColor
5 | {
6 | public ImVec4 Value;
7 | public ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f / 255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
8 | public ImColor(uint rgba) { float sc = 1.0f / 255.0f; Value.x = (float)(rgba & 0xFF) * sc; Value.y = (float)((rgba >> 8) & 0xFF) * sc; Value.z = (float)((rgba >> 16) & 0xFF) * sc; Value.w = (float)(rgba >> 24) * sc; }
9 | public ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
10 | public ImColor(ImVec4 col) { Value = col; }
11 |
12 | public static implicit operator uint(ImColor value) { return ImGui.ColorConvertFloat4ToU32(value.Value); }
13 | public static implicit operator ImVec4(ImColor value) { return value.Value; }
14 | public static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r, g, b; ImGui.ColorConvertHSVtoRGB(h, s, v, out r, out g, out b); return new ImColor(r, g, b, a); }
15 |
16 | public void SetHSV(float h, float s, float v, float a = 1.0f) { ImGui.ColorConvertHSVtoRGB(h, s, v, out Value.x, out Value.y, out Value.z); Value.w = a; }
17 |
18 | //#define IM_COL32(R,G,B,A) (((uint)(A)<<24) | ((uint)(B)<<16) | ((uint)(G)<<8) | ((uint)(R)))
19 | public static ImColor White { get { return new ImColor(0xFFFFFFFF); } }
20 | public static ImColor Black { get { return new ImColor(0xFF000000); } }
21 | public static ImColor Transparent { get { return new ImColor(0x00000000); } }
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiTextEditState.cs.h:
--------------------------------------------------------------------------------
1 | // Internal state of the currently focused/edited text input box
2 | struct IMGUI_API ImGuiTextEditState
3 | {
4 | uint Id; // widget id owning the text state
5 | ImVector Text; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer.
6 | ImVector InitialText; // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
7 | ImVector TempTextBuffer;
8 | int CurLenA, CurLenW; // we need to maintain our buffer length in both UTF-8 and wchar format.
9 | int BufSizeA; // end-user buffer size
10 | float ScrollX;
11 | ImGuiStb::STB_TexteditState StbState;
12 | float CursorAnim;
13 | bool CursorFollow;
14 | bool SelectedAllMouseLock;
15 |
16 | ImGuiTextEditState() { memset(this, 0, sizeof(*this)); }
17 | void CursorAnimReset() { CursorAnim = -0.30f; } // After a user-input the cursor stays on for a while without blinking
18 | void CursorClamp() { StbState.cursor = ImMin(StbState.cursor, CurLenW); StbState.select_start = ImMin(StbState.select_start, CurLenW); StbState.select_end = ImMin(StbState.select_end, CurLenW); }
19 | bool HasSelection() const { return StbState.select_start != StbState.select_end; }
20 | void ClearSelection() { StbState.select_start = StbState.select_end = StbState.cursor; }
21 | void SelectAll() { StbState.select_start = 0; StbState.select_end = CurLenW; StbState.cursor = StbState.select_end; StbState.has_preferred_x = false; }
22 | void OnKeyPressed(int key);
23 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiCol.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // a color identifier for styling
4 |
5 | // Enumeration for PushStyleColor() / PopStyleColor()
6 | public enum ImGuiCol : int
7 | {
8 | ImGuiCol_Text,
9 | ImGuiCol_TextDisabled,
10 | ImGuiCol_WindowBg,
11 | ImGuiCol_ChildWindowBg,
12 | ImGuiCol_Border,
13 | ImGuiCol_BorderShadow,
14 | ImGuiCol_FrameBg, // Background of checkbox, radio button, plot, slider, text input
15 | ImGuiCol_FrameBgHovered,
16 | ImGuiCol_FrameBgActive,
17 | ImGuiCol_TitleBg,
18 | ImGuiCol_TitleBgCollapsed,
19 | ImGuiCol_TitleBgActive,
20 | ImGuiCol_MenuBarBg,
21 | ImGuiCol_ScrollbarBg,
22 | ImGuiCol_ScrollbarGrab,
23 | ImGuiCol_ScrollbarGrabHovered,
24 | ImGuiCol_ScrollbarGrabActive,
25 | ImGuiCol_ComboBg,
26 | ImGuiCol_CheckMark,
27 | ImGuiCol_SliderGrab,
28 | ImGuiCol_SliderGrabActive,
29 | ImGuiCol_Button,
30 | ImGuiCol_ButtonHovered,
31 | ImGuiCol_ButtonActive,
32 | ImGuiCol_Header,
33 | ImGuiCol_HeaderHovered,
34 | ImGuiCol_HeaderActive,
35 | ImGuiCol_Column,
36 | ImGuiCol_ColumnHovered,
37 | ImGuiCol_ColumnActive,
38 | ImGuiCol_ResizeGrip,
39 | ImGuiCol_ResizeGripHovered,
40 | ImGuiCol_ResizeGripActive,
41 | ImGuiCol_CloseButton,
42 | ImGuiCol_CloseButtonHovered,
43 | ImGuiCol_CloseButtonActive,
44 | ImGuiCol_PlotLines,
45 | ImGuiCol_PlotLinesHovered,
46 | ImGuiCol_PlotHistogram,
47 | ImGuiCol_PlotHistogramHovered,
48 | ImGuiCol_TextSelectedBg,
49 | ImGuiCol_TooltipBg,
50 | ImGuiCol_ModalWindowDarkening, // darken entire screen when a modal window is active
51 | ImGuiCol_COUNT
52 | };
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiSimpleColumns.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // Simple column measurement currently used for MenuItem() only. This is very short-sighted for now and NOT a generic helper.
4 | internal class ImGuiSimpleColumns
5 | {
6 | internal int Count;
7 | internal float Spacing;
8 | internal float Width, NextWidth;
9 | internal float[] Pos = new float[8];
10 | internal float[] NextWidths = new float[8];
11 |
12 | //ImGuiSimpleColumns();
13 | internal void Update(int count, float spacing, bool clear)
14 | {
15 | System.Diagnostics.Debug.Assert(Count <= Pos.Length);
16 | Count = count;
17 | Width = NextWidth = 0.0f;
18 | Spacing = spacing;
19 | if (clear)
20 | for (var i = 0; i < NextWidths.Length; i++)
21 | NextWidths[i] = 0;
22 |
23 | for (int i = 0; i < Count; i++)
24 | {
25 | if (i > 0 && NextWidths[i] > 0.0f)
26 | Width += Spacing;
27 | Pos[i] = (float)(int)Width;
28 | Width += NextWidths[i];
29 | NextWidths[i] = 0.0f;
30 | }
31 | }
32 | internal float DeclColumns(float w0, float w1, float w2)
33 | {
34 | NextWidth = 0.0f;
35 | NextWidths[0] = ImGui.Max(NextWidths[0], w0);
36 | NextWidths[1] = ImGui.Max(NextWidths[1], w1);
37 | NextWidths[2] = ImGui.Max(NextWidths[2], w2);
38 | for (int i = 0; i < 3; i++)
39 | NextWidth += NextWidths[i] + ((i > 0 && NextWidths[i] > 0.0f) ? Spacing : 0.0f);
40 | return ImGui.Max(Width, NextWidth);
41 | }
42 | internal float CalcExtraSpace(float avail_w)
43 | {
44 | return ImGui.Max(0.0f, avail_w - Width);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImColor.cs.h:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Draw List
3 | // Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList.
4 | //-----------------------------------------------------------------------------
5 |
6 | // Helpers macros to generate 32-bits encoded colors
7 | #define IM_COL32(R,G,B,A) (((uint)(A)<<24) | ((uint)(B)<<16) | ((uint)(G)<<8) | ((uint)(R)))
8 | #define IM_COL32_WHITE (0xFFFFFFFF)
9 | #define IM_COL32_BLACK (0xFF000000)
10 | #define IM_COL32_BLACK_TRANS (0x00000000) // Transparent black
11 |
12 | // ImColor() is just a helper that implicity converts to either uint (packed 4x1 byte) or ImVec4 (4x1 float)
13 | // None of the ImGui API are using ImColor directly but you can use it as a convenience to pass colors in either uint or ImVec4 formats.
14 | struct ImColor
15 | {
16 | ImVec4 Value;
17 |
18 | ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; }
19 | ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f / 255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
20 | ImColor(uint rgba) { float sc = 1.0f / 255.0f; Value.x = (float)(rgba & 0xFF) * sc; Value.y = (float)((rgba >> 8) & 0xFF) * sc; Value.z = (float)((rgba >> 16) & 0xFF) * sc; Value.w = (float)(rgba >> 24) * sc; }
21 | ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
22 | ImColor(const ImVec4& col) { Value = col; }
23 | inline operator uint() const { return ImGui::ColorConvertFloat4ToU32(Value); }
24 | inline operator ImVec4() const { return Value; }
25 |
26 | inline void SetHSV(float h, float s, float v, float a = 1.0f) { ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; }
27 |
28 | static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r, g, b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r, g, b, a); }
29 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiListClipper.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImGui
3 | {
4 | // Helper: Manually clip large list of items.
5 | // If you are displaying thousands of even spaced items and you have a random access to the list, you can perform clipping yourself to save on CPU.
6 | // Usage:
7 | // ImGuiListClipper clipper(count, ImGui::GetTextLineHeightWithSpacing());
8 | // for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) // display only visible items
9 | // ImGui::Text("line number %d", i);
10 | // clipper.End();
11 | // NB: 'count' is only used to clamp the result, if you don't know your count you can use INT_MAX
12 | internal class ImGuiListClipper
13 | {
14 | internal float ItemsHeight;
15 | internal int ItemsCount, DisplayStart, DisplayEnd;
16 |
17 | internal ImGuiListClipper() { ItemsHeight = 0.0f; ItemsCount = DisplayStart = DisplayEnd = -1; }
18 | internal ImGuiListClipper(int count, float height) { ItemsCount = -1; Begin(count, height); }
19 | ~ImGuiListClipper() { System.Diagnostics.Debug.Assert(ItemsCount == -1); } // user forgot to call End()
20 |
21 | internal void Begin(int count, float height) // items_height: generally pass GetTextLineHeightWithSpacing() or GetItemsLineHeightWithSpacing()
22 | {
23 | System.Diagnostics.Debug.Assert(ItemsCount == -1);
24 | ItemsCount = count;
25 | ItemsHeight = height;
26 | ImGui.Instance.CalcListClipping(ItemsCount, ItemsHeight, ref DisplayStart, ref DisplayEnd); // calculate how many to clip/display
27 | ImGui.Instance.SetCursorPosY(ImGui.Instance.GetCursorPosY() + DisplayStart * ItemsHeight); // advance cursor
28 | }
29 | internal void End()
30 | {
31 | System.Diagnostics.Debug.Assert(ItemsCount >= 0);
32 | ImGui.Instance.SetCursorPosY(ImGui.Instance.GetCursorPosY() + (ItemsCount - DisplayEnd) * ItemsHeight); // advance cursor
33 | ItemsCount = -1;
34 | }
35 | };
36 | }
37 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiTextEditCallbackData.cs.h:
--------------------------------------------------------------------------------
1 | // Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used and the corresponding callback is triggered.
2 | struct ImGuiTextEditCallbackData
3 | {
4 | ImGuiInputTextFlags EventFlag; // One of ImGuiInputTextFlags_Callback* // Read-only
5 | ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only
6 | void* UserData; // What user passed to InputText() // Read-only
7 | bool ReadOnly; // Read-only mode // Read-only
8 |
9 | // CharFilter event:
10 | ImWchar EventChar; // Character input // Read-write (replace character or set to zero)
11 |
12 | // Completion,History,Always events:
13 | // If you modify the buffer contents make sure you update 'BufTextLen' and set 'BufDirty' to true.
14 | ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only
15 | char* Buf; // Current text buffer // Read-write (pointed data only, can't replace the actual pointer)
16 | int BufTextLen; // Current text length in bytes // Read-write
17 | int BufSize; // Maximum text length in bytes // Read-only
18 | bool BufDirty; // Set if you modify Buf/BufTextLen!! // Write
19 | int CursorPos; // // Read-write
20 | int SelectionStart; // // Read-write (== to SelectionEnd when no selection)
21 | int SelectionEnd; // // Read-write
22 |
23 | // NB: Helper functions for text manipulation. Calling those function loses selection.
24 | void DeleteChars(int pos, int bytes_count);
25 | void InsertChars(int pos, const char* text, const char* text_end = NULL);
26 | bool HasSelection() const { return SelectionStart != SelectionEnd; }
27 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiIO.cs.cpp:
--------------------------------------------------------------------------------
1 | ImGuiIO::ImGuiIO()
2 | {
3 | // Most fields are initialized with zero
4 | memset(this, 0, sizeof(*this));
5 |
6 | DisplaySize = ImVec2(-1.0f, -1.0f);
7 | DeltaTime = 1.0f / 60.0f;
8 | IniSavingRate = 5.0f;
9 | IniFilename = "imgui.ini";
10 | LogFilename = "imgui_log.txt";
11 | Fonts = &GImDefaultFontAtlas;
12 | FontGlobalScale = 1.0f;
13 | DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
14 | MousePos = ImVec2(-1, -1);
15 | MousePosPrev = ImVec2(-1, -1);
16 | MouseDoubleClickTime = 0.30f;
17 | MouseDoubleClickMaxDist = 6.0f;
18 | MouseDragThreshold = 6.0f;
19 | for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++)
20 | MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
21 | for (int i = 0; i < IM_ARRAYSIZE(KeysDownDuration); i++)
22 | KeysDownDuration[i] = KeysDownDurationPrev[i] = -1.0f;
23 | for (int i = 0; i < ImGuiKey_COUNT; i++)
24 | KeyMap[i] = -1;
25 | KeyRepeatDelay = 0.250f;
26 | KeyRepeatRate = 0.050f;
27 | UserData = NULL;
28 |
29 | // User functions
30 | RenderDrawListsFn = NULL;
31 | MemAllocFn = malloc;
32 | MemFreeFn = free;
33 | GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
34 | SetClipboardTextFn = SetClipboardTextFn_DefaultImpl;
35 | ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl;
36 | }
37 |
38 | // Pass in translated ASCII characters for text input.
39 | // - with glfw you can get those from the callback set in glfwSetCharCallback()
40 | // - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message
41 | void ImGuiIO::AddInputCharacter(ImWchar c)
42 | {
43 | const int n = ImStrlenW(InputCharacters);
44 | if (n + 1 < IM_ARRAYSIZE(InputCharacters))
45 | {
46 | InputCharacters[n] = c;
47 | InputCharacters[n + 1] = '\0';
48 | }
49 | }
50 |
51 | void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
52 | {
53 | // We can't pass more wchars than ImGuiIO::InputCharacters[] can hold so don't convert more
54 | const int wchars_buf_len = sizeof(ImGuiIO::InputCharacters) / sizeof(ImWchar);
55 | ImWchar wchars[wchars_buf_len];
56 | ImTextStrFromUtf8(wchars, wchars_buf_len, utf8_chars, NULL);
57 | for (int i = 0; i < wchars_buf_len && wchars[i] != 0; i++)
58 | AddInputCharacter(wchars[i]);
59 | }
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiInputTextFlags.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System;
4 | // flags for InputText*()
5 |
6 | // Flags for ImGui::InputText()
7 | [Flags]
8 | public enum ImGuiInputTextFlags : int
9 | {
10 | // Default: 0
11 | ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/
12 | ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
13 | ImGuiInputTextFlags_CharsUppercase = 1 << 2, // Turn a..z into A..Z
14 | ImGuiInputTextFlags_CharsNoBlank = 1 << 3, // Filter out spaces, tabs
15 | ImGuiInputTextFlags_AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus
16 | ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to when the value was modified)
17 | ImGuiInputTextFlags_CallbackCompletion = 1 << 6, // Call user function on pressing TAB (for completion handling)
18 | ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Call user function on pressing Up/Down arrows (for history handling)
19 | ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Call user function every time. User code may query cursor position, modify text buffer.
20 | ImGuiInputTextFlags_CallbackCharFilter = 1 << 9, // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
21 | ImGuiInputTextFlags_AllowTabInput = 1 << 10, // Pressing TAB input a '\t' character into the text field
22 | ImGuiInputTextFlags_CtrlEnterForNewLine = 1 << 11, // In multi-line mode, allow exiting edition by pressing Enter. Ctrl+Enter to add new line (by default adds new lines with Enter).
23 | ImGuiInputTextFlags_NoHorizontalScroll = 1 << 12, // Disable following the cursor horizontally
24 | ImGuiInputTextFlags_AlwaysInsertMode = 1 << 13, // Insert mode
25 | ImGuiInputTextFlags_ReadOnly = 1 << 14, // Read-only mode
26 | ImGuiInputTextFlags_Password = 1 << 15, // Password mode, display all characters as '*'
27 | // [Internal]
28 | ImGuiInputTextFlags_Multiline = 1 << 20 // For internal use by InputTextMultiline()
29 | };
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiWindow.cs.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // ImGuiWindow
3 | //-----------------------------------------------------------------------------
4 |
5 | ImGuiWindow::ImGuiWindow(const char* name)
6 | {
7 | Name = ImStrdup(name);
8 | ID = ImHash(name, 0);
9 | IDStack.push_back(ID);
10 | MoveID = GetID("#MOVE");
11 |
12 | Flags = 0;
13 | PosFloat = Pos = ImVec2(0.0f, 0.0f);
14 | Size = SizeFull = ImVec2(0.0f, 0.0f);
15 | SizeContents = SizeContentsExplicit = ImVec2(0.0f, 0.0f);
16 | WindowPadding = ImVec2(0.0f, 0.0f);
17 | Scroll = ImVec2(0.0f, 0.0f);
18 | ScrollTarget = ImVec2(FLT_MAX, FLT_MAX);
19 | ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f);
20 | ScrollbarX = ScrollbarY = false;
21 | ScrollbarSizes = ImVec2(0.0f, 0.0f);
22 | BorderSize = 0.0f;
23 | Active = WasActive = false;
24 | Accessed = false;
25 | Collapsed = false;
26 | SkipItems = false;
27 | BeginCount = 0;
28 | PopupID = 0;
29 | AutoFitFramesX = AutoFitFramesY = -1;
30 | AutoFitOnlyGrows = false;
31 | AutoPosLastDirection = -1;
32 | HiddenFrames = 0;
33 | SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiSetCond_Always | ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver | ImGuiSetCond_Appearing;
34 | SetWindowPosCenterWanted = false;
35 |
36 | LastFrameActive = -1;
37 | ItemWidthDefault = 0.0f;
38 | FontWindowScale = 1.0f;
39 |
40 | DrawList = (ImDrawList*)ImGui::MemAlloc(sizeof(ImDrawList));
41 | IM_PLACEMENT_NEW(DrawList) ImDrawList();
42 | DrawList->_OwnerName = Name;
43 | RootWindow = NULL;
44 | RootNonPopupWindow = NULL;
45 |
46 | FocusIdxAllCounter = FocusIdxTabCounter = -1;
47 | FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = IM_INT_MAX;
48 | FocusIdxAllRequestNext = FocusIdxTabRequestNext = IM_INT_MAX;
49 | }
50 |
51 | ImGuiWindow::~ImGuiWindow()
52 | {
53 | DrawList->~ImDrawList();
54 | ImGui::MemFree(DrawList);
55 | DrawList = NULL;
56 | ImGui::MemFree(Name);
57 | Name = NULL;
58 | }
59 |
60 | uint ImGuiWindow::GetID(const char* str, const char* str_end)
61 | {
62 | uint seed = IDStack.back();
63 | uint id = ImHash(str, str_end ? (int)(str_end - str) : 0, seed);
64 | ImGui::KeepAliveID(id);
65 | return id;
66 | }
67 |
68 | uint ImGuiWindow::GetID(const void* ptr)
69 | {
70 | uint seed = IDStack.back();
71 | uint id = ImHash(&ptr, sizeof(void*), seed);
72 | ImGui::KeepAliveID(id);
73 | return id;
74 | }
--------------------------------------------------------------------------------
/ImGui_CPP/imconfig.h:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // USER IMPLEMENTATION
3 | // This file contains compile-time options for ImGui.
4 | // Other options (memory allocation overrides, callbacks, etc.) can be set at runtime via the ImGuiIO structure - ImGui::GetIO().
5 | //-----------------------------------------------------------------------------
6 |
7 | #pragma once
8 |
9 | //---- Define assertion handler. Defaults to calling assert().
10 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
11 |
12 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
13 | //#define IMGUI_API __declspec( dllexport )
14 | //#define IMGUI_API __declspec( dllimport )
15 |
16 | //---- Include imgui_user.h at the end of imgui.h
17 | //#define IMGUI_INCLUDE_IMGUI_USER_H
18 |
19 | //---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
20 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
21 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS
22 |
23 | //---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty)
24 | //#define IMGUI_DISABLE_TEST_WINDOWS
25 |
26 | //---- Don't define obsolete functions names
27 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
28 |
29 | //---- Implement STB libraries in a namespace to avoid conflicts
30 | //#define IMGUI_STB_NAMESPACE ImGuiStb
31 |
32 | //---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
33 | /*
34 | #define IM_VEC2_CLASS_EXTRA \
35 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
36 | operator MyVec2() const { return MyVec2(x,y); }
37 |
38 | #define IM_VEC4_CLASS_EXTRA \
39 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
40 | operator MyVec4() const { return MyVec4(x,y,z,w); }
41 | */
42 |
43 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
44 | //---- e.g. create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers.
45 | /*
46 | namespace ImGui
47 | {
48 | void Value(const char* prefix, const MyMatrix44& v, const char* float_format = NULL);
49 | }
50 | */
51 |
52 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiTextFilter.cs.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // ImGuiTextFilter
3 | //-----------------------------------------------------------------------------
4 |
5 | // Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
6 | ImGuiTextFilter::ImGuiTextFilter(const char* default_filter)
7 | {
8 | if (default_filter)
9 | {
10 | ImFormatString(InputBuf, IM_ARRAYSIZE(InputBuf), "%s", default_filter);
11 | Build();
12 | }
13 | else
14 | {
15 | InputBuf[0] = 0;
16 | CountGrep = 0;
17 | }
18 | }
19 |
20 | bool ImGuiTextFilter::Draw(const char* label, float width)
21 | {
22 | if (width != 0.0f)
23 | ImGui::PushItemWidth(width);
24 | bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
25 | if (width != 0.0f)
26 | ImGui::PopItemWidth();
27 | if (value_changed)
28 | Build();
29 | return value_changed;
30 | }
31 |
32 | void ImGuiTextFilter::TextRange::split(char separator, ImVector& out)
33 | {
34 | out.resize(0);
35 | const char* wb = b;
36 | const char* we = wb;
37 | while (we < e)
38 | {
39 | if (*we == separator)
40 | {
41 | out.push_back(TextRange(wb, we));
42 | wb = we + 1;
43 | }
44 | we++;
45 | }
46 | if (wb != we)
47 | out.push_back(TextRange(wb, we));
48 | }
49 |
50 | void ImGuiTextFilter::Build()
51 | {
52 | Filters.resize(0);
53 | TextRange input_range(InputBuf, InputBuf + strlen(InputBuf));
54 | input_range.split(',', Filters);
55 |
56 | CountGrep = 0;
57 | for (int i = 0; i != Filters.Size; i++)
58 | {
59 | Filters[i].trim_blanks();
60 | if (Filters[i].empty())
61 | continue;
62 | if (Filters[i].front() != '-')
63 | CountGrep += 1;
64 | }
65 | }
66 |
67 | bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
68 | {
69 | if (Filters.empty())
70 | return true;
71 |
72 | if (text == NULL)
73 | text = "";
74 |
75 | for (int i = 0; i != Filters.Size; i++)
76 | {
77 | const TextRange& f = Filters[i];
78 | if (f.empty())
79 | continue;
80 | if (f.front() == '-')
81 | {
82 | // Subtract
83 | if (ImStristr(text, text_end, f.begin() + 1, f.end()) != NULL)
84 | return false;
85 | }
86 | else
87 | {
88 | // Grep
89 | if (ImStristr(text, text_end, f.begin(), f.end()) != NULL)
90 | return true;
91 | }
92 | }
93 |
94 | // Implicit * grep
95 | if (CountGrep == 0)
96 | return true;
97 |
98 | return false;
99 | }
--------------------------------------------------------------------------------
/ImGui.NET.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{28F8251D-72A4-4941-9F44-7B34BCAD68CC}"
7 | ProjectSection(SolutionItems) = preProject
8 | ImGui_CPP\imconfig.h = ImGui_CPP\imconfig.h
9 | ImGui_CPP\imgui.cpp = ImGui_CPP\imgui.cpp
10 | ImGui_CPP\imgui.h = ImGui_CPP\imgui.h
11 | ImGui_CPP\imgui_demo.cpp = ImGui_CPP\imgui_demo.cpp
12 | ImGui_CPP\imgui_draw.cpp = ImGui_CPP\imgui_draw.cpp
13 | ImGui_CPP\imgui_internal.h = ImGui_CPP\imgui_internal.h
14 | ImGui_CPP\stb_rect_pack.h = ImGui_CPP\stb_rect_pack.h
15 | ImGui_CPP\stb_textedit.h = ImGui_CPP\stb_textedit.h
16 | ImGui_CPP\stb_truetype.h = ImGui_CPP\stb_truetype.h
17 | EndProjectSection
18 | EndProject
19 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ImGuiSharp.Shared", "ImGuiSharp.Shared\ImGuiSharp.Shared.shproj", "{3BB0F0AC-52A6-4953-8B2E-8C7DEF3E9745}"
20 | EndProject
21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImGuiSharp.MonoGame.Windows", "ImGuiSharp.MonoGame.Windows\ImGuiSharp.MonoGame.Windows.csproj", "{42AB25D4-D692-49CB-8B15-A37FFF296098}"
22 | EndProject
23 | Global
24 | GlobalSection(SharedMSBuildProjectFiles) = preSolution
25 | ImGuiSharp.Shared\ImGuiSharp.Shared.projitems*{3bb0f0ac-52a6-4953-8b2e-8c7def3e9745}*SharedItemsImports = 13
26 | ImGuiSharp.Shared\ImGuiSharp.Shared.projitems*{42ab25d4-d692-49cb-8b15-a37fff296098}*SharedItemsImports = 4
27 | EndGlobalSection
28 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
29 | Debug|x64 = Debug|x64
30 | Debug|x86 = Debug|x86
31 | Release|x64 = Release|x64
32 | Release|x86 = Release|x86
33 | EndGlobalSection
34 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
35 | {42AB25D4-D692-49CB-8B15-A37FFF296098}.Debug|x64.ActiveCfg = Debug|x64
36 | {42AB25D4-D692-49CB-8B15-A37FFF296098}.Debug|x64.Build.0 = Debug|x64
37 | {42AB25D4-D692-49CB-8B15-A37FFF296098}.Debug|x86.ActiveCfg = Debug|x86
38 | {42AB25D4-D692-49CB-8B15-A37FFF296098}.Debug|x86.Build.0 = Debug|x86
39 | {42AB25D4-D692-49CB-8B15-A37FFF296098}.Release|x64.ActiveCfg = Release|x64
40 | {42AB25D4-D692-49CB-8B15-A37FFF296098}.Release|x86.ActiveCfg = Release|x86
41 | {42AB25D4-D692-49CB-8B15-A37FFF296098}.Release|x86.Build.0 = Release|x86
42 | EndGlobalSection
43 | GlobalSection(SolutionProperties) = preSolution
44 | HideSolutionNode = FALSE
45 | EndGlobalSection
46 | EndGlobal
47 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImFontConfig.cs:
--------------------------------------------------------------------------------
1 | using SharpFont;
2 |
3 | namespace ImGui
4 | {
5 | // Configuration data when adding a font or merging fonts
6 | internal class ImFontConfig
7 | {
8 | internal Face Face;
9 | internal byte[] FontData; // // TTF data
10 | internal int FontDataSize; // // TTF data size
11 | internal bool FontDataOwnedByAtlas; // true // TTF data ownership taken by the container ImFontAtlas (will delete memory itself). Set to true
12 | internal int FontNo; // 0 // Index of font within TTF file
13 | internal float SizePixels; // // Size in pixels for rasterizer
14 | internal int OversampleH, OversampleV; // 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
15 | internal bool PixelSnapH; // false // Align every character to pixel boundary (if enabled, set OversampleH/V to 1)
16 | internal ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs
17 | internal char[] GlyphRanges; // // List of Unicode range (2 value per range, values are inclusive, zero-terminated list)
18 | internal bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs).
19 | internal bool MergeGlyphCenterV; // false // When merging (multiple ImFontInput for one ImFont), vertically center new glyphs instead of aligning their baseline
20 |
21 | // [Internal]
22 | internal string Name; // Name (strictly for debugging)
23 | internal ImFont DstFont;
24 |
25 | public ImFontConfig()
26 | {
27 | Face = null;
28 | FontData = null;
29 | FontDataSize = 0;
30 | FontDataOwnedByAtlas = true;
31 | FontNo = 0;
32 | SizePixels = 0.0f;
33 | OversampleH = 3;
34 | OversampleV = 1;
35 | PixelSnapH = false;
36 | GlyphExtraSpacing = new ImVec2(0.0f, 0.0f);
37 | GlyphRanges = null;
38 | MergeMode = false;
39 | MergeGlyphCenterV = false;
40 | DstFont = null;
41 | //memset(Name, 0, sizeof(Name));
42 | Name = null;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiStorage.cs.h:
--------------------------------------------------------------------------------
1 | // Helper: Key->value storage
2 | // - Store collapse state for a tree (Int 0/1)
3 | // - Store color edit options (Int using values in ImGuiColorEditMode enum).
4 | // - Custom user storage for temporary values.
5 | // Typically you don't have to worry about this since a storage is held within each Window.
6 | // Declare your own storage if:
7 | // - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state).
8 | // - You want to store custom debug data easily without adding or editing structures in your code.
9 | struct ImGuiStorage
10 | {
11 | struct Pair
12 | {
13 | uint key;
14 | union { int val_i; float val_f; void* val_p; };
15 | Pair(uint _key, int _val_i) { key = _key; val_i = _val_i; }
16 | Pair(uint _key, float _val_f) { key = _key; val_f = _val_f; }
17 | Pair(uint _key, void* _val_p) { key = _key; val_p = _val_p; }
18 | };
19 | ImVector Data;
20 |
21 | // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
22 | // - Set***() functions find pair, insertion on demand if missing.
23 | // - Sorted insertion is costly but should amortize. A typical frame shouldn't need to insert any new pair.
24 | IMGUI_API void Clear();
25 | IMGUI_API int GetInt(uint key, int default_val = 0) const;
26 | IMGUI_API void SetInt(uint key, int val);
27 | IMGUI_API float GetFloat(uint key, float default_val = 0.0f) const;
28 | IMGUI_API void SetFloat(uint key, float val);
29 | IMGUI_API void* GetVoidPtr(uint key) const; // default_val is NULL
30 | IMGUI_API void SetVoidPtr(uint key, void* val);
31 |
32 | // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set.
33 | // - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
34 | // - A typical use case where this is convenient:
35 | // float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
36 | // - You can also use this to quickly create temporary editable values during a session of using Edit&Continue, without restarting your application.
37 | IMGUI_API int* GetIntRef(uint key, int default_val = 0);
38 | IMGUI_API float* GetFloatRef(uint key, float default_val = 0);
39 | IMGUI_API void** GetVoidPtrRef(uint key, void* default_val = NULL);
40 |
41 | // Use on your own storage if you know only integer are being stored (open/close all tree nodes)
42 | IMGUI_API void SetAllInt(int val);
43 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImVec4.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System.Runtime.CompilerServices;
4 |
5 | public struct ImVec4
6 | {
7 | public float x, y, z, w;
8 | public ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; }
9 |
10 | public static bool operator ==(ImVec4 lhs, ImVec4 rhs) { return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z && lhs.w == rhs.w; }
11 | public static bool operator !=(ImVec4 lhs, ImVec4 rhs) { return lhs.x != rhs.x || lhs.y != rhs.y || lhs.z != rhs.z || lhs.w != rhs.w; }
12 | public static ImVec4 operator *(ImVec4 lhs, float rhs)
13 | {
14 | lhs.x *= rhs;
15 | lhs.y *= rhs;
16 | lhs.z *= rhs;
17 | lhs.w *= rhs;
18 | return lhs;
19 | }
20 | public static ImVec4 operator -(ImVec4 lhs, ImVec4 rhs) { return new ImVec4(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z, lhs.w - rhs.w); }
21 |
22 | public override int GetHashCode()
23 | {
24 | var hash = this.x.GetHashCode();
25 | hash = ImGui.CombineHashCodes(hash, y.GetHashCode());
26 | hash = ImGui.CombineHashCodes(hash, z.GetHashCode());
27 | hash = ImGui.CombineHashCodes(hash, w.GetHashCode());
28 | return hash;
29 | }
30 |
31 | ///
32 | /// Returns a boolean indicating whether the given Object is equal to this Vector3 instance.
33 | ///
34 | /// The Object to compare against.
35 | /// True if the Object is equal to this Vector3; False otherwise.
36 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
37 | public override bool Equals(object obj)
38 | {
39 | if (!(obj is ImVec4))
40 | return false;
41 | return Equals((ImVec4)obj);
42 | }
43 |
44 | ///
45 | /// Returns a boolean indicating whether the given Vector3 is equal to this Vector3 instance.
46 | ///
47 | /// The Vector3 to compare this instance to.
48 | /// True if the other Vector3 is equal to this instance; False otherwise.
49 | public bool Equals(ImVec4 other)
50 | {
51 | return x == other.x &&
52 | y == other.y &&
53 | z == other.z &&
54 | w == other.w;
55 | }
56 |
57 | public override string ToString()
58 | {
59 | return string.Format("{{ X: {0}, Y: {1}, Z: {2}, W: {3} }}", x, y, z, w);
60 | }
61 | };
62 | }
63 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiStyle.cs.h:
--------------------------------------------------------------------------------
1 | struct ImGuiStyle
2 | {
3 | float Alpha; // Global alpha applies to everything in ImGui
4 | ImVec2 WindowPadding; // Padding within a window
5 | ImVec2 WindowMinSize; // Minimum window size
6 | float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows
7 | ImGuiAlign WindowTitleAlign; // Alignment for title bar text
8 | float ChildWindowRounding; // Radius of child window corners rounding. Set to 0.0f to have rectangular windows
9 | ImVec2 FramePadding; // Padding within a framed rectangle (used by most widgets)
10 | float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
11 | ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines
12 | ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
13 | ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
14 | float WindowFillAlphaDefault; // Default alpha of window background, if not specified in ImGui::Begin()
15 | float IndentSpacing; // Horizontal indentation when e.g. entering a tree node
16 | float ColumnsMinSpacing; // Minimum horizontal spacing between two columns
17 | float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar
18 | float ScrollbarRounding; // Radius of grab corners for scrollbar
19 | float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar
20 | float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
21 | ImVec2 DisplayWindowPadding; // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
22 | ImVec2 DisplaySafeAreaPadding; // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
23 | bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
24 | bool AntiAliasedShapes; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
25 | float CurveTessellationTol; // Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
26 | ImVec4 Colors[ImGuiCol_COUNT];
27 |
28 | IMGUI_API ImGuiStyle();
29 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImRect.cs.h:
--------------------------------------------------------------------------------
1 | // 2D axis aligned bounding-box
2 | // NB: we can't rely on ImVec2 math operators being available here
3 | struct IMGUI_API ImRect
4 | {
5 | ImVec2 Min; // Upper-left
6 | ImVec2 Max; // Lower-right
7 |
8 | ImRect() : Min(FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX) {}
9 | ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {}
10 | ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {}
11 | ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {}
12 |
13 | ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x)*0.5f, (Min.y + Max.y)*0.5f); }
14 | ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); }
15 | float GetWidth() const { return Max.x - Min.x; }
16 | float GetHeight() const { return Max.y - Min.y; }
17 | ImVec2 GetTL() const { return Min; } // Top-left
18 | ImVec2 GetTR() const { return ImVec2(Max.x, Min.y); } // Top-right
19 | ImVec2 GetBL() const { return ImVec2(Min.x, Max.y); } // Bottom-left
20 | ImVec2 GetBR() const { return Max; } // Bottom-right
21 | bool Contains(const ImVec2& p) const { return p.x >= Min.x && p.y >= Min.y && p.x < Max.x && p.y < Max.y; }
22 | bool Contains(const ImRect& r) const { return r.Min.x >= Min.x && r.Min.y >= Min.y && r.Max.x < Max.x && r.Max.y < Max.y; }
23 | bool Overlaps(const ImRect& r) const { return r.Min.y < Max.y && r.Max.y > Min.y && r.Min.x < Max.x && r.Max.x > Min.x; }
24 | void Add(const ImVec2& rhs) { if (Min.x > rhs.x) Min.x = rhs.x; if (Min.y > rhs.y) Min.y = rhs.y; if (Max.x < rhs.x) Max.x = rhs.x; if (Max.y < rhs.y) Max.y = rhs.y; }
25 | void Add(const ImRect& rhs) { if (Min.x > rhs.Min.x) Min.x = rhs.Min.x; if (Min.y > rhs.Min.y) Min.y = rhs.Min.y; if (Max.x < rhs.Max.x) Max.x = rhs.Max.x; if (Max.y < rhs.Max.y) Max.y = rhs.Max.y; }
26 | void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
27 | void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
28 | void Reduce(const ImVec2& amount) { Min.x += amount.x; Min.y += amount.y; Max.x -= amount.x; Max.y -= amount.y; }
29 | void Clip(const ImRect& clip) { if (Min.x < clip.Min.x) Min.x = clip.Min.x; if (Min.y < clip.Min.y) Min.y = clip.Min.y; if (Max.x > clip.Max.x) Max.x = clip.Max.x; if (Max.y > clip.Max.y) Max.y = clip.Max.y; }
30 | void Round() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
31 | ImVec2 GetClosestPoint(ImVec2 p, bool on_edge) const
32 | {
33 | if (!on_edge && Contains(p))
34 | return p;
35 | if (p.x > Max.x) p.x = Max.x;
36 | else if (p.x < Min.x) p.x = Min.x;
37 | if (p.y > Max.y) p.y = Max.y;
38 | else if (p.y < Min.y) p.y = Min.y;
39 | return p;
40 | }
41 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImVec2.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System.Diagnostics;
4 | using System.Runtime.CompilerServices;
5 | using System.Runtime.InteropServices;
6 |
7 | [DebuggerDisplay("X: {x}, Y: {y}")]
8 | [StructLayout(LayoutKind.Sequential, Pack = 1)]
9 | public struct ImVec2
10 | {
11 | public float x, y;
12 | public ImVec2(float _x, float _y) { x = _x; y = _y; }
13 |
14 | public static ImVec2 Zero { get { return new ImVec2(0, 0); } }
15 | public static ImVec2 One { get { return new ImVec2(1, 1); } }
16 |
17 | public static bool operator ==(ImVec2 lhs, ImVec2 rhs) { return lhs.x == rhs.x && lhs.y == rhs.y; }
18 | public static bool operator !=(ImVec2 lhs, ImVec2 rhs) { return lhs.x != rhs.x || lhs.y != rhs.y; }
19 | public static ImVec2 operator *(ImVec2 lhs, float rhs) { return new ImVec2(lhs.x * rhs, lhs.y * rhs); }
20 | public static ImVec2 operator /(ImVec2 lhs, float rhs) { return new ImVec2(lhs.x / rhs, lhs.y / rhs); }
21 | public static ImVec2 operator +(ImVec2 lhs, ImVec2 rhs) { return new ImVec2(lhs.x + rhs.x, lhs.y + rhs.y); }
22 | public static ImVec2 operator -(ImVec2 lhs, ImVec2 rhs) { return new ImVec2(lhs.x - rhs.x, lhs.y - rhs.y); }
23 | public static ImVec2 operator *(ImVec2 lhs, ImVec2 rhs) { return new ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
24 | public static ImVec2 operator /(ImVec2 lhs, ImVec2 rhs) { return new ImVec2(lhs.x / rhs.x, lhs.y / rhs.y); }
25 |
26 | public override int GetHashCode()
27 | {
28 | var hash = this.x.GetHashCode();
29 | hash = ImGui.CombineHashCodes(hash, y.GetHashCode());
30 | return hash;
31 | }
32 |
33 | ///
34 | /// Returns a boolean indicating whether the given Object is equal to this Vector3 instance.
35 | ///
36 | /// The Object to compare against.
37 | /// True if the Object is equal to this Vector3; False otherwise.
38 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
39 | public override bool Equals(object obj)
40 | {
41 | if (!(obj is ImVec2))
42 | return false;
43 | return Equals((ImVec2)obj);
44 | }
45 |
46 | ///
47 | /// Returns a boolean indicating whether the given Vector3 is equal to this Vector3 instance.
48 | ///
49 | /// The Vector3 to compare this instance to.
50 | /// True if the other Vector3 is equal to this instance; False otherwise.
51 | public bool Equals(ImVec2 other)
52 | {
53 | return x == other.x &&
54 | y == other.y;
55 | }
56 |
57 | public override string ToString()
58 | {
59 | return string.Format("{{ X: {0}, Y: {1} }}", x, y);
60 | }
61 | };
62 | }
63 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiWindowFlags.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System;
4 |
5 | // window flags for Begin*()
6 |
7 | // Flags for ImGui::Begin()
8 | [Flags]
9 | public enum ImGuiWindowFlags : int
10 | {
11 | // Default: 0
12 | ImGuiWindowFlags_NoTitleBar = 1 << 0, // Disable title-bar
13 | ImGuiWindowFlags_NoResize = 1 << 1, // Disable user resizing with the lower-right grip
14 | ImGuiWindowFlags_NoMove = 1 << 2, // Disable user moving the window
15 | ImGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scrollbars (window can still scroll with mouse or programatically)
16 | ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user vertically scrolling with mouse wheel
17 | ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it
18 | ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame
19 | ImGuiWindowFlags_ShowBorders = 1 << 7, // Show borders around windows and items
20 | ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file
21 | ImGuiWindowFlags_NoInputs = 1 << 9, // Disable catching mouse or keyboard inputs
22 | ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar
23 | ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Allow horizontal scrollbar to appear (off by default). You need to use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
24 | ImGuiWindowFlags_NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state
25 | ImGuiWindowFlags_NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programatically giving it focus)
26 | ImGuiWindowFlags_AlwaysVerticalScrollbar = 1 << 14, // Always show vertical scrollbar (even if ContentSize.y < Size.y)
27 | ImGuiWindowFlags_ForceHorizontalScrollbar = 1 << 15, // Always show horizontal scrollbar (even if ContentSize.x < Size.x)
28 | // [Internal]
29 | ImGuiWindowFlags_ChildWindow = 1 << 20, // Don't use! For internal use by BeginChild()
30 | ImGuiWindowFlags_ChildWindowAutoFitX = 1 << 21, // Don't use! For internal use by BeginChild()
31 | ImGuiWindowFlags_ChildWindowAutoFitY = 1 << 22, // Don't use! For internal use by BeginChild()
32 | ImGuiWindowFlags_ComboBox = 1 << 23, // Don't use! For internal use by ComboBox()
33 | ImGuiWindowFlags_Tooltip = 1 << 24, // Don't use! For internal use by BeginTooltip()
34 | ImGuiWindowFlags_Popup = 1 << 25, // Don't use! For internal use by BeginPopup()
35 | ImGuiWindowFlags_Modal = 1 << 26, // Don't use! For internal use by BeginPopupModal()
36 | ImGuiWindowFlags_ChildMenu = 1 << 27 // Don't use! For internal use by BeginMenu()
37 | };
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImFont.cs.h:
--------------------------------------------------------------------------------
1 | // Font runtime data and rendering
2 | // ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
3 | struct ImFont
4 | {
5 | // Members: Settings
6 | float FontSize; // // Height of characters, set during loading (don't change after loading)
7 | float Scale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
8 | ImVec2 DisplayOffset; // = (0.0f,1.0f) // Offset font rendering by xx pixels
9 | ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
10 | ImFontConfig* ConfigData; // // Pointer within ImFontAtlas->ConfigData
11 | int ConfigDataCount; //
12 |
13 | // Members: Runtime data
14 | struct Glyph
15 | {
16 | ImWchar Codepoint;
17 | float XAdvance;
18 | float X0, Y0, X1, Y1;
19 | float U0, V0, U1, V1; // Texture coordinates
20 | };
21 | float Ascent, Descent; // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
22 | ImFontAtlas* ContainerAtlas; // What we has been loaded into
23 | ImVector Glyphs;
24 | const Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
25 | float FallbackXAdvance; //
26 | ImVector IndexXAdvance; // Sparse. Glyphs->XAdvance directly indexable (more cache-friendly that reading from Glyphs, for CalcTextSize functions which are often bottleneck in large UI)
27 | ImVector IndexLookup; // Sparse. Index glyphs by Unicode code-point.
28 |
29 | // Methods
30 | IMGUI_API ImFont();
31 | IMGUI_API ~ImFont();
32 | IMGUI_API void Clear();
33 | IMGUI_API void BuildLookupTable();
34 | IMGUI_API const Glyph* FindGlyph(unsigned short c) const;
35 | IMGUI_API void SetFallbackChar(ImWchar c);
36 | float GetCharAdvance(unsigned short c) const { return ((int)c < IndexXAdvance.Size) ? IndexXAdvance[(int)c] : FallbackXAdvance; }
37 | bool IsLoaded() const { return ContainerAtlas != NULL; }
38 |
39 | // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
40 | // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
41 | IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
42 | IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
43 | IMGUI_API void RenderText(float size, ImVec2 pos, uint col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawList* draw_list, float wrap_width = 0.0f, bool cpu_fine_clip = false) const;
44 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImVector.cs.h:
--------------------------------------------------------------------------------
1 | // Lightweight std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
2 | // Our implementation does NOT call c++ constructors because we don't use them in ImGui. Don't use this class as a straight std::vector replacement in your code!
3 | template
4 | class ImVector
5 | {
6 | public:
7 | int Size;
8 | int Capacity;
9 | T* Data;
10 |
11 | typedef T value_type;
12 | typedef value_type* iterator;
13 | typedef const value_type* const_iterator;
14 |
15 | ImVector() { Size = Capacity = 0; Data = NULL; }
16 | ~ImVector() { if (Data) ImGui::MemFree(Data); }
17 |
18 | inline bool empty() const { return Size == 0; }
19 | inline int size() const { return Size; }
20 | inline int capacity() const { return Capacity; }
21 |
22 | inline value_type& operator[](int i) { IM_ASSERT(i < Size); return Data[i]; }
23 | inline const value_type& operator[](int i) const { IM_ASSERT(i < Size); return Data[i]; }
24 |
25 | inline void clear() { if (Data) { Size = Capacity = 0; ImGui::MemFree(Data); Data = NULL; } }
26 | inline iterator begin() { return Data; }
27 | inline const_iterator begin() const { return Data; }
28 | inline iterator end() { return Data + Size; }
29 | inline const_iterator end() const { return Data + Size; }
30 | inline value_type& front() { IM_ASSERT(Size > 0); return Data[0]; }
31 | inline const value_type& front() const { IM_ASSERT(Size > 0); return Data[0]; }
32 | inline value_type& back() { IM_ASSERT(Size > 0); return Data[Size - 1]; }
33 | inline const value_type& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; }
34 | inline void swap(ImVector& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
35 |
36 | inline int _grow_capacity(int new_size) { int new_capacity = Capacity ? (Capacity + Capacity / 2) : 8; return new_capacity > new_size ? new_capacity : new_size; }
37 |
38 | inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
39 | inline void reserve(int new_capacity)
40 | {
41 | if (new_capacity <= Capacity) return;
42 | T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(value_type));
43 | memcpy(new_data, Data, (size_t)Size * sizeof(value_type));
44 | ImGui::MemFree(Data);
45 | Data = new_data;
46 | Capacity = new_capacity;
47 | }
48 |
49 | inline void push_back(const value_type& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); Data[Size++] = v; }
50 | inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
51 |
52 | inline iterator erase(const_iterator it) { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(value_type)); Size--; return Data + off; }
53 | inline iterator insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= Data && it <= Data + Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(value_type)); Data[off] = v; Size++; return Data + off; }
54 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiStorage.cs.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // ImGuiStorage
3 | //-----------------------------------------------------------------------------
4 |
5 | // Helper: Key->value storage
6 | void ImGuiStorage::Clear()
7 | {
8 | Data.clear();
9 | }
10 |
11 | // std::lower_bound but without the bullshit
12 | static ImVector::iterator LowerBound(ImVector& data, uint key)
13 | {
14 | ImVector::iterator first = data.begin();
15 | ImVector::iterator last = data.end();
16 | int count = (int)(last - first);
17 | while (count > 0)
18 | {
19 | int count2 = count / 2;
20 | ImVector::iterator mid = first + count2;
21 | if (mid->key < key)
22 | {
23 | first = ++mid;
24 | count -= count2 + 1;
25 | }
26 | else
27 | {
28 | count = count2;
29 | }
30 | }
31 | return first;
32 | }
33 |
34 | int ImGuiStorage::GetInt(uint key, int default_val) const
35 | {
36 | ImVector::iterator it = LowerBound(const_cast&>(Data), key);
37 | if (it == Data.end() || it->key != key)
38 | return default_val;
39 | return it->val_i;
40 | }
41 |
42 | float ImGuiStorage::GetFloat(uint key, float default_val) const
43 | {
44 | ImVector::iterator it = LowerBound(const_cast&>(Data), key);
45 | if (it == Data.end() || it->key != key)
46 | return default_val;
47 | return it->val_f;
48 | }
49 |
50 | void* ImGuiStorage::GetVoidPtr(uint key) const
51 | {
52 | ImVector::iterator it = LowerBound(const_cast&>(Data), key);
53 | if (it == Data.end() || it->key != key)
54 | return NULL;
55 | return it->val_p;
56 | }
57 |
58 | // References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
59 | int* ImGuiStorage::GetIntRef(uint key, int default_val)
60 | {
61 | ImVector::iterator it = LowerBound(Data, key);
62 | if (it == Data.end() || it->key != key)
63 | it = Data.insert(it, Pair(key, default_val));
64 | return &it->val_i;
65 | }
66 |
67 | float* ImGuiStorage::GetFloatRef(uint key, float default_val)
68 | {
69 | ImVector::iterator it = LowerBound(Data, key);
70 | if (it == Data.end() || it->key != key)
71 | it = Data.insert(it, Pair(key, default_val));
72 | return &it->val_f;
73 | }
74 |
75 | void** ImGuiStorage::GetVoidPtrRef(uint key, void* default_val)
76 | {
77 | ImVector::iterator it = LowerBound(Data, key);
78 | if (it == Data.end() || it->key != key)
79 | it = Data.insert(it, Pair(key, default_val));
80 | return &it->val_p;
81 | }
82 |
83 | // FIXME-OPT: Need a way to reuse the result of lower_bound when doing GetInt()/SetInt() - not too bad because it only happens on explicit interaction (maximum one a frame)
84 | void ImGuiStorage::SetInt(uint key, int val)
85 | {
86 | ImVector::iterator it = LowerBound(Data, key);
87 | if (it == Data.end() || it->key != key)
88 | {
89 | Data.insert(it, Pair(key, val));
90 | return;
91 | }
92 | it->val_i = val;
93 | }
94 |
95 | void ImGuiStorage::SetFloat(uint key, float val)
96 | {
97 | ImVector::iterator it = LowerBound(Data, key);
98 | if (it == Data.end() || it->key != key)
99 | {
100 | Data.insert(it, Pair(key, val));
101 | return;
102 | }
103 | it->val_f = val;
104 | }
105 |
106 | void ImGuiStorage::SetVoidPtr(uint key, void* val)
107 | {
108 | ImVector::iterator it = LowerBound(Data, key);
109 | if (it == Data.end() || it->key != key)
110 | {
111 | Data.insert(it, Pair(key, val));
112 | return;
113 | }
114 | it->val_p = val;
115 | }
116 |
117 | void ImGuiStorage::SetAllInt(int v)
118 | {
119 | for (int i = 0; i < Data.Size; i++)
120 | Data[i].val_i = v;
121 | }
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiTextEditCallbackData.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | public unsafe delegate int ImGuiTextEditCallback(ImGuiTextEditCallbackData data);
4 |
5 | // Shared state of ImGui::InputText() when using custom callbacks (advanced)
6 | public struct ImGuiTextEditCallbackData
7 | {
8 | internal ImGuiInputTextFlags EventFlag; // One of ImGuiInputTextFlags_Callback* // Read-only
9 | internal ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only
10 | //internal void* UserData; // What user passed to InputText() // Read-only
11 | internal bool ReadOnly; // Read-only mode // Read-only
12 |
13 | // CharFilter event:
14 | internal char EventChar; // Character input // Read-write (replace character or set to zero)
15 |
16 | // Completion,History,Always events:
17 | // If you modify the buffer contents make sure you update 'BufTextLen' and set 'BufDirty' to true.
18 | internal ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only
19 | internal char[] Buf; // Current text buffer // Read-write (pointed data only, can't replace the actual pointer)
20 | internal int BufTextLen; // Current text length in bytes // Read-write
21 | internal int BufSize; // Maximum text length in bytes // Read-only
22 | internal bool BufDirty; // Set if you modify Buf/BufTextLen!! // Write
23 | internal int CursorPos; // // Read-write
24 | internal int SelectionStart; // // Read-write (== to SelectionEnd when no selection)
25 | internal int SelectionEnd; // // Read-write
26 |
27 | // NB: Helper functions for text manipulation. Calling those function loses selection.
28 | internal void DeleteChars(int pos, int bytes_count)
29 | {
30 | System.Diagnostics.Debug.Assert(pos + bytes_count <= BufTextLen);
31 | int dst = pos;
32 | int src = pos + bytes_count;
33 | char c;
34 | while ((c = Buf[src++]) != 0)
35 | Buf[dst++] = c;
36 | Buf[dst] = '\0';
37 |
38 | if (CursorPos + bytes_count >= pos)
39 | CursorPos -= bytes_count;
40 | else if (CursorPos >= pos)
41 | CursorPos = pos;
42 | SelectionStart = SelectionEnd = CursorPos;
43 | BufDirty = true;
44 | BufTextLen -= bytes_count;
45 | }
46 |
47 | internal void InsertChars(int pos, string data, int new_text, int new_text_end)
48 | {
49 | int new_text_len = new_text_end > -1 ? (new_text_end - new_text) : data.Length;
50 | if (new_text_len + BufTextLen + 1 >= BufSize)
51 | return;
52 |
53 | if (BufTextLen != pos)
54 | {
55 | //memmove(Buf + pos + new_text_len, Buf + pos, (size_t)(BufTextLen - pos));
56 | for (var i = pos; i < BufTextLen - pos; i++)
57 | Buf[i + new_text_len] = Buf[i];
58 |
59 | }
60 | //memcpy(Buf + pos, new_text, (size_t)new_text_len * sizeof(char));
61 | for (var i = new_text; i < new_text_len; i++)
62 | Buf[pos + i] = data[i];
63 | Buf[BufTextLen + new_text_len] = '\0';
64 |
65 | if (CursorPos >= pos)
66 | CursorPos += new_text_len;
67 | SelectionStart = SelectionEnd = CursorPos;
68 | BufDirty = true;
69 | BufTextLen += new_text_len;
70 | }
71 |
72 | internal bool HasSelection() { return SelectionStart != SelectionEnd; }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 | *.opensdf
10 | *.opendb
11 | *.sdf
12 | *.VC.db
13 |
14 | # User-specific files (MonoDevelop/Xamarin Studio)
15 | *.userprefs
16 |
17 | # Build results
18 | [Dd]ebug/
19 | [Dd]ebugPublic/
20 | [Rr]elease/
21 | [Rr]eleases/
22 | x64/
23 | x86/
24 | build/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 |
29 | # Visual Studo 2015 cache/options directory
30 | .vs/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | *_i.c
46 | *_p.c
47 | *_i.h
48 | *.ilk
49 | *.meta
50 | *.obj
51 | *.pch
52 | *.pdb
53 | *.pgc
54 | *.pgd
55 | *.rsp
56 | *.sbr
57 | *.tlb
58 | *.tli
59 | *.tlh
60 | *.tmp
61 | *.tmp_proj
62 | *.log
63 | *.vspscc
64 | *.vssscc
65 | .builds
66 | *.pidb
67 | *.svclog
68 | *.scc
69 |
70 | # Chutzpah Test files
71 | _Chutzpah*
72 |
73 | # Visual C++ cache files
74 | ipch/
75 | *.aps
76 | *.ncb
77 | *.opensdf
78 | *.sdf
79 | *.cachefile
80 |
81 | # Visual Studio profiler
82 | *.psess
83 | *.vsp
84 | *.vspx
85 |
86 | # TFS 2012 Local Workspace
87 | $tf/
88 |
89 | # Guidance Automation Toolkit
90 | *.gpState
91 |
92 | # ReSharper is a .NET coding add-in
93 | _ReSharper*/
94 | *.[Rr]e[Ss]harper
95 | *.DotSettings.user
96 |
97 | # JustCode is a .NET coding addin-in
98 | .JustCode
99 |
100 | # TeamCity is a build add-in
101 | _TeamCity*
102 |
103 | # DotCover is a Code Coverage Tool
104 | *.dotCover
105 |
106 | # NCrunch
107 | _NCrunch_*
108 | .*crunch*.local.xml
109 |
110 | # MightyMoose
111 | *.mm.*
112 | AutoTest.Net/
113 |
114 | # Web workbench (sass)
115 | .sass-cache/
116 |
117 | # Installshield output folder
118 | [Ee]xpress/
119 |
120 | # DocProject is a documentation generator add-in
121 | DocProject/buildhelp/
122 | DocProject/Help/*.HxT
123 | DocProject/Help/*.HxC
124 | DocProject/Help/*.hhc
125 | DocProject/Help/*.hhk
126 | DocProject/Help/*.hhp
127 | DocProject/Help/Html2
128 | DocProject/Help/html
129 |
130 | # Click-Once directory
131 | publish/
132 |
133 | # Publish Web Output
134 | *.[Pp]ublish.xml
135 | *.azurePubxml
136 | # TODO: Comment the next line if you want to checkin your web deploy settings
137 | # but database connection strings (with potential passwords) will be unencrypted
138 | *.pubxml
139 | *.publishproj
140 |
141 | # NuGet Packages
142 | *.nupkg
143 | # The packages folder can be ignored because of Package Restore
144 | **/packages/*
145 | # except build/, which is used as an MSBuild target.
146 | !**/packages/build/
147 | # Uncomment if necessary however generally it will be regenerated when needed
148 | #!**/packages/repositories.config
149 |
150 | # Windows Azure Build Output
151 | csx/
152 | *.build.csdef
153 |
154 | # Windows Store app package directory
155 | AppPackages/
156 |
157 | # Others
158 | *.[Cc]ache
159 | ClientBin/
160 | [Ss]tyle[Cc]op.*
161 | ~$*
162 | *~
163 | *.dbmdl
164 | *.dbproj.schemaview
165 | *.pfx
166 | *.publishsettings
167 | node_modules/
168 | bower_components/
169 |
170 | # RIA/Silverlight projects
171 | Generated_Code/
172 |
173 | # Backup & report files from converting an old project file
174 | # to a newer Visual Studio version. Backup files are not needed,
175 | # because we have git ;-)
176 | _UpgradeReport_Files/
177 | Backup*/
178 | UpgradeLog*.XML
179 | UpgradeLog*.htm
180 |
181 | # SQL Server files
182 | *.mdf
183 | *.ldf
184 |
185 | # Business Intelligence projects
186 | *.rdl.data
187 | *.bim.layout
188 | *.bim_*.settings
189 |
190 | # Microsoft Fakes
191 | FakesAssemblies/
192 |
193 | # Node.js Tools for Visual Studio
194 | .ntvs_analysis.dat
195 |
196 | # Visual Studio 6 build log
197 | *.plg
198 |
199 | # Visual Studio 6 workspace options file
200 | *.opt
201 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImRect.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 |
3 | namespace ImGui
4 | {
5 | // 2D axis aligned bounding-box
6 | // NB: we can't rely on ImVec2 math operators being available here
7 | [DebuggerDisplay("Min: {Min}, Max: {Max}")]
8 | internal struct ImRect
9 | {
10 | public ImVec2 Min; // Upper-left
11 | public ImVec2 Max; // Lower-right
12 |
13 | public static ImRect Empty
14 | {
15 | get
16 | {
17 | return new ImRect(
18 | new ImVec2(float.MaxValue, float.MaxValue),
19 | new ImVec2(float.MinValue, float.MinValue));
20 | }
21 | }
22 |
23 | public ImRect(ImVec2 min, ImVec2 max)
24 | {
25 | Min = min;
26 | Max = max;
27 | }
28 |
29 | public ImRect(ImVec4 v) : this(new ImVec2(v.x, v.y), new ImVec2(v.z, v.w)) { }
30 | public ImRect(float x1, float y1, float x2, float y2) : this(new ImVec2(x1, y1), new ImVec2(x2, y2)) { }
31 |
32 | public ImVec2 GetCenter() { return new ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); }
33 |
34 | public ImVec2 GetSize() { return new ImVec2(Max.x - Min.x, Max.y - Min.y); }
35 |
36 | public float GetWidth() { return Max.x - Min.x; }
37 | public float GetHeight() { return Max.y - Min.y; }
38 | public ImVec2 GetTL() { return Min; } // Top-left
39 | public ImVec2 GetTR() { return new ImVec2(Max.x, Min.y); } // Top-right
40 | public ImVec2 GetBL() { return new ImVec2(Min.x, Max.y); } // Bottom-left
41 | public ImVec2 GetBR() { return Max; } // Bottom-right
42 |
43 | public bool Contains(ImVec2 p) { return p.x >= Min.x && p.y >= Min.y && p.x < Max.x && p.y < Max.y; }
44 | public bool Contains(ImRect r) { return r.Min.x >= Min.x && r.Min.y >= Min.y && r.Max.x < Max.x && r.Max.y < Max.y; }
45 | public bool Overlaps(ImRect r) { return r.Min.y < Max.y && r.Max.y > Min.y && r.Min.x < Max.x && r.Max.x > Min.x; }
46 | public void Add(ImVec2 rhs) { if (Min.x > rhs.x) Min.x = rhs.x; if (Min.y > rhs.y) Min.y = rhs.y; if (Max.x < rhs.x) Max.x = rhs.x; if (Max.y < rhs.y) Max.y = rhs.y; }
47 | public void Add(ImRect rhs) { if (Min.x > rhs.Min.x) Min.x = rhs.Min.x; if (Min.y > rhs.Min.y) Min.y = rhs.Min.y; if (Max.x < rhs.Max.x) Max.x = rhs.Max.x; if (Max.y < rhs.Max.y) Max.y = rhs.Max.y; }
48 | public void Expand(float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
49 | public void Expand(ImVec2 amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
50 | public void Reduce(ImVec2 amount) { Min.x += amount.x; Min.y += amount.y; Max.x -= amount.x; Max.y -= amount.y; }
51 | public void Clip(ImRect clip) { if (Min.x < clip.Min.x) Min.x = clip.Min.x; if (Min.y < clip.Min.y) Min.y = clip.Min.y; if (Max.x > clip.Max.x) Max.x = clip.Max.x; if (Max.y > clip.Max.y) Max.y = clip.Max.y; }
52 | public void Round() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
53 |
54 | public ImVec2 GetClosestPoint(ImVec2 p, bool on_edge)
55 | {
56 | if (!on_edge && Contains(p))
57 | return p;
58 | if (p.x > Max.x) p.x = Max.x;
59 | else if (p.x < Min.x) p.x = Min.x;
60 | if (p.y > Max.y) p.y = Max.y;
61 | else if (p.y < Min.y) p.y = Min.y;
62 | return p;
63 | }
64 |
65 | public float x
66 | {
67 | get { return Min.x; }
68 | set { Min.x = value; }
69 | }
70 |
71 | public float y
72 | {
73 | get { return Min.y; }
74 | set { Min.y = value; }
75 | }
76 |
77 | public float width
78 | {
79 | get { return Max.x - Min.x; }
80 | set { Max.x = Min.x + value; }
81 | }
82 |
83 | public float height
84 | {
85 | get { return Max.y - Min.y; }
86 | set { Max.y = Min.y + value; }
87 | }
88 |
89 | public override string ToString()
90 | {
91 | return $"{{ Min: {Min}, Max: {Max} }}";
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiDrawContext.cs.h:
--------------------------------------------------------------------------------
1 | // Transient per-window data, reset at the beginning of the frame
2 | // FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered.
3 | struct IMGUI_API ImGuiDrawContext
4 | {
5 | ImVec2 CursorPos;
6 | ImVec2 CursorPosPrevLine;
7 | ImVec2 CursorStartPos;
8 | ImVec2 CursorMaxPos; // Implicitly calculate the size of our contents, always extending. Saved into window->SizeContents at the end of the frame
9 | float CurrentLineHeight;
10 | float CurrentLineTextBaseOffset;
11 | float PrevLineHeight;
12 | float PrevLineTextBaseOffset;
13 | float LogLinePosY;
14 | int TreeDepth;
15 | uint LastItemID;
16 | ImRect LastItemRect;
17 | bool LastItemHoveredAndUsable; // Item rectangle is hovered, and its window is currently interactable with (not blocked by a popup preventing access to the window)
18 | bool LastItemHoveredRect; // Item rectangle is hovered, but its window may or not be currently interactable with (might be blocked by a popup preventing access to the window)
19 | bool MenuBarAppending;
20 | float MenuBarOffsetX;
21 | ImVector ChildWindows;
22 | ImGuiStorage* StateStorage;
23 | ImGuiLayoutType LayoutType;
24 |
25 | // We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
26 | float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
27 | float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f]
28 | bool AllowKeyboardFocus; // == AllowKeyboardFocusStack.back() [empty == true]
29 | bool ButtonRepeat; // == ButtonRepeatStack.back() [empty == false]
30 | ImVector ItemWidthStack;
31 | ImVector TextWrapPosStack;
32 | ImVector AllowKeyboardFocusStack;
33 | ImVector ButtonRepeatStack;
34 | ImVectorGroupStack;
35 | ImGuiColorEditMode ColorEditMode;
36 | int StackSizesBackup[6]; // Store size of various stacks for asserting
37 |
38 | float IndentX; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
39 | float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
40 | int ColumnsCurrent;
41 | int ColumnsCount;
42 | float ColumnsMinX;
43 | float ColumnsMaxX;
44 | float ColumnsStartPosY;
45 | float ColumnsCellMinY;
46 | float ColumnsCellMaxY;
47 | bool ColumnsShowBorders;
48 | uint ColumnsSetID;
49 | ImVector ColumnsData;
50 |
51 | ImGuiDrawContext()
52 | {
53 | CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f);
54 | CurrentLineHeight = PrevLineHeight = 0.0f;
55 | CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
56 | LogLinePosY = -1.0f;
57 | TreeDepth = 0;
58 | LastItemID = 0;
59 | LastItemRect = ImRect(0.0f, 0.0f, 0.0f, 0.0f);
60 | LastItemHoveredAndUsable = LastItemHoveredRect = false;
61 | MenuBarAppending = false;
62 | MenuBarOffsetX = 0.0f;
63 | StateStorage = NULL;
64 | LayoutType = ImGuiLayoutType_Vertical;
65 | ItemWidth = 0.0f;
66 | ButtonRepeat = false;
67 | AllowKeyboardFocus = true;
68 | TextWrapPos = -1.0f;
69 | ColorEditMode = ImGuiColorEditMode_RGB;
70 | memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
71 |
72 | IndentX = 0.0f;
73 | ColumnsOffsetX = 0.0f;
74 | ColumnsCurrent = 0;
75 | ColumnsCount = 1;
76 | ColumnsMinX = ColumnsMaxX = 0.0f;
77 | ColumnsStartPosY = 0.0f;
78 | ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
79 | ColumnsShowBorders = true;
80 | ColumnsSetID = 0;
81 | }
82 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiTextEditState.cs:
--------------------------------------------------------------------------------
1 | using STB_TEXTEDIT_POSITIONTYPE = System.Int32;
2 | using STB_TEXTEDIT_CHARTYPE = System.Char;
3 | using ImWchar = System.Char;
4 | using STB_TEXTEDIT_STRING = ImGui.ImGuiTextEditState;
5 |
6 |
7 | namespace ImGui
8 | {
9 | internal class STB_TexteditState
10 | {
11 | /////////////////////
12 | //
13 | // internal data
14 | //
15 |
16 | internal int cursor;
17 | // position of the text cursor within the string
18 |
19 | internal int select_start; // selection start point
20 | internal int select_end;
21 | // selection start and end point in characters; if equal, no selection.
22 | // note that start may be less than or greater than end (e.g. when
23 | // dragging the mouse, start is where the initial click was, and you
24 | // can drag in either direction)
25 |
26 | internal bool insert_mode;
27 | // each textfield keeps its own insert mode state. to keep an app-wide
28 | // insert mode, copy this value in/out of the app state
29 |
30 | /////////////////////
31 | //
32 | // private data
33 | //
34 | internal byte cursor_at_end_of_line; // not implemented yet
35 | internal byte initialized;
36 | internal byte has_preferred_x;
37 | internal byte single_line;
38 | internal byte padding1, padding2, padding3;
39 | internal float preferred_x; // this determines where the cursor up/down tries to seek to along x
40 | internal StbUndoState undostate = new StbUndoState();
41 |
42 | internal bool STB_TEXT_HAS_SELECTION()
43 | {
44 | return select_start != select_end;
45 | }
46 | }
47 |
48 | internal class StbUndoState
49 | {
50 | public const int STB_TEXTEDIT_UNDOSTATECOUNT = 99;
51 | public const int STB_TEXTEDIT_UNDOCHARCOUNT = 999;
52 |
53 | // private data
54 | internal StbUndoRecord[] undo_rec = new StbUndoRecord[STB_TEXTEDIT_UNDOSTATECOUNT];
55 | internal STB_TEXTEDIT_CHARTYPE[] undo_char = new STB_TEXTEDIT_CHARTYPE[STB_TEXTEDIT_UNDOCHARCOUNT];
56 | internal short undo_point, redo_point;
57 | internal short undo_char_point, redo_char_point;
58 | }
59 |
60 | internal struct StbUndoRecord
61 | {
62 | // private data
63 | internal STB_TEXTEDIT_POSITIONTYPE where;
64 | internal short insert_length;
65 | internal short delete_length;
66 | internal short char_storage;
67 | }
68 |
69 |
70 |
71 | // Internal state of the currently focused/edited text input box
72 | internal class ImGuiTextEditState
73 | {
74 | internal uint Id; // widget id owning the text state
75 | internal ImVector Text; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer.
76 | internal ImVector InitialText; // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
77 | internal ImVector TempTextBuffer;
78 | internal int CurLenA, CurLenW; // we need to maintain our buffer length in both UTF-8 and wchar format.
79 | internal int BufSizeA; // end-user buffer size
80 | internal float ScrollX;
81 | internal STB_TexteditState StbState;
82 | internal float CursorAnim;
83 | internal bool CursorFollow;
84 | internal bool SelectedAllMouseLock;
85 |
86 |
87 | internal ImGuiTextEditState()
88 | {
89 | Text = new ImVector();
90 | InitialText = new ImVector();
91 | TempTextBuffer = new ImVector();
92 | StbState = new STB_TexteditState();
93 | }
94 | internal void CursorAnimReset() { CursorAnim = -0.30f; } // After a user-input the cursor stays on for a while without blinking
95 | internal void CursorClamp() { StbState.cursor = ImGui.Min(StbState.cursor, CurLenW); StbState.select_start = ImGui.Min(StbState.select_start, CurLenW); StbState.select_end = ImGui.Min(StbState.select_end, CurLenW); }
96 | internal bool HasSelection() { return StbState.select_start != StbState.select_end; }
97 | internal void ClearSelection() { StbState.select_start = StbState.select_end = StbState.cursor; }
98 | internal void SelectAll() { StbState.select_start = 0; StbState.select_end = CurLenW; StbState.cursor = StbState.select_end; StbState.has_preferred_x = 0; }
99 | internal void OnKeyPressed(int key)
100 | {
101 | stb_textedit.stb_textedit_key(this, StbState, key);
102 | CursorFollow = true;
103 | CursorAnimReset();
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiDrawContext.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 |
4 | // Transient per-window data, reset at the beginning of the frame
5 | // FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered.
6 | class ImGuiDrawContext
7 | {
8 | internal ImVec2 CursorPos;
9 | internal ImVec2 CursorPosPrevLine;
10 | internal ImVec2 CursorStartPos;
11 | internal ImVec2 CursorMaxPos; // Implicitly calculate the size of our contents, always extending. Saved into window->SizeContents at the end of the frame
12 | internal float CurrentLineHeight;
13 | internal float CurrentLineTextBaseOffset;
14 | internal float PrevLineHeight;
15 | internal float PrevLineTextBaseOffset;
16 | internal float LogLinePosY;
17 | internal int TreeDepth;
18 | internal uint LastItemID;
19 | internal ImRect LastItemRect;
20 | internal bool LastItemHoveredAndUsable; // Item rectangle is hovered, and its window is currently interactable with (not blocked by a popup preventing access to the window)
21 | internal bool LastItemHoveredRect; // Item rectangle is hovered, but its window may or not be currently interactable with (might be blocked by a popup preventing access to the window)
22 | internal bool MenuBarAppending;
23 | internal float MenuBarOffsetX;
24 | internal ImVector ChildWindows;
25 | internal ImGuiStorage StateStorage;
26 | internal ImGuiLayoutType LayoutType;
27 |
28 | // We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
29 | internal float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
30 | internal float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f]
31 | internal bool AllowKeyboardFocus; // == AllowKeyboardFocusStack.back() [empty == true]
32 | internal bool ButtonRepeat; // == ButtonRepeatStack.back() [empty == false]
33 | internal ImVector ItemWidthStack;
34 | internal ImVector TextWrapPosStack;
35 | internal ImVector AllowKeyboardFocusStack;
36 | internal ImVector ButtonRepeatStack;
37 | internal ImVector GroupStack;
38 | internal ImGuiColorEditMode ColorEditMode;
39 | internal int[] StackSizesBackup = new int[6]; // Store size of various stacks for asserting
40 |
41 | internal float IndentX; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
42 | internal float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
43 | internal int ColumnsCurrent;
44 | internal int ColumnsCount;
45 | internal float ColumnsMinX;
46 | internal float ColumnsMaxX;
47 | internal float ColumnsStartPosY;
48 | internal float ColumnsCellMinY;
49 | internal float ColumnsCellMaxY;
50 | internal bool ColumnsShowBorders;
51 | internal uint ColumnsSetID;
52 | internal ImVector ColumnsData;
53 |
54 | internal ImGuiDrawContext()
55 | {
56 | ItemWidthStack = new ImVector();
57 | TextWrapPosStack = new ImVector();
58 | AllowKeyboardFocusStack = new ImVector();
59 | ButtonRepeatStack = new ImVector();
60 | GroupStack = new ImVector();
61 | ChildWindows = new ImVector();
62 | ColumnsData = new ImVector();
63 |
64 | CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = new ImVec2(0.0f, 0.0f);
65 | CurrentLineHeight = PrevLineHeight = 0.0f;
66 | CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
67 | LogLinePosY = -1.0f;
68 | TreeDepth = 0;
69 | LastItemID = 0;
70 | LastItemRect = new ImRect(0.0f, 0.0f, 0.0f, 0.0f);
71 | LastItemHoveredAndUsable = LastItemHoveredRect = false;
72 | MenuBarAppending = false;
73 | MenuBarOffsetX = 0.0f;
74 | StateStorage = null;
75 | LayoutType = ImGuiLayoutType.ImGuiLayoutType_Vertical;
76 | ItemWidth = 0.0f;
77 | ButtonRepeat = false;
78 | AllowKeyboardFocus = true;
79 | TextWrapPos = -1.0f;
80 | ColorEditMode = ImGuiColorEditMode.ImGuiColorEditMode_RGB;
81 | //memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
82 |
83 | IndentX = 0.0f;
84 | ColumnsOffsetX = 0.0f;
85 | ColumnsCurrent = 0;
86 | ColumnsCount = 1;
87 | ColumnsMinX = ColumnsMaxX = 0.0f;
88 | ColumnsStartPosY = 0.0f;
89 | ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
90 | ColumnsShowBorders = true;
91 | ColumnsSetID = 0;
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImVector.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | // Lightweight std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
7 | // Our implementation does NOT call c++ constructors because we don't use them in ImGui. Don't use this class as a straight std::vector replacement in your code!
8 | public class ImVector : IDisposable
9 | {
10 | public int Size;
11 | public int Capacity;
12 |
13 | public T[] Data;
14 | //T* Data;
15 |
16 | public Type value_type = typeof(T);
17 |
18 | //typedef value_type* iterator;
19 | //typedef const value_type* const_iterator;
20 |
21 | public ImVector() { Size = Capacity = 0; }
22 | //~ImVector() { if (Data) ImGui::MemFree(Data); }
23 |
24 | public bool empty() { return Size == 0; }
25 | public int size() { return Size; }
26 | public int capacity() { return Capacity; }
27 |
28 | public T this[int i]
29 | {
30 | get
31 | {
32 | //IM_ASSERT(i < Size);
33 | return Data[i];
34 | }
35 | set
36 | {
37 | Data[i] = value;
38 | }
39 |
40 | }
41 |
42 | public void clear() { Size = Capacity = 0; Data = null; }
43 | //public IEnumerator begin() { return Data; }
44 | //public const_iterator begin() const { return Data; }
45 | public T front()
46 | {
47 | System.Diagnostics.Debug.Assert(Size > 0);
48 | return Data[0];
49 | }
50 | //public const value_type& front() const { IM_ASSERT(Size > 0); return Data[0]; }
51 | public T back()
52 | {
53 | System.Diagnostics.Debug.Assert(Size > 0);
54 | return Data[Size - 1];
55 | }
56 |
57 | public void back(T val)
58 | {
59 | System.Diagnostics.Debug.Assert(Size > 0);
60 | Data[Size - 1] = val;
61 | }
62 | //public const value_type& back() const { IM_ASSERT(Size > 0); return Data[Size-1]; }
63 | //public void swap(ImVector& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
64 |
65 | public int _grow_capacity(int new_size)
66 | {
67 | int new_capacity = Capacity > 0 ? (Capacity + Capacity / 2) : 8;
68 | return new_capacity > new_size ? new_capacity : new_size;
69 | }
70 |
71 | public void resize(int new_size)
72 | {
73 | if (new_size > Capacity)
74 | reserve(_grow_capacity(new_size));
75 | Size = new_size;
76 | }
77 |
78 | public void reserve(int new_capacity)
79 | {
80 | if (new_capacity <= Capacity) return;
81 | Capacity = new_capacity;
82 | if (Data == null)
83 | Data = new T[new_capacity];
84 | else
85 | Array.Resize(ref Data, new_capacity);
86 | }
87 |
88 | public void push_back(T v)
89 | {
90 | if (Size == Capacity)
91 | reserve(_grow_capacity(Size + 1));
92 | Data[Size++] = v;
93 | }
94 | public void pop_back()
95 | {
96 | //IM_ASSERT(Size > 0);
97 | Size--;
98 | }
99 |
100 | public void erase(int it)
101 | {
102 | System.Diagnostics.Debug.Assert(it >= 0 && it < Size);
103 | for (var i = it; i < Size - 1; i++)
104 | Data[i] = Data[i + 1];
105 | Size--;
106 | }
107 |
108 | public void insert(int it, T v)
109 | {
110 | System.Diagnostics.Debug.Assert(it >= 0 && it <= Size);
111 | var off = it;
112 | if (Size == Capacity)
113 | reserve(Capacity > 0 ? Capacity * 2 : 4);
114 | if (off < Size)
115 | {
116 | //memmove( off + 1, off, ((size_t)Size - (size_t)off) * sizeof(value_type));
117 | for (int i = Size; i > it; i--)
118 | Data[i] = Data[i - 1];
119 | }
120 | Data[off] = v;
121 | Size++;
122 | //return Data + off;
123 | }
124 |
125 | public void sort(Func sorter)
126 | {
127 | Array.Sort(Data, new Comparison(sorter));
128 | }
129 |
130 | public void swap(ImVector rhs)
131 | {
132 | int rhs_size = rhs.Size;
133 | rhs.Size = Size;
134 | Size = rhs_size;
135 |
136 | int rhs_cap = rhs.Capacity;
137 | rhs.Capacity = Capacity;
138 | Capacity = rhs_cap;
139 |
140 | T[] rhs_data = rhs.Data;
141 | rhs.Data = Data;
142 | Data = rhs_data;
143 | }
144 |
145 |
146 | public void Dispose()
147 | {
148 | Data = null;
149 | }
150 |
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiWindow.cs.h:
--------------------------------------------------------------------------------
1 | // Windows data
2 | struct IMGUI_API ImGuiWindow
3 | {
4 | char* Name;
5 | uint ID;
6 | ImGuiWindowFlags Flags;
7 | ImVec2 PosFloat;
8 | ImVec2 Pos; // Position rounded-up to nearest pixel
9 | ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
10 | ImVec2 SizeFull; // Size when non collapsed
11 | ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame
12 | ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
13 | ImVec2 WindowPadding; // Window padding at the time of begin. We need to lock it, in particular manipulation of the ShowBorder would have an effect
14 | uint MoveID; // == window->GetID("#MOVE")
15 | ImVec2 Scroll;
16 | ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
17 | ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
18 | bool ScrollbarX, ScrollbarY;
19 | ImVec2 ScrollbarSizes;
20 | float BorderSize;
21 | bool Active; // Set to true on Begin()
22 | bool WasActive;
23 | bool Accessed; // Set to true when any widget access the current window
24 | bool Collapsed; // Set when collapsing window to become only title-bar
25 | bool SkipItems; // == Visible && !Collapsed
26 | int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
27 | uint PopupID; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
28 | int AutoFitFramesX, AutoFitFramesY;
29 | bool AutoFitOnlyGrows;
30 | int AutoPosLastDirection;
31 | int HiddenFrames;
32 | int SetWindowPosAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowPos() call will succeed with this particular flag.
33 | int SetWindowSizeAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowSize() call will succeed with this particular flag.
34 | int SetWindowCollapsedAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowCollapsed() call will succeed with this particular flag.
35 | bool SetWindowPosCenterWanted;
36 |
37 | ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
38 | ImVector IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
39 | ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
40 | ImRect ClippedWindowRect; // = ClipRect just after setup in Begin()
41 | int LastFrameActive;
42 | float ItemWidthDefault;
43 | ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items
44 | ImGuiStorage StateStorage;
45 | float FontWindowScale; // Scale multiplier per-window
46 | ImDrawList* DrawList;
47 | ImGuiWindow* RootWindow;
48 | ImGuiWindow* RootNonPopupWindow;
49 |
50 | // Focus
51 | int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()
52 | int FocusIdxTabCounter; // (same, but only count widgets which you can Tab through)
53 | int FocusIdxAllRequestCurrent; // Item being requested for focus
54 | int FocusIdxTabRequestCurrent; // Tab-able item being requested for focus
55 | int FocusIdxAllRequestNext; // Item being requested for focus, for next update (relies on layout to be stable between the frame pressing TAB and the next frame)
56 | int FocusIdxTabRequestNext; // "
57 |
58 | public:
59 | ImGuiWindow(const char* name);
60 | ~ImGuiWindow();
61 |
62 | uint GetID(const char* str, const char* str_end = NULL);
63 | uint GetID(const void* ptr);
64 |
65 | ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
66 | float CalcFontSize() const { return GImGui->FontBaseSize * FontWindowScale; }
67 | float TitleBarHeight() const { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f; }
68 | ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
69 | float MenuBarHeight() const { return (Flags & ImGuiWindowFlags_MenuBar) ? CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; }
70 | ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
71 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImFontAtlas.cs.h:
--------------------------------------------------------------------------------
1 | // Load and rasterize multiple TTF fonts into a same texture.
2 | // Sharing a texture for multiple fonts allows us to reduce the number of draw calls during rendering.
3 | // We also add custom graphic data into the texture that serves for ImGui.
4 | // 1. (Optional) Call AddFont*** functions. If you don't call any, the default font will be loaded for you.
5 | // 2. Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
6 | // 3. Upload the pixels data into a texture within your graphics system.
7 | // 4. Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture. This value will be passed back to you during rendering to identify the texture.
8 | // 5. Call ClearTexData() to free textures memory on the heap.
9 | struct ImFontAtlas
10 | {
11 | IMGUI_API ImFontAtlas();
12 | IMGUI_API ~ImFontAtlas();
13 | IMGUI_API ImFont* AddFont(const ImFontConfig* font_cfg);
14 | IMGUI_API ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL);
15 | IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL);
16 | IMGUI_API ImFont* AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // Transfer ownership of 'ttf_data' to ImFontAtlas, will be deleted after Build()
17 | IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_ttf_data' still owned by caller. Compress with binary_to_compressed_c.cpp
18 | IMGUI_API ImFont* AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_ttf_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 paramaeter
19 | IMGUI_API void ClearTexData(); // Clear the CPU-side texture data. Saves RAM once the texture has been copied to graphics memory.
20 | IMGUI_API void ClearInputData(); // Clear the input TTF data (inc sizes, glyph ranges)
21 | IMGUI_API void ClearFonts(); // Clear the ImGui-side font data (glyphs storage, UV coordinates)
22 | IMGUI_API void Clear(); // Clear all
23 |
24 | // Retrieve texture data
25 | // User is in charge of copying the pixels into graphics memory, then call SetTextureUserID()
26 | // After loading the texture into your graphic system, store your texture handle in 'TexID' (ignore if you aren't using multiple fonts nor images)
27 | // RGBA32 format is provided for convenience and high compatibility, but note that all RGB pixels are white, so 75% of the memory is wasted.
28 | // Pitch = Width * BytesPerPixels
29 | IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
30 | IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
31 | void SetTexID(void* id) { TexID = id; }
32 |
33 | // Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
34 | // (Those functions could be static but aren't so most users don't have to refer to the ImFontAtlas:: name ever if in their code; just using io.Fonts->)
35 | IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
36 | IMGUI_API const ImWchar* GetGlyphRangesKorean(); // Default + Korean characters
37 | IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
38 | IMGUI_API const ImWchar* GetGlyphRangesChinese(); // Japanese + full set of about 21000 CJK Unified Ideographs
39 | IMGUI_API const ImWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters
40 |
41 | // Members
42 | // (Access texture data via GetTexData*() calls which will setup a default font for you.)
43 | void* TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It ia passed back to you during rendering.
44 | unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
45 | unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
46 | int TexWidth; // Texture width calculated during Build().
47 | int TexHeight; // Texture height calculated during Build().
48 | int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
49 | ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel
50 | ImVector Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font.
51 |
52 | // Private
53 | ImVector ConfigData; // Internal data
54 | IMGUI_API bool Build(); // Build pixels data. This is automatically for you by the GetTexData*** functions.
55 | IMGUI_API void RenderCustomTexData(int pass, void* rects);
56 | };
57 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiStorage.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImGui
3 | {
4 | using System.Runtime.InteropServices;
5 |
6 | // Simple custom key value storage
7 | // Helper: Key->value storage
8 | // - Store collapse state for a tree (Int 0/1)
9 | // - Store color edit options (Int using values in ImGuiColorEditMode enum).
10 | // - Custom user storage for temporary values.
11 | // Typically you don't have to worry about this since a storage is held within each Window.
12 | // Declare your own storage if:
13 | // - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state).
14 | // - You want to store custom debug data easily without adding or editing structures in your code.
15 | public class ImGuiStorage
16 | {
17 | [StructLayout(LayoutKind.Explicit, Size = 8)]
18 | public struct Pair
19 | {
20 | [FieldOffset(0)]
21 | public uint key;
22 |
23 | [FieldOffset(4)]
24 | public int val_i;
25 |
26 | [FieldOffset(4)]
27 | public float val_f;
28 |
29 | //union { int val_i; float val_f; void* val_p; }
30 |
31 | public Pair(uint _key, int _val_i)
32 | {
33 | val_f = 0f;
34 | key = _key;
35 | val_i = _val_i;
36 | }
37 |
38 | public Pair(uint _key, float _val_f)
39 | {
40 | val_i = 0;
41 | key = _key;
42 | val_f = _val_f;
43 | }
44 |
45 | //public Pair(uint _key, void* _val_p)
46 | //{
47 | // key = _key; val_p = _val_p;
48 | //}
49 | }
50 |
51 | public ImVector Data = new ImVector();
52 |
53 | internal void Clear()
54 | {
55 | Data.clear();
56 | }
57 |
58 | // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
59 | // - Set***() functions find pair, insertion on demand if missing.
60 | // - Sorted insertion is costly but should amortize. A typical frame shouldn't need to insert any new pair.
61 | int FindByKey(uint key)
62 | {
63 | var first = 0;
64 | var last = Data.Size;
65 | int count = (last - first);
66 | while (count > 0)
67 | {
68 | int count2 = count / 2;
69 | int mid = first + count2;
70 | if (Data[mid].key < key)
71 | {
72 | first = ++mid;
73 | count -= count2 + 1;
74 | }
75 | else
76 | {
77 | count = count2;
78 | }
79 | }
80 | return first;
81 | }
82 |
83 | internal int GetInt(uint key, int default_val)
84 | {
85 | var idx = FindByKey(key);
86 | if (idx < Data.Size && Data[idx].key == key)
87 | return Data[idx].val_i;
88 |
89 | return default_val;
90 | }
91 |
92 | internal float GetFloat(uint key, float default_val)
93 | {
94 | var idx = FindByKey(key);
95 | if (idx < Data.Size && Data[idx].key == key)
96 | return Data[idx].val_f;
97 |
98 | return default_val;
99 | }
100 |
101 | //void* GetVoidPtr(uint key) const; // default_val is NULL
102 | //void SetVoidPtr(uint key, void* val);
103 |
104 | // FIXME-OPT: Need a way to reuse the result of lower_bound when doing GetInt()/SetInt() - not too bad because it only happens on explicit interaction (maximum one a frame)
105 | public void SetInt(uint key, int val)
106 | {
107 | var idx = FindByKey(key);
108 | if (idx < Data.Size && Data[idx].key == key)
109 | {
110 | var pair = Data[idx];
111 | pair.val_i = val;
112 | Data[idx] = pair;
113 | }
114 | else {
115 | Data.insert(idx, new Pair(key, val));
116 | }
117 | }
118 |
119 | internal void SetFloat(uint key, float val)
120 | {
121 | var idx = FindByKey(key);
122 | if (idx < Data.Size && Data[idx].key == key)
123 | {
124 | var pair = Data[idx];
125 | pair.val_f = val;
126 | Data[idx] = pair;
127 | }
128 | else {
129 | Data.insert(idx, new Pair(key, val));
130 | }
131 | }
132 |
133 | // Use on your own storage if you know only integer are being stored (open/close all tree nodes)
134 | internal void SetAllInt(int v)
135 | {
136 | for (int i = 0; i < Data.Size; i++)
137 | {
138 | var pair = Data[i];
139 | pair.val_i = v;
140 | Data[i] = pair;
141 | }
142 | }
143 |
144 | // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set.
145 | // - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
146 | // - A typical use case where this is convenient:
147 | // float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
148 | // - You can also use this to quickly create temporary editable values during a session of using Edit&Continue, without restarting your application.
149 | //int* GetIntRef(uint key, int default_val = 0);
150 | //float* GetFloatRef(uint key, float default_val = 0);
151 | //void** GetVoidPtrRef(uint key, void* default_val = NULL);
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiStyle.cs.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // User facing structures
3 | //-----------------------------------------------------------------------------
4 |
5 | ImGuiStyle::ImGuiStyle()
6 | {
7 | Alpha = 1.0f; // Global alpha applies to everything in ImGui
8 | WindowPadding = ImVec2(8, 8); // Padding within a window
9 | WindowMinSize = ImVec2(32, 32); // Minimum window size
10 | WindowRounding = 9.0f; // Radius of window corners rounding. Set to 0.0f to have rectangular windows
11 | WindowTitleAlign = ImGuiAlign_Left; // Alignment for title bar text
12 | ChildWindowRounding = 0.0f; // Radius of child window corners rounding. Set to 0.0f to have rectangular windows
13 | FramePadding = ImVec2(4, 3); // Padding within a framed rectangle (used by most widgets)
14 | FrameRounding = 0.0f; // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets).
15 | ItemSpacing = ImVec2(8, 4); // Horizontal and vertical spacing between widgets/lines
16 | ItemInnerSpacing = ImVec2(4, 4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
17 | TouchExtraPadding = ImVec2(0, 0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
18 | WindowFillAlphaDefault = 0.70f; // Default alpha of window background, if not specified in ImGui::Begin()
19 | IndentSpacing = 22.0f; // Horizontal spacing when e.g. entering a tree node
20 | ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns
21 | ScrollbarSize = 16.0f; // Width of the vertical scrollbar, Height of the horizontal scrollbar
22 | ScrollbarRounding = 9.0f; // Radius of grab corners rounding for scrollbar
23 | GrabMinSize = 10.0f; // Minimum width/height of a grab box for slider/scrollbar
24 | GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
25 | DisplayWindowPadding = ImVec2(22, 22); // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
26 | DisplaySafeAreaPadding = ImVec2(4, 4); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
27 | AntiAliasedLines = true; // Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU.
28 | AntiAliasedShapes = true; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
29 | CurveTessellationTol = 1.25f; // Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
30 |
31 | Colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
32 | Colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
33 | Colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
34 | Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
35 | Colors[ImGuiCol_Border] = ImVec4(0.70f, 0.70f, 0.70f, 0.65f);
36 | Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
37 | Colors[ImGuiCol_FrameBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.30f); // Background of checkbox, radio button, plot, slider, text input
38 | Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.90f, 0.80f, 0.80f, 0.40f);
39 | Colors[ImGuiCol_FrameBgActive] = ImVec4(0.90f, 0.65f, 0.65f, 0.45f);
40 | Colors[ImGuiCol_TitleBg] = ImVec4(0.50f, 0.50f, 1.00f, 0.45f);
41 | Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.40f, 0.40f, 0.80f, 0.20f);
42 | Colors[ImGuiCol_TitleBgActive] = ImVec4(0.50f, 0.50f, 1.00f, 0.55f);
43 | Colors[ImGuiCol_MenuBarBg] = ImVec4(0.40f, 0.40f, 0.55f, 0.80f);
44 | Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.20f, 0.25f, 0.30f, 0.60f);
45 | Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.80f, 0.30f);
46 | Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.80f, 0.40f);
47 | Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.80f, 0.50f, 0.50f, 0.40f);
48 | Colors[ImGuiCol_ComboBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.99f);
49 | Colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f);
50 | Colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
51 | Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.80f, 0.50f, 0.50f, 1.00f);
52 | Colors[ImGuiCol_Button] = ImVec4(0.67f, 0.40f, 0.40f, 0.60f);
53 | Colors[ImGuiCol_ButtonHovered] = ImVec4(0.67f, 0.40f, 0.40f, 1.00f);
54 | Colors[ImGuiCol_ButtonActive] = ImVec4(0.80f, 0.50f, 0.50f, 1.00f);
55 | Colors[ImGuiCol_Header] = ImVec4(0.40f, 0.40f, 0.90f, 0.45f);
56 | Colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.90f, 0.80f);
57 | Colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.87f, 0.80f);
58 | Colors[ImGuiCol_Column] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
59 | Colors[ImGuiCol_ColumnHovered] = ImVec4(0.70f, 0.60f, 0.60f, 1.00f);
60 | Colors[ImGuiCol_ColumnActive] = ImVec4(0.90f, 0.70f, 0.70f, 1.00f);
61 | Colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
62 | Colors[ImGuiCol_ResizeGripHovered] = ImVec4(1.00f, 1.00f, 1.00f, 0.60f);
63 | Colors[ImGuiCol_ResizeGripActive] = ImVec4(1.00f, 1.00f, 1.00f, 0.90f);
64 | Colors[ImGuiCol_CloseButton] = ImVec4(0.50f, 0.50f, 0.90f, 0.50f);
65 | Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.70f, 0.70f, 0.90f, 0.60f);
66 | Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.70f, 0.70f, 0.70f, 1.00f);
67 | Colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
68 | Colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
69 | Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
70 | Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
71 | Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
72 | Colors[ImGuiCol_TooltipBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
73 | Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
74 | }
--------------------------------------------------------------------------------
/ImGuiSharp.MonoGame.Windows/ImGuiSharp.MonoGame.Windows.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Debug
8 | x86
9 | 8.0.30703
10 | 2.0
11 | {42AB25D4-D692-49CB-8B15-A37FFF296098}
12 | Exe
13 | Properties
14 | ImGui.MonoGame
15 | ImGuiSharp.MonoGame.Windows
16 | 512
17 | Windows
18 | v4.5
19 |
20 |
21 |
22 |
23 |
24 | x86
25 | true
26 | full
27 | false
28 | bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
29 | DEBUG;TRACE;WINDOWS
30 | prompt
31 | 4
32 | true
33 |
34 |
35 | x86
36 | pdbonly
37 | true
38 | bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
39 | TRACE;WINDOWS
40 | prompt
41 | 4
42 | true
43 |
44 |
45 | Icon.ico
46 |
47 |
48 |
49 |
50 |
51 | true
52 | bin\x64\Debug\
53 | DEBUG;TRACE;WINDOWS
54 | true
55 | full
56 | x64
57 | prompt
58 | MinimumRecommendedRules.ruleset
59 | true
60 |
61 |
62 | bin\x64\Release\
63 | TRACE;WINDOWS
64 | true
65 | true
66 | pdbonly
67 | x64
68 | prompt
69 | MinimumRecommendedRules.ruleset
70 | true
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll
80 |
81 |
82 | ..\packages\SharpFont.3.1.0\lib\net20\SharpFont.dll
83 | True
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
100 |
101 |
102 |
103 |
104 |
111 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/API.h:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Internal API
3 | // No guarantee of forward compatibility here.
4 | //-----------------------------------------------------------------------------
5 |
6 | namespace ImGui
7 | {
8 | // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
9 | // If this ever crash because g.CurrentWindow is NULL it means that either
10 | // - ImGui::NewFrame() has never been called, which is illegal.
11 | // - You are calling ImGui functions after ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
12 | inline ImGuiWindow* GetCurrentWindowRead() { ImGuiState& g = *GImGui; return g.CurrentWindow; }
13 | inline ImGuiWindow* GetCurrentWindow() { ImGuiState& g = *GImGui; g.CurrentWindow->Accessed = true; return g.CurrentWindow; }
14 | IMGUI_API ImGuiWindow* GetParentWindow();
15 | IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
16 | IMGUI_API void FocusWindow(ImGuiWindow* window);
17 |
18 | IMGUI_API void SetActiveID(uint id, ImGuiWindow* window);
19 | IMGUI_API void SetHoveredID(uint id);
20 | IMGUI_API void KeepAliveID(uint id);
21 |
22 | IMGUI_API void EndFrame(); // Automatically called by Render()
23 |
24 | IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
25 | IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
26 | IMGUI_API bool ItemAdd(const ImRect& bb, const uint* id);
27 | IMGUI_API bool IsClippedEx(const ImRect& bb, const uint* id, bool clip_even_when_logged);
28 | IMGUI_API bool IsHovered(const ImRect& bb, uint id, bool flatten_childs = false);
29 | IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, bool is_active, bool tab_stop = true); // Return true if focus is requested
30 | IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
31 | IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);
32 | IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
33 |
34 | IMGUI_API void OpenPopupEx(const char* str_id, bool reopen_existing);
35 |
36 | inline IMGUI_API uint GetColorU32(ImGuiCol idx, float alpha_mul) { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * alpha_mul; return ImGui::ColorConvertFloat4ToU32(c); }
37 | inline IMGUI_API uint GetColorU32(const ImVec4& col) { ImVec4 c = col; c.w *= GImGui->Style.Alpha; return ImGui::ColorConvertFloat4ToU32(c); }
38 |
39 | // NB: All position are in absolute pixels coordinates (not window coordinates)
40 | // FIXME: Refactor all RenderText* functions into one.
41 | IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
42 | IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
43 | IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImGuiAlign align = ImGuiAlign_Default, const ImVec2* clip_min = NULL, const ImVec2* clip_max = NULL);
44 | IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, uint fill_col, bool border = true, float rounding = 0.0f);
45 | IMGUI_API void RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale = 1.0f, bool shadow = false);
46 | IMGUI_API void RenderCheckMark(ImVec2 pos, uint col);
47 | IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
48 |
49 | IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_existing_clip_rect = true);
50 | IMGUI_API void PopClipRect();
51 |
52 | IMGUI_API bool ButtonBehavior(const ImRect& bb, uint id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
53 | IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
54 |
55 | IMGUI_API bool SliderBehavior(const ImRect& frame_bb, uint id, float* v, float v_min, float v_max, float power, int decimal_precision, ImGuiSliderFlags flags = 0);
56 | IMGUI_API bool SliderFloatN(const char* label, float* v, int components, float v_min, float v_max, const char* display_format, float power);
57 | IMGUI_API bool SliderIntN(const char* label, int* v, int components, int v_min, int v_max, const char* display_format);
58 |
59 | IMGUI_API bool DragBehavior(const ImRect& frame_bb, uint id, float* v, float v_speed, float v_min, float v_max, int decimal_precision, float power);
60 | IMGUI_API bool DragFloatN(const char* label, float* v, int components, float v_speed, float v_min, float v_max, const char* display_format, float power);
61 | IMGUI_API bool DragIntN(const char* label, int* v, int components, float v_speed, int v_min, int v_max, const char* display_format);
62 |
63 | IMGUI_API bool InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);
64 | IMGUI_API bool InputFloatN(const char* label, float* v, int components, int decimal_precision, ImGuiInputTextFlags extra_flags);
65 | IMGUI_API bool InputIntN(const char* label, int* v, int components, ImGuiInputTextFlags extra_flags);
66 | IMGUI_API bool InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags);
67 | IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, uint id, int decimal_precision);
68 |
69 | IMGUI_API bool TreeNodeBehaviorIsOpened(uint id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
70 |
71 | IMGUI_API void PlotEx(ImGuiPlotType plot_type, const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size);
72 |
73 | IMGUI_API int ParseFormatPrecision(const char* fmt, int default_value);
74 | IMGUI_API float RoundScalar(float value, int decimal_precision);
75 |
76 | } // namespace ImGuiP
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImDrawList.cs.h:
--------------------------------------------------------------------------------
1 | // Draw command list
2 | // This is the low-level list of polygons that ImGui functions are filling. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering.
3 | // At the moment, each ImGui window contains its own ImDrawList but they could potentially be merged in the future.
4 | // If you want to add custom rendering within a window, you can use ImGui::GetWindowDrawList() to access the current draw list and add your own primitives.
5 | // You can interleave normal ImGui:: calls and adding primitives to the current draw list.
6 | // All positions are in screen coordinates (0,0=top-left, 1 pixel per unit). Primitives are always added to the list and not culled (culling is done at render time and at a higher-level by ImGui:: functions).
7 | struct ImDrawList
8 | {
9 | // This is what you have to render
10 | ImVector CmdBuffer; // Commands. Typically 1 command = 1 gpu draw call.
11 | ImVector IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those
12 | ImVector VtxBuffer; // Vertex buffer.
13 |
14 | // [Internal, used while building lists]
15 | const char* _OwnerName; // Pointer to owner window's name (if any) for debugging
16 | unsigned int _VtxCurrentIdx; // [Internal] == VtxBuffer.Size
17 | ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
18 | ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
19 | ImVector _ClipRectStack; // [Internal]
20 | ImVector _TextureIdStack; // [Internal]
21 | ImVector _Path; // [Internal] current path building
22 | int _ChannelsCurrent; // [Internal] current channel number (0)
23 | int _ChannelsCount; // [Internal] number of active channels (1+)
24 | ImVector _Channels; // [Internal] draw channels for columns API (not resized down so _ChannelsCount may be smaller than _Channels.Size)
25 |
26 | ImDrawList() { _OwnerName = NULL; Clear(); }
27 | ~ImDrawList() { ClearFreeMemory(); }
28 | IMGUI_API void PushClipRect(const ImVec4& clip_rect); // Scissoring. Note that the values are (x1,y1,x2,y2) and NOT (x1,y1,w,h). This is passed down to your render function but not used for CPU-side clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
29 | IMGUI_API void PushClipRectFullScreen();
30 | IMGUI_API void PopClipRect();
31 | IMGUI_API void PushTextureID(const ImTextureID& texture_id);
32 | IMGUI_API void PopTextureID();
33 |
34 | // Primitives
35 | IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, uint col, float thickness = 1.0f);
36 | IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, uint col, float rounding = 0.0f, int rounding_corners = 0x0F, float thickness = 1.0f); // a: upper-left, b: lower-right
37 | IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, uint col, float rounding = 0.0f, int rounding_corners = 0x0F); // a: upper-left, b: lower-right
38 | IMGUI_API void AddRectFilledMultiColor(const ImVec2& a, const ImVec2& b, uint col_upr_left, uint col_upr_right, uint col_bot_right, uint col_bot_left);
39 | IMGUI_API void AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, uint col, float thickness = 1.0f);
40 | IMGUI_API void AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, uint col);
41 | IMGUI_API void AddCircle(const ImVec2& centre, float radius, uint col, int num_segments = 12, float thickness = 1.0f);
42 | IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, uint col, int num_segments = 12);
43 | IMGUI_API void AddText(const ImVec2& pos, uint col, const char* text_begin, const char* text_end = NULL);
44 | IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, uint col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
45 | IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), uint col = 0xFFFFFFFF);
46 | IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, uint col, bool closed, float thickness, bool anti_aliased);
47 | IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, uint col, bool anti_aliased);
48 | IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, uint col, float thickness, int num_segments = 0);
49 |
50 | // Stateful path API, add points then finish with PathFill() or PathStroke()
51 | inline void PathClear() { _Path.resize(0); }
52 | inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
53 | inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || _Path[_Path.Size - 1].x != pos.x || _Path[_Path.Size - 1].y != pos.y) _Path.push_back(pos); }
54 | inline void PathFill(uint col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col, true); PathClear(); }
55 | inline void PathStroke(uint col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness, true); PathClear(); }
56 | IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 10);
57 | IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
58 | IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0);
59 | IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, int rounding_corners = 0x0F);
60 |
61 | // Channels
62 | // - Use to simulate layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives)
63 | // - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end)
64 | IMGUI_API void ChannelsSplit(int channels_count);
65 | IMGUI_API void ChannelsMerge();
66 | IMGUI_API void ChannelsSetCurrent(int channel_index);
67 |
68 | // Advanced
69 | IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles.
70 | IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
71 |
72 | // Internal helpers
73 | // NB: all primitives needs to be reserved via PrimReserve() beforehand!
74 | IMGUI_API void Clear();
75 | IMGUI_API void ClearFreeMemory();
76 | IMGUI_API void PrimReserve(int idx_count, int vtx_count);
77 | IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, uint col); // Axis aligned rectangle (composed of two triangles)
78 | IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, uint col);
79 | IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, uint col);
80 | inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, uint col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); }
81 | inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, uint col) { _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
82 | inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
83 | IMGUI_API void UpdateClipRect();
84 | IMGUI_API void UpdateTextureID();
85 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiState.cs.h:
--------------------------------------------------------------------------------
1 | // Main state for ImGui
2 | struct ImGuiState
3 | {
4 | bool Initialized;
5 | ImGuiIO IO;
6 | ImGuiStyle Style;
7 | ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
8 | float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize()
9 | float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Size of characters.
10 | ImVec2 FontTexUvWhitePixel; // (Shortcut) == Font->TexUvWhitePixel
11 |
12 | float Time;
13 | int FrameCount;
14 | int FrameCountEnded;
15 | int FrameCountRendered;
16 | ImVector Windows;
17 | ImVector WindowsSortBuffer;
18 | ImGuiWindow* CurrentWindow; // Being drawn into
19 | ImVector CurrentWindowStack;
20 | ImGuiWindow* FocusedWindow; // Will catch keyboard inputs
21 | ImGuiWindow* HoveredWindow; // Will catch mouse inputs
22 | ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only)
23 | uint HoveredId; // Hovered widget
24 | bool HoveredIdAllowOverlap;
25 | uint HoveredIdPreviousFrame;
26 | uint ActiveId; // Active widget
27 | uint ActiveIdPreviousFrame;
28 | bool ActiveIdIsAlive;
29 | bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
30 | bool ActiveIdAllowOverlap; // Set only by active widget
31 | ImGuiWindow* ActiveIdWindow;
32 | ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window. Pointer is only valid if ActiveID is the "#MOVE" identifier of a window.
33 | ImVector Settings; // .ini Settings
34 | float SettingsDirtyTimer; // Save .ini settinngs on disk when time reaches zero
35 | ImVector ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
36 | ImVector StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
37 | ImVector FontStack; // Stack for PushFont()/PopFont()
38 | ImVector OpenedPopupStack; // Which popups are open (persistent)
39 | ImVector CurrentPopupStack; // Which level of BeginPopup() we are in (reset every frame)
40 |
41 | // Storage for SetNexWindow** and SetNextTreeNode*** functions
42 | ImVec2 SetNextWindowPosVal;
43 | ImVec2 SetNextWindowSizeVal;
44 | ImVec2 SetNextWindowContentSizeVal;
45 | bool SetNextWindowCollapsedVal;
46 | ImGuiSetCond SetNextWindowPosCond;
47 | ImGuiSetCond SetNextWindowSizeCond;
48 | ImGuiSetCond SetNextWindowContentSizeCond;
49 | ImGuiSetCond SetNextWindowCollapsedCond;
50 | bool SetNextWindowFocus;
51 | bool SetNextTreeNodeOpenedVal;
52 | ImGuiSetCond SetNextTreeNodeOpenedCond;
53 |
54 | // Render
55 | ImDrawData RenderDrawData; // Main ImDrawData instance to pass render information to the user
56 | ImVector RenderDrawLists[3];
57 | float ModalWindowDarkeningRatio;
58 | ImDrawList OverlayDrawList; // Optional software render of mouse cursors, if io.MouseDrawCursor is set + a few debug overlays
59 | ImGuiMouseCursor MouseCursor;
60 | ImGuiMouseCursorData MouseCursorData[ImGuiMouseCursor_Count_];
61 |
62 | // Widget state
63 | ImGuiTextEditState InputTextState;
64 | ImFont InputTextPasswordFont;
65 | uint ScalarAsInputTextId; // Temporary text input when CTRL+clicking on a slider, etc.
66 | ImGuiStorage ColorEditModeStorage; // Store user selection of color edit mode
67 | ImVec2 ActiveClickDeltaToCenter;
68 | float DragCurrentValue; // Currently dragged value, always float, not rounded by end-user precision settings
69 | ImVec2 DragLastMouseDelta;
70 | float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
71 | float DragSpeedScaleSlow;
72 | float DragSpeedScaleFast;
73 | ImVec2 ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
74 | char Tooltip[1024];
75 | char* PrivateClipboard; // If no custom clipboard handler is defined
76 | ImVec2 OsImePosRequest, OsImePosSet; // Cursor position request & last passed to the OS Input Method Editor
77 |
78 | // Logging
79 | bool LogEnabled;
80 | FILE* LogFile; // If != NULL log to stdout/ file
81 | ImGuiTextBuffer* LogClipboard; // Else log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
82 | int LogStartDepth;
83 | int LogAutoExpandMaxDepth;
84 |
85 | // Misc
86 | float FramerateSecPerFrame[120]; // calculate estimate of framerate for user
87 | int FramerateSecPerFrameIdx;
88 | float FramerateSecPerFrameAccum;
89 | int CaptureMouseNextFrame; // explicit capture via CaptureInputs() sets those flags
90 | int CaptureKeyboardNextFrame;
91 | char TempBuffer[1024 * 3 + 1]; // temporary text buffer
92 |
93 | ImGuiState()
94 | {
95 | Initialized = false;
96 | Font = NULL;
97 | FontSize = FontBaseSize = 0.0f;
98 | FontTexUvWhitePixel = ImVec2(0.0f, 0.0f);
99 |
100 | Time = 0.0f;
101 | FrameCount = 0;
102 | FrameCountEnded = FrameCountRendered = -1;
103 | CurrentWindow = NULL;
104 | FocusedWindow = NULL;
105 | HoveredWindow = NULL;
106 | HoveredRootWindow = NULL;
107 | HoveredId = 0;
108 | HoveredIdAllowOverlap = false;
109 | HoveredIdPreviousFrame = 0;
110 | ActiveId = 0;
111 | ActiveIdPreviousFrame = 0;
112 | ActiveIdIsAlive = false;
113 | ActiveIdIsJustActivated = false;
114 | ActiveIdAllowOverlap = false;
115 | ActiveIdWindow = NULL;
116 | MovedWindow = NULL;
117 | SettingsDirtyTimer = 0.0f;
118 |
119 | SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
120 | SetNextWindowSizeVal = ImVec2(0.0f, 0.0f);
121 | SetNextWindowCollapsedVal = false;
122 | SetNextWindowPosCond = 0;
123 | SetNextWindowSizeCond = 0;
124 | SetNextWindowContentSizeCond = 0;
125 | SetNextWindowCollapsedCond = 0;
126 | SetNextWindowFocus = false;
127 | SetNextTreeNodeOpenedVal = false;
128 | SetNextTreeNodeOpenedCond = 0;
129 |
130 | ScalarAsInputTextId = 0;
131 | ActiveClickDeltaToCenter = ImVec2(0.0f, 0.0f);
132 | DragCurrentValue = 0.0f;
133 | DragLastMouseDelta = ImVec2(0.0f, 0.0f);
134 | DragSpeedDefaultRatio = 0.01f;
135 | DragSpeedScaleSlow = 0.01f;
136 | DragSpeedScaleFast = 10.0f;
137 | ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
138 | memset(Tooltip, 0, sizeof(Tooltip));
139 | PrivateClipboard = NULL;
140 | OsImePosRequest = OsImePosSet = ImVec2(-1.0f, -1.0f);
141 |
142 | ModalWindowDarkeningRatio = 0.0f;
143 | OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging
144 | MouseCursor = ImGuiMouseCursor_Arrow;
145 | memset(MouseCursorData, 0, sizeof(MouseCursorData));
146 |
147 | LogEnabled = false;
148 | LogFile = NULL;
149 | LogClipboard = NULL;
150 | LogStartDepth = 0;
151 | LogAutoExpandMaxDepth = 2;
152 |
153 | memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
154 | FramerateSecPerFrameIdx = 0;
155 | FramerateSecPerFrameAccum = 0.0f;
156 | CaptureMouseNextFrame = CaptureKeyboardNextFrame = -1;
157 | memset(TempBuffer, 0, sizeof(TempBuffer));
158 | }
159 | };
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui_Internal.h/ImGuiWindow.cs:
--------------------------------------------------------------------------------
1 | namespace ImGui
2 | {
3 | // Windows data
4 | internal class ImGuiWindow
5 | {
6 | internal string Name;
7 | internal uint ID;
8 | internal ImGuiWindowFlags Flags;
9 | internal ImVec2 PosFloat;
10 | internal ImVec2 Pos; // Position rounded-up to nearest pixel
11 | internal ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
12 | internal ImVec2 SizeFull; // Size when non collapsed
13 | internal ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame
14 | internal ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
15 | internal ImVec2 WindowPadding; // Window padding at the time of begin. We need to lock it, in particular manipulation of the ShowBorder would have an effect
16 | internal uint MoveID; // == window->GetID("#MOVE")
17 | internal ImVec2 Scroll;
18 | internal ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
19 | internal ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
20 | internal bool ScrollbarX, ScrollbarY;
21 | internal ImVec2 ScrollbarSizes;
22 | internal float BorderSize;
23 | internal bool Active; // Set to true on Begin()
24 | internal bool WasActive;
25 | internal bool Accessed; // Set to true when any widget access the current window
26 | internal bool Collapsed; // Set when collapsing window to become only title-bar
27 | internal bool SkipItems; // == Visible && !Collapsed
28 | internal int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
29 | internal uint PopupID; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
30 | internal int AutoFitFramesX, AutoFitFramesY;
31 | internal bool AutoFitOnlyGrows;
32 | internal int AutoPosLastDirection;
33 | internal int HiddenFrames;
34 | internal int SetWindowPosAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowPos() call will succeed with this particular flag.
35 | internal int SetWindowSizeAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowSize() call will succeed with this particular flag.
36 | internal int SetWindowCollapsedAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowCollapsed() call will succeed with this particular flag.
37 | internal bool SetWindowPosCenterWanted;
38 |
39 | internal ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
40 | internal ImVector IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
41 | internal ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
42 | internal ImRect ClippedWindowRect; // = ClipRect just after setup in Begin()
43 | internal int LastFrameActive;
44 | internal float ItemWidthDefault;
45 | internal ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items
46 | internal ImGuiStorage StateStorage;
47 | internal float FontWindowScale; // Scale multiplier per-window
48 | internal ImDrawList DrawList;
49 | internal ImGuiWindow RootWindow;
50 | internal ImGuiWindow RootNonPopupWindow;
51 |
52 | // Focus
53 | internal int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()
54 | internal int FocusIdxTabCounter; // (same, but only count widgets which you can Tab through)
55 | internal int FocusIdxAllRequestCurrent; // Item being requested for focus
56 | internal int FocusIdxTabRequestCurrent; // Tab-able item being requested for focus
57 | internal int FocusIdxAllRequestNext; // Item being requested for focus, for next update (relies on layout to be stable between the frame pressing TAB and the next frame)
58 | internal int FocusIdxTabRequestNext; // "
59 |
60 | internal ImGuiWindow(string name)
61 | {
62 | DC = new ImGuiDrawContext();
63 | IDStack = new ImVector();
64 | StateStorage = new ImGuiStorage();
65 | MenuColumns = new ImGuiSimpleColumns();
66 | DrawList = new ImDrawList();
67 |
68 | Name = name;
69 |
70 | ID = ImGui.Hash(0, name);
71 | IDStack.push_back(ID);
72 | MoveID = GetID("#MOVE");
73 |
74 | Flags = 0;
75 | PosFloat = Pos = new ImVec2(0.0f, 0.0f);
76 | Size = SizeFull = new ImVec2(0.0f, 0.0f);
77 | SizeContents = SizeContentsExplicit = new ImVec2(0.0f, 0.0f);
78 | WindowPadding = new ImVec2(0.0f, 0.0f);
79 | Scroll = new ImVec2(0.0f, 0.0f);
80 | ScrollTarget = new ImVec2(float.MaxValue, float.MaxValue);
81 | ScrollTargetCenterRatio = new ImVec2(0.5f, 0.5f);
82 | ScrollbarX = ScrollbarY = false;
83 | ScrollbarSizes = new ImVec2(0.0f, 0.0f);
84 | BorderSize = 0.0f;
85 | Active = WasActive = false;
86 | Accessed = false;
87 | Collapsed = false;
88 | SkipItems = false;
89 | BeginCount = 0;
90 | PopupID = 0;
91 | AutoFitFramesX = AutoFitFramesY = -1;
92 | AutoFitOnlyGrows = false;
93 | AutoPosLastDirection = -1;
94 | HiddenFrames = 0;
95 | SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = (int)(ImGuiSetCond.ImGuiSetCond_Always | ImGuiSetCond.ImGuiSetCond_Once | ImGuiSetCond.ImGuiSetCond_FirstUseEver | ImGuiSetCond.ImGuiSetCond_Appearing);
96 | SetWindowPosCenterWanted = false;
97 |
98 | LastFrameActive = -1;
99 | ItemWidthDefault = 0.0f;
100 | FontWindowScale = 1.0f;
101 |
102 | RootWindow = null;
103 | RootNonPopupWindow = null;
104 |
105 | FocusIdxAllCounter = FocusIdxTabCounter = -1;
106 | FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = int.MaxValue;
107 | FocusIdxAllRequestNext = FocusIdxTabRequestNext = int.MaxValue;
108 | }
109 |
110 | public void Dispose()
111 | {
112 | DrawList.Dispose();
113 | DrawList = null;
114 | }
115 |
116 | internal uint GetID(string str, int start = 0, int end = -1)
117 | {
118 | uint seed = IDStack.back();
119 | uint id = ImGui.Hash(seed, str, start, end);
120 | ImGui.Instance.KeepAliveID(id);
121 | return id;
122 | }
123 |
124 | internal ImRect Rect()
125 | {
126 | return new ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y);
127 | }
128 | internal float CalcFontSize()
129 | {
130 | //TODO: Is it ok to access state like this?
131 | return ImGui.Instance.State.FontBaseSize * FontWindowScale;
132 | }
133 | internal float TitleBarHeight()
134 | {
135 | //TODO: Is it ok to access style like this?
136 | return ((Flags & ImGuiWindowFlags.ImGuiWindowFlags_NoTitleBar) == ImGuiWindowFlags.ImGuiWindowFlags_NoTitleBar) ? 0.0f : (CalcFontSize() + ImGui.Instance.Style.FramePadding.y * 2.0f);
137 | }
138 | internal ImRect TitleBarRect()
139 | {
140 | return new ImRect(Pos, new ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight()));
141 | }
142 |
143 | internal float MenuBarHeight()
144 | {
145 | //TODO: Is it ok to access style like this?
146 | return ((Flags & ImGuiWindowFlags.ImGuiWindowFlags_MenuBar) == ImGuiWindowFlags.ImGuiWindowFlags_MenuBar) ? (CalcFontSize() + ImGui.Instance.Style.FramePadding.y * 2.0f) : 0.0f;
147 | }
148 |
149 | internal ImRect MenuBarRect()
150 | {
151 | float y1 = Pos.y + TitleBarHeight();
152 | return new ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight());
153 | }
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/ImGuiSharp.Shared/ImGui.h/ImGuiIO.cs.h:
--------------------------------------------------------------------------------
1 | // This is where your app communicate with ImGui. Access via ImGui::GetIO().
2 | // Read 'Programmer guide' section in .cpp file for general usage.
3 | struct ImGuiIO
4 | {
5 | //------------------------------------------------------------------
6 | // Settings (fill once) // Default value:
7 | //------------------------------------------------------------------
8 |
9 | ImVec2 DisplaySize; // // Display size, in pixels. For clamping windows positions.
10 | float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds.
11 | float IniSavingRate; // = 5.0f // Maximum time between saving positions/sizes to .ini file, in seconds.
12 | const char* IniFilename; // = "imgui.ini" // Path to .ini file. NULL to disable .ini saving.
13 | const char* LogFilename; // = "imgui_log.txt" // Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
14 | float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds.
15 | float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
16 | float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging
17 | int KeyMap[ImGuiKey_COUNT]; // // Map of indices into the KeysDown[512] entries array
18 | float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds. (for actions where 'repeat' is active)
19 | float KeyRepeatRate; // = 0.020f // When holding a key/button, rate at which it repeats, in seconds.
20 | void* UserData; // = NULL // Store your own data for retrieval by callbacks.
21 |
22 | ImFontAtlas* Fonts; // // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
23 | float FontGlobalScale; // = 1.0f // Global scale all fonts
24 | bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel.
25 | ImVec2 DisplayFramebufferScale; // = (1.0f,1.0f) // For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui.
26 | ImVec2 DisplayVisibleMin; // (0.0f,0.0f) // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area.
27 | ImVec2 DisplayVisibleMax; // (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
28 |
29 | //------------------------------------------------------------------
30 | // User Functions
31 | //------------------------------------------------------------------
32 |
33 | // Rendering function, will be called in Render().
34 | // Alternatively you can keep this to NULL and call GetDrawData() after Render() to get the same pointer.
35 | // See example applications if you are unsure of how to implement this.
36 | void(*RenderDrawListsFn)(ImDrawData* data);
37 |
38 | // Optional: access OS clipboard
39 | // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
40 | const char* (*GetClipboardTextFn)();
41 | void(*SetClipboardTextFn)(const char* text);
42 |
43 | // Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer.
44 | // (default to posix malloc/free)
45 | void* (*MemAllocFn)(size_t sz);
46 | void(*MemFreeFn)(void* ptr);
47 |
48 | // Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME in Windows)
49 | // (default to use native imm32 api on Windows)
50 | void(*ImeSetInputScreenPosFn)(int x, int y);
51 | void* ImeWindowHandle; // (Windows) Set this to your HWND to get automatic IME cursor positioning.
52 |
53 | //------------------------------------------------------------------
54 | // Input - Fill before calling NewFrame()
55 | //------------------------------------------------------------------
56 |
57 | ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
58 | bool MouseDown[5]; // Mouse buttons: left, right, middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
59 | float MouseWheel; // Mouse wheel: 1 unit scrolls about 5 lines text.
60 | bool MouseDrawCursor; // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
61 | bool KeyCtrl; // Keyboard modifier pressed: Control
62 | bool KeyShift; // Keyboard modifier pressed: Shift
63 | bool KeyAlt; // Keyboard modifier pressed: Alt
64 | bool KeysDown[512]; // Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data)
65 | ImWchar InputCharacters[16 + 1]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper.
66 |
67 | // Functions
68 | IMGUI_API void AddInputCharacter(ImWchar c); // Helper to add a new character into InputCharacters[]
69 | IMGUI_API void AddInputCharactersUTF8(const char* utf8_chars); // Helper to add new characters into InputCharacters[] from an UTF-8 string
70 | IMGUI_API void ClearInputCharacters() { InputCharacters[0] = 0; } // Helper to clear the text input buffer
71 |
72 | //------------------------------------------------------------------
73 | // Output - Retrieve after calling NewFrame(), you can use them to discard inputs or hide them from the rest of your application
74 | //------------------------------------------------------------------
75 |
76 | bool WantCaptureMouse; // Mouse is hovering a window or widget is active (= ImGui will use your mouse input)
77 | bool WantCaptureKeyboard; // Widget is active (= ImGui will use your keyboard input)
78 | bool WantTextInput; // Some text input widget is active, which will read input characters from the InputCharacters array.
79 | float Framerate; // Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames
80 | int MetricsAllocs; // Number of active memory allocations
81 | int MetricsRenderVertices; // Vertices output during last call to Render()
82 | int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3
83 | int MetricsActiveWindows; // Number of visible windows (exclude child windows)
84 |
85 | //------------------------------------------------------------------
86 | // [Internal] ImGui will maintain those fields for you
87 | //------------------------------------------------------------------
88 |
89 | ImVec2 MousePosPrev; // Previous mouse position
90 | ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are negative to allow mouse enabling/disabling.
91 | bool MouseClicked[5]; // Mouse button went from !Down to Down
92 | ImVec2 MouseClickedPos[5]; // Position at time of clicking
93 | float MouseClickedTime[5]; // Time of last click (used to figure out double-click)
94 | bool MouseDoubleClicked[5]; // Has mouse button been double-clicked?
95 | bool MouseReleased[5]; // Mouse button went from Down to !Down
96 | bool MouseDownOwned[5]; // Track if button was clicked inside a window. We don't request mouse capture from the application if click started outside ImGui bounds.
97 | float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
98 | float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
99 | float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the click point
100 | float KeysDownDuration[512]; // Duration the keyboard key has been down (0.0f == just pressed)
101 | float KeysDownDurationPrev[512]; // Previous duration the key has been down
102 |
103 | IMGUI_API ImGuiIO();
104 | };
--------------------------------------------------------------------------------